usm-core
v0.4.8
Published
Universal Schema Model — storage- and transport-agnostic core: search schema, collection/model bases, and the live-query subscription engine
Downloads
1,620
Readme
usm-core
Universal Schema Model — the storage- and transport-agnostic core.
A reflective, Hasura-style data-modeling engine for Node.js. This package holds everything that doesn't depend on a database or an API protocol:
- Vocabulary —
SCALAR_TYPES,OPERATORS,OPERATORS_BY_TYPE,coerce. - Schema —
CollectionSchema(a table descriptor) andSearchSchema(a registry that resolves relationships and vends searchers).SearchSchemais storage-agnostic: it takes a searcher factory supplied by an adapter. - Model bases — abstract
Collection→KeyedCollection(key normalization + TTL/LRU cache over an abstractbatchLoadByKeyValues) →ModelCollection(hydratedgetByKey+search/aggregate), plusModelType. - Searcher contract —
Searcher(implemented by adapters). - Subscriptions —
SubscriptionManager(cohort multiplexing + change-driven or polling refetch, pushes only on change) and theChangeSourceinterface.
It depends on nothing GraphQL- or SQL-specific, so it can back multiple adapters (Postgres today) and multiple API layers (GraphQL today).
Install
npm install usm-coreCompanion packages
- usm-adapter-postgres — knex/Postgres adapter: concrete searcher (the
where/order_by → SQL compiler), knex collections, a
SearchSchemafactory, and a LISTEN/NOTIFYChangeSource. - usm-api-graphql — turns a
SearchSchemainto Hasura-style GraphQL (queries, aggregates, live-query subscriptions).
Shape
usm-core (this package)
▲
┌──────────┴───────────┐
usm-api-graphql usm-adapter-postgresAdapters and API layers depend on core; never on each other.
