New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@codetanzania/emis-api-client

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codetanzania/emis-api-client - npm Package Compare versions

Comparing version 0.14.1 to 0.15.0

18

CHANGELOG.md

@@ -0,1 +1,19 @@

#### 0.15.0 (2019-06-09)
##### Chores
* **deps:**
* force latest version & audit fix ([1c32bec4](https://github.com/CodeTanzania/emis-api-client/commit/1c32bec43287d3b190f3af4ca6f0001eb9ee012f))
* update dependency rollup to v1.14.4 ([058bb7c0](https://github.com/CodeTanzania/emis-api-client/commit/058bb7c0c651ba44582c9721ce7f4110adb810a9))
* format package.json ([011f137f](https://github.com/CodeTanzania/emis-api-client/commit/011f137f89c86b1f2f2e313316b10cd0dffa2855))
##### Documentation Changes
* **client:** improve jsdocs ([2d21cac3](https://github.com/CodeTanzania/emis-api-client/commit/2d21cac37936845d434fedb595bb6beee2f66d09))
##### New Features
* add bucket support on http request paths ([2088e37f](https://github.com/CodeTanzania/emis-api-client/commit/2088e37f6eb3e73c5f60d241988303f7111858c1))
* add bucket to predefine shortcuts ([e841391c](https://github.com/CodeTanzania/emis-api-client/commit/e841391ce5b3f264720620d4d758987e258e89cf))
#### 0.14.1 (2019-06-07)

@@ -2,0 +20,0 @@

98

es/index.js

@@ -8,3 +8,3 @@ import moment from 'moment';

import { getString } from '@lykmapipo/env';
import { forEach, isEmpty, merge, isString, isArray, isPlainObject, toLower, omit, first, min, max, clone, upperFirst } from 'lodash';
import { isEmpty, forEach, merge, isString, isArray, isPlainObject, toLower, omit, first, min, max, clone, upperFirst } from 'lodash';

@@ -21,2 +21,10 @@ // default http client

/**
* @function
* @name getJwtToken
* @description retrieve jwt token from session storage if not set
* @return {string| undefined} jwt token
* @since 0.14.0
* @version 0.1.0
*/
const getJwtToken = () => {

@@ -37,3 +45,3 @@ if (isEmpty(jwtToken)) {

* @returns {boolean} check if token is valid or not
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -50,5 +58,8 @@ * @example

if (isEmpty(jwtToken)) {
return false;
}
try {
verify(jwtToken, JWT_SECRET);
return true;

@@ -495,3 +506,3 @@ } catch (error) {

* @returns {object} Object having party, permission and other meta data
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -527,3 +538,3 @@ * @static

* @description Signout current signin user and clear session Storage
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -596,2 +607,3 @@ * @static

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -605,3 +617,8 @@

[methodName]: () => {
const endpoint = `/${toLower(plural)}/schema`;
// derive endpoint
let endpoint = `/${toLower(plural)}/schema`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/schema`;
}
// issue http request
return get(endpoint);

@@ -632,3 +649,3 @@ },

// ensure resource
const { shortcut, wellknown } = normalizeResource(resource);
const { shortcut, wellknown, bucket } = normalizeResource(resource);

@@ -643,3 +660,8 @@ // generate method name

const params = prepareParams(mergeObjects(resource.params, options));
const endpoint = `${BASE_URL}/${toLower(wellknown.plural)}/export`;
// derive endpoint
let endpoint = `${BASE_URL}/${toLower(wellknown.plural)}/export`;
if (!isEmpty(bucket)) {
endpoint = `${BASE_URL}/${toLower(wellknown.plural)}/${bucket}/export`;
}
// build export url
const url = buildURL(endpoint, params);

@@ -671,3 +693,3 @@ return url;

// ensure resource
const { shortcut, wellknown } = normalizeResource(resource);
const { shortcut, wellknown, bucket } = normalizeResource(resource);

@@ -682,3 +704,8 @@ // generate method name

const params = mergeObjects(resource.params, options);
const endpoint = `/${toLower(wellknown.plural)}`;
// derive endpoint
let endpoint = `/${toLower(wellknown.plural)}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(wellknown.plural)}/${bucket}`;
}
// issue http request
return get(endpoint, params);

@@ -712,2 +739,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -723,3 +751,8 @@

const params = mergeObjects(resource.params);
const endpoint = `/${toLower(plural)}/${id}`;
// derive endpoint
let endpoint = `/${toLower(plural)}/${id}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/${id}`;
}
// issue http request
return get(endpoint, params);

@@ -753,2 +786,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -765,3 +799,8 @@

const data = mergeObjects(payload, defaults);
const endpoint = `/${toLower(plural)}`;
// derive endpoint
let endpoint = `/${toLower(plural)}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}`;
}
// issue http request
return post(endpoint, data);

@@ -795,2 +834,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -807,3 +847,8 @@

const data = mergeObjects(payload, defaults);
const endpoint = `/${toLower(plural)}/${idOf(data)}`;
// derive endpoint
let endpoint = `/${toLower(plural)}/${idOf(data)}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/${idOf(data)}`;
}
// issue http request
return put(endpoint, data);

@@ -837,2 +882,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -849,3 +895,8 @@

const data = mergeObjects(payload, defaults);
const endpoint = `/${toLower(plural)}/${idOf(data)}`;
// derive endpoint
let endpoint = `/${toLower(plural)}/${idOf(data)}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/${idOf(data)}`;
}
// issue http request
return patch(endpoint, data);

@@ -879,2 +930,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -888,4 +940,8 @@

[methodName]: id => {
// prepare params
const endpoint = `/${toLower(plural)}/${id}`;
// derive endpoint
let endpoint = `/${toLower(plural)}/${id}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/${id}`;
}
// issue http request
return del(endpoint);

@@ -1081,5 +1137,4 @@ },

wellknown: 'predefine',
params: mergeObjects(DEFAULT_PARAMS, {
filter: { namespace: 'ItemUnit', key: 'unit' },
}),
bucket: 'itemunits',
params: mergeObjects(DEFAULT_PARAMS),
},

@@ -1089,5 +1144,4 @@ itemCategory: {

wellknown: 'predefine',
params: mergeObjects(DEFAULT_PARAMS, {
filter: { namespace: 'ItemCategory', key: 'category' },
}),
bucket: 'itemcategories',
params: mergeObjects(DEFAULT_PARAMS),
},

@@ -1094,0 +1148,0 @@ };

@@ -22,2 +22,10 @@ 'use strict';

/**
* @function
* @name getJwtToken
* @description retrieve jwt token from session storage if not set
* @return {string| undefined} jwt token
* @since 0.14.0
* @version 0.1.0
*/
const getJwtToken = () => {

@@ -38,3 +46,3 @@ if (lodash.isEmpty(jwtToken)) {

* @returns {boolean} check if token is valid or not
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -51,5 +59,8 @@ * @example

if (lodash.isEmpty(jwtToken)) {
return false;
}
try {
jsonwebtoken.verify(jwtToken, JWT_SECRET);
return true;

@@ -496,3 +507,3 @@ } catch (error) {

* @returns {object} Object having party, permission and other meta data
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -528,3 +539,3 @@ * @static

* @description Signout current signin user and clear session Storage
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -597,2 +608,3 @@ * @static

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -606,3 +618,8 @@

[methodName]: () => {
const endpoint = `/${lodash.toLower(plural)}/schema`;
// derive endpoint
let endpoint = `/${lodash.toLower(plural)}/schema`;
if (!lodash.isEmpty(bucket)) {
endpoint = `/${lodash.toLower(plural)}/${bucket}/schema`;
}
// issue http request
return get(endpoint);

@@ -633,3 +650,3 @@ },

// ensure resource
const { shortcut, wellknown } = normalizeResource(resource);
const { shortcut, wellknown, bucket } = normalizeResource(resource);

@@ -644,3 +661,8 @@ // generate method name

const params = prepareParams(common.mergeObjects(resource.params, options));
const endpoint = `${BASE_URL}/${lodash.toLower(wellknown.plural)}/export`;
// derive endpoint
let endpoint = `${BASE_URL}/${lodash.toLower(wellknown.plural)}/export`;
if (!lodash.isEmpty(bucket)) {
endpoint = `${BASE_URL}/${lodash.toLower(wellknown.plural)}/${bucket}/export`;
}
// build export url
const url = buildURL(endpoint, params);

@@ -672,3 +694,3 @@ return url;

// ensure resource
const { shortcut, wellknown } = normalizeResource(resource);
const { shortcut, wellknown, bucket } = normalizeResource(resource);

@@ -683,3 +705,8 @@ // generate method name

const params = common.mergeObjects(resource.params, options);
const endpoint = `/${lodash.toLower(wellknown.plural)}`;
// derive endpoint
let endpoint = `/${lodash.toLower(wellknown.plural)}`;
if (!lodash.isEmpty(bucket)) {
endpoint = `/${lodash.toLower(wellknown.plural)}/${bucket}`;
}
// issue http request
return get(endpoint, params);

@@ -713,2 +740,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -724,3 +752,8 @@

const params = common.mergeObjects(resource.params);
const endpoint = `/${lodash.toLower(plural)}/${id}`;
// derive endpoint
let endpoint = `/${lodash.toLower(plural)}/${id}`;
if (!lodash.isEmpty(bucket)) {
endpoint = `/${lodash.toLower(plural)}/${bucket}/${id}`;
}
// issue http request
return get(endpoint, params);

@@ -754,2 +787,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -766,3 +800,8 @@

const data = common.mergeObjects(payload, defaults);
const endpoint = `/${lodash.toLower(plural)}`;
// derive endpoint
let endpoint = `/${lodash.toLower(plural)}`;
if (!lodash.isEmpty(bucket)) {
endpoint = `/${lodash.toLower(plural)}/${bucket}`;
}
// issue http request
return post(endpoint, data);

@@ -796,2 +835,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -808,3 +848,8 @@

const data = common.mergeObjects(payload, defaults);
const endpoint = `/${lodash.toLower(plural)}/${common.idOf(data)}`;
// derive endpoint
let endpoint = `/${lodash.toLower(plural)}/${common.idOf(data)}`;
if (!lodash.isEmpty(bucket)) {
endpoint = `/${lodash.toLower(plural)}/${bucket}/${common.idOf(data)}`;
}
// issue http request
return put(endpoint, data);

@@ -838,2 +883,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -850,3 +896,8 @@

const data = common.mergeObjects(payload, defaults);
const endpoint = `/${lodash.toLower(plural)}/${common.idOf(data)}`;
// derive endpoint
let endpoint = `/${lodash.toLower(plural)}/${common.idOf(data)}`;
if (!lodash.isEmpty(bucket)) {
endpoint = `/${lodash.toLower(plural)}/${bucket}/${common.idOf(data)}`;
}
// issue http request
return patch(endpoint, data);

@@ -880,2 +931,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -889,4 +941,8 @@

[methodName]: id => {
// prepare params
const endpoint = `/${lodash.toLower(plural)}/${id}`;
// derive endpoint
let endpoint = `/${lodash.toLower(plural)}/${id}`;
if (!lodash.isEmpty(bucket)) {
endpoint = `/${lodash.toLower(plural)}/${bucket}/${id}`;
}
// issue http request
return del(endpoint);

@@ -1082,5 +1138,4 @@ },

wellknown: 'predefine',
params: common.mergeObjects(DEFAULT_PARAMS, {
filter: { namespace: 'ItemUnit', key: 'unit' },
}),
bucket: 'itemunits',
params: common.mergeObjects(DEFAULT_PARAMS),
},

@@ -1090,5 +1145,4 @@ itemCategory: {

wellknown: 'predefine',
params: common.mergeObjects(DEFAULT_PARAMS, {
filter: { namespace: 'ItemCategory', key: 'category' },
}),
bucket: 'itemcategories',
params: common.mergeObjects(DEFAULT_PARAMS),
},

@@ -1095,0 +1149,0 @@ };

{
"name": "@codetanzania/emis-api-client",
"version": "0.14.1",
"version": "0.15.0",
"description": "http client for EMIS API.",

@@ -70,11 +70,11 @@ "main": "lib/index.js",

"rimraf": "2.6.3",
"rollup": "1.14.3"
"rollup": "1.14.5"
},
"peerDependencies": {},
"dependencies": {
"@lykmapipo/common": ">=0.16.0",
"@lykmapipo/env": ">=0.7.3",
"@lykmapipo/common": ">=0.20.0",
"@lykmapipo/env": ">=0.8.0",
"axios": ">=0.18.0",
"inflection": ">=1.12.0",
"jsonwebtoken": "^8.5.1",
"jsonwebtoken": ">=8.5.1",
"lodash": ">=4.17.11",

@@ -89,6 +89,11 @@ "moment": ">=2.24.0"

"commitlint": {
"extends": ["@commitlint/config-conventional"]
"extends": [
"@commitlint/config-conventional"
]
},
"lint-staged": {
"src/**/*.js": ["npm run lint", "git add -A"]
"src/**/*.js": [
"npm run lint",
"git add -A"
]
},

@@ -95,0 +100,0 @@ "husky": {

@@ -32,2 +32,10 @@ import moment from 'moment';

/**
* @function
* @name getJwtToken
* @description retrieve jwt token from session storage if not set
* @return {string| undefined} jwt token
* @since 0.14.0
* @version 0.1.0
*/
const getJwtToken = () => {

@@ -48,3 +56,3 @@ if (isEmpty(jwtToken)) {

* @returns {boolean} check if token is valid or not
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -61,5 +69,8 @@ * @example

if (isEmpty(jwtToken)) {
return false;
}
try {
verify(jwtToken, JWT_SECRET);
return true;

@@ -506,3 +517,3 @@ } catch (error) {

* @returns {object} Object having party, permission and other meta data
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -538,3 +549,3 @@ * @static

* @description Signout current signin user and clear session Storage
* @since 0.13.2
* @since 0.14.0
* @version 0.1.0

@@ -607,2 +618,3 @@ * @static

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -616,3 +628,8 @@

[methodName]: () => {
const endpoint = `/${toLower(plural)}/schema`;
// derive endpoint
let endpoint = `/${toLower(plural)}/schema`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/schema`;
}
// issue http request
return get(endpoint);

@@ -643,3 +660,3 @@ },

// ensure resource
const { shortcut, wellknown } = normalizeResource(resource);
const { shortcut, wellknown, bucket } = normalizeResource(resource);

@@ -654,3 +671,8 @@ // generate method name

const params = prepareParams(mergeObjects(resource.params, options));
const endpoint = `${BASE_URL}/${toLower(wellknown.plural)}/export`;
// derive endpoint
let endpoint = `${BASE_URL}/${toLower(wellknown.plural)}/export`;
if (!isEmpty(bucket)) {
endpoint = `${BASE_URL}/${toLower(wellknown.plural)}/${bucket}/export`;
}
// build export url
const url = buildURL(endpoint, params);

@@ -682,3 +704,3 @@ return url;

// ensure resource
const { shortcut, wellknown } = normalizeResource(resource);
const { shortcut, wellknown, bucket } = normalizeResource(resource);

@@ -693,3 +715,8 @@ // generate method name

const params = mergeObjects(resource.params, options);
const endpoint = `/${toLower(wellknown.plural)}`;
// derive endpoint
let endpoint = `/${toLower(wellknown.plural)}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(wellknown.plural)}/${bucket}`;
}
// issue http request
return get(endpoint, params);

@@ -723,2 +750,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -734,3 +762,8 @@

const params = mergeObjects(resource.params);
const endpoint = `/${toLower(plural)}/${id}`;
// derive endpoint
let endpoint = `/${toLower(plural)}/${id}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/${id}`;
}
// issue http request
return get(endpoint, params);

@@ -764,2 +797,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -776,3 +810,8 @@

const data = mergeObjects(payload, defaults);
const endpoint = `/${toLower(plural)}`;
// derive endpoint
let endpoint = `/${toLower(plural)}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}`;
}
// issue http request
return post(endpoint, data);

@@ -806,2 +845,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -818,3 +858,8 @@

const data = mergeObjects(payload, defaults);
const endpoint = `/${toLower(plural)}/${idOf(data)}`;
// derive endpoint
let endpoint = `/${toLower(plural)}/${idOf(data)}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/${idOf(data)}`;
}
// issue http request
return put(endpoint, data);

@@ -848,2 +893,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -860,3 +906,8 @@

const data = mergeObjects(payload, defaults);
const endpoint = `/${toLower(plural)}/${idOf(data)}`;
// derive endpoint
let endpoint = `/${toLower(plural)}/${idOf(data)}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/${idOf(data)}`;
}
// issue http request
return patch(endpoint, data);

@@ -890,2 +941,3 @@ },

wellknown: { plural },
bucket,
} = normalizeResource(resource);

@@ -899,4 +951,8 @@

[methodName]: id => {
// prepare params
const endpoint = `/${toLower(plural)}/${id}`;
// derive endpoint
let endpoint = `/${toLower(plural)}/${id}`;
if (!isEmpty(bucket)) {
endpoint = `/${toLower(plural)}/${bucket}/${id}`;
}
// issue http request
return del(endpoint);

@@ -903,0 +959,0 @@ },

@@ -148,5 +148,4 @@ import { clone, forEach, merge, upperFirst } from 'lodash';

wellknown: 'predefine',
params: mergeObjects(DEFAULT_PARAMS, {
filter: { namespace: 'ItemUnit', key: 'unit' },
}),
bucket: 'itemunits',
params: mergeObjects(DEFAULT_PARAMS),
},

@@ -156,5 +155,4 @@ itemCategory: {

wellknown: 'predefine',
params: mergeObjects(DEFAULT_PARAMS, {
filter: { namespace: 'ItemCategory', key: 'category' },
}),
bucket: 'itemcategories',
params: mergeObjects(DEFAULT_PARAMS),
},

@@ -161,0 +159,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc