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 ¶
- Variables
- type FolderFile
- type Reader
- func (r *Reader) ByID(ctx context.Context, id string) (*resource.Resource, error)
- func (r *Reader) Bytes(ctx context.Context, res *resource.Resource, limit int64) ([]byte, error)
- func (r *Reader) Folder(ctx context.Context, scope resource.ScopeFilter, path string, ...) ([]FolderFile, error)
- func (r *Reader) Head(ctx context.Context, res *resource.Resource) (int, error)
- func (r *Reader) Resolve(ctx context.Context, ref string, claims resource.Claims) (*resource.Resource, error)
- func (r *Reader) Scheme() string
- func (r *Reader) Source(ctx context.Context, ref string, claims resource.Claims, limit int64) (string, error)
- func (r *Reader) Text(ctx context.Context, res *resource.Resource, version int, limit int64) (string, error)
Constants ¶
This section is empty.
Variables ¶
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
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 ¶
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 ¶
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
Bytes reads a file's current content, at most limit bytes, for the caller that resolved 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 ¶
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) 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.