Reference

Type helpers

Narrow tree.meta.kv between single-driver KvDescriptor and multi-driver KvNamespaceMap with isSingleDriverSchema.

Use isSingleDriverSchema to narrow tree.meta.kv at runtime.

Narrow the schema type

narrow.ts
import { isSingleDriverSchema } from 'comark-kv'

if (isSingleDriverSchema(tree.meta.kv!)) {
  // KvDescriptor — paths kv.key
} else {
  // KvNamespaceMap — paths kv.ns.key
}

Import from comark-kv or comark-kv/model depending on your bundle. The helper is the same function.

Copyright © 2026