Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@availity/api-core

Package Overview
Dependencies
Maintainers
6
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@availity/api-core - npm Package Compare versions

Comparing version 1.0.0-alpha.17 to 1.0.0

src/resources/settings.js

4

package.json
{
"name": "@availity/api-core",
"version": "1.0.0-alpha.17",
"version": "1.0.0",
"description": "Base API definitions for the Availity REST API",

@@ -20,3 +20,3 @@ "keywords": [

"devDependencies": {
"@availity/localstorage-core": "^1.0.0-alpha.17"
"@availity/localstorage-core": "^1.0.0"
},

@@ -23,0 +23,0 @@ "publishConfig": {

@@ -133,1 +133,5 @@ # api-core

```
## AvMicroservice
`AvMicroservice` extends `AvApi` and thus can call the same methods. It has slightly different `config` options used for some child apis.

@@ -15,3 +15,3 @@ import AvLocalStorage from '@availity/localstorage-core';

this.merge = merge;
this.defaultConfig = this.merge({}, API_OPTIONS, config);
this.defaultConfig = this.merge({}, API_OPTIONS.API, config);
this.localStorage = new AvLocalStorage();

@@ -18,0 +18,0 @@ }

import AvApi from './api';
import AvMicroservice from './ms';
import AvLogMessages from './resources/logs';

@@ -14,2 +15,4 @@ import AvNavigation from './resources/navigation';

import AvUserPermissions from './resources/userPermissions';
import AvFiles from './resources/files';
import AvSettings from './resources/settings';

@@ -19,2 +22,3 @@ export default AvApi;

export {
AvMicroservice,
AvLogMessages,

@@ -32,2 +36,4 @@ AvNavigation,

AvUserPermissions,
AvFiles,
AvSettings,
};

@@ -1,9 +0,26 @@

class AvMicroservice {
constructor(http, promise, config) {
if (!http || !config || !promise) {
throw new Error('[http], [promise] and [config] and must be defined');
import AvApi from './api';
import API_OPTIONS from './options';
export default class AvMicroservice extends AvApi {
constructor({ http, promise, merge, config }) {
super({
http,
promise,
merge,
config,
});
this.defaultConfig = this.merge({}, API_OPTIONS.MS, config);
}
getUrl(config) {
const { path, name, id } = this.config(config);
let parts = [path, name];
if (id) {
parts = [path, name, id];
}
return parts
.join('/')
.replace(/[/]+/g, '/')
.replace(/\/$/, '');
}
}
export default AvMicroservice;
const API_OPTIONS = {
// default base segment for Availity API endpoints
path: '/api',
API: {
// default base segment for Availity API endpoints
path: '/api',
// full url to api resource
url: null,
// full url to api resource
url: null,
// name of resource
name: null,
// name of resource
name: null,
// defaults version for api
version: '/v1',
// defaults version for api
version: '/v1',
// cache all request by default
cache: true,
// cache all request by default
cache: true,
// flag used to enable behaviors around the Availity Rest API
api: true,
// flag used to enable behaviors around the Availity Rest API
api: true,
polling: true, // 1s, 2s, 5s, 10s
polling: true, // 1s, 2s, 5s, 10s
pollingIntervals: [1e3, 2e3, 5e3, 1e4], // in ms
pollingIntervals: [1e3, 2e3, 5e3, 1e4], // in ms
// default headers
headers: {
// Turn off content encoding for angular apis
'X-Response-Encoding-Context': 'NONE',
// default headers
headers: {
// Turn off content encoding for angular apis
'X-Response-Encoding-Context': 'NONE',
},
sessionBust: true,
},
MS: {
// default base segment for Availity API endpoints
path: '/ms/api/availity/internal',
sessionBust: true,
// full url to api resource
url: null,
// name of resource
name: null,
// defaults version for api
version: null,
// cache all request by default
cache: false,
// flag used to enable behaviors around the Availity Rest API
api: true,
polling: false, // 1s, 2s, 5s, 10s
pollingIntervals: [1e3, 2e3, 5e3, 1e4], // in ms
// default headers
headers: {
// Turn off content encoding for angular apis
'X-Response-Encoding-Context': 'NONE',
},
sessionBust: false,
},
};
export default API_OPTIONS;

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -16,2 +16,4 @@ # Availity API's

* [AvProxy](#avproxy)
* [AvFiles](#avfiles)
* [AvSettings](#avsettings)

@@ -93,2 +95,15 @@ ## Intro

### AvFiles
Upload a file to a bucket in the vault
#### Methods
#### `uploadFile(data, config)`
Method to upload a file. `data` contains FormData elements with a key of either `reference` (if pointed to an existing file) or `filedata` (if uploading a new file)
`config` should contain `customerId` and `id` (the bucketId)
### AvSettings
Store and retrieve settings to be reused.
Use `query(params)` with at least an `applicationId` and `userId` in the `params` object
Use `update(data)` with at least an `applicationId` and `userId` in the `scope` object, and key/value pairs of data

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvLogMessages from '../logs';

@@ -0,0 +0,0 @@ import AvNavigation from '../navigation';

@@ -0,0 +0,0 @@ import AvNotification from '../notifications';

@@ -0,0 +0,0 @@ import AvOrganizations from '../organizations';

@@ -0,0 +0,0 @@ import AvPdfs from '../pdfs';

@@ -0,0 +0,0 @@ import AvPermissions from '../permissions';

@@ -0,0 +0,0 @@ import AvProviders from '../providers';

@@ -0,0 +0,0 @@ import AvProxy from '../proxy';

@@ -58,3 +58,3 @@ import AvRegions from '../regions';

test('getRegions should call avUsers.me() and then query with result', () => {
test('getRegions should call avUsers.me() and then query with result', async () => {
api = new AvRegions({

@@ -75,8 +75,7 @@ http: mockHttp,

Object.assign(expectedConfig.params, { userId: mockUser.id });
return api.getRegions(testConfig).then(() => {
expect(api.query).toHaveBeenLastCalledWith(expectedConfig);
});
await api.getRegions(testConfig);
expect(api.query).toHaveBeenLastCalledWith(expectedConfig);
});
test('getRegions should handle undefined config param', () => {
test('getRegions should handle undefined config param', async () => {
api = new AvRegions({

@@ -92,5 +91,4 @@ http: mockHttp,

const expectedConfig = { params: { userId: mockUser.id } };
return api.getRegions().then(() => {
expect(api.query).toHaveBeenLastCalledWith(expectedConfig);
});
await api.getRegions();
expect(api.query).toHaveBeenLastCalledWith(expectedConfig);
});

@@ -97,0 +95,0 @@

@@ -0,0 +0,0 @@ import AvSpaces from '../spaces';

@@ -0,0 +0,0 @@ import AvUsers from '../user';

@@ -0,0 +0,0 @@ import AvUserPermissions from '../userPermissions';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -0,0 +0,0 @@ import AvApi from '../api';

@@ -572,3 +572,5 @@ import AvApi from '../api';

);
return true;
});
jest.runAllTimers();

@@ -592,20 +594,18 @@ return output;

test('should call http', () => {
test('should call http', async () => {
const mockConfig = {
testVal: 'test',
};
return api.request(mockConfig).then(response => {
expect(response).toEqual(mockFinalResponse);
expect(mockHttp).toHaveBeenCalledWith(mockConfig);
});
const response = await api.request(mockConfig);
expect(response).toEqual(mockFinalResponse);
expect(mockHttp).toHaveBeenCalledWith(mockConfig);
});
test('should catch error in http, returning undefined if no error.response', () => {
test('should catch error in http, returning undefined if no error.response', async () => {
mockHttp.mockImplementationOnce(() => Promise.reject(new Error('err')));
return api.request({}).then(response => {
expect(response).toBeUndefined();
});
const response = await api.request({});
expect(response).toBeUndefined();
});
test('should default attempt in polling is true', () => {
test('should default attempt in polling is true', async () => {
const mockConfig = {

@@ -618,6 +618,6 @@ polling: true,

};
return api.request(mockConfig).then(response => {
expect(mockHttp).toHaveBeenCalledWith(expectedConfig);
expect(response).toEqual(mockFinalResponse);
});
const response = await api.request(mockConfig);
expect(mockHttp).toHaveBeenCalledWith(expectedConfig);
expect(response).toEqual(mockFinalResponse);
});

@@ -624,0 +624,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