storage-client
Use when reading, creating, conditionally editing, listing or moving pod resources with @jeswr/storage-client, or maintaining its Solid/LWS backends and offline fixtures.
- License 许可
- MIT
- 所属仓库
- jeswr/solid-sdk
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- storage-client
- description
- Use when reading, creating, conditionally editing, listing or moving pod resources with @jeswr/storage-client, or maintaining its Solid/LWS backends and offline fixtures.
02 资源文件 117
- 参考文档package.json2.0 KB
- 参考文档README.md14.0 KB
- 参考文档references/lws-read.md7.8 KB
- 参考文档references/lws-write.md5.9 KB
- 参考文档references/solid-write.md13.0 KB
- 脚本src/api-additions.test.ts17.8 KB
- 脚本src/client.test.ts5.4 KB
- 脚本src/client.ts1.5 KB
- 脚本src/create-at.test.ts9.3 KB
- 脚本src/errors.test.ts9.4 KB
- 脚本src/errors.ts7.3 KB
- 脚本src/exact-create.test.ts5.6 KB
- 脚本src/exact-create.ts1017 B
- 脚本src/fixtures/css.ts4.5 KB
- 脚本src/fixtures/lws.ts6.0 KB
- 脚本src/helpers.test.ts2.3 KB
- 脚本src/helpers.ts4.4 KB
- 脚本src/http.ts11.7 KB
- 脚本src/index.test.ts1.5 KB
- 脚本src/index.ts410 B
- 脚本src/internal.test.ts7.3 KB
- 脚本src/internal.ts5.9 KB
- 脚本src/json-patch.test.ts8.2 KB
- 脚本src/json-patch.ts7.0 KB
- 脚本src/listing-limits.test.ts12.5 KB
- 脚本src/lws-backend.test.ts51.5 KB
- 脚本src/lws-backend.ts12.2 KB
- 脚本src/lws-write.test.ts67.7 KB
- 脚本src/lws-write.ts26.0 KB
- 脚本src/lws.ts158 B
- 脚本src/memory.test.ts56.4 KB
- 脚本src/memory.ts42.0 KB
- 脚本src/network-read.test.ts26.4 KB
- 脚本src/rdf-parse-abort.test.ts1.5 KB
- 脚本src/rdf.test.ts18.0 KB
- 脚本src/rdf.ts11.9 KB
- 脚本src/read.ts7.3 KB
- 脚本src/recorded-conformance.test.ts4.4 KB
- 脚本src/services.test.ts46.5 KB
- 脚本src/services.ts5.7 KB
- 脚本src/solid-backend.test.ts24.6 KB
- 脚本src/solid-backend.ts9.9 KB
- 脚本src/solid-patch.ts4.6 KB
- 脚本src/solid-write.test.ts102.8 KB
- 脚本src/solid-write.ts29.5 KB
- 脚本src/solid.ts256 B
- 脚本src/testing.test.ts24.1 KB
- 脚本src/testing.ts9.5 KB
- 脚本src/trash.ts4.0 KB
- 脚本src/types.ts8.5 KB
- 脚本src/versions.ts3.2 KB
- 参考文档testing/fixtures/css/baseline/SC-CAP-discovery-cache/000001.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-CAP-discovery-cache/000002.json2.7 KB
- 参考文档testing/fixtures/css/baseline/SC-CAP-discovery-cache/000003.json1.1 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000001.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000002.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000003.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000004.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000005.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000006.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000007.json2.3 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000008.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000009.json2.3 KB
- 参考文档testing/fixtures/css/baseline/SC-META-links/000010.json2.1 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000001.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000002.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000003.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000004.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000005.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000006.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000007.json2.1 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000008.json2.5 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000009.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000010.json2.1 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000011.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000012.json2.1 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000013.json1.1 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000014.json2.1 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000015.json2.5 KB
- 参考文档testing/fixtures/css/baseline/SC-MOVE-resource/000016.json1.5 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-json/000001.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-json/000002.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-json/000003.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-json/000004.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-json/000005.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-json/000006.json1.9 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-json/000007.json2.1 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000001.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000002.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000003.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000004.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000005.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000006.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000007.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000008.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000009.json2.2 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000010.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-rdf/000011.json2.2 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000001.json1.4 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000002.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000003.json1.5 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000004.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000005.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000006.json1.5 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000007.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000008.json2.2 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000009.json2.0 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000010.json2.2 KB
- 参考文档testing/fixtures/css/baseline/SC-PATCH-where/000011.json2.2 KB
- 参考文档testing/fixtures/css/baseline/setup/000001.json2.0 KB
- 参考文档testing/fixtures/css/baseline/setup/000002.json2.7 KB
- 参考文档testing/fixtures/css/baseline/setup/000003.json1.1 KB
- 参考文档testing/fixtures/README.md1.4 KB
- 参考文档testing/fixtures/sparq-solid/baseline/setup/000001.json605 B
- 参考文档testing/fixtures/sparq-solid/baseline/setup/000002.json992 B
- 参考文档tsconfig.json251 B
- 脚本vitest.config.ts524 B
03 SKILL.md 正文
<!-- AUTHORED-BY Codex GPT-6.1-Sol --> <!-- AUTHORED-BY Claude Opus 5.5 --> <!-- AUTHORED-BY Codex GPT-6 -->
@jeswr/storage-client
Quick reference
Apps import createPodClient from @jeswr/storage-client. Inject the authenticated, guarded
fetch supplied by the auth layer; discovery and storage operations use that same transport.
Pass a storage root or a resource inside it. The factory resolves a StorageDescription,
derives features through capabilities() (including cached Solid probes), and picks the
backend from description.protocol. It returns { storage, description, features };
storage.features is the same features object. Discovery errors propagate without guessing
a backend. Apps should use this root API; direct ./solid and ./lws imports are for backend
work and tests (the SDK layer guard disallows app manifest edges to those subpaths).
import { createPodClient } from '@jeswr/storage-client';
declare const authenticatedFetch: typeof fetch; // Inject pod-auth auth.fetch.
declare const storageRoot: string;
declare const signal: AbortSignal;
const { storage, features } = await createPodClient({
fetch: authenticatedFetch,
storage: storageRoot,
signal,
});
const created = await storage.create(storage.root, 'first draft', {
name: 'note.txt', contentType: 'text/plain',
});
const current = await storage.head(created.url);
if (current.etag === null) throw new Error('A validator is required to edit this resource');
await storage.write(created.url, 'second draft', {
contentType: 'text/plain', ifMatch: current.etag,
});
Read LWS app differences before assuming path containment, permission headers or recursive notifications. Use pod-notifications for changes; pod-access provides WAC/ACP and LWS ODRL sharing/requests. Availability describes server support, not caller permission.
capabilities in the factory options is an optional DescriptionCache, shared with other
capability consumers; the default is the capabilities package's shared in-memory cache.
clock supplies discovery/cache time. signal covers client creation; pass operation signals
separately for subsequent reads/writes. backend explicitly forces an implementation for
diagnostics/tests; description and features still report discovery evidence, so it is not a
way to advertise capabilities the server lacks. All storage operation URLs remain absolute
and scoped to description.root; an LWS storage id never authorises a foreign fetch.
Conditional mutations and returned URLs
write,writeRdf,patch,move,delete, andsetMetadatarequire a nonemptyifMatch. Keep ETags verbatim. Re-read after a 412 (StorageError.code === 'precondition-failed');./helpersprovidesretryOnConflictfor callers that can safely reapply their change.- Only
writeandwriteRdfaccept'*': Solid sends no precondition; LWS sendsIf-Match: *and still returns 404 when the resource is absent. Prefer the observed ETag for edits.createneeds noifMatchbecause it creates a new resource. setMetadatatakes the metadata document's ETag fromstorage.metadata(url), rather than the content ETag. A write result may haveetag: nullif a committed mutation omitted it and its follow-up HEAD failed; read again before the next conditional mutation.etagSourcesays where a write result's ETag came from:"response"is the mutation's own validator;"follow-up"came from a later HEAD and may already be another writer's version. Use only a"response"ETag asifMatchwhen a follow-up write or delete must not clobber a concurrent update.- Solid
create(container, body, { exactUrl })preserves one canonical direct child URL and usesIf-None-Match: *. It cannot be combined withname; queries/fragments (including empty ones), nested or foreign targets and wrong trailing-slash kinds fail before I/O. LWS rejectsexactUrlas unsupported. Use this for existing deterministic paths, including raw colons. Memory exact creates materialize missing Solid parents after body collection and cancellation checks, matching Solid PUT; a failed body leaves those parents absent. - With
create(container, body, { name }), Solid PUTs an exact encoded child name withIf-None-Match: *; a taken name givesconflict. LWS POSTs withSlugas a hint, and the server decides the identifier. Without a name, both use POST. Always use the returnedurl, including after moves; never construct a resource URL from a hint. LWS move ignoresname. - Fixed Solid URLs use
createAt(client, url, body, options?)from./helpers, returning the backend'sWriteResult. Options omitname; setkind: 'container'for a trailing-slash container. Before callingcreate, it verifies parent +encodeURIComponent(decodedName)(+/for containers) is byte-equal to the requested URL. Literal colons, lowercase percent escapes changed by re-encoding, malformed escapes, noncanonical URLs, query/fragment and kind/slash mismatches give non-retryableStorageError('bad-request')before any request.isExactChildUrl(parent, url)from the same entry point is the pure, nonthrowing predicate for canonical direct children (resources or trailing-slash containers). It checks URL spelling and containment, not service semantics or permission.createAtseparately refuses a parent matching the advertised trash endpoint withbad-requestbeforecreate, so the body cannot execute as a trash command. Scope validation remains in force. Non-Solid clients giveStorageError('unsupported'): LWS cannot promise exact-name creation. A taken HTTP Solid name propagates asconflictwith status 412; Solid memory matches exact target collisions with 412 and messagename taken. Resource/container path collisions retain 409; do not treat a real HTTP 409 as an identical-create replay.
LWS RDF patch is read-modify-write by default: read the RDF and check the caller's initial
ETag, apply inserts/deletes locally, then PUT with that read's ETag. On 412 the backend re-reads
and reapplies once against the newer state; a second 412 propagates. This can merge a patch
into newer content, so callers needing strict rejection of all intervening edits should use
an explicit conditional writeRdf instead. Advertised SPARQL Update is used only for the actual
resource media type and default-graph patches; named-graph patches retain RMW. Variables and
nonempty where are unsupported. LWS stores RDF bodies as opaque content.
Offline fixtures (./testing, Node only)
createRecordingFetch({ fetch, directory }) returns the original transport unless RECORD=1
at construction. When enabled it buffers bodies, forwards the effective Request, and writes
one version-1 JSON pair per request as 000001.json, 000002.json, etc., in invocation order.
Use a fresh scenario directory for each recorder; files are created exclusively, never
silently overwritten. Conformance runners can target
packages/storage-client/testing/fixtures/<target>/<scenario>/. Package tests use temporary
directories and synthetic CSS/sparq exchanges; no live server is needed.
Headers are normalised; Authorization, DPoP, Set-Cookie, Cookie and Proxy-Authorization are omitted case-insensitively from both persisted sides. Live requests/responses retain those headers. Bodies use base64 to preserve arbitrary bytes; null means no body, distinct from empty bytes. This is header redaction only: use public/synthetic body and URL data for fixtures, and inspect captures before committing them.
import {
createRecordingFetch, createReplayFetch, loadFixtures,
} from '@jeswr/storage-client/testing';
import { createPodClient } from '@jeswr/storage-client';
import { createMemoryCache } from '@jeswr/storage-capabilities/cache';
declare const authenticatedFetch: typeof fetch;
declare const directory: string; // Fresh directory containing synthetic/public fixture data.
declare const storageRoot: string;
const freshCache = createMemoryCache();
const recordedFetch = createRecordingFetch({ fetch: authenticatedFetch, directory });
// In RECORD=1 mode, inject recordedFetch into the conformance client's factory.
// In offline tests, inject the replay instead:
const replay = createReplayFetch(await loadFixtures(directory));
const client = await createPodClient({ fetch: replay, storage: storageRoot, capabilities: freshCache });
// Run the recorded scenario using client.storage, then prove all pairs were consumed:
replay.assertDone();
Replay checks method, URL, public headers and exact request bytes in order, ignoring credential headers. Extra requests, mismatches, corrupt fixtures and unused entries fail; no network fallback exists. Mismatches do not consume entries and never echo request/header/body data. Responses preserve recorded URLs, redirect flags, status and bytes. Match discovery/cache state and generated names to the recording; use deterministic name hints in reproducible tests.
T-020 implements the ADR-003 §1 types (src/types.ts, re-exported as types from the root), the
§2 error model (StorageError, pure toStorageError(method, url, response, bodyText?, now?),
storageErrorFrom that reads at most 64 KiB of a JSON/problem body), ./helpers
(createAt for fixed Solid destinations, retryOnConflict, which re-reads before every retry,
plus the in-house RFC 6902 applyJsonPatch),
and ./memory (createMemoryStorage({ protocol, root, pageSize, moveResource, strictConditional, clock })).
T-021 adds the Solid backend's read side; T-022 adds its mutations. ./solid exports
createSolidBackend({ fetch, root, features?, etagFollowUp? }) and the pure async
buildN3Patch({ inserts, deletes, where? }). T-023 adds ./lws →
createLwsBackend({ fetch, root, storage?, features? }). T-024 adds conditional LWS mutations
in src/lws-write.ts. T-025 adds createPodClient and the Node-only recorder/replayer in ./testing.
Solid read side (ADR-003 §6):
- Every URL must be absolute: its standalone parse (
new URL(url), without a base) must pass guarded-fetchassertWithinPodScope(root, …)and equal the root-based resolution of the input; otherwisescope, before any request, on both backends. This rejects ambiguous same-scheme references (https:host/path,https:/pathand their backslash variants), redacting credentials from errors and causes. The canonical scoped URL is always fetched, including cursor pages; opaque query spelling/order survives canonicalisation. Solid scopes supplied cursors before rejecting them withbad-request(one page). Redirects are never followed (redirect: 'manual'; a 3xx isinvalid-response). Transport failures are retryablenetworkerrors; aborts are non-retryablenetworkerrors. listGETs Turtle and readsldp:containsthrough@solid/object'sContainer, with a localResourcesubclass fordct:format. Members outside the storage or not directly contained are dropped (fail closed). Kind comes fromldp:(Basic)Containeror a trailing slash, contentType from a validdct:formatliteral or the IANA media-type class, size fromposix:size, modified fromdc:modified, elseposix:mtime(epoch seconds). Non-IRIrdf:typeobjects and malformed fields are dropped, never the member. Items are sorted by URL. A non-container ismethod-not-allowed.list/listAllacceptListingOptions.maxBytes, a non-negative safe integer response-byte cap per page. Invalid caps throwTypeErrorbefore fetching; zero is a real cap and exact limits succeed. Both HTTP backends reusehttp.ts'sboundedTextreader (extracted from LWS JSON collection), counting actual streamed bytes before decoding/parsing and cancelling overflow without awaiting cancellation. Overflow is non-retryableStorageError('payload-too-large')with the page URL and cap in its message; no entries from that page escape. Consumers oflistAllmust propagate later-page failures even after receiving complete earlier pages. Omitting the option keeps existing backend limits; raising it never raises LWS's 16 MiB hard cap. Memory measures the same UTF-8 container representation asread, including empty listings.head/readuseLink(context = the response URL; anchored links ignored) fortype,describedby→metadataUrl, WAC-Allowuser→allow, and path arithmetic forparent.readsends Accept, If-None-Match andRange: bytes=…(206). Only 200, a requested 206 and a conditional 304 succeed; any other 2xx/3xx isinvalid-response.bodyis the live stream;bytes()/text()/blob()buffer that same stream once (use one or the other). A body failing mid-transfer is anetworkerror on both paths (non-retryable once the signal aborted).- Scope errors redact embedded credentials of the target and the root in every authority
spelling (backslashes included).
list()refuses a URL with a query or fragment (bad-request), except a query matching the advertised version-history template for a scoped resource. Fragments remain refused.kindfollows the path (never the query), and the slashless root alias is the root even with a query or fragment (parentOf→ null). Both network backends'listAll()scope, canonicalise and validate the container exactly aslist()before pagination checks aborts, so even an already-aborted signal cannot expose raw container credentials in errors. Pagination receives only the canonical container and cursors. readRdfacceptstext/turtle, application/ld+json;q=0.9, maps 304 tonotModified, and reports a non-RDF or unparsable body asnot-rdf. On both HTTP backends, its GET also maps 406 or 501 tonot-rdf, preserving status, URL, method and problem details; other operations retain their usual HTTP error mapping.metadatareads thedescribedbydocument as RDF (unsupportedwhen none is advertised).Linkand WAC-Allow parsing reuse@jeswr/storage-capabilities(parseLinkHeaders,parseWacAllow). Both backends parse authoritative Link headers with explicit overflow rejection: at most 64 KiB UTF-8 per combined field value, 1,024 nonempty members (including malformed members), and 1 MiB of cumulative resolved target + anchor context URL lengths, measured in UTF-16 code units before retaining each member. Every retained member counts both URLs, including duplicates and the response URL used when no anchor is supplied. Overflow givesinvalid-responseand discards the body before storage validation or type, next, describedby, up or linkset discovery can use partial results. Exact limits are accepted. Repeated relation tokens within one member add only one target per relation; separate members retain their order and duplicates. Targets append without copying earlier entries.
Keepalive writes and display names
WriteOptions and CreateOptions accept keepalive?: boolean, forwarded to the injected
fetch for write, writeRdf and create. Browsers cap keepalive bodies at 64 KiB.
The client measures encoded bytes (UTF-8 for strings, the view's byte length for Uint8Array,
and Blob.size), accepts exactly 65,536 bytes and rejects larger or unknown-size bodies with
non-retryable StorageError('bad-request') before sending. ReadableStreams and Blobs without
a known finite size are refused with keepalive. Callers can fall back to their outbox.
Omitting keepalive retains ordinary streaming and upload behavior; the memory backend
applies the same body-size check.
MetadataOp.title?: string carries a display title when the server chooses a different
identifier from the requested name. On LWS, an add writes RFC 9264's title target attribute;
adding an existing href with a title updates that attribute and retains the others. On Solid,
an add sets dct:title on the anchor in its describedby document, through the existing N3
Patch builder. Empty titles are valid. A remove still removes matching hrefs on LWS; on
Solid, supplying title also removes that exact title literal from the anchor. Use the
metadata document's ETag for these edits.
Every listing Entry now has displayName: string | null: LWS reads the listing target's
title, Solid reads the member's dct:title in the container listing. Missing or malformed
fields are null; no extra metadata requests are made. displayNameOf(entry), exported from
both the package root and ./helpers, returns displayName ?? decodedLastPathSegment.
It removes a container's trailing slash before choosing the segment and keeps the raw segment
when percent decoding fails. An empty displayName remains empty.
LWS read side
LWS reads use scoped opaque identifiers, paginated JSON listings and linkset metadata; storage-id links never authorise a request outside the root. Read the LWS read protocol details before changing discovery validation, read/list/metadata handling, pagination or response size limits.
LWS write side
LWS mutations use conditional writes, server-assigned create identifiers, linkset metadata patches and logical containment for moves and recursive deletion. Read the LWS write protocol details before changing any LWS mutation, including RDF patch retries, ETag handling or move/delete preflight.
Solid write side
Solid mutations use conditional HTTP requests and N3/SPARQL patches; moves emulate copy and delete with preflight and conditional rollback. Read the Solid write protocol details before changing mutations, patch serialization, recursive deletion, move safety or describedby metadata updates.
Rules the memory backend enforces, and the real backends must match:
- Every mutation (
write,writeRdf,patch,setMetadata,move,delete) needsifMatch(TypeError otherwise, unlessstrictConditional: false, where Solid proceeds and LWS answers 428).'*'is accepted only bywrite/writeRdf(ADR-003 §3); elsewhere it is a TypeError. On Solid,'*'means no precondition. On LWS it isIf-Match: *, and PUT never creates (404). - Mutations are applied one at a time, so an ETag check and its commit are never split by another
mutation, and concurrent creates never share a URL. Reads snapshot the node before any await, so
bytes and ETag always describe the same state. An abort while a body is being collected cancels
the stream and nothing is committed; a queued mutation whose signal fires rejects at once. A
failing body stream is a non-retryable
networkerror. Only canonical, IRI-safe URLs are accepted (bad-requestotherwise). - Every serialisation escapes IRIREF-forbidden characters in IRIs and prefix namespaces
(
escapeIri), relabels unsafe blank-node labels and refuses malformed language tags and prefix names (exact TurtlePN_PREFIX), so crafted terms can never forge triples. Every term is rebuilt with n3's DataFactory from its RDF/JS fields only (a foreign term's ownidis never written; non-string fields are a TypeError). Prefixes are only cosmetic: a dotted prefix name, one that some IRI starts with (name:), or a namespace containing[(IPv6 hosts) is silently dropped. Variables (N3 Patch only) are rebuilt the same way. Moving a resource rewrites metadata anchors on that resource and its fragments only.listAllstops between entries once aborted. - A stale ETag gives
precondition-failed(412) with the currentetag. ETags change on every write, and a container's ETag changes only on membership changes. - LWS lists in pages (
nextcursors are opaque), Solid lists in one page.listAllrefuses a repeated page and stops at 10 000 pages. A raw LWS containerreadreturns the same page with anextlink, and thecontainer?page=NURL is readable. - RDF patch applies inserts/deletes atomically, and a missing deletion is a 409
conflict. Named graphs are refused (422) for Turtle / N-Triples resources, andwriteRdfthrows a TypeError rather than labelling graph blocks as Turtle.whereisunsupportedin memory. JSON Patch applies to JSON resources only. - Solid moves are copy+delete emulation (new URL, capped at 2 000 resources) and drop ACLs.
ACL-preserving moves use
movePreservingAccessfrom@jeswr/pod-access/roles(SDK-APP-04). LWS moves need MoveResource (unsupportedwithfeature: 'move'otherwise), and the server picks the name. - LWS
setMetadatarefuses the server-managed relslinkset,typeandup. Solid rels that are not IRIs map tohttp://www.iana.org/assignments/relation/<rel>. readRdfwith a matchingifNoneMatchresolves withnotModified: trueand an empty dataset (an extension to ADR-003'sRdfReadResult). MemorywriteRdfserialises the n3-writable formats andapplication/ld+jsonthrough@jeswr/rdf-serialize. JSON-LD is an expanded, context-free array ([]for an empty dataset), with document-local blank-node labels, named graphs and literal lexical values preserved. Prefixes are ignored; no caller context is accepted and no remote context is emitted or fetched. Malformed terms and directional literals (includingrdf:dirLangString) reject withTypeError. JSON-LD RDF patch support is unchanged (415). The Solid and LWS HTTP backends support mutations; their JSON-LD writes remain unsupported.
RDF/JS types (DatasetCore, Quad, Term) come from @jeswr/fetch-rdf's type re-exports, so the
emitted declarations need no @rdfjs/types dependency (which the layer guard does not allow).
Before implementation, read SDK core ADR-001 D4 and ADR-003-storage-client.md in
solid-suite-planning/specs/sdk-core/ and this repository's AGENTS.md.
This package is security critical. Keep coverage thresholds at 100% and add behavioral and adversarial tests with the implementation.
Keep dev tool versions aligned with the root. pnpm 10.4.1 with ignore-scripts requires
local tool declarations for filtered scripts.
Validate changes with this package's lint, build, typecheck, and test scripts.
Optional trash and version clients (SDK-APP-12)
./trash → createTrashClient(storage); ./versions → createVersionsClient(storage). Both require advertised available features and scoped endpoints.
Read optional service client guidance for API contracts, query templates, conditional restores, memory flags and the protocol appendix.
04 同仓库更多 Skills
storage-conformance
Work on @jeswr/storage-conformance, the shared storage conformance suite package in the Solid SDK workspace.
fetch-rdf-engine-tests
Maintain fetch-rdf's real Node WASM parser integration tests without introducing a reverse engine dependency in fetch-rdf.
alpha
Use when checking fixtures, including folded YAML descriptions.
widget
Use when testing package skills: YAML quoting works.
web-seo
Use when improving technical and entity SEO for a modern personal, portfolio, documentation, or marketing site, including crawlable HTML, canonical metadata, sitemap and robots, Person/ProfilePage JSON-LD, Core Web Vitals, and honest ranking expectations.
solid-wac
Use when implementing or auditing Solid server WAC authorization, ACL creation and inheritance, auxiliary-resource escalation, method-to-mode mapping, 401 versus 403 challenges, WAC-Allow, or defensive typed ACL parsing with @solid/object and @rdfjs/wrapper.