@agentshouse/mdruntime-families
react-admin and Refine data providers over the
@agentshouse/mdruntime
client, so an App built on either framework reads and writes its Rooms.
Install
npm install @agentshouse/mdruntime-families @agentshouse/mdruntime
Usage
Each resource names the MD Type of its records and the folder they live in.
A record's id is its Path in the Room, prefixed by the Room's locator and /
when the App reaches several Rooms; a new record is created in the first.
import { QueryClient } from '@tanstack/react-query';
import { dataProvider } from '@agentshouse/mdruntime-families/react-admin';
const resources = { contacts: { type: 'contact', folder: 'contacts' } };
const queryClient = new QueryClient();
const provider = dataProvider(runtime, { resources, queryClient });
// <Admin dataProvider={provider} queryClient={queryClient}>
import { dataProvider, liveProvider } from '@agentshouse/mdruntime-families/refine';
// <Refine dataProvider={dataProvider(runtime, { resources })}
// liveProvider={liveProvider(runtime, { resources })} options={{ liveMode: 'auto' }}>
runtime is the client the host hands the App. A filter or sort field such
as address.city reads the value at /address/city. react-admin filters
compare for equality, a list for membership, and the suffixes _gt, _gte,
_lt, _lte and _neq compare as named; Refine filters take eq, ne,
lt, gt, lte, gte, in, nin, or and and. A field the Room schema
declares a reference, at any depth, holds the referenced record's id; id and
a reference compare only for equality and membership. Pages and totals are
counted over every matching record, and a page reads only its own window of
the Room; a list asked for without a page reads every record, window by
window. react-admin's update writes the fields
that differ from previousData, based on it, so the Save of a field another
writer changed meanwhile is refused; Refine's update and either updateMany
compare with the stored record. A Room the Runtime holds locked is left out of
every list, and a read or a write of a record in it rejects with the code
room-locked. A list stays current: react-admin's queries of a resource are
invalidated, and Refine's live mode refetches, when a record a page or a read
shows changes, a record a filter names starts or stops matching it, a page's
total changes, or a Room the list left out as locked unlocks.
License
MIT