scriptsrc

package
v1.147.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package scriptsrc reads the managed-resource text a managed script is made from: the source a create or an update names by reference instead of carrying inline (#2114), and the page script, SQL or template a script loads as a string with load("res:...") (#2113).

A reference is resolved under the caller's own access, as fetch resolves one: a file the caller could not read is not there. The text is read from a version of the file -- its head, or the version a script pinned when it was saved -- so a run and a replay of it read the bytes the save read.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("no managed resource you can read is at that reference")

ErrNotFound is a reference that names no file the caller may read.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads text from the managed-resource library.

func New

func New(store resource.Store, blobs resource.S3Client, bucket, scheme string) *Reader

New builds a reader over the library, or nil when there is no library to read: no record store or no blob storage.

func (*Reader) ByID

func (r *Reader) ByID(ctx context.Context, id string) (*resource.Resource, error)

ByID reads the file a script version pinned, by id. The pin was resolved under its author's access when the version was saved; a run reads what the save read.

func (*Reader) Head

func (r *Reader) Head(ctx context.Context, res *resource.Resource) (int, error)

Head is the version number the file's current content was recorded as, or 0 on a deployment that keeps no version history.

func (*Reader) Resolve

func (r *Reader) Resolve(ctx context.Context, ref string, claims resource.Claims) (*resource.Resource, error)

Resolve finds the file a reference names: an mcp:resource:<id> reference, or the mcp:// URI the file answers at. A file the caller may not read is reported as absent, never as forbidden, so a reference reveals nothing.

func (*Reader) Scheme

func (r *Reader) Scheme() string

Scheme is the URI scheme the library's files answer at.

func (*Reader) Source

func (r *Reader) Source(ctx context.Context, ref string, claims resource.Claims, limit int64) (string, error)

Source reads the text a save names by reference as a script's source (#2114): the file's current content, held to the source size a script may have, under the caller's own access.

func (*Reader) Text

func (r *Reader) Text(ctx context.Context, res *resource.Resource, version int, limit int64) (string, error)

Text reads a version of the file as text, at most limit bytes. Version 0 is the file's current content. A file that is not UTF-8 text is refused, as is one past the limit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL