scriptsrc

package
v1.162.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 7 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 FolderFile added in v1.155.0

type FolderFile struct {
	Path     string
	Resource *resource.Resource
}

FolderFile is a file under a folder.

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) AtPath added in v1.159.0

func (r *Reader) AtPath(ctx context.Context, lib resource.ScopeFilter, tail string) (*resource.Resource, error)

AtPath is the file at tail ("folder/sub/name.jpg") in one library, nil when there is none. It checks no caller: what a mount serves was decided when it was made.

Only a file filed at that path now is served. The store also answers the URI a file was moved away from, so its old links keep working; a mount does not follow that, or a file moved out of a mounted folder, into a library the site's audience could never read, would still be served at its old address. A tail no file can be filed at (bytes that are not UTF-8, a NUL or another control character) names nothing, and is not looked up.

func (*Reader) Blobs added in v1.159.0

func (r *Reader) Blobs() (blobs resource.S3Client, bucket string)

Blobs is the store the library's bytes are kept in, and its bucket.

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) Bytes added in v1.155.0

func (r *Reader) Bytes(ctx context.Context, res *resource.Resource, limit int64) ([]byte, error)

Bytes reads a file's current content, at most limit bytes, for the caller that resolved it.

func (*Reader) CheckFolder added in v1.159.0

func (r *Reader) CheckFolder(ctx context.Context, lib resource.ScopeFilter, folder string, claims resource.Claims) error

CheckFolder refuses a folder the caller may not read, or one the library does not hold. A library the caller cannot see is reported as absent, so the refusal reveals nothing about it.

func (*Reader) Folder added in v1.155.0

func (r *Reader) Folder(ctx context.Context, scope resource.ScopeFilter, path string, claims resource.Claims) ([]FolderFile, error)

Folder lists the files under path in one library the caller may see, with each file's path relative to it.

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