deyta.namespaces.scope(id) (or
deyta.namespaces.scopeByExternalRef(ref)).
The scope is a lightweight handle. No network call is made when constructing
it.
Surface
Why this pattern
Less repetition
Stop typing
namespace_id: "ns_..." on every call.Fewer bugs
No more accidental cross-namespace operations from a copy-paste.
External refs work everywhere
Scope by your app’s user/tenant ID; the SDK resolves the namespace as needed.
Free to construct
The scope is local — no network call until you issue an operation.
Top-level resources are still there
deyta.memory, deyta.namespaces, and deyta.integrations remain available
for unscoped or cross-namespace ad-hoc work. The sub-client is a convenience,
not a replacement.
Errors and the scope
Scoping does not change the shape of errors. Operations on a scoped sub-client throw the sameDeytaError / DeytaConnectionError types as the top-level
client, with the same status codes and error codes.
scopeByExternalRef makes no network call, a typo in
the reference doesn’t surface until the first real operation. If you want to
fail fast on construction, call await ns.metadata() once after scoping.