1.7.0 • Published 2 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
2 years ago
1.6.1
2 years ago
1.6.0
2 years ago
1.5.0
2 years ago
1.4.0
2 years ago
1.2.2
2 years ago
1.3.0
2 years ago
1.2.1
2 years ago
1.2.0
2 years ago
1.1.0
2 years ago
1.0.13
2 years ago
1.0.11
3 years ago
1.0.12
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
0.1.9
4 years ago
0.1.8
4 years ago
0.1.7
4 years ago
0.1.6
4 years ago
0.1.5
4 years ago
0.1.4
4 years ago
0.1.3
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago