logiak-web-sdk

1.2.3 • Public • Published

Logiak Web SDK

Communication Bridge Between Logiak Platform and Web Apps

Installation

npm install logiak-web-sdk

or

yarn add logiak-web-sdk

Sample Usage

Imports & Initialisation

// es-6
import { auth, data, init, meta } from 'logiak-web-sdk';

or

// common-js
const { auth, data, init, meta } = require('logiak-web-sdk');

// Required config
const config = {
  project: '',
  version: '',
  language: '',
  baseURL: '',
};

// SDK must be initialized before usage
init(config);

Modules

auth

// User authentication
auth.login({ username: '', password: '' }).then().catch(); // Login
auth.loggedInUser().then().catch(); // Get loggedIn user
auth.logout().then().catch(); // Logout

data

// Table Data
data.getTables().then().catch(); // Get all tables data
data.getTable('table-name').then().catch(); // Get data for a single table
data.getTableList().then().catch(); // Get the list of table names

// Object Data
data.getObject('object-name').then().catch();
data.getObject('object-name', sampleQueryFilter).then().catch(); // see the section: `Optional Query Filter`

meta

// App/Project
meta.getApp().then().catch(); // Get project info
meta.getAppInfo().then().catch(); // Get app info

// Metadata
meta.getSchema().then().catch(); // Get all schemas
meta.getSchema('object-name').then().catch(); // Get schema for a single object

Optional Query Filter

(See Firebase Structured Query Language)[https://firebase.google.com/docs/firestore/reference/rest/v1/StructuredQuery]

const sampleQueryFilter = {
  where: {
    filter: {
      fieldFilter: {
        field: { fieldPath: 'email' },
        op: 'EQUAL',
        value: { stringValue: 'data.collector@ehealthnigeria.org' }
      }
    }
  },
  orderBy: [
    {
      field: { fieldPath: 'batch' },
      direction: 'DESCENDING'
    }],
  startAt: {
    values: [
      { stringValue: 'A009' }
    ]
  },
  endAt: {
    values: [
      { stringValue: 'A004' }
    ]
  }
};

Readme

Keywords

none

Package Sidebar

Install

npm i logiak-web-sdk

Weekly Downloads

1

Version

1.2.3

License

ISC

Unpacked Size

13.7 kB

Total Files

19

Last publish

Collaborators

  • ehealthafrica-sw