@codetanzania/emis-api-client
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -0,1 +1,11 @@ | ||
#### 0.4.0 (2019-01-26) | ||
##### Chores | ||
* switch git add . to git add -A ([23fb8d6e](https://github.com/CodeTanzania/emis-api-client/commit/23fb8d6e88450feba92e1597678b4ddbf1e16895)) | ||
##### New Features | ||
* add getSchemas to fetch /v1/schemas of api ([5e08bd88](https://github.com/CodeTanzania/emis-api-client/commit/5e08bd889fd73fbe7a11aa50c0b0462a04df0105)) | ||
#### 0.3.1 (2019-01-25) | ||
@@ -2,0 +12,0 @@ |
173
es/index.js
@@ -1,3 +0,3 @@ | ||
import axios, { spread } from 'axios'; | ||
import { isEmpty, camelCase, toLower, get } from 'lodash'; | ||
import axios from 'axios'; | ||
import { isEmpty, camelCase, toLower } from 'lodash'; | ||
import { singularize, pluralize } from 'inflection'; | ||
@@ -84,3 +84,3 @@ | ||
*/ | ||
const spread$1 = spread; | ||
const spread = axios.spread; // eslint-disable-line | ||
@@ -107,3 +107,3 @@ /** | ||
*/ | ||
const get$1 = (url, params) => { | ||
const get = (url, params) => { | ||
const httpClient = createHttpClient(); | ||
@@ -205,3 +205,3 @@ return httpClient.get(url, { params }); | ||
// get resource id from payload | ||
const idOf = data => get(data, '_id') || get(data, 'id'); | ||
const idOf = data => (data ? data._id || data.id : undefined); // eslint-disable-line | ||
@@ -228,7 +228,7 @@ /** | ||
[fn('get', singular, 'Schema')]: () => | ||
get$1(`/${toLower(plural)}/schema`).then(response => response.data), | ||
get(`/${toLower(plural)}/schema`).then(response => response.data), | ||
[fn('get', plural)]: params => | ||
get$1(`/${toLower(plural)}`, params).then(response => response.data), | ||
get(`/${toLower(plural)}`, params).then(response => response.data), | ||
[fn('get', singular)]: id => | ||
get$1(`/${toLower(plural)}/${id}`).then(response => response.data), | ||
get(`/${toLower(plural)}/${id}`).then(response => response.data), | ||
[fn('post', singular)]: data => | ||
@@ -250,2 +250,11 @@ post(`/${toLower(plural)}`, data).then(response => response.data), | ||
const getSchemas = () => | ||
get('/schemas').then(response => { | ||
const schemas = response.data; | ||
if (schemas) { | ||
schemas.Warehouse = schemas.Feature; | ||
} | ||
return schemas; | ||
}); | ||
const { | ||
@@ -431,148 +440,2 @@ getActivitySchema, | ||
export { | ||
getActivitySchema, | ||
getActivities, | ||
getActivity, | ||
postActivity, | ||
putActivity, | ||
patchActivity, | ||
deleteActivity, | ||
getAdjustmentSchema, | ||
getAdjustments, | ||
getAdjustment, | ||
postAdjustment, | ||
putAdjustment, | ||
patchAdjustment, | ||
deleteAdjustment, | ||
getAlertSchema, | ||
getAlerts, | ||
getAlert, | ||
postAlert, | ||
putAlert, | ||
patchAlert, | ||
deleteAlert, | ||
getAssessmentSchema, | ||
getAssessments, | ||
getAssessment, | ||
postAssessment, | ||
putAssessment, | ||
patchAssessment, | ||
deleteAssessment, | ||
getFeatureSchema, | ||
getFeatures, | ||
getFeature, | ||
postFeature, | ||
putFeature, | ||
patchFeature, | ||
deleteFeature, | ||
getIncidentSchema, | ||
getIncidents, | ||
getIncident, | ||
postIncident, | ||
putIncident, | ||
patchIncident, | ||
deleteIncident, | ||
getIncidentTypeSchema, | ||
getIncidentTypes, | ||
getIncidentType, | ||
postIncidentType, | ||
putIncidentType, | ||
patchIncidentType, | ||
deleteIncidentType, | ||
getIndicatorSchema, | ||
getIndicators, | ||
getIndicator, | ||
postIndicator, | ||
putIndicator, | ||
patchIndicator, | ||
deleteIndicator, | ||
getItemSchema, | ||
getItems, | ||
getItem, | ||
postItem, | ||
putItem, | ||
patchItem, | ||
deleteItem, | ||
getPartySchema, | ||
getPartySchema as getStakeholderSchema, | ||
getParties, | ||
getParties as getStakeholders, | ||
getParty, | ||
getParty as getStakeholder, | ||
postParty, | ||
postParty as postStakeholder, | ||
putParty, | ||
putParty as putStakeholder, | ||
patchParty, | ||
patchParty as patchStakeholder, | ||
deleteParty, | ||
deleteParty as deleteStakeholder, | ||
getPermissionSchema, | ||
getPermissions, | ||
getPermission, | ||
postPermission, | ||
putPermission, | ||
patchPermission, | ||
deletePermission, | ||
getPlanSchema, | ||
getPlans, | ||
getPlan, | ||
postPlan, | ||
putPlan, | ||
patchPlan, | ||
deletePlan, | ||
getProcedureSchema, | ||
getProcedures, | ||
getProcedure, | ||
postProcedure, | ||
putProcedure, | ||
patchProcedure, | ||
deleteProcedure, | ||
getQuestionSchema, | ||
getQuestions, | ||
getQuestion, | ||
postQuestion, | ||
putQuestion, | ||
patchQuestion, | ||
deleteQuestion, | ||
getQuestionnaireSchema, | ||
getQuestionnaires, | ||
getQuestionnaire, | ||
postQuestionnaire, | ||
putQuestionnaire, | ||
patchQuestionnaire, | ||
deleteQuestionnaire, | ||
getRoleSchema, | ||
getRoles, | ||
getRole, | ||
postRole, | ||
putRole, | ||
patchRole, | ||
deleteRole, | ||
getStockSchema, | ||
getStocks, | ||
getStock, | ||
postStock, | ||
putStock, | ||
patchStock, | ||
deleteStock, | ||
getWarehouseSchema, | ||
getWarehouses, | ||
getWarehouse, | ||
postWarehouse, | ||
putWarehouse, | ||
patchWarehouse, | ||
deleteWarehouse, | ||
CONTENT_TYPE, | ||
HEADERS, | ||
createHttpClient, | ||
disposeHttpClient, | ||
all, | ||
spread$1 as spread, | ||
get$1 as get, | ||
post, | ||
put, | ||
patch, | ||
del, | ||
createHttpActionsFor, | ||
}; | ||
export { getSchemas, getActivitySchema, getActivities, getActivity, postActivity, putActivity, patchActivity, deleteActivity, getAdjustmentSchema, getAdjustments, getAdjustment, postAdjustment, putAdjustment, patchAdjustment, deleteAdjustment, getAlertSchema, getAlerts, getAlert, postAlert, putAlert, patchAlert, deleteAlert, getAssessmentSchema, getAssessments, getAssessment, postAssessment, putAssessment, patchAssessment, deleteAssessment, getFeatureSchema, getFeatures, getFeature, postFeature, putFeature, patchFeature, deleteFeature, getIncidentSchema, getIncidents, getIncident, postIncident, putIncident, patchIncident, deleteIncident, getIncidentTypeSchema, getIncidentTypes, getIncidentType, postIncidentType, putIncidentType, patchIncidentType, deleteIncidentType, getIndicatorSchema, getIndicators, getIndicator, postIndicator, putIndicator, patchIndicator, deleteIndicator, getItemSchema, getItems, getItem, postItem, putItem, patchItem, deleteItem, getPartySchema, getPartySchema as getStakeholderSchema, getParties, getParties as getStakeholders, getParty, getParty as getStakeholder, postParty, postParty as postStakeholder, putParty, putParty as putStakeholder, patchParty, patchParty as patchStakeholder, deleteParty, deleteParty as deleteStakeholder, getPermissionSchema, getPermissions, getPermission, postPermission, putPermission, patchPermission, deletePermission, getPlanSchema, getPlans, getPlan, postPlan, putPlan, patchPlan, deletePlan, getProcedureSchema, getProcedures, getProcedure, postProcedure, putProcedure, patchProcedure, deleteProcedure, getQuestionSchema, getQuestions, getQuestion, postQuestion, putQuestion, patchQuestion, deleteQuestion, getQuestionnaireSchema, getQuestionnaires, getQuestionnaire, postQuestionnaire, putQuestionnaire, patchQuestionnaire, deleteQuestionnaire, getRoleSchema, getRoles, getRole, postRole, putRole, patchRole, deleteRole, getStockSchema, getStocks, getStock, postStock, putStock, patchStock, deleteStock, getWarehouseSchema, getWarehouses, getWarehouse, postWarehouse, putWarehouse, patchWarehouse, deleteWarehouse, CONTENT_TYPE, HEADERS, createHttpClient, disposeHttpClient, all, spread, get, post, put, patch, del, createHttpActionsFor }; |
@@ -0,13 +1,11 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function _interopDefault(ex) { | ||
return ex && typeof ex === 'object' && 'default' in ex ? ex.default : ex; | ||
} | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
const axios = require('axios'); | ||
var axios = _interopDefault(require('axios')); | ||
var lodash = require('lodash'); | ||
var inflection = require('inflection'); | ||
const axios__default = _interopDefault(axios); | ||
const lodash = require('lodash'); | ||
const inflection = require('inflection'); | ||
// default http client | ||
@@ -46,3 +44,3 @@ let client; | ||
const options = { baseURL: BASE_URL, headers: HEADERS }; | ||
client = axios__default.create(options); | ||
client = axios.create(options); | ||
client.id = Date.now(); | ||
@@ -79,3 +77,3 @@ } | ||
*/ | ||
const all = (...promises) => axios__default.all([...promises]); | ||
const all = (...promises) => axios.all([...promises]); | ||
@@ -94,3 +92,3 @@ /** | ||
*/ | ||
const spread = axios.spread; | ||
const spread = axios.spread; // eslint-disable-line | ||
@@ -214,3 +212,3 @@ /** | ||
// get resource id from payload | ||
const idOf = data => lodash.get(data, '_id') || lodash.get(data, 'id'); | ||
const idOf = data => (data ? data._id || data.id : undefined); // eslint-disable-line | ||
@@ -258,2 +256,11 @@ /** | ||
const getSchemas = () => | ||
get('/schemas').then(response => { | ||
const schemas = response.data; | ||
if (schemas) { | ||
schemas.Warehouse = schemas.Feature; | ||
} | ||
return schemas; | ||
}); | ||
const { | ||
@@ -439,2 +446,3 @@ getActivitySchema, | ||
exports.getSchemas = getSchemas; | ||
exports.getActivitySchema = getActivitySchema; | ||
@@ -441,0 +449,0 @@ exports.getActivities = getActivities; |
{ | ||
"name": "@codetanzania/emis-api-client", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "http client for EMIS API.", | ||
@@ -11,5 +11,5 @@ "main": "lib/index.js", | ||
"lint:src": "eslint --fix --ext .js src/ rollup.config.js", | ||
"lint": "npm run build && eslint --fix --ext .js src/ test/unit rollup.config.js", | ||
"lint": "npm run build && eslint --fix --ext .js src/ test/ rollup.config.js", | ||
"test": "npm run lint -s && mocha test/**/*.spec.js", | ||
"cmt": "git add . && git-cz", | ||
"cmt": "git add -A && git-cz", | ||
"changelog": "changelog" | ||
@@ -85,3 +85,3 @@ }, | ||
"npm run lint:src", | ||
"git add ." | ||
"git add -A" | ||
] | ||
@@ -88,0 +88,0 @@ }, |
@@ -1,3 +0,3 @@ | ||
import axios, { spread as toSimpleArgs } from 'axios'; | ||
import { isEmpty, camelCase, toLower as low, get as value } from 'lodash'; | ||
import axios from 'axios'; | ||
import { isEmpty, camelCase, toLower as low } from 'lodash'; | ||
import { singularize, pluralize } from 'inflection'; | ||
@@ -84,3 +84,3 @@ | ||
*/ | ||
export const spread = toSimpleArgs; | ||
export const spread = axios.spread; // eslint-disable-line | ||
@@ -204,3 +204,3 @@ /** | ||
// get resource id from payload | ||
const idOf = data => value(data, '_id') || value(data, 'id'); | ||
const idOf = data => (data ? data._id || data.id : undefined); // eslint-disable-line | ||
@@ -207,0 +207,0 @@ /** |
@@ -1,5 +0,14 @@ | ||
import { createHttpActionsFor } from './client'; | ||
import { get, createHttpActionsFor } from './client'; | ||
export * from './client'; | ||
export const getSchemas = () => | ||
get('/schemas').then(response => { | ||
const schemas = response.data; | ||
if (schemas) { | ||
schemas.Warehouse = schemas.Feature; | ||
} | ||
return schemas; | ||
}); | ||
export const { | ||
@@ -6,0 +15,0 @@ getActivitySchema, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52934
1377