Contribute to this page
API cheatsheet
A quick reference to the whole @machhub-dev/sdk-ts surface. Follow the links for
details and examples.
import { SDK } from '@machhub-dev/sdk-ts';const sdk = new SDK();await sdk.Initialize(/* config? */);See Install & initialize.
Namespaces at a glance
Section titled “Namespaces at a glance”| Namespace | Key methods | Guide |
|---|---|---|
sdk.collection(name) | getAll, getOne, create, update, delete, filter, orFilter, sort, offset, limit, first, count, expand, fields, filterInArray | Collections |
sdk.auth | login, logout, getCurrentUser, getJWTData, validateCurrentUser, validateJWT | Authentication |
sdk.auth (authz) | checkPermission, checkAction, getPermissions, getGroups, createGroup, addUserToGroup, getUsers, createUser | Authorization |
sdk.tag | getAllTags, publish, subscribe, unsubscribe, getValue | Realtime |
sdk.historian | query, getHistoricalDataAsCSV | Historian |
sdk.processes | execute, getProcesses, changeTriggers | Processes |
Common snippets
Section titled “Common snippets”// Queryawait sdk.collection('products') .filter('inStock', '=', true) .sort('price', 'asc') .offset(0).limit(25) .getAll();
// Authawait sdk.auth.login('username', 'password');const me = await sdk.auth.getCurrentUser();
// Realtimeawait sdk.tag.subscribe('line1/+/temperature', (v, topic) => console.log(topic, v));await sdk.tag.publish('line1/oven/temperature', 72.4);
// Historianawait sdk.historian.query(`SELECT math::mean(value) AS avg FROM historian WHERE topic = 'line1/oven/temperature'`);
// Processawait sdk.processes.execute('computeAverage', { window: '1h' });RecordID
Section titled “RecordID”application_id.collection:record_id — e.g. myapp.products:PROD-001. Updates and
deletes need the full id; relations are written as { Table, ID }. See
RecordID.