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

@superfaceai/one-sdk

Package Overview
Dependencies
Maintainers
3
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superfaceai/one-sdk - npm Package Compare versions

Comparing version 0.0.29-beta.5 to 0.0.29-beta.6

5

CHANGELOG.md

@@ -10,2 +10,4 @@ # Changelog

## [0.0.29-beta.6] - 2021-07-16
## [0.0.29-beta.5] - 2021-07-08

@@ -190,3 +192,4 @@ ### Changed

[Unreleased]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.29-beta.5...HEAD
[Unreleased]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.29-beta.6...HEAD
[0.0.29-beta.6]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.29-beta.5...v0.0.29-beta.6
[0.0.29-beta.5]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.29-beta.4...v0.0.29-beta.5

@@ -193,0 +196,0 @@ [0.0.29-beta.4]: https://github.com/superfaceai/one-sdk-js/compare/v0.0.29-beta.3...v0.0.29-beta.4

4

dist/client/client.js

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

_this.hookContext = {};
var superCacheKey = config_1.Config.superfacePath;
var superCacheKey = config_1.Config().superfacePath;
if (SUPER_CACHE[superCacheKey] === undefined) {

@@ -85,3 +85,3 @@ SUPER_CACHE[superCacheKey] = internal_1.SuperJson.loadSync(superCacheKey).unwrap();

_this.superJson = SUPER_CACHE[superCacheKey];
if (!config_1.Config.disableReporting) {
if (!config_1.Config().disableReporting) {
_this.hookMetrics();

@@ -88,0 +88,0 @@ _this.metricReporter = new reporter_1.MetricReporter(_this.superJson);

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

}); });
events.on('post-bind', { priority: 1 }, function (context, args, res) { return __awaiter(_this, void 0, void 0, function () {
events.on('post-bind-and-perform', { priority: 1 }, function (context, args, res) { return __awaiter(_this, void 0, void 0, function () {
var performContext, action, error, err_2, resolution;

@@ -276,0 +276,0 @@ return __generator(this, function (_a) {

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

http = new http_1.HttpClient(fetchInstance);
sdkToken = config_1.Config.sdkAuthToken;
sdkToken = config_1.Config().sdkAuthToken;
registryDebug('Binding SDK to registry');

@@ -161,3 +161,3 @@ return [4 /*yield*/, http.request('/registry/bind', {

: undefined,
baseUrl: (_a = options === null || options === void 0 ? void 0 : options.registryUrl) !== null && _a !== void 0 ? _a : config_1.Config.superfaceApiUrl,
baseUrl: (_a = options === null || options === void 0 ? void 0 : options.registryUrl) !== null && _a !== void 0 ? _a : config_1.Config().superfaceApiUrl,
accept: 'application/json',

@@ -164,0 +164,0 @@ contentType: 'application/json',

@@ -140,5 +140,3 @@ "use strict";

switch (_a.label) {
case 0:
console.log(options);
return [4 /*yield*/, this.bind(options)];
case 0: return [4 /*yield*/, this.bind(options)];
case 1:

@@ -226,3 +224,3 @@ _a.sent();

__decorate([
events_1.eventInterceptor({ eventName: 'bind', placement: 'around' }),
events_1.eventInterceptor({ eventName: 'bind-and-perform', placement: 'around' }),
__metadata("design:type", Function),

@@ -229,0 +227,0 @@ __metadata("design:paramtypes", [typeof (_b = typeof TInput !== "undefined" && TInput) === "function" ? _b : Object, Object]),

export declare const DEFAULT_API_URL = "https://superface.ai";
export declare const DEFAULT_SUPERFACE_PATH: string;
export declare const DEFAULT_METRIC_DEBOUNCE_TIME = 60000;
export declare const Config: {
export declare const DEFAULT_METRIC_DEBOUNCE_TIME: {
min: number;
max: number;
};
export declare type Config = {
superfaceApiUrl: string;
sdkAuthToken: string | undefined;
sdkAuthToken?: string;
superfacePath: string;
metricDebounceTime: number;
metricDebounceTimeMin: number;
metricDebounceTimeMax: number;
disableReporting: boolean;
};
export declare type Config = typeof Config;
export declare const Config: () => Config;

@@ -5,3 +5,2 @@ "use strict";

};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -16,3 +15,6 @@ exports.Config = exports.DEFAULT_METRIC_DEBOUNCE_TIME = exports.DEFAULT_SUPERFACE_PATH = exports.DEFAULT_API_URL = void 0;

var SUPERFACE_PATH_NAME = 'SUPERFACE_PATH';
var METRIC_DEBOUNCE_TIME = 'SUPERFACE_METRIC_DEBOUNCE_TIME';
var METRIC_DEBOUNCE_TIME = {
min: 'SUPERFACE_METRIC_DEBOUNCE_TIME_MIN',
max: 'SUPERFACE_METRIC_DEBOUNCE_TIME_MAX',
};
var DISABLE_REPORTING = 'SUPERFACE_DISABLE_METRIC_REPORTING';

@@ -22,3 +24,6 @@ // Defaults

exports.DEFAULT_SUPERFACE_PATH = path_1.join(process.cwd(), 'superface', 'super.json');
exports.DEFAULT_METRIC_DEBOUNCE_TIME = 60000;
exports.DEFAULT_METRIC_DEBOUNCE_TIME = {
min: 1000,
max: 60000,
};
// Extraction functions

@@ -43,22 +48,37 @@ function getSuperfaceApiUrl() {

}
function getMetricDebounceTime() {
var envValue = process.env[METRIC_DEBOUNCE_TIME];
function getMetricDebounceTime(which) {
var envValue = process.env[METRIC_DEBOUNCE_TIME[which]];
if (envValue === undefined) {
return exports.DEFAULT_METRIC_DEBOUNCE_TIME;
return exports.DEFAULT_METRIC_DEBOUNCE_TIME[which];
}
try {
return parseInt(envValue);
var result = parseInt(envValue);
if (result <= 0) {
throw undefined;
}
return result;
}
catch (e) {
configDebug("Invalid value: " + envValue + " for " + METRIC_DEBOUNCE_TIME + ", expected number");
return exports.DEFAULT_METRIC_DEBOUNCE_TIME;
configDebug("Invalid value: " + envValue + " for " + METRIC_DEBOUNCE_TIME[which] + ", expected positive number");
return exports.DEFAULT_METRIC_DEBOUNCE_TIME[which];
}
}
exports.Config = {
superfaceApiUrl: getSuperfaceApiUrl(),
sdkAuthToken: getSdkAuthToken(),
superfacePath: (_a = process.env[SUPERFACE_PATH_NAME]) !== null && _a !== void 0 ? _a : exports.DEFAULT_SUPERFACE_PATH,
metricDebounceTime: getMetricDebounceTime(),
disableReporting: process.env.NODE_ENV === 'test' ? true : !!process.env[DISABLE_REPORTING],
var configCache;
var Config = function () {
var _a;
if (configCache === undefined) {
configCache = {
superfaceApiUrl: getSuperfaceApiUrl(),
sdkAuthToken: getSdkAuthToken(),
superfacePath: (_a = process.env[SUPERFACE_PATH_NAME]) !== null && _a !== void 0 ? _a : exports.DEFAULT_SUPERFACE_PATH,
metricDebounceTimeMin: getMetricDebounceTime('min'),
metricDebounceTimeMax: getMetricDebounceTime('max'),
disableReporting: process.env.NODE_ENV === 'test'
? true
: !!process.env[DISABLE_REPORTING],
};
}
return configCache;
};
exports.Config = Config;
//# sourceMappingURL=config.js.map

@@ -96,7 +96,13 @@ "use strict";

var defaults;
var priority;
if (typeof targetedProfile === 'string') {
defaults = payload.defaults;
}
else if (targetedProfile.defaults) {
defaults = normalize_1.normalizeUsecaseDefaults(payload.defaults, normalize_1.normalizeUsecaseDefaults(targetedProfile.defaults));
else {
if (targetedProfile.defaults) {
defaults = normalize_1.normalizeUsecaseDefaults(payload.defaults, normalize_1.normalizeUsecaseDefaults(targetedProfile.defaults));
}
if (targetedProfile.priority) {
priority = targetedProfile.priority;
}
}

@@ -114,3 +120,4 @@ var providers;

}
document.profiles[profileName] = __assign(__assign({}, payload), { defaults: defaults,
document.profiles[profileName] = __assign(__assign({}, payload), { priority: priority,
defaults: defaults,
providers: providers });

@@ -167,3 +174,3 @@ return true;

else if (profileProvider.defaults) {
defaults = normalize_1.normalizeUsecaseDefaults(payload.defaults, normalize_1.normalizeUsecaseDefaults(profileProvider.defaults));
defaults = normalize_1.normalizeProfileProviderDefaults(payload.defaults, normalize_1.normalizeUsecaseDefaults(targetedProfile.defaults));
}

@@ -170,0 +177,0 @@ // when specified profile provider has file & defaults

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

SuperJson.loadSync = function (path) {
var superfile = path !== null && path !== void 0 ? path : config_1.Config.superfacePath;
var superfile = path !== null && path !== void 0 ? path : config_1.Config().superfacePath;
try {

@@ -184,3 +184,3 @@ var statInfo = fs_1.statSync(superfile);

case 0:
superfile = path !== null && path !== void 0 ? path : config_1.Config.superfacePath;
superfile = path !== null && path !== void 0 ? path : config_1.Config().superfacePath;
_a.label = 1;

@@ -294,5 +294,8 @@ case 1:

provider: provider,
priority: profileEntry.priority.findIndex(function (providerName) { return provider === providerName; }),
version: 'unknown',
};
var providerPriority = profileEntry.priority.findIndex(function (providerName) { return provider === providerName; });
if (providerPriority > -1) {
anonymizedProvider.priority = providerPriority;
}
if ('file' in providerEntry) {

@@ -299,0 +302,0 @@ anonymizedProvider.version = 'file';

@@ -79,3 +79,6 @@ import { UseCase } from '../client';

];
bind: [InstanceType<typeof UseCase>['bindAndPerform'], EventContextBase];
'bind-and-perform': [
InstanceType<typeof UseCase>['bindAndPerform'],
EventContextBase
];
};

@@ -82,0 +85,0 @@ export declare type EventParams = {

@@ -38,2 +38,3 @@ import { SuperJson } from '../internal/superjson';

private timer;
private startTime;
private fetchInstance;

@@ -47,2 +48,3 @@ private readonly sdkToken;

flush(): void;
private setTimer;
private reportSdkInitEvent;

@@ -49,0 +51,0 @@ private reportPerformMetricsEvent;

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

this.fetchInstance = new fetch_1.CrossFetch();
this.sdkToken = config_1.Config.sdkAuthToken;
this.sdkToken = config_1.Config().sdkAuthToken;
this.configHash = superJson.configHash;

@@ -107,10 +107,37 @@ this.anonymizedSuperJson = superJson.anonymized;

MetricReporter.prototype.flush = function () {
var metrics = this.aggregateMetrics();
if (metrics === undefined) {
return;
}
this.performMetrics = [];
this.startTime = undefined;
if (this.timer !== undefined) {
console.log('flushing');
this.sendEvent(this.aggregateMetrics());
this.performMetrics = [];
clearTimeout(this.timer);
this.timer = undefined;
}
this.timer = undefined;
this.sendEvent(metrics);
};
// Sets debounce timer, unless maximum debounce time elapsed
MetricReporter.prototype.setTimer = function () {
var _this = this;
var now = Date.now();
var timeHasElapsed = this.startTime !== undefined &&
now - this.startTime >= config_1.Config().metricDebounceTimeMax;
// If this is the first request in a batch, set the batch start time for max debounce
if (this.startTime === undefined) {
this.startTime = now;
}
// If the max debounce time elapsed, do nothing - let the timer execute
if (timeHasElapsed) {
return;
}
// If the debounce time did not elapse, remove previous set timer
if (this.timer !== undefined) {
clearTimeout(this.timer);
}
// Set the timer for min debounce time - it will execute unless another metric request comes
this.timer = setTimeout(function () {
_this.flush();
}, config_1.Config().metricDebounceTimeMin);
};
MetricReporter.prototype.reportSdkInitEvent = function (event) {

@@ -120,16 +147,5 @@ this.sendEvent(this.createSDKInitEventPayload(event));

MetricReporter.prototype.reportPerformMetricsEvent = function (_a) {
var _this = this;
var _ = _a.eventType, metrics = __rest(_a, ["eventType"]);
this.performMetrics.push(metrics);
if (this.timer !== undefined) {
clearTimeout(this.timer);
}
this.timer = setTimeout(function () {
_this.sendEvent(_this.aggregateMetrics());
_this.performMetrics = [];
if (_this.timer !== undefined) {
clearTimeout(_this.timer);
_this.timer = undefined;
}
}, config_1.Config.metricDebounceTime);
this.setTimer();
};

@@ -168,2 +184,5 @@ MetricReporter.prototype.reportProviderChangeEvent = function (event) {

var e_1, _a;
if (this.performMetrics.length === 0) {
return undefined;
}
var metrics = [];

@@ -221,3 +240,3 @@ var dates = this.performMetrics.map(function (metric) { return metric.occurredAt; }).sort();

MetricReporter.prototype.sendEvent = function (payload) {
var url = new URL('/insights/sdk_event', config_1.Config.superfaceApiUrl).href;
var url = new URL('/insights/sdk_event', config_1.Config().superfaceApiUrl).href;
void this.fetchInstance

@@ -224,0 +243,0 @@ .fetch(url, {

{
"name": "@superfaceai/one-sdk",
"version": "0.0.29-beta.5",
"version": "0.0.29-beta.6",
"description": "Level 5 autonomous, self-driving API client, https://superface.ai",

@@ -33,3 +33,3 @@ "main": "dist/index.js",

"@types/debug": "^4.1.5",
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.24",
"eslint": "^7.28.0",

@@ -41,7 +41,7 @@ "eslint-config-prettier": "8.3.0",

"eslint-plugin-simple-import-sort": "^7.0.0",
"jest": "^26.6.3",
"jest": "^27.0.6",
"mockttp": "^2.0.1",
"prettier": "2.3.2",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4",
"ts-jest": "^27.0.3",
"typescript": "4.3.2"

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

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 too big to display

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