Socket
Socket
Sign inDemoInstall

@availity/api-axios

Package Overview
Dependencies
Maintainers
12
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@availity/api-axios - npm Package Compare versions

Comparing version 8.0.2 to 8.0.3

dist/index.d.mts

82

CHANGELOG.md

@@ -5,2 +5,84 @@ # Changelog

## [8.0.3](https://github.com/Availity/sdk-js/compare/@availity/api-axios@8.0.2...@availity/api-axios@8.0.3) (2023-08-23)
# 1.0.0 (2023-08-23)
### Bug Fixes
* add lerna ignore for package-locks ([3217d96](https://github.com/Availity/sdk-js/commit/3217d96c1ad7b3b9b752d9376b88d9b91daabca6))
* api implementation peerDeps ([28c163d](https://github.com/Availity/sdk-js/commit/28c163dcd02ef8a4623c91c1231d4c6a8f07e7c3))
* **api-axios:** add avTelemetryApi types ([99f8ebf](https://github.com/Availity/sdk-js/commit/99f8ebf3e099b0a932bd13dd31c325c3beba2216))
* **api-axios:** change axios to peerDep ([9e0a9cd](https://github.com/Availity/sdk-js/commit/9e0a9cdb24e3764707a844a9a36a38a34bd162e8))
* **api-axios:** export telemetry types ([c2f9d89](https://github.com/Availity/sdk-js/commit/c2f9d894511d645ade86a663fe9f05af029c3ddf))
* **api-axios:** fix ms to extend core ms ([a2f65e5](https://github.com/Availity/sdk-js/commit/a2f65e563989f16690c1b65231245f88d0a7f4b3))
* **api-axios:** fix organizations resources check in axios ([36a1b9b](https://github.com/Availity/sdk-js/commit/36a1b9b91f26773f2e9ef096886276c9f3e47de7))
* **api-axios:** fixed dev dep getting removed ([365776a](https://github.com/Availity/sdk-js/commit/365776a8a7cd74982fc56f67f278d989c06431da))
* **api-axios:** had to update packge to require v4.0 of api-core ([c5160de](https://github.com/Availity/sdk-js/commit/c5160dede5ab26553ecec383d7c3dfd72be8bc1c))
* **api-axios:** make afterUpdate an arrow function ([9c8724c](https://github.com/Availity/sdk-js/commit/9c8724c1bd1efda2783fe97ac4b0482228e60807))
* **api-axios:** override getQueryResultKey for regions ([03f8b42](https://github.com/Availity/sdk-js/commit/03f8b42083e31ca3b75654f88bc1b324a4a29dbb))
* **api-axios:** remove resolveHost and change AvUsersApi back to AvUserApi ([1263cac](https://github.com/Availity/sdk-js/commit/1263cac6182cc70cdcda6a5cf3818cecb3c7bc95))
* **api-axios:** replace axios merge with deep-assign ([a7183b1](https://github.com/Availity/sdk-js/commit/a7183b10e000102b51208b3f4297a6b4ba3ff897))
* **api-axios:** resolve lint error ([62efcaf](https://github.com/Availity/sdk-js/commit/62efcaf010c65d3d2bf8b0004953608628c15465))
* **api-axios:** set the browser field ([9206790](https://github.com/Availity/sdk-js/commit/92067904e99d6d893db4d3b063da4bc47af22ad0))
* **api-axios:** update name of types ([c9bee17](https://github.com/Availity/sdk-js/commit/c9bee17647b5be953788c33d3770c7dc994784f1))
* **api-axios:** update permissions response type ([a6ef800](https://github.com/Availity/sdk-js/commit/a6ef8005eccb1278b9a1a826b5881c77ee585a91))
* **api-axios:** url creation was not working as expected ([630e4c7](https://github.com/Availity/sdk-js/commit/630e4c7d7395547e75f9396e038cca54dd2f1124))
* **api-axios:** us merge-options for merge ([25b75b4](https://github.com/Availity/sdk-js/commit/25b75b4657a80544e9e803117612a30bf6551b98))
* **api-axios:** use merge-options-es5 instead of merge-options ([993ccc6](https://github.com/Availity/sdk-js/commit/993ccc6ff8db97b6e1d66454c93e7a33dfe95aee))
* **api-core:** filesDelivery merge ([eb75160](https://github.com/Availity/sdk-js/commit/eb75160e7b07a43e858066f38ff8cef969391362))
* fixed package-lock issues boiling down to this repo ([8c896f4](https://github.com/Availity/sdk-js/commit/8c896f486e49eb969320edfbfab422d47abe4ab1))
* import axios properly ([1c616dd](https://github.com/Availity/sdk-js/commit/1c616dd63e00733249498cc94ff526772270a906))
### chore
* **api-axios:** bump axios to v1 ([c45f2e5](https://github.com/Availity/sdk-js/commit/c45f2e519291c2ecf4687653a3a4c55e6169eeac))
* **api-core:** core, angular, axios api naming consistency ([f129fad](https://github.com/Availity/sdk-js/commit/f129fad36f4e4d8c81fd0b4989811846dd245ee3))
### Code Refactoring
* **api-core:** pass config object to core classes ([d7b859c](https://github.com/Availity/sdk-js/commit/d7b859c80837a8256bcf4538b30d042882db2640))
* build!: switch from lerna to nx and compile to esm with tsup ([c586085](https://github.com/Availity/sdk-js/commit/c5860856ca96b743a0653d335ea00f0889132f7f))
### Features
* **analytics-core:** added dma logging service ([68aee41](https://github.com/Availity/sdk-js/commit/68aee41761e5a5960ee1e997e32e471aad455dc1))
* **api-axios:** add aries 2 pdf resource ([fbcfa65](https://github.com/Availity/sdk-js/commit/fbcfa65a6163a4775a9a9327b0a9c56fed5162ea))
* **api-axios:** add route configurations api ([f91c9aa](https://github.com/Availity/sdk-js/commit/f91c9aa13eba40af7af52f11393810b5daa49ad3))
* **api-axios:** add support for filtering organizations by permission and resource ([69b2a3a](https://github.com/Availity/sdk-js/commit/69b2a3a9b965fa00fe41aa0651365c59800e323d))
* **api-axios:** add telemetry resource DP-2591 ([57977ec](https://github.com/Availity/sdk-js/commit/57977ec062ef3fa0e8143a66e6564ceeea45cbf8))
* **api-axios:** add typescript support ([6d2d9ee](https://github.com/Availity/sdk-js/commit/6d2d9eee72a3aaa1cf2619179eddfb1da86dd82c))
* **api-axios:** move api-core code into api-axios ([aaa6b90](https://github.com/Availity/sdk-js/commit/aaa6b901838b216bcd1e0169594e5474cc7f57e7))
* **api-core:** add codes resource ([4ea7ba4](https://github.com/Availity/sdk-js/commit/4ea7ba41fcef02b67b2e4928b17a04eff2d8b9fd))
* **api-core:** add file upload delivery batch api ([eff0a3c](https://github.com/Availity/sdk-js/commit/eff0a3cff384d99d13d0fd0795e693eef5c51af2))
* **api-core:** add webQL resource ([67b9797](https://github.com/Availity/sdk-js/commit/67b9797718ac55d0a2a08d7e5e7513791dc82a28))
* **api-core:** added graphql resource for slotmachine ([356a686](https://github.com/Availity/sdk-js/commit/356a6868b24be6b5388000770d711bcce5e5fa00))
* **api-core:** added new resource for disclaimers ([b7de72e](https://github.com/Availity/sdk-js/commit/b7de72ed6d6c910a2571e18753bfee6a038837d7))
* **api-core:** helper function for settings api ([#64](https://github.com/Availity/sdk-js/issues/64)) ([f247235](https://github.com/Availity/sdk-js/commit/f2472358bfef0744ec31e7b764ae1586b314af6b))
### Reverts
* Revert "chore: testing build stuff" ([24cc807](https://github.com/Availity/sdk-js/commit/24cc807fa91236f38a82b17a006bbe88641af32a))
### BREAKING CHANGES
* **api-axios:** axios version 1.4.0 or greater is now required
* Drop Internet Explorer support
* **api-axios:** api-core no longer required, naming, args for constructor
* upgrades other packages that are using old package-locks
* **api-axios:** api-axios requires v4.0.0 of api-core
* **api-core:** export naming conventions have been refactored to match for each implementation (angular/axios). Constructors are prefixed with 'Av', implementations are prefixed with 'av', and Apis are postfixed with 'Api'.
* **api-core:** Options to core classes are being passed in as config object instead of parameters.
## [8.0.2](https://github.com/Availity/sdk-js/compare/@availity/api-axios@8.0.1...@availity/api-axios@8.0.2) (2023-08-01)

@@ -7,0 +89,0 @@

4

dist/index.d.ts
import { AxiosRequestConfig, AxiosResponse } from 'axios';
/* eslint-disable @typescript-eslint/no-empty-interface */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable max-classes-per-file */

@@ -5,0 +9,0 @@

1003

dist/index.js

@@ -0,1 +1,2 @@

"use strict";
var __create = Object.create;

@@ -11,2 +12,3 @@ var __defProp = Object.defineProperty;

var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __reflectGet = Reflect.get;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;

@@ -49,4 +51,36 @@ var __spreadValues = (a, b) => {

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -115,31 +149,53 @@ // src/index.js

API: {
// default base segment for Availity API endpoints
path: "/api",
// full url to api resource
url: null,
// name of resource
name: null,
// defaults version for api
version: "/v1",
// cache all request by default
cache: true,
// flag used to enable behaviors around the Availity Rest API
api: true,
polling: true,
// 1s, 2s, 5s, 10s
pollingIntervals: [1e3, 2e3, 5e3, 1e4],
// in ms
pollingMethod: "GET",
// default headers
headers: {
// Turn off content encoding for angular apis
"X-Response-Encoding-Context": "NONE"
},
sessionBust: true,
// send credentials on CORS requests
withCredentials: true
},
MS: {
// default base segment for Availity API endpoints
path: "/ms/api/availity/internal",
// 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
pollingMethod: "POST",
// default headers
headers: {
// Turn off content encoding for angular apis
"X-Response-Encoding-Context": "NONE"
},
sessionBust: false,
// send credentials on CORS requests
withCredentials: true

@@ -160,2 +216,3 @@ }

}
// Get the merged config
config(config = {}) {

@@ -172,2 +229,3 @@ return (0, import_merge.default)({}, this.defaultConfig, config);

}
// Set the cache parameters
cacheParams(config) {

@@ -189,2 +247,3 @@ const params = {};

}
// Get the cache value with default function
getCacheBustVal(cacheBust, defaultFn) {

@@ -202,2 +261,3 @@ if (!cacheBust) {

}
// Get pagebust value, make sure it is instantiated first
getPageBust() {

@@ -209,5 +269,7 @@ if (typeof this.pageBustValue === "undefined") {

}
// Set the page bust value to given value or timestamp
setPageBust(value) {
this.pageBustValue = typeof value === "undefined" ? Date.now() : value;
}
// Get final url from config
getUrl(config, id = "") {

@@ -225,2 +287,3 @@ if (!config.api) {

}
// Return location if should poll otherwise false
getLocation(response) {

@@ -233,2 +296,3 @@ const { config, headers = {} } = response;

}
// Condition for calls that should continue polling
shouldPoll(response) {

@@ -246,180 +310,224 @@ if (!(response == null ? void 0 : response.config))

}
async request(config, afterResponse) {
if (config.polling) {
config.attempt = config.attempt || 0;
config.attempt += 1;
}
const response = await this.http(config);
return this.onResponse(response, afterResponse);
// Make request with axios
request(config, afterResponse) {
return __async(this, null, function* () {
if (config.polling) {
config.attempt = config.attempt || 0;
config.attempt += 1;
}
const response = yield this.http(config);
return this.onResponse(response, afterResponse);
});
}
async onResponse(response, afterResponse) {
if (this.shouldPoll(response)) {
const newConfig = this.config(response.config);
const pollingUrl = this.getLocation(response);
if (pollingUrl) {
newConfig.method = this.defaultConfig.pollingMethod;
newConfig.url = pollingUrl;
newConfig.cache = false;
await new Promise((resolve) => {
setTimeout(resolve, newConfig.pollingIntervals[newConfig.attempt] || 1e3);
});
return this.request(newConfig, afterResponse);
// Handle response with possible polling
onResponse(response, afterResponse) {
return __async(this, null, function* () {
if (this.shouldPoll(response)) {
const newConfig = this.config(response.config);
const pollingUrl = this.getLocation(response);
if (pollingUrl) {
newConfig.method = this.defaultConfig.pollingMethod;
newConfig.url = pollingUrl;
newConfig.cache = false;
yield new Promise((resolve) => {
setTimeout(resolve, newConfig.pollingIntervals[newConfig.attempt] || 1e3);
});
return this.request(newConfig, afterResponse);
}
}
}
return afterResponse ? afterResponse(response) : response;
return afterResponse ? afterResponse(response) : response;
});
}
async sendBeacon(data, config) {
if (!data) {
throw new Error("called method without [data]");
}
config = this.config(config);
config.method = "POST";
config.url = this.getUrl(config);
config.data = data;
const beforeFunc = this.beforeCreate || this.beforePost;
if (beforeFunc) {
config.data = beforeFunc(config.data);
}
if (navigator.sendBeacon) {
const result = navigator.sendBeacon(config.url, new Blob([config.data], {
type: "application/x-www-form-urlencoded"
}));
if (result)
return Promise.resolve();
}
return this.request(config, this.afterCreate || this.afterPost);
// Send request with browser's navigator.sendBeacon
sendBeacon(data, config) {
return __async(this, null, function* () {
if (!data) {
throw new Error("called method without [data]");
}
config = this.config(config);
config.method = "POST";
config.url = this.getUrl(config);
config.data = data;
const beforeFunc = this.beforeCreate || this.beforePost;
if (beforeFunc) {
config.data = beforeFunc(config.data);
}
if (navigator.sendBeacon) {
const result = navigator.sendBeacon(
config.url,
new Blob([config.data], {
type: "application/x-www-form-urlencoded"
})
);
if (result)
return Promise.resolve();
}
return this.request(config, this.afterCreate || this.afterPost);
});
}
async create(data, config) {
if (!data) {
throw new Error("called method without [data]");
}
config = this.config(config);
config.method = "POST";
config.url = this.getUrl(config);
config.data = data;
const beforeFunc = this.beforeCreate || this.beforePost;
if (beforeFunc) {
config.data = beforeFunc(config.data);
}
return this.request(config, this.afterCreate || this.afterPost);
// create
create(data, config) {
return __async(this, null, function* () {
if (!data) {
throw new Error("called method without [data]");
}
config = this.config(config);
config.method = "POST";
config.url = this.getUrl(config);
config.data = data;
const beforeFunc = this.beforeCreate || this.beforePost;
if (beforeFunc) {
config.data = beforeFunc(config.data);
}
return this.request(config, this.afterCreate || this.afterPost);
});
}
async post(data, config) {
return this.create(data, config);
post(data, config) {
return __async(this, null, function* () {
return this.create(data, config);
});
}
async postGet(data, config) {
if (!data) {
throw new Error("called method without [data]");
}
config = this.config(config);
config.method = "POST";
config.headers = config.headers || {};
config.headers["X-HTTP-Method-Override"] = "GET";
config.headers["Content-Type"] = config.headers["Content-Type"] || "application/x-www-form-urlencoded";
config.url = this.getUrl(config);
config.data = data;
if (this.beforePostGet) {
config.data = this.beforePostGet(config.data);
}
if (typeof config.data !== "string" && config.headers["Content-Type"] === "application/x-www-form-urlencoded") {
config.data = import_qs.default.stringify(config.data, {
encode: false,
arrayFormat: "repeat",
indices: false,
allowDots: true
});
}
return this.request(config, this.afterPostGet);
// post request with method-override to get
postGet(data, config) {
return __async(this, null, function* () {
if (!data) {
throw new Error("called method without [data]");
}
config = this.config(config);
config.method = "POST";
config.headers = config.headers || {};
config.headers["X-HTTP-Method-Override"] = "GET";
config.headers["Content-Type"] = config.headers["Content-Type"] || "application/x-www-form-urlencoded";
config.url = this.getUrl(config);
config.data = data;
if (this.beforePostGet) {
config.data = this.beforePostGet(config.data);
}
if (typeof config.data !== "string" && config.headers["Content-Type"] === "application/x-www-form-urlencoded") {
config.data = import_qs.default.stringify(config.data, {
encode: false,
arrayFormat: "repeat",
indices: false,
allowDots: true
});
}
return this.request(config, this.afterPostGet);
});
}
async get(id, config) {
if (!id) {
throw new Error("called method without [id]");
}
config = this.config(config);
config.method = "GET";
config.url = this.getUrl(config, id);
config = this.cacheParams(config);
return this.request(config, this.afterGet);
// read
get(id, config) {
return __async(this, null, function* () {
if (!id) {
throw new Error("called method without [id]");
}
config = this.config(config);
config.method = "GET";
config.url = this.getUrl(config, id);
config = this.cacheParams(config);
return this.request(config, this.afterGet);
});
}
async query(config) {
config = this.config(config);
config.method = "GET";
config.url = this.getUrl(config);
config = this.cacheParams(config);
return this.request(config, this.afterQuery);
// get request with params
query(config) {
return __async(this, null, function* () {
config = this.config(config);
config.method = "GET";
config.url = this.getUrl(config);
config = this.cacheParams(config);
return this.request(config, this.afterQuery);
});
}
async getPage(page = 1, config = {}, limit) {
var _a;
limit = limit || ((_a = config.params) == null ? void 0 : _a.limit) || 50;
const offset = (page - 1) * limit;
return this.query(this.addParams({ offset, limit }, config, false));
getPage() {
return __async(this, arguments, function* (page = 1, config = {}, limit) {
var _a;
limit = limit || ((_a = config.params) == null ? void 0 : _a.limit) || 50;
const offset = (page - 1) * limit;
return this.query(this.addParams({ offset, limit }, config, false));
});
}
async all(config) {
const response = await this.query(config);
const key = this.getQueryResultKey(response.data);
const totalPages = Math.ceil(response.data.totalCount / response.data.limit);
const result = response.data[key] || [];
if (totalPages > 1) {
const otherPages = [];
for (let i = 0; i < totalPages - 1; i += 1) {
otherPages[i] = i + 2;
all(config) {
return __async(this, null, function* () {
const response = yield this.query(config);
const key = this.getQueryResultKey(response.data);
const totalPages = Math.ceil(response.data.totalCount / response.data.limit);
const result = response.data[key] || [];
if (totalPages > 1) {
const otherPages = [];
for (let i = 0; i < totalPages - 1; i += 1) {
otherPages[i] = i + 2;
}
const pages = yield Promise.all(
otherPages.map((page) => __async(this, null, function* () {
const resp = yield this.getPage(page, config, response.data.limit);
return resp.data[key] || [];
}))
);
return [...result, ...pages].flat();
}
const pages = await Promise.all(otherPages.map(async (page) => {
const resp = await this.getPage(page, config, response.data.limit);
return resp.data[key] || [];
}));
return [...result, ...pages].flat();
}
return result;
return result;
});
}
async update(id, data, config) {
if (typeof id !== "string" && typeof id !== "number") {
config = data;
data = id;
id = "";
}
config = this.config(config);
config.method = "PUT";
config.url = this.getUrl(config, id);
config.data = data;
const beforeFunc = this.beforeUpdate || this.beforePut;
if (beforeFunc) {
config.data = beforeFunc(config.data);
}
return this.request(config, this.afterUpdate || this.afterPut);
// update
update(id, data, config) {
return __async(this, null, function* () {
if (typeof id !== "string" && typeof id !== "number") {
config = data;
data = id;
id = "";
}
config = this.config(config);
config.method = "PUT";
config.url = this.getUrl(config, id);
config.data = data;
const beforeFunc = this.beforeUpdate || this.beforePut;
if (beforeFunc) {
config.data = beforeFunc(config.data);
}
return this.request(config, this.afterUpdate || this.afterPut);
});
}
async put(...args) {
return this.update(...args);
put(...args) {
return __async(this, null, function* () {
return this.update(...args);
});
}
async patch(id, data, config) {
if (typeof id !== "string" && typeof id !== "number") {
config = data;
data = id;
id = "";
}
config = this.config(config);
config.method = "PATCH";
config.url = this.getUrl(config, id);
config.data = data;
const beforeFunc = this.beforePatch;
if (beforeFunc) {
config.data = beforeFunc(config.data);
}
return this.request(config, this.afterPatch);
patch(id, data, config) {
return __async(this, null, function* () {
if (typeof id !== "string" && typeof id !== "number") {
config = data;
data = id;
id = "";
}
config = this.config(config);
config.method = "PATCH";
config.url = this.getUrl(config, id);
config.data = data;
const beforeFunc = this.beforePatch;
if (beforeFunc) {
config.data = beforeFunc(config.data);
}
return this.request(config, this.afterPatch);
});
}
async remove(id, config) {
if (typeof id !== "string" && typeof id !== "number") {
config = id;
id = "";
}
config = this.config(config);
config.method = "DELETE";
config.url = this.getUrl(config, id);
const beforeFunc = this.beforeRemove || this.beforeDelete;
if (beforeFunc) {
config = beforeFunc(config);
}
return this.request(config, this.afterRemove || this.afterDelete);
// delete
remove(id, config) {
return __async(this, null, function* () {
if (typeof id !== "string" && typeof id !== "number") {
config = id;
id = "";
}
config = this.config(config);
config.method = "DELETE";
config.url = this.getUrl(config, id);
const beforeFunc = this.beforeRemove || this.beforeDelete;
if (beforeFunc) {
config = beforeFunc(config);
}
return this.request(config, this.afterRemove || this.afterDelete);
});
}
async delete(...args) {
return this.remove(...args);
delete(...args) {
return __async(this, null, function* () {
return this.remove(...args);
});
}

@@ -436,2 +544,3 @@ };

}
// Override aries 1 url concatenation
getUrl(config, id = "") {

@@ -445,2 +554,3 @@ const { path, version, name, id: configId } = this.config(config);

}
// Polling location is the same url
getLocation(response) {

@@ -482,5 +592,7 @@ return this.getUrl(response.config);

}
async getDisclaimers(id, config) {
const queryConfig = this.addParams({ id }, config);
return this.query(queryConfig);
getDisclaimers(id, config) {
return __async(this, null, function* () {
const queryConfig = this.addParams({ id }, config);
return this.query(queryConfig);
});
}

@@ -528,13 +640,21 @@ };

}
async debug(entries) {
return this.sendBeacon(this.send("debug", entries));
debug(entries) {
return __async(this, null, function* () {
return this.sendBeacon(this.send("debug", entries));
});
}
async info(entries) {
return this.sendBeacon(this.send("info", entries));
info(entries) {
return __async(this, null, function* () {
return this.sendBeacon(this.send("info", entries));
});
}
async warn(entries) {
return this.sendBeacon(this.send("warn", entries));
warn(entries) {
return __async(this, null, function* () {
return this.sendBeacon(this.send("warn", entries));
});
}
async error(entries) {
return this.sendBeacon(this.send("error", entries));
error(entries) {
return __async(this, null, function* () {
return this.sendBeacon(this.send("error", entries));
});
}

@@ -554,10 +674,12 @@ };

}
async uploadFile(data, config) {
if (!config.customerId || !config.clientId) {
throw new Error("[config.customerId] and [config.clientId] must be defined");
}
config = this.config(config);
config.headers["X-Availity-Customer-ID"] = config.customerId;
config.headers["X-Client-ID"] = config.clientId;
return this.create(data, config);
uploadFile(data, config) {
return __async(this, null, function* () {
if (!config.customerId || !config.clientId) {
throw new Error("[config.customerId] and [config.clientId] must be defined");
}
config = this.config(config);
config.headers["X-Availity-Customer-ID"] = config.customerId;
config.headers["X-Client-ID"] = config.clientId;
return this.create(data, config);
});
}

@@ -579,10 +701,12 @@ };

}
async uploadFilesDelivery(data, config) {
if (!config.customerId || !config.clientId) {
throw new Error("[config.customerId] and [config.clientId] must be defined");
}
config = this.config(config);
config.headers["X-Availity-Customer-ID"] = config.customerId;
config.headers["X-Client-ID"] = config.clientId;
return this.create(data || {}, config);
uploadFilesDelivery(data, config) {
return __async(this, null, function* () {
if (!config.customerId || !config.clientId) {
throw new Error("[config.customerId] and [config.clientId] must be defined");
}
config = this.config(config);
config.headers["X-Availity-Customer-ID"] = config.customerId;
config.headers["X-Client-ID"] = config.clientId;
return this.create(data || {}, config);
});
}

@@ -616,13 +740,21 @@ getLocation(response) {

}
async debug(entries) {
return this.sendBeacon(this.send("debug", entries));
debug(entries) {
return __async(this, null, function* () {
return this.sendBeacon(this.send("debug", entries));
});
}
async info(entries) {
return this.sendBeacon(this.send("info", entries));
info(entries) {
return __async(this, null, function* () {
return this.sendBeacon(this.send("info", entries));
});
}
async warn(entries) {
return this.sendBeacon(this.send("warn", entries));
warn(entries) {
return __async(this, null, function* () {
return this.sendBeacon(this.send("warn", entries));
});
}
async error(entries) {
return this.sendBeacon(this.send("error", entries));
error(entries) {
return __async(this, null, function* () {
return this.sendBeacon(this.send("error", entries));
});
}

@@ -651,5 +783,7 @@ };

}
async deleteByTopic(topic, config) {
const removeConfig = this.addParams({ topicId: topic }, config);
return this.remove(removeConfig);
deleteByTopic(topic, config) {
return __async(this, null, function* () {
const removeConfig = this.addParams({ topicId: topic }, config);
return this.remove(removeConfig);
});
}

@@ -670,5 +804,7 @@ };

}
async me(config) {
const response = await this.get("me", config);
return response.data;
me(config) {
return __async(this, null, function* () {
const response = yield this.get("me", config);
return response.data;
});
}

@@ -692,5 +828,7 @@ };

}
async getPermissions(permissionId, region) {
return this.query({
params: { permissionId, region }
getPermissions(permissionId, region) {
return __async(this, null, function* () {
return this.query({
params: { permissionId, region }
});
});

@@ -702,3 +840,3 @@ }

// src/resources/organizations.js
var AvOrganizationsApi = class extends AvApi {
var AvOrganizationsApi = class _AvOrganizationsApi extends AvApi {
constructor(config) {

@@ -709,141 +847,161 @@ super(__spreadValues({

}, config));
// Instance variables to help with caching for filtered organizations
__publicField(this, "previousPermissionIds", []);
__publicField(this, "previousRegionId", "");
__publicField(this, "userPermissions", []);
}
previousPermissionIds = [];
previousRegionId = "";
userPermissions = [];
async queryOrganizations(user, config) {
const queryConfig = this.addParams({ userId: user.id }, config);
return this.query(queryConfig);
queryOrganizations(user, config) {
return __async(this, null, function* () {
const queryConfig = this.addParams({ userId: user.id }, config);
return this.query(queryConfig);
});
}
async getOrganizations(config) {
var _a;
if ((_a = config == null ? void 0 : config.params) == null ? void 0 : _a.userId) {
return this.query(config);
}
const user = await avUserApi.me();
return this.queryOrganizations(user, config);
getOrganizations(config) {
return __async(this, null, function* () {
var _a;
if ((_a = config == null ? void 0 : config.params) == null ? void 0 : _a.userId) {
return this.query(config);
}
const user = yield avUserApi.me();
return this.queryOrganizations(user, config);
});
}
async postGet(data, config, additionalPostGetArgs) {
if (additionalPostGetArgs) {
this.region = void 0;
const { permissionIds } = additionalPostGetArgs;
if (typeof data === "string") {
const dataTemp = import_qs3.default.parse(data);
const { region } = dataTemp;
if (region) {
this.region = region;
delete dataTemp.region;
postGet(data, config, additionalPostGetArgs) {
return __async(this, null, function* () {
if (additionalPostGetArgs) {
this.region = void 0;
const { permissionIds } = additionalPostGetArgs;
if (typeof data === "string") {
const dataTemp = import_qs3.default.parse(data);
const { region } = dataTemp;
if (region) {
this.region = region;
delete dataTemp.region;
}
if (permissionIds) {
dataTemp.permissionId = permissionIds;
}
data = import_qs3.default.stringify(dataTemp, { arrayFormat: "repeat" });
} else if (typeof data === "object") {
const { region } = data;
if (region) {
this.region = region;
delete data.region;
}
if (permissionIds) {
data.permissionId = permissionIds;
}
}
if (permissionIds) {
dataTemp.permissionId = permissionIds;
}
data = import_qs3.default.stringify(dataTemp, { arrayFormat: "repeat" });
} else if (typeof data === "object") {
const { region } = data;
if (region) {
this.region = region;
delete data.region;
}
if (permissionIds) {
data.permissionId = permissionIds;
}
const { data: organizationsData } = yield __superGet(_AvOrganizationsApi.prototype, this, "postGet").call(this, data, config);
const { organizations, limit, offset, totalCount } = organizationsData;
const authorizedOrgs = yield this.getFilteredOrganizations(additionalPostGetArgs, data);
const authorizedFilteredOrgs = organizations.filter(
(org) => authorizedOrgs.some((authOrg) => authOrg.id === org.id)
);
return {
data: {
authorizedFilteredOrgs,
totalCount,
limit,
offset
}
};
}
const { data: organizationsData } = await super.postGet(data, config);
const { organizations, limit, offset, totalCount } = organizationsData;
const authorizedOrgs = await this.getFilteredOrganizations(additionalPostGetArgs, data);
const authorizedFilteredOrgs = organizations.filter((org) => authorizedOrgs.some((authOrg) => authOrg.id === org.id));
return {
data: {
authorizedFilteredOrgs,
totalCount,
limit,
offset
}
};
}
return super.postGet(data, config);
return __superGet(_AvOrganizationsApi.prototype, this, "postGet").call(this, data, config);
});
}
async getFilteredOrganizations(additionalPostGetArgs, data) {
const { resourceIds = [], permissionIds } = additionalPostGetArgs;
if (typeof data === "string") {
data = import_qs3.default.parse(data);
}
const { permissionId } = data;
let permissionIdsToUse = permissionIds || permissionId;
permissionIdsToUse = this.sanitizeIds(permissionIdsToUse);
const resourceIdsToUse = this.sanitizeIds(resourceIds);
const resourceIdsArray = Array.isArray(resourceIdsToUse) ? resourceIdsToUse : [resourceIdsToUse];
const permissionIdsOR = Array.isArray(permissionIdsToUse) ? permissionIdsToUse : [permissionIdsToUse];
if (this.region !== this.previousRegionId || !this.arePermissionsEqual(permissionIdsOR)) {
const {
data: { axiUserPermissions: userPermissions }
} = await avUserPermissionsApi.postGet({
permissionId: permissionIdsOR,
region: this.region
});
if (userPermissions) {
this.userPermissions = userPermissions.reduce((accum, cur) => {
accum[cur.id] = cur;
return accum;
}, {});
this.previousPermissionIds = permissionIdsOR;
this.previousRegionId = this.region;
} else {
throw new Error("avUserPermissions call failed");
getFilteredOrganizations(additionalPostGetArgs, data) {
return __async(this, null, function* () {
const { resourceIds = [], permissionIds } = additionalPostGetArgs;
if (typeof data === "string") {
data = import_qs3.default.parse(data);
}
}
const authorizedOrgs = permissionIdsOR.reduce((accum, permissionIdOR) => {
if (Array.isArray(permissionIdOR)) {
const matchedOrgs = permissionIdOR.reduce((matchedANDOrgsByPerm, permissionIdAND, index) => {
if (this.userPermissions[permissionIdAND]) {
for (const org of this.userPermissions[permissionIdAND].organizations) {
if (index === 0) {
matchedANDOrgsByPerm[org.id] = org;
} else if (matchedANDOrgsByPerm[org.id]) {
matchedANDOrgsByPerm[org.id].resources = [...matchedANDOrgsByPerm[org.id].resources, ...org.resources];
const { permissionId } = data;
let permissionIdsToUse = permissionIds || permissionId;
permissionIdsToUse = this.sanitizeIds(permissionIdsToUse);
const resourceIdsToUse = this.sanitizeIds(resourceIds);
const resourceIdsArray = Array.isArray(resourceIdsToUse) ? resourceIdsToUse : [resourceIdsToUse];
const permissionIdsOR = Array.isArray(permissionIdsToUse) ? permissionIdsToUse : [permissionIdsToUse];
if (this.region !== this.previousRegionId || !this.arePermissionsEqual(permissionIdsOR)) {
const {
data: { axiUserPermissions: userPermissions }
} = yield avUserPermissionsApi.postGet({
permissionId: permissionIdsOR,
region: this.region
});
if (userPermissions) {
this.userPermissions = userPermissions.reduce((accum, cur) => {
accum[cur.id] = cur;
return accum;
}, {});
this.previousPermissionIds = permissionIdsOR;
this.previousRegionId = this.region;
} else {
throw new Error("avUserPermissions call failed");
}
}
const authorizedOrgs = permissionIdsOR.reduce((accum, permissionIdOR) => {
if (Array.isArray(permissionIdOR)) {
const matchedOrgs = permissionIdOR.reduce((matchedANDOrgsByPerm, permissionIdAND, index) => {
if (this.userPermissions[permissionIdAND]) {
for (const org of this.userPermissions[permissionIdAND].organizations) {
if (index === 0) {
matchedANDOrgsByPerm[org.id] = org;
} else if (matchedANDOrgsByPerm[org.id]) {
matchedANDOrgsByPerm[org.id].resources = [...matchedANDOrgsByPerm[org.id].resources, ...org.resources];
}
}
}
matchedANDOrgsByPerm = Object.keys(matchedANDOrgsByPerm).filter((orgId) => {
if (this.userPermissions[permissionIdAND]) {
return this.userPermissions[permissionIdAND].organizations.some((org) => org.id === orgId);
}
return false;
}).reduce((obj, orgId) => {
obj[orgId] = matchedANDOrgsByPerm[orgId];
return obj;
}, {});
return matchedANDOrgsByPerm;
}, {});
for (const orgId of Object.keys(matchedOrgs)) {
if (!accum[orgId]) {
accum[orgId] = matchedOrgs[orgId];
accum[orgId].match = false;
} else {
accum[orgId].resources = [...accum[orgId].resources, ...matchedOrgs[orgId].resources];
}
}
matchedANDOrgsByPerm = Object.keys(matchedANDOrgsByPerm).filter((orgId) => {
if (this.userPermissions[permissionIdAND]) {
return this.userPermissions[permissionIdAND].organizations.some((org) => org.id === orgId);
} else if (this.userPermissions[permissionIdOR]) {
for (const org of this.userPermissions[permissionIdOR].organizations) {
if (!accum[org.id]) {
accum[org.id] = org;
accum[org.id].match = false;
} else {
accum[org.id].resources = [...accum[org.id].resources, ...org.resources];
}
return false;
}).reduce((obj, orgId) => {
obj[orgId] = matchedANDOrgsByPerm[orgId];
return obj;
}, {});
return matchedANDOrgsByPerm;
}, {});
for (const orgId of Object.keys(matchedOrgs)) {
if (!accum[orgId]) {
accum[orgId] = matchedOrgs[orgId];
accum[orgId].match = false;
} else {
accum[orgId].resources = [...accum[orgId].resources, ...matchedOrgs[orgId].resources];
}
}
} else if (this.userPermissions[permissionIdOR]) {
for (const org of this.userPermissions[permissionIdOR].organizations) {
if (!accum[org.id]) {
accum[org.id] = org;
accum[org.id].match = false;
return accum;
}, {});
if (resourceIdsArray.length === 0) {
for (const orgId of Object.keys(authorizedOrgs)) {
authorizedOrgs[orgId].match = true;
}
} else {
resourceIdsArray.forEach((resourceIdOR) => {
if (Array.isArray(resourceIdOR)) {
for (const orgId of Object.keys(authorizedOrgs)) {
if (authorizedOrgs[orgId]) {
const isMatch = resourceIdOR.every(
(resId) => authorizedOrgs[orgId].resources.some((res) => res.id === resId)
);
if (isMatch) {
authorizedOrgs[orgId].match = true;
}
}
}
} else {
accum[org.id].resources = [...accum[org.id].resources, ...org.resources];
}
}
}
return accum;
}, {});
if (resourceIdsArray.length === 0) {
for (const orgId of Object.keys(authorizedOrgs)) {
authorizedOrgs[orgId].match = true;
}
} else {
resourceIdsArray.forEach((resourceIdOR) => {
if (Array.isArray(resourceIdOR)) {
for (const orgId of Object.keys(authorizedOrgs)) {
if (authorizedOrgs[orgId]) {
const isMatch = resourceIdOR.every((resId) => authorizedOrgs[orgId].resources.some((res) => res.id === resId));
if (isMatch) {
for (const orgId of Object.keys(authorizedOrgs)) {
const isMatch = authorizedOrgs[orgId].resources.some((res) => res.id === resourceIdOR);
if (isMatch || !resourceIdOR) {
authorizedOrgs[orgId].match = true;

@@ -853,18 +1011,11 @@ }

}
} else {
for (const orgId of Object.keys(authorizedOrgs)) {
const isMatch = authorizedOrgs[orgId].resources.some((res) => res.id === resourceIdOR);
if (isMatch || !resourceIdOR) {
authorizedOrgs[orgId].match = true;
}
}
});
}
return Object.keys(authorizedOrgs).reduce((accum, orgId) => {
if (authorizedOrgs[orgId].match) {
accum.push(authorizedOrgs[orgId]);
}
});
}
return Object.keys(authorizedOrgs).reduce((accum, orgId) => {
if (authorizedOrgs[orgId].match) {
accum.push(authorizedOrgs[orgId]);
}
return accum;
}, []);
return accum;
}, []);
});
}

@@ -931,9 +1082,11 @@ arePermissionsEqual(permissionId) {

}
async getPdf(data, config) {
if (!data.applicationId || !data.fileName || !data.html) {
throw new Error("[applicationId], [fileName] and [html] must be defined");
}
const response = await this.post(data, config);
this.onPdf(response);
return response;
getPdf(data, config) {
return __async(this, null, function* () {
if (!data.applicationId || !data.fileName || !data.html) {
throw new Error("[applicationId], [fileName] and [html] must be defined");
}
const response = yield this.post(data, config);
this.onPdf(response);
return response;
});
}

@@ -969,5 +1122,7 @@ };

}
async getPermissions(id, region) {
return this.query({
params: { id, region }
getPermissions(id, region) {
return __async(this, null, function* () {
return this.query({
params: { id, region }
});
});

@@ -986,5 +1141,7 @@ }

}
async getProviders(customerId, config) {
const queryConfig = this.addParams({ customerId }, config);
return this.query(queryConfig);
getProviders(customerId, config) {
return __async(this, null, function* () {
const queryConfig = this.addParams({ customerId }, config);
return this.query(queryConfig);
});
}

@@ -1010,2 +1167,6 @@ normalize(providers) {

}, config));
__publicField(this, "afterUpdate", (response) => {
this.setPageBust();
return response;
});
}

@@ -1015,22 +1176,22 @@ getQueryResultKey() {

}
afterUpdate = (response) => {
this.setPageBust();
return response;
};
async getRegions(config) {
var _a;
if ((_a = config == null ? void 0 : config.params) == null ? void 0 : _a.userId) {
return this.query(config);
}
const user = await avUserApi.me();
const queryConfig = this.addParams({ userId: user.id }, config);
return this.query(queryConfig);
}
async getCurrentRegion() {
return this.query({
params: {
currentlySelected: true
getRegions(config) {
return __async(this, null, function* () {
var _a;
if ((_a = config == null ? void 0 : config.params) == null ? void 0 : _a.userId) {
return this.query(config);
}
const user = yield avUserApi.me();
const queryConfig = this.addParams({ userId: user.id }, config);
return this.query(queryConfig);
});
}
getCurrentRegion() {
return __async(this, null, function* () {
return this.query({
params: {
currentlySelected: true
}
});
});
}
};

@@ -1046,5 +1207,7 @@ var avRegionsApi = new AvRegionsApi();

}
async getConfiguration(transactionTypeCode, submissionModeCode, payerId) {
return this.query({
params: { transactionTypeCode, submissionModeCode, payerId }
getConfiguration(transactionTypeCode, submissionModeCode, payerId) {
return __async(this, null, function* () {
return this.query({
params: { transactionTypeCode, submissionModeCode, payerId }
});
});

@@ -1065,35 +1228,39 @@ }

}
async getApplication(applicationId, config) {
var _a;
if (!applicationId) {
throw new Error("[applicationId] must be defined");
}
if ((_a = config == null ? void 0 : config.params) == null ? void 0 : _a.userId) {
const queryConfig2 = this.addParams({ applicationId }, config);
return this.query(queryConfig2);
}
const user = await avUserApi.me();
const queryConfig = this.addParams({ applicationId, userId: user.id }, config);
return this.query(queryConfig);
getApplication(applicationId, config) {
return __async(this, null, function* () {
var _a;
if (!applicationId) {
throw new Error("[applicationId] must be defined");
}
if ((_a = config == null ? void 0 : config.params) == null ? void 0 : _a.userId) {
const queryConfig2 = this.addParams({ applicationId }, config);
return this.query(queryConfig2);
}
const user = yield avUserApi.me();
const queryConfig = this.addParams({ applicationId, userId: user.id }, config);
return this.query(queryConfig);
});
}
async setApplication(applicationId, data, config) {
var _a, _b;
if (typeof applicationId !== "string" && typeof applicationId !== "number") {
config = data;
data = applicationId;
applicationId = "";
}
if (!applicationId && !((_a = data == null ? void 0 : data.scope) == null ? void 0 : _a.applicationId)) {
throw new Error("[applicationId] must be defined");
}
if ((_b = data == null ? void 0 : data.scope) == null ? void 0 : _b.userId) {
setApplication(applicationId, data, config) {
return __async(this, null, function* () {
var _a, _b;
if (typeof applicationId !== "string" && typeof applicationId !== "number") {
config = data;
data = applicationId;
applicationId = "";
}
if (!applicationId && !((_a = data == null ? void 0 : data.scope) == null ? void 0 : _a.applicationId)) {
throw new Error("[applicationId] must be defined");
}
if ((_b = data == null ? void 0 : data.scope) == null ? void 0 : _b.userId) {
data.scope.applicationId = applicationId;
return this.update(data, config);
}
const user = yield avUserApi.me();
data = data || {};
data.scope = data.scope || {};
data.scope.applicationId = applicationId;
data.scope.userId = user.id;
return this.update(data, config);
}
const user = await avUserApi.me();
data = data || {};
data.scope = data.scope || {};
data.scope.applicationId = applicationId;
data.scope.userId = user.id;
return this.update(data, config);
});
}

@@ -1138,8 +1305,10 @@ };

}
async getSpaceName(spaceId) {
if (!spaceId) {
throw new Error("[spaceId] must be defined");
}
const response = await this.get(spaceId);
return response.data.name;
getSpaceName(spaceId) {
return __async(this, null, function* () {
if (!spaceId) {
throw new Error("[spaceId] must be defined");
}
const response = yield this.get(spaceId);
return response.data.name;
});
}

@@ -1146,0 +1315,0 @@ };

{
"name": "@availity/api-axios",
"version": "8.0.2",
"version": "8.0.3",
"description": "Wrappers for axios designed to work with the Availity portal",

@@ -35,11 +35,11 @@ "keywords": [

"dependencies": {
"@availity/resolve-url": "2.0.3",
"@availity/resolve-url": "2.0.4",
"lodash": "^4.17.21",
"qs": "^6.10.1"
"qs": "^6.11.2"
},
"devDependencies": {
"axios": "^1.4.0",
"msw": "^0.49.2",
"tsup": "^5.12.8",
"typescript": "^4.6.4"
"msw": "^0.49.3",
"tsup": "^7.2.0",
"typescript": "^5.1.6"
},

@@ -46,0 +46,0 @@ "peerDependencies": {

@@ -6,3 +6,3 @@ {

"test": {
"executor": "@nrwl/jest:jest",
"executor": "@nx/jest:jest",
"outputs": ["coverage/api-axios"],

@@ -18,4 +18,4 @@ "options": {

"preset": "angular",
"commitMessageFormat": "chore(${projectName}): release version ${version} [skip ci]",
"tagPrefix": "@availity/${projectName}@",
"commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
"tagPrefix": "@availity/{projectName}@",
"baseBranch": "master"

@@ -25,3 +25,3 @@ }

"lint": {
"executor": "@nrwl/linter:eslint",
"executor": "@nx/linter:eslint",
"options": {

@@ -28,0 +28,0 @@ "eslintConfig": ".eslintrc.yaml",

Sorry, the diff of this file is not supported yet

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