AGENT SKILL

ldp-container

Use when reading LDP container memberships, building typed listing metadata, sharing listing parsing across Solid clients, filtering untrusted ldp:contains entries, or maintaining @jeswr/ldp-container.

License 许可
MIT
所属仓库
jeswr/solid-sdk
最近更新
2026-11-15
Stars
★ 2
Forks
0

01 前言 Front Matter

name
ldp-container
description
Use when reading LDP container memberships, building typed listing metadata, sharing listing parsing across Solid clients, filtering untrusted ldp:contains entries, or maintaining @jeswr/ldp-container.

02 资源文件 22

03 SKILL.md 正文

<!-- AUTHORED-BY Codex GPT-6.1-Sol -->

Shared LDP container listings

Use readContainerMembers(fetch, containerUrl, { scope, package?, signal?, maxBytes?, maxQuads? }) for ordinary GETs; 404/410 returns null. Inject the caller's scoped, redirect-refusing fetch. This helper checks the initial URL and delegates transport policy to that fetch. Pass the body stream directly to parseRdf (null body becomes ""), with maxBytes defaulting to 16 MiB, optional maxQuads (parser default 1,000,000), and the same signal passed to fetch. The fetch-rdf hardening change supplies limit/abort enforcement and stream cancellation; limits reject with code: "PARSE_LIMIT", and abort rejects with AbortError even for stalled bodies. Cancel missing/non-ok response bodies best effort, without awaiting cancellation.

Use parseContainerMembers(dataset, containerUrl, { scope, allowRoot? }) after custom reads such as y-solid's capped streaming read. Membership must come from ContainerDataset; never match triples by hand. Resolve and guard every entry inside its own try/catch, use the canonical value returned by assertWithinPodScope, and preserve listing order while deduplicating by URL. Accept only NamedNodes. Guard members against both scope and containerUrl with { allowRoot: false } for the latter: ancestors, siblings, and all self aliases must be skipped, even when they are inside the broader scope. allowRoot only controls the overall scope check. Encoded %2F/%5C paths are refused by guarded-fetch. Supply a single-container dataset: the first ldp:contains subject selected by ContainerDataset supplies membership, independently of containerUrl. Mixed-container datasets are unsupported; containerUrl is the resolution base and containment boundary.

Keep scope guards in @jeswr/guarded-fetch; do not re-export them here. Keep stricter compatibility filters, sorting, non-container filters, and read caps in callers. Never weaken those policies while consolidating listings. The runtime must remain browser-safe.

buildListingDataset(containerUrl, entries: Iterable<ListingMetadata>) constructs synthetic default-graph membership and metadata through the generated ListingMember and ListingContainer wrappers interpreted by @jeswr/model-runtime. Supply url, title, nullable modified (Date), size and contentType, plus types. Null fields are omitted; zero, epoch dates and empty strings survive. Only supplied types are emitted; never call build() or mark() here. Generated guards reject unsafe subject/type IRIs and drop invalid optional values. The facade keeps invalid dates throwing RangeError. Callers enforce HTTP(S)/pod-scope policy and collect a complete successful listing before replacing a cached graph; the builder does no I/O.

Generation uses codegen/'s ontology/SHACL plus codegen.config.json. All fields are sets, and text sanitization is disabled to preserve literal contents. rdf:type is a reserved structural predicate: its explicit property shape fails admission, so use the generated wrapper's built-in .types set. README documents the exact rejection for the generator follow-up. After building federation-codegen, run pnpm --filter @jeswr/ldp-container run codegen. Never edit src/generated/; the byte-for-byte drift test, including the lockfile, must pass. The build copies generated JS/declarations into dist. Keep the listing facade at 100% coverage.

04 同仓库更多 Skills