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

@or-sdk/base

Package Overview
Dependencies
Maintainers
2
Versions
335
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@or-sdk/base - npm Package Compare versions

Comparing version 0.33.1 to 0.33.2-beta.2459.0

15

dist/cjs/Base.js

@@ -59,3 +59,3 @@ "use strict";

function Base(_a) {
var token = _a.token, discoveryUrl = _a.discoveryUrl, serviceKey = _a.serviceKey, requestAccountId = _a.requestAccountId, requestProvidersAccountId = _a.requestProvidersAccountId, feature = _a.feature, accountId = _a.accountId, serviceUrl = _a.serviceUrl, useDefaultSerializer = _a.useDefaultSerializer, _b = _a.paramSerializer, paramSerializer = _b === void 0 ? utils_1.paramsSerializer : _b, _c = _a.httpAgents, httpAgents = _c === void 0 ? {} : _c;
var token = _a.token, discoveryUrl = _a.discoveryUrl, serviceKey = _a.serviceKey, requestAccountId = _a.requestAccountId, requestProvidersAccountId = _a.requestProvidersAccountId, feature = _a.feature, accountId = _a.accountId, serviceUrl = _a.serviceUrl, useDefaultSerializer = _a.useDefaultSerializer, _b = _a.paramSerializer, paramSerializer = _b === void 0 ? utils_1.paramsSerializer : _b, _c = _a.httpAgents, httpAgents = _c === void 0 ? {} : _c, _d = _a.interceptors, interceptors = _d === void 0 ? {} : _d;
this.discoveryUrl = null;

@@ -77,2 +77,3 @@ this.requestAccountId = false;

this._serviceUrl = serviceUrl || null;
this.injectInterceptors(interceptors);
if (accountId) {

@@ -166,2 +167,14 @@ this._currentAccountId = accountId;

};
Base.prototype.injectInterceptors = function (_a) {
var _this = this;
var request = _a.request, response = _a.response;
if (request) {
var requestInterceptors = Array.isArray(request) ? request : [request];
requestInterceptors.forEach(function (i) { return _this.axios.interceptors.request.use(i); });
}
if (response) {
var responseInterceptors = Array.isArray(response) ? response : [response];
responseInterceptors.forEach(function (i) { return _this.axios.interceptors.response.use(i); });
}
};
/** @ignore */

@@ -168,0 +181,0 @@ Base.prototype.getServiceData = function () {

@@ -14,3 +14,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

export class Base {
constructor({ token, discoveryUrl, serviceKey, requestAccountId, requestProvidersAccountId, feature, accountId, serviceUrl, useDefaultSerializer, paramSerializer = paramsSerializer, httpAgents = {}, }) {
constructor({ token, discoveryUrl, serviceKey, requestAccountId, requestProvidersAccountId, feature, accountId, serviceUrl, useDefaultSerializer, paramSerializer = paramsSerializer, httpAgents = {}, interceptors = {}, }) {
this.discoveryUrl = null;

@@ -32,2 +32,3 @@ this.requestAccountId = false;

this._serviceUrl = serviceUrl || null;
this.injectInterceptors(interceptors);
if (accountId) {

@@ -96,2 +97,12 @@ this._currentAccountId = accountId;

}
injectInterceptors({ request, response }) {
if (request) {
const requestInterceptors = Array.isArray(request) ? request : [request];
requestInterceptors.forEach((i) => this.axios.interceptors.request.use(i));
}
if (response) {
const responseInterceptors = Array.isArray(response) ? response : [response];
responseInterceptors.forEach((i) => this.axios.interceptors.response.use(i));
}
}
/** @ignore */

@@ -98,0 +109,0 @@ getServiceData() {

3

dist/types/Base.d.ts

@@ -17,3 +17,3 @@ import { RawAxiosRequestHeaders, AxiosError } from 'axios';

private _serviceUrl;
protected constructor({ token, discoveryUrl, serviceKey, requestAccountId, requestProvidersAccountId, feature, accountId, serviceUrl, useDefaultSerializer, paramSerializer, httpAgents, }: BaseConfig);
protected constructor({ token, discoveryUrl, serviceKey, requestAccountId, requestProvidersAccountId, feature, accountId, serviceUrl, useDefaultSerializer, paramSerializer, httpAgents, interceptors, }: BaseConfig);
/**

@@ -35,2 +35,3 @@ * @deprecated used for migration stage only

init(): Promise<void>;
private injectInterceptors;
/** @ignore */

@@ -37,0 +38,0 @@ private getServiceData;

/// <reference types="node" />
/// <reference types="node" />
import { Method } from 'axios';
import { AxiosResponse, InternalAxiosRequestConfig, Method } from 'axios';
import * as http from 'http';

@@ -8,2 +8,8 @@ import * as https from 'https';

export { AxiosError } from 'axios';
export declare type BaseRequestInterceptor = (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig;
export declare type BaseResponseInterceptor = (response: AxiosResponse) => AxiosResponse;
export declare type BaseInterceptors = {
request?: BaseRequestInterceptor | Array<BaseRequestInterceptor>;
response?: BaseResponseInterceptor | Array<BaseResponseInterceptor>;
};
export interface BaseConfig {

@@ -51,2 +57,6 @@ /**

httpAgents?: RequestAgents;
/**
* Request/response Axios interceptors to be used with every request/response
*/
interceptors?: BaseInterceptors;
}

@@ -53,0 +63,0 @@ export declare type Token = string | (() => string);

{
"name": "@or-sdk/base",
"version": "0.33.1",
"version": "0.33.2-beta.2459.0",
"main": "dist/cjs/index.js",

@@ -35,4 +35,3 @@ "module": "dist/esm/index.js",

"access": "public"
},
"gitHead": "e6e22b64a49703be6c5ef09c1ef380797b306d6e"
}
}
import axios, { AxiosInstance, RawAxiosRequestHeaders, AxiosRequestConfig, AxiosError } from 'axios';
import { BaseConfig, CalApiParams, MakeApiUrlData, ServiceDiscoveryResponse } from './types';
import { BaseConfig, BaseInterceptors, CalApiParams, MakeApiUrlData, ServiceDiscoveryResponse } from './types';
import { normalizeRoute, normalizeUrl, paramsSerializer, parseAxiosError, getServiceUrlWithRoute } from './utils';

@@ -40,2 +40,3 @@ import {

httpAgents = {},
interceptors = {},
}: BaseConfig) {

@@ -52,2 +53,3 @@ this.token = token;

this._serviceUrl = serviceUrl || null;
this.injectInterceptors(interceptors);

@@ -127,2 +129,14 @@ if (accountId) {

private injectInterceptors({ request, response }: BaseInterceptors) {
if (request) {
const requestInterceptors = Array.isArray(request) ? request : [request];
requestInterceptors.forEach((i) => this.axios.interceptors.request.use(i));
}
if (response) {
const responseInterceptors = Array.isArray(response) ? response : [response];
responseInterceptors.forEach((i) => this.axios.interceptors.response.use(i));
}
}
/** @ignore */

@@ -129,0 +143,0 @@ private async getServiceData(): Promise<ServiceDiscoveryResponse> {

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

import { Method } from 'axios';
import { AxiosResponse, InternalAxiosRequestConfig, Method } from 'axios';
import * as http from 'http';

@@ -8,2 +8,11 @@ import * as https from 'https';

export type BaseRequestInterceptor = (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig;
export type BaseResponseInterceptor = (response: AxiosResponse) => AxiosResponse;
export type BaseInterceptors = {
request?: BaseRequestInterceptor | Array<BaseRequestInterceptor>;
response?: BaseResponseInterceptor | Array<BaseResponseInterceptor>;
};
export interface BaseConfig {

@@ -60,2 +69,7 @@ /**

httpAgents?: RequestAgents;
/**
* Request/response Axios interceptors to be used with every request/response
*/
interceptors?: BaseInterceptors;
}

@@ -62,0 +76,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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