Update mcp types.newDocumentVersion signature - panic from body
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -2087,12 +2087,7 @@ func (r *Resolver) AddDocumentTool(ctx context.Context, req *mcp.CallToolRequest
|
|||||||
panic(fmt.Errorf("cannot create document: %w", err))
|
panic(fmt.Errorf("cannot create document: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := types.NewAddDocumentOutput(document, documentVersion)
|
return nil, types.NewAddDocumentOutput(document, documentVersion), nil
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("cannot build add document output: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, out, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) UpdateDocumentTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateDocumentInput) (*mcp.CallToolResult, types.UpdateDocumentOutput, error) {
|
func (r *Resolver) UpdateDocumentTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateDocumentInput) (*mcp.CallToolResult, types.UpdateDocumentOutput, error) {
|
||||||
@@ -2139,12 +2134,7 @@ func (r *Resolver) ListDocumentVersionsTool(ctx context.Context, req *mcp.CallTo
|
|||||||
panic(fmt.Errorf("cannot list document versions: %w", err))
|
panic(fmt.Errorf("cannot list document versions: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := types.NewListDocumentVersionsOutput(versionPage)
|
return nil, types.NewListDocumentVersionsOutput(versionPage), nil
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("cannot build list document versions output: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, out, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) GetDocumentVersionTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetDocumentVersionInput) (*mcp.CallToolResult, types.GetDocumentVersionOutput, error) {
|
func (r *Resolver) GetDocumentVersionTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetDocumentVersionInput) (*mcp.CallToolResult, types.GetDocumentVersionOutput, error) {
|
||||||
@@ -2157,13 +2147,8 @@ func (r *Resolver) GetDocumentVersionTool(ctx context.Context, req *mcp.CallTool
|
|||||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
dv, err := types.NewDocumentVersion(version)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("cannot build document version: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, types.GetDocumentVersionOutput{
|
return nil, types.GetDocumentVersionOutput{
|
||||||
DocumentVersion: dv,
|
DocumentVersion: types.NewDocumentVersion(version),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2195,13 +2180,8 @@ func (r *Resolver) CreateDraftDocumentVersionTool(ctx context.Context, req *mcp.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dv, err := types.NewDocumentVersion(draftVersion)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("cannot build document version: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, types.CreateDraftDocumentVersionOutput{
|
return nil, types.CreateDraftDocumentVersionOutput{
|
||||||
DocumentVersion: dv,
|
DocumentVersion: types.NewDocumentVersion(draftVersion),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2232,13 +2212,8 @@ func (r *Resolver) UpdateDocumentVersionTool(ctx context.Context, req *mcp.CallT
|
|||||||
panic(fmt.Errorf("cannot update document version: %w", err))
|
panic(fmt.Errorf("cannot update document version: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
dv, err := types.NewDocumentVersion(documentVersion)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("cannot build document version: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, types.UpdateDocumentVersionOutput{
|
return nil, types.UpdateDocumentVersionOutput{
|
||||||
DocumentVersion: dv,
|
DocumentVersion: types.NewDocumentVersion(documentVersion),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3865,13 +3840,8 @@ func (r *Resolver) RequestDocumentVersionApprovalTool(ctx context.Context, req *
|
|||||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
dv, err := types.NewDocumentVersion(documentVersion)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("cannot build document version: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, types.RequestDocumentVersionApprovalOutput{
|
return nil, types.RequestDocumentVersionApprovalOutput{
|
||||||
DocumentVersion: dv,
|
DocumentVersion: types.NewDocumentVersion(documentVersion),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3891,14 +3861,9 @@ func (r *Resolver) PublishMajorDocumentVersionTool(ctx context.Context, req *mcp
|
|||||||
panic(fmt.Errorf("cannot publish major document version: %w", err))
|
panic(fmt.Errorf("cannot publish major document version: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
dv, err := types.NewDocumentVersion(documentVersion)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("cannot build document version: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, types.PublishMajorDocumentVersionOutput{
|
return nil, types.PublishMajorDocumentVersionOutput{
|
||||||
Document: types.NewDocument(document),
|
Document: types.NewDocument(document),
|
||||||
DocumentVersion: dv,
|
DocumentVersion: types.NewDocumentVersion(documentVersion),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3918,14 +3883,9 @@ func (r *Resolver) PublishMinorDocumentVersionTool(ctx context.Context, req *mcp
|
|||||||
panic(fmt.Errorf("cannot publish minor document version: %w", err))
|
panic(fmt.Errorf("cannot publish minor document version: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
dv, err := types.NewDocumentVersion(documentVersion)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("cannot build document version: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, types.PublishMinorDocumentVersionOutput{
|
return nil, types.PublishMinorDocumentVersionOutput{
|
||||||
Document: types.NewDocument(document),
|
Document: types.NewDocument(document),
|
||||||
DocumentVersion: dv,
|
DocumentVersion: types.NewDocumentVersion(documentVersion),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,22 +110,17 @@ func NewListDocumentsOutput(documentPage *page.Page[*coredata.Document, coredata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAddDocumentOutput(doc *coredata.Document, docVersion *coredata.DocumentVersion) (AddDocumentOutput, error) {
|
func NewAddDocumentOutput(doc *coredata.Document, docVersion *coredata.DocumentVersion) AddDocumentOutput {
|
||||||
dv, err := NewDocumentVersion(docVersion)
|
|
||||||
if err != nil {
|
|
||||||
return AddDocumentOutput{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return AddDocumentOutput{
|
return AddDocumentOutput{
|
||||||
Document: NewDocument(doc),
|
Document: NewDocument(doc),
|
||||||
DocumentVersion: dv,
|
DocumentVersion: NewDocumentVersion(docVersion),
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDocumentVersion(dv *coredata.DocumentVersion) (*DocumentVersion, error) {
|
func NewDocumentVersion(dv *coredata.DocumentVersion) *DocumentVersion {
|
||||||
contentMD, err := proseMirrorJSONToMarkdown(dv.Content)
|
contentMD, err := proseMirrorJSONToMarkdown(dv.Content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot convert document version content to markdown: %w", err)
|
panic(fmt.Errorf("cannot convert document version content to markdown: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &DocumentVersion{
|
return &DocumentVersion{
|
||||||
@@ -143,17 +138,13 @@ func NewDocumentVersion(dv *coredata.DocumentVersion) (*DocumentVersion, error)
|
|||||||
PublishedAt: dv.PublishedAt,
|
PublishedAt: dv.PublishedAt,
|
||||||
CreatedAt: dv.CreatedAt,
|
CreatedAt: dv.CreatedAt,
|
||||||
UpdatedAt: dv.UpdatedAt,
|
UpdatedAt: dv.UpdatedAt,
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewListDocumentVersionsOutput(versionPage *page.Page[*coredata.DocumentVersion, coredata.DocumentVersionOrderField]) (ListDocumentVersionsOutput, error) {
|
func NewListDocumentVersionsOutput(versionPage *page.Page[*coredata.DocumentVersion, coredata.DocumentVersionOrderField]) ListDocumentVersionsOutput {
|
||||||
versions := make([]*DocumentVersion, 0, len(versionPage.Data))
|
versions := make([]*DocumentVersion, 0, len(versionPage.Data))
|
||||||
for _, v := range versionPage.Data {
|
for _, v := range versionPage.Data {
|
||||||
dv, err := NewDocumentVersion(v)
|
versions = append(versions, NewDocumentVersion(v))
|
||||||
if err != nil {
|
|
||||||
return ListDocumentVersionsOutput{}, err
|
|
||||||
}
|
|
||||||
versions = append(versions, dv)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextCursor *page.CursorKey
|
var nextCursor *page.CursorKey
|
||||||
@@ -165,7 +156,7 @@ func NewListDocumentVersionsOutput(versionPage *page.Page[*coredata.DocumentVers
|
|||||||
return ListDocumentVersionsOutput{
|
return ListDocumentVersionsOutput{
|
||||||
NextCursor: nextCursor,
|
NextCursor: nextCursor,
|
||||||
DocumentVersions: versions,
|
DocumentVersions: versions,
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDocumentVersionSignature(dvs *coredata.DocumentVersionSignature) *DocumentVersionSignature {
|
func NewDocumentVersionSignature(dvs *coredata.DocumentVersionSignature) *DocumentVersionSignature {
|
||||||
|
|||||||
Reference in New Issue
Block a user