Registry / database / meadow-provider-offline

meadow-provider-offline

JSON →
library1.0.1jsnpmunverified

Offline-capable data provider for Fable/Meadow applications that intercepts RestClient requests and routes them to an in-process SQLite database via Orator IPC. Wraps the existing Fable RestClient, handling Meadow CRUD operations (Create, Read, Update, Delete, Count) locally while passing through non-Meadow HTTP requests unchanged. Features dirty record tracking with coalescing, cache-through mode, negative ID assignment for offline-created records, binary/blob storage via IndexedDB, and native SQLite bridge for mobile. Supports proactive data seeding and works identically in browser (sql.js WASM) and mobile environments. Current stable version: 1.0.1, maintained by Fable ecosystem.

npm install meadow-provider-offline
INSTALL
IMPORT
SIG · MEADOW-PROVIDER-OF
M
meadow-provider-offline
databasejavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

meadow-provider-offline (default)
import libMeadowProviderOffline from 'meadow-provider-offline';
const mead = require('meadow-provider-offline');
Module is ESM/CJS dual. Use named import or require as shown. No named exports; default export is the provider constructor.
libMeadowProviderOffline (CommonJS)
const libMeadowProviderOffline = require('meadow-provider-offline');
For Node.js or bundlers that don't support ESM fully.
MeadowProviderOffline (service type registration)
_Fable.serviceManager.addServiceType('MeadowProviderOffline', libMeadowProviderOffline);
_Fable.addServiceType(...)
Must use serviceManager, not Fable directly. Case-sensitive string.

Initializes Fable app, registers offline provider, adds entities, connects RestClient interception, and seeds data.

const libFable = require('fable'); const libMeadowProviderOffline = require('meadow-provider-offline'); const _Fable = new libFable({ Product: 'MyApp', ProductVersion: '1.0.0' }); _Fable.serviceManager.addServiceType('MeadowProviderOffline', libMeadowProviderOffline); const tmpOffline = _Fable.serviceManager.instantiateServiceProvider('MeadowProviderOffline', { SessionDataSource: 'None', DefaultSessionObject: { CustomerID: 1, SessionID: 'browser-offline', DeviceID: 'Browser', UserID: 1, UserRole: 'Administrator', UserRoleIndex: 255, LoggedIn: true } }); tmpOffline.initializeAsync((pError) => { if (pError) { throw pError; } tmpOffline.addEntity(bookSchema, (pBookError) => { tmpOffline.addEntity(authorSchema, (pAuthorError) => { tmpOffline.connect(_Fable.RestClient); tmpOffline.seedEntity('Book', bookRecords); tmpOffline.seedEntity('Author', authorRecords); }); }); });
Debug
Known issues
breakingImport path changed in v1.0.0: previously `meadow-provider-offline-browser` renamed to `meadow-provider-offline`. Old package deprecated.
fix
npm uninstall meadow-provider-offline-browser && npm install meadow-provider-offline@latest
affects: <1.0.0
deprecatedSessionDataSource: 'None' is deprecated; use 'Internal' or a real datasource name. In v2 it will be removed.
fix
Use SessionDataSource: 'Internal' or provide a valid datasource name.
affects: >=1.0.0 <2.0.0
gotchaaddEntity must be called with a schema object (not schema name string). Many users pass a string and get 'Cannot read property X of undefined'.
fix
Pass the full schema object from your Meadow entity definition, e.g., tmpOffline.addEntity(bookSchema, callback);
affects: >=1.0.0
gotchaconnect() must be called AFTER all addEntity calls are complete. Otherwise REST URLs won't be intercepted.
fix
Ensure initializeAsync callback has invoked all addEntity calls before calling connect().
affects: >=1.0.0
breakingseedEntity expects array of objects. Passing a single object silently fails (no error) and no data is seeded.
fix
Call seedEntity with an array, even for one record: tmpOffline.seedEntity('Book', [bookRecord]);
affects: >=1.0.0
deprecateddisconnect() will be renamed to disconnectAsync() in v2 to indicate async cleanup.
fix
Use disconnect() as before, but be prepared for rename.
affects: >=1.0.0 <2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'meadow-provider-offline'
Package not installed or old package name used
fix
Run: npm install meadow-provider-offline. If you have the old package, uninstall it first.
TypeError: tmpOffline.addEntity is not a function
Provider not fully initialized before calling addEntity
fix
Ensure addEntity is called inside the initializeAsync callback, not outside.
Request not intercepted: URL /1.0/Books/0/10 goes to network
connect() called before all addEntity calls completed
fix
Move connect() to after all addEntity calls in the callback.
TypeError: Cannot read property 'CustomerID' of undefined
DefaultSessionObject missing required fields
fix
Provide CustomerID, SessionID, DeviceID, UserID, UserRole, UserRoleIndex, LoggedIn in session object.
seedEntity did not seed any data
Passed a single object instead of an array
fix
Wrap the object in an array: tmpOffline.seedEntity('Book', [myObject]);
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
fablerequiredCore framework for service management, RestClient integration
meadow-connection-sqlite-browserrequiredBrowser-side SQLite connection via sql.js WASM
orator-ipcrequiredIn-process Orator layer for routing requests
Agent activity
5 hits · last 30 days
node
4
Resources