Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
229
create.go2 kB
package node_mutate import ( "context" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fctx" "github.com/Southclaws/fault/fmsg" "github.com/Southclaws/opt" "github.com/Southclaws/storyden/app/resources/account" "github.com/Southclaws/storyden/app/resources/library" "github.com/Southclaws/storyden/app/resources/mark" "github.com/Southclaws/storyden/app/resources/message" "github.com/Southclaws/storyden/app/resources/rbac" "github.com/Southclaws/storyden/app/resources/visibility" ) func (s *Manager) Create(ctx context.Context, owner account.AccountID, name string, p Partial, ) (*library.Node, error) { if v, ok := p.Visibility.Get(); ok { if v == visibility.VisibilityPublished { acc, err := s.accountQuery.GetByID(ctx, owner) if err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } if err := acc.Roles.Permissions().Authorise(ctx, nil, rbac.PermissionManageLibrary); err != nil { return nil, fault.Wrap(err, fctx.With(ctx), fmsg.WithDesc("non admin cannot publish nodes", "You do not have permission to publish, please submit as draft, review or unlisted."), ) } } } pre, err := s.preMutation(ctx, p, opt.NewEmpty[library.Node]()) if err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } opts := pre.opts nodeSlug := p.Slug.Or(mark.NewSlugFromName(name)) n, err := s.nodeWriter.Create(ctx, owner, name, nodeSlug, opts...) if err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } if props, ok := p.Properties.Get(); ok { updatedProps, err := s.applyPropertyMutations(ctx, n, props) if err != nil { return nil, fault.Wrap(err, fctx.With(ctx)) } if updatedProps != nil { n.Properties = opt.New(*updatedProps) } } s.bus.Publish(ctx, &message.EventNodeCreated{ ID: library.NodeID(n.Mark.ID()), }) if p.Visibility.OrZero() == visibility.VisibilityPublished { s.bus.Publish(ctx, &message.EventNodePublished{ ID: library.NodeID(n.Mark.ID()), }) } return n, nil }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server