nx-content-store
v0.1.0
Published
Managed shared-store platform for content: stores, keys, content CRUD, revisions, backends, sync.
Downloads
94
Maintainers
Readme
nx-content-store
Managed shared-store platform for content: stores, keys, content CRUD, revisions, backends, and sync. Generic and not aiFunctions-specific; ready for use by nx-content-store-server and clients.
Install
npm install nx-content-storeUsage
import {
createManagedContentStore,
type StorePersistenceAdapter,
type ManagedContentStore,
} from 'nx-content-store';
// Provide a persistence adapter (e.g. from xronox-content-store).
const store: ManagedContentStore = createManagedContentStore({
persistence: myPersistenceAdapter,
authorization: myAuthService, // optional
diagnostics: myDiagnostics, // optional
});
await store.stores.create({ storeId: 'my-store', slug: 'my-store', name: 'My Store', visibility: 'private', authPolicy: { read: 'secret-key', write: 'secret-key', admin: 'secret-key' }, backendPolicy: { readOrder: ['default'], writePrimary: 'default' } });
const s = await store.stores.get('my-store');
await store.content.set({ storeId: 'my-store', key: 'docs/readme.md' }, { content: '# Hello', format: 'md' });
const text = await store.content.get({ storeId: 'my-store', key: 'docs/readme.md' });Public API
- Factory:
createManagedContentStore({ persistence, authorization?, diagnostics? })→ManagedContentStore - Facade:
ManagedContentStore—stores,keys,content,revisions,backends,sync,diagnostics - Types: Store, key, content selector/entry, revision, backend binding, sync run, request context, and all input/result types
- Errors:
ContentStoreError,StoreNotFoundError,ContentConflictError, etc. - Utils:
normalizeKey,normalizeFormat,resolveSelector, etc.
Persistence is injected; no xronox types are exposed. Key/namespace/format normalization and variant fallback are applied in the core.
License
UNLICENSED
