1.7.0 • Published 3 years ago
@zestlabs-io/zest-js-sdk v1.7.0
Zest Cloud API JS/TS SDK
Usage in node module
npm i @zestlabs-io/zest-js-sdk
Set your key and secret for Zest Cloud as environment variable:
export ZEST_KEY=HereComesYourKey ZEST_SECRET=HereComesYourSecret
Example usage
Once set up, you can use below code to interact with the Zest Cloud.
Creating user
import { AuthServiceApiHMAC } from '@zestlabs-io/zest-js-sdk';
// Fetch the key and secret from env
const cloudKey = process.env.ZEST_KEY || '';
const cloudSecret = process.env.ZEST_SECRET || '';
// This is the base url for ZEST Cloud
const baseUrl = 'https://dev.zestlabs.cloud';
// Create the API you need with baseURL, key and secret
const api = new AuthServiceApiHMAC(baseUrl, cloudKey, cloudSecret);
// Call the API
const userCreateResponse = await api.createUser({ firstName: 'Test', lastName: 'User', email: 'test@zestlabs.io' });
Creating data pool and uploading data to it
import { DistrconfigPoolType, PoolDataServiceApiHMAC } from '@zestlabs-io/zest-js-sdk';
// Fetch the key and secret from env
const cloudKey = process.env.ZEST_KEY || '';
const cloudSecret = process.env.ZEST_SECRET || '';
// This is the base url for ZEST Cloud
const baseUrl = 'https://dev.zestlabs.cloud';
const distrApi = new DistrConfigServiceApiHMAC(baseUrl, cloudKey, cloudSecret);
// Create global type of my_pool
const poolCreateResp = await distrApi.createPool({
id: 'my_pool',
poolType: DistrconfigPoolType.GLOBAL,
pkExtractExpression: '$.pk',
tagExtractExpression: '$.locality',
});
const dataApi = new DataAPI(baseUrl, cloudKey, cloudSecret);
// Create some data in my_pool
const createResp = await dataApi.bulkCreate('my_pool',
[{ pk: 'customer1', locality: 'loc1' } as any,
{ pk: 'customer2', locality: 'loc1' } as any,
{ pk: 'customer3', locality: 'loc2' } as any]);
For more details on the SDK, please refer to the tests:
License
MIT
1.7.0
3 years ago
1.6.1
3 years ago
1.6.0
3 years ago
1.5.0
3 years ago
1.4.0
3 years ago
1.2.2
3 years ago
1.3.0
3 years ago
1.2.1
3 years ago
1.2.0
3 years ago
1.1.0
4 years ago
1.0.13
4 years ago
1.0.11
4 years ago
1.0.12
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
0.1.9
5 years ago
0.1.8
5 years ago
0.1.7
5 years ago
0.1.6
5 years ago
0.1.5
5 years ago
0.1.4
5 years ago
0.1.3
5 years ago
0.1.2
5 years ago
0.1.1
5 years ago
0.1.0
5 years ago