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

hypertune

Package Overview
Dependencies
Maintainers
3
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypertune - npm Package Compare versions

Comparing version 1.7.1 to 1.7.2

2

CHANGELOG.md
# Changelog
## 1.7.1
## 1.7.2

@@ -5,0 +5,0 @@ ### Breaking changes

@@ -25,3 +25,3 @@ import { InitResponseBody, Expression, Query, Value, ObjectValueWithVariables, InitSource, VercelEdgeConfigClient, Endpoints, UpdateListener } from "../shared";

[variableName: string]: Value;
}, schemaVersion: string | null, shouldInitializeFromServer: boolean, shouldGetUpdatesFromServer: boolean, logger: Logger, vercelEdgeConfigClient: VercelEdgeConfigClient | null, vercelEdgeConfigItemKey: string | null, endpoints: Endpoints, query: Query<ObjectValueWithVariables>, fallbackInitData: InitResponseBody | null);
}, schemaVersion: string | null, shouldInitializeFromServer: boolean, shouldStartIntervals: boolean, shouldGetUpdatesFromServer: boolean, logger: Logger, vercelEdgeConfigClient: VercelEdgeConfigClient | null, vercelEdgeConfigItemKey: string | null, endpoints: Endpoints, query: Query<ObjectValueWithVariables>, fallbackInitData: InitResponseBody | null);
initFromData(initData: InitResponseBody | null): void;

@@ -28,0 +28,0 @@ private init;

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

// eslint-disable-next-line max-params
constructor(token, queryCode, variableValues, schemaVersion, shouldInitializeFromServer, shouldGetUpdatesFromServer, logger, vercelEdgeConfigClient, vercelEdgeConfigItemKey, endpoints, query, fallbackInitData) {
constructor(token, queryCode, variableValues, schemaVersion, shouldInitializeFromServer, shouldStartIntervals, shouldGetUpdatesFromServer, logger, vercelEdgeConfigClient, vercelEdgeConfigItemKey, endpoints, query, fallbackInitData) {
this.shouldClose = false;

@@ -52,3 +52,16 @@ this.token = token;

}
this.startIntervals();
if (shouldStartIntervals) {
this.startIntervals();
}
else {
this.logger.info("Not starting intervals.");
}
if (environment_1.isBrowser) {
window.addEventListener("beforeunload", () => __awaiter(this, void 0, void 0, function* () {
if (this.shouldClose) {
return;
}
yield this.logger.flush();
}));
}
}

@@ -93,8 +106,12 @@ initFromData(initData) {

const { lastServerInitTime, shouldGetUpdatesFromServer } = this;
// We don't need to initialize from the server if we already have and either
// don't need to get updates or the last server init was < X seconds ago
if (lastServerInitTime &&
(!shouldGetUpdatesFromServer ||
Date.now() - lastServerInitTime < this.getUpdateIntervalMs())) {
return Promise.resolve();
if (lastServerInitTime) {
if (!shouldGetUpdatesFromServer) {
this.logger.debug(`Not initializing from server as have already and not getting updates.`);
return Promise.resolve();
}
const msSinceLastServerInit = Date.now() - lastServerInitTime;
if (msSinceLastServerInit < this.getUpdateIntervalMs()) {
this.logger.debug(`Not initializing from server as already did ${msSinceLastServerInit}ms ago.`);
return Promise.resolve();
}
}

@@ -197,8 +214,5 @@ // If a server initialization is not already in progress, start it, then

});
if (this.initData) {
if (this.initData.commitId === newInitData.commitId) {
this.logger.debug(`Already have latest commit from ${initSourceName}.`);
return;
}
this.logger.info(`Commit hash (${this.initData.commitHash}) is not latest from ${initSourceName} (${newInitData.commitHash}).`);
if (this.initData && this.initData.commitId === newInitData.commitId) {
this.logger.debug(`Already have latest commit from ${initSourceName}.`);
return;
}

@@ -241,10 +255,2 @@ this.logger.info(`Initializing from ${initSourceName}...`);

flushLogQueue();
if (environment_1.isBrowser) {
window.addEventListener("beforeunload", () => __awaiter(this, void 0, void 0, function* () {
if (this.shouldClose) {
return;
}
yield this.logger.flush();
}));
}
}

@@ -251,0 +257,0 @@ getUpdateIntervalMs() {

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

function initialize(NodeConstructor, options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
let token;

@@ -52,5 +52,9 @@ let endpoints;

try {
const context = new Context_1.default(token, options.queryCode, options.variableValues, (_c = options.schemaVersion) !== null && _c !== void 0 ? _c : null, (_d = options.shouldInitializeFromServer) !== null && _d !== void 0 ? _d : true, (_e = options.shouldListenForUpdates) !== null && _e !== void 0 ? _e :
// Listen for updates by default on backend servers and RN apps
(environment_1.isBackendServer || environment_1.isReactNative || (0, environment_1.isNextJsServer)()), logger, (_f = options.vercelEdgeConfigClient) !== null && _f !== void 0 ? _f : null, (_g = options.vercelEdgeConfigItemKey) !== null && _g !== void 0 ? _g : null, endpoints, options.query, (_h = options.fallbackInitData) !== null && _h !== void 0 ? _h : null);
const context = new Context_1.default(token, options.queryCode, options.variableValues, (_c = options.schemaVersion) !== null && _c !== void 0 ? _c : null, (_d = options.shouldInitializeFromServer) !== null && _d !== void 0 ? _d : true, (_e = options.shouldStartIntervals) !== null && _e !== void 0 ? _e :
// Start intervals by default in the browser, backend servers and React
// native apps
(environment_1.isBrowser || environment_1.isBackendServer || environment_1.isReactNative), (_f = options.shouldListenForUpdates) !== null && _f !== void 0 ? _f :
// Get updates by default on Next.js servers, backend servers and React
// native apps
((0, environment_1.isNextJsServer)() || environment_1.isBackendServer || environment_1.isReactNative), logger, (_g = options.vercelEdgeConfigClient) !== null && _g !== void 0 ? _g : null, (_h = options.vercelEdgeConfigItemKey) !== null && _h !== void 0 ? _h : null, endpoints, options.query, (_j = options.fallbackInitData) !== null && _j !== void 0 ? _j : null);
return new NodeConstructor({

@@ -61,3 +65,3 @@ context,

step: null,
expression: (_k = (_j = context.initData) === null || _j === void 0 ? void 0 : _j.reducedExpression) !== null && _k !== void 0 ? _k : null,
expression: (_l = (_k = context.initData) === null || _k === void 0 ? void 0 : _k.reducedExpression) !== null && _l !== void 0 ? _l : null,
});

@@ -64,0 +68,0 @@ }

import { ReductionLogs, DbNodeOp, Expression, Value, CustomLogger, Endpoints } from "../shared";
import { LoggingMode } from "..";
export default class Logger {
readonly id: string;
private readonly backendLoggingMode;

@@ -18,5 +19,5 @@ private readonly logCache;

error(message: string, error: Error): void;
warn(message: string): void;
info(message: string): void;
debug(message: string): void;
warn(message: string, metadata?: any): void;
info(message: string, metadata?: any): void;
debug(message: string, metadata?: any): void;
private localError;

@@ -23,0 +24,0 @@ private localDebug;

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

this.logCache = new Set();
this.id = (0, shared_1.uniqueId)();
this.backendLoggingMode = loggingMode;

@@ -86,13 +87,11 @@ this.customLogger = customLogger;

}
warn(message) {
this.localLog(graphql_1.LogLevel.Warn, message, {});
this.backendLogger.log(graphql_1.LogType.SdkMessage, graphql_1.LogLevel.Warn, message, {
sdkVersion: shared_1.sdkVersion,
});
warn(message, metadata = {}) {
this.localLog(graphql_1.LogLevel.Warn, message, metadata);
this.backendLogger.log(graphql_1.LogType.SdkMessage, graphql_1.LogLevel.Warn, message, Object.assign(Object.assign({}, metadata), { sdkVersion: shared_1.sdkVersion }));
}
info(message) {
this.localLog(graphql_1.LogLevel.Info, message, {});
info(message, metadata = {}) {
this.localLog(graphql_1.LogLevel.Info, message, metadata);
}
debug(message) {
this.localLog(graphql_1.LogLevel.Debug, message, {});
debug(message, metadata = {}) {
this.localLog(graphql_1.LogLevel.Debug, message, metadata);
}

@@ -106,5 +105,6 @@ localError(message, error) {

localLog(level, message, metadataOrError) {
const loggerId = this.id;
if (this.customLogger) {
this.customLogger(level, message, metadataOrError instanceof Error
? Object.assign(Object.assign({}, metadataOrError), { sdkVersion: shared_1.sdkVersion, errorMessage: metadataOrError.message, errorStack: metadataOrError.stack }) : metadataOrError);
? Object.assign(Object.assign({}, metadataOrError), { sdkVersion: shared_1.sdkVersion, errorMessage: metadataOrError.message, errorStack: metadataOrError.stack, loggerId }) : Object.assign(Object.assign({}, metadataOrError), { loggerId }));
return;

@@ -111,0 +111,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/** Replaced by the value in package.json on build */
exports.default = "1.7.1";
exports.default = "1.7.2";
//# sourceMappingURL=sdkVersion.js.map

@@ -574,2 +574,3 @@ import { z } from "zod";

shouldInitializeFromServer?: boolean;
shouldStartIntervals?: boolean;
shouldListenForUpdates?: boolean;

@@ -576,0 +577,0 @@ loggingMode?: LoggingMode;

{
"name": "hypertune",
"version": "1.7.1",
"version": "1.7.2",
"private": false,

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -49,2 +49,3 @@ import pRetry from "p-retry";

shouldInitializeFromServer: boolean,
shouldStartIntervals: boolean,
shouldGetUpdatesFromServer: boolean,

@@ -86,3 +87,16 @@ logger: Logger,

this.startIntervals();
if (shouldStartIntervals) {
this.startIntervals();
} else {
this.logger.info("Not starting intervals.");
}
if (isBrowser) {
window.addEventListener("beforeunload", async () => {
if (this.shouldClose) {
return;
}
await this.logger.flush();
});
}
}

@@ -155,10 +169,16 @@

// We don't need to initialize from the server if we already have and either
// don't need to get updates or the last server init was < X seconds ago
if (
lastServerInitTime &&
(!shouldGetUpdatesFromServer ||
Date.now() - lastServerInitTime < this.getUpdateIntervalMs())
) {
return Promise.resolve();
if (lastServerInitTime) {
if (!shouldGetUpdatesFromServer) {
this.logger.debug(
`Not initializing from server as have already and not getting updates.`
);
return Promise.resolve();
}
const msSinceLastServerInit = Date.now() - lastServerInitTime;
if (msSinceLastServerInit < this.getUpdateIntervalMs()) {
this.logger.debug(
`Not initializing from server as already did ${msSinceLastServerInit}ms ago.`
);
return Promise.resolve();
}
}

@@ -322,12 +342,5 @@

if (this.initData) {
if (this.initData.commitId === newInitData.commitId) {
this.logger.debug(
`Already have latest commit from ${initSourceName}.`
);
return;
}
this.logger.info(
`Commit hash (${this.initData.commitHash}) is not latest from ${initSourceName} (${newInitData.commitHash}).`
);
if (this.initData && this.initData.commitId === newInitData.commitId) {
this.logger.debug(`Already have latest commit from ${initSourceName}.`);
return;
}

@@ -378,11 +391,2 @@

flushLogQueue();
if (isBrowser) {
window.addEventListener("beforeunload", async () => {
if (this.shouldClose) {
return;
}
await this.logger.flush();
});
}
}

@@ -389,0 +393,0 @@

@@ -73,5 +73,10 @@ import {

options.shouldInitializeFromServer ?? true,
options.shouldStartIntervals ??
// Start intervals by default in the browser, backend servers and React
// native apps
(isBrowser || isBackendServer || isReactNative),
options.shouldListenForUpdates ??
// Listen for updates by default on backend servers and RN apps
(isBackendServer || isReactNative || isNextJsServer()),
// Get updates by default on Next.js servers, backend servers and React
// native apps
(isNextJsServer() || isBackendServer || isReactNative),
logger,

@@ -78,0 +83,0 @@ options.vercelEdgeConfigClient ?? null,

@@ -14,2 +14,3 @@ import { GraphQLClient } from "graphql-request";

Endpoints,
uniqueId,
} from "../shared";

@@ -22,2 +23,3 @@ import { LogLevel, LogType } from "../generated/graphql";

export default class Logger {
public readonly id: string;
private readonly backendLoggingMode: LoggingMode;

@@ -39,2 +41,3 @@ private readonly logCache: Set<string> = new Set();

}) {
this.id = uniqueId();
this.backendLoggingMode = loggingMode;

@@ -163,5 +166,6 @@ this.customLogger = customLogger;

public warn(message: string): void {
this.localLog(LogLevel.Warn, message, {});
public warn(message: string, metadata: any = {}): void {
this.localLog(LogLevel.Warn, message, metadata);
this.backendLogger.log(LogType.SdkMessage, LogLevel.Warn, message, {
...metadata,
sdkVersion,

@@ -171,8 +175,8 @@ });

public info(message: string): void {
this.localLog(LogLevel.Info, message, {});
public info(message: string, metadata: any = {}): void {
this.localLog(LogLevel.Info, message, metadata);
}
public debug(message: string): void {
this.localLog(LogLevel.Debug, message, {});
public debug(message: string, metadata: any = {}): void {
this.localLog(LogLevel.Debug, message, metadata);
}

@@ -193,2 +197,4 @@

): void {
const loggerId = this.id;
if (this.customLogger) {

@@ -204,4 +210,5 @@ this.customLogger(

errorStack: metadataOrError.stack,
loggerId,
}
: metadataOrError
: { ...metadataOrError, loggerId }
);

@@ -208,0 +215,0 @@ return;

@@ -725,2 +725,3 @@ /* eslint-disable capitalized-comments */

shouldInitializeFromServer?: boolean;
shouldStartIntervals?: boolean;
shouldListenForUpdates?: boolean;

@@ -727,0 +728,0 @@ loggingMode?: LoggingMode;

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 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