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

@rarible/logger

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rarible/logger - npm Package Compare versions

Comparing version 0.9.14 to 0.9.15

build/utils/to-loggable-value.d.ts

12

build/domain.d.ts
export declare type LoggableValue = null | undefined | boolean | number | string | object;
export declare type AbstractLogger = {
raw(data: Record<string, LoggableValue>): void;
trace(...params: LoggableValue[]): void;
debug(...params: LoggableValue[]): void;
info(...params: LoggableValue[]): void;
warn(...params: LoggableValue[]): void;
error(...params: LoggableValue[]): void;
raw(data: Record<string, any>): void;
trace(...params: any[]): void;
debug(...params: any[]): void;
info(...params: any[]): void;
warn(...params: any[]): void;
error(...params: any[]): void;
};

@@ -10,0 +10,0 @@ export declare enum LogLevel {

@@ -21,8 +21,8 @@ import type { RequestInit } from "node-fetch";

}
export declare function handleFetchErrorResponse(fetchResponse: any, options?: {
export declare function handleFetchErrorResponse(response: unknown, options?: {
code?: string;
requestInit?: RequestInit;
}): Promise<void>;
export declare function handleAxiosErrorResponse(axiosError: any, options?: {
export declare function handleAxiosErrorResponse(error: unknown, options?: {
code: string;
}): void;

@@ -34,33 +34,26 @@ "use strict";

exports.NetworkError = NetworkError;
function handleFetchErrorResponse(fetchResponse, options) {
function handleFetchErrorResponse(response, options) {
var _a, _b, _c;
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
var responseData, e_1;
var data;
return (0, tslib_1.__generator)(this, function (_d) {
switch (_d.label) {
case 0:
if (!(isFetchResponse(fetchResponse) && !fetchResponse.ok)) return [3 /*break*/, 6];
responseData = void 0;
_d.label = 1;
if (!(isFetchResponse(response) && !response.ok)) return [3 /*break*/, 2];
return [4 /*yield*/, response
.clone()
.json()
.catch(function () { return response.clone().text(); })
.catch(function () { return "unknown error"; })];
case 1:
_d.trys.push([1, 3, , 5]);
return [4 /*yield*/, fetchResponse.clone().json()];
case 2:
responseData = _d.sent();
return [3 /*break*/, 5];
case 3:
e_1 = _d.sent();
return [4 /*yield*/, fetchResponse.clone().text()];
case 4:
responseData = _d.sent();
return [3 /*break*/, 5];
case 5: throw new NetworkError({
status: fetchResponse.status,
url: decodeURIComponent(fetchResponse.url),
data: responseData,
formData: (_b = (_a = options === null || options === void 0 ? void 0 : options.requestInit) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.toString(),
method: (_c = options === null || options === void 0 ? void 0 : options.requestInit) === null || _c === void 0 ? void 0 : _c.method,
code: options === null || options === void 0 ? void 0 : options.code,
});
case 6: return [2 /*return*/];
data = _d.sent();
throw new NetworkError({
status: response.status,
url: decodeURIComponent(response.url),
data: data,
formData: (_b = (_a = options === null || options === void 0 ? void 0 : options.requestInit) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.toString(),
method: (_c = options === null || options === void 0 ? void 0 : options.requestInit) === null || _c === void 0 ? void 0 : _c.method,
code: options === null || options === void 0 ? void 0 : options.code,
});
case 2: return [2 /*return*/];
}

@@ -72,21 +65,46 @@ });

function isFetchResponse(response) {
return response && "ok" in response;
return typeof response === "object" && response !== null && "ok" in response;
}
function handleAxiosErrorResponse(axiosError, options) {
var _a, _b, _c, _d, _e;
if (isAxiosError(axiosError)) {
var url = ((_a = axiosError === null || axiosError === void 0 ? void 0 : axiosError.config) === null || _a === void 0 ? void 0 : _a.url) || "";
throw new NetworkError({
status: (_b = axiosError === null || axiosError === void 0 ? void 0 : axiosError.response) === null || _b === void 0 ? void 0 : _b.status,
url: url && decodeURIComponent(url),
data: (_c = axiosError === null || axiosError === void 0 ? void 0 : axiosError.response) === null || _c === void 0 ? void 0 : _c.data,
formData: (_d = axiosError === null || axiosError === void 0 ? void 0 : axiosError.config) === null || _d === void 0 ? void 0 : _d.data,
method: (_e = axiosError === null || axiosError === void 0 ? void 0 : axiosError.config) === null || _e === void 0 ? void 0 : _e.method,
code: options === null || options === void 0 ? void 0 : options.code,
});
function handleAxiosErrorResponse(error, options) {
if (isAxiosError(error)) {
throw createAxiosNetworkError(error, options === null || options === void 0 ? void 0 : options.code);
}
}
exports.handleAxiosErrorResponse = handleAxiosErrorResponse;
function decodeUri(url) {
return url ? decodeURIComponent(url) : "unknown-url";
}
function isAxiosError(e) {
return (e === null || e === void 0 ? void 0 : e.isAxiosError) === true;
return typeof e === "object" && e !== null && "isAxiosError" in e;
}
function createAxiosNetworkError(error, code) {
var _a, _b;
if (error.response) {
return new NetworkError({
status: error.response.status,
url: decodeUri(error.config.url),
data: error.response.data,
formData: error.config.data,
method: error.config.method,
code: code,
});
}
if (error.request) {
return new NetworkError({
status: (_a = error.request) === null || _a === void 0 ? void 0 : _a.status,
url: decodeUri(error.config.url),
data: (_b = error.request) === null || _b === void 0 ? void 0 : _b.readyState,
formData: error.config.data,
method: error.config.method,
code: code,
});
}
return new NetworkError({
status: -1,
url: "unknown",
data: "none",
formData: undefined,
method: "unknown",
code: code,
});
}

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

import type { AbstractLogger, LoggableValue } from "../domain";
import type { AbstractLogger } from "../domain";
export declare type RemoteLoggerConfig = {

@@ -12,8 +12,8 @@ initialContext: Promise<Record<string, string>>;

constructor(handler: (values: Record<string, string>[]) => Promise<void>, config: Partial<RemoteLoggerConfig>);
debug(...params: LoggableValue[]): void;
error(...params: LoggableValue[]): void;
info(...params: LoggableValue[]): void;
trace(...params: LoggableValue[]): void;
warn(...params: LoggableValue[]): void;
raw(data: Record<string, LoggableValue>): void;
debug(...params: any[]): void;
error(...params: any[]): void;
info(...params: any[]): void;
trace(...params: any[]): void;
warn(...params: any[]): void;
raw(data: Record<string, any>): void;
private log;

@@ -20,0 +20,0 @@ private rawAsync;

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

var _1 = require(".");
describe("ElkLogger", function () {
describe("RemoteLogger", function () {
it("should correctly log data", function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {

@@ -8,0 +8,0 @@ var handler, logger, _a, calls, result;

@@ -1,11 +0,11 @@

import type { AbstractLogger, LoggableValue } from "./domain";
import type { AbstractLogger } from "./domain";
export declare class UnionLogger implements AbstractLogger {
private readonly loggers;
constructor(loggers: AbstractLogger[]);
debug(...args: LoggableValue[]): void;
error(...args: LoggableValue[]): void;
info(...args: LoggableValue[]): void;
trace(...args: LoggableValue[]): void;
warn(...args: LoggableValue[]): void;
raw(data: Record<string, LoggableValue>): void;
debug(...args: any[]): void;
error(...args: any[]): void;
info(...args: any[]): void;
trace(...args: any[]): void;
warn(...args: any[]): void;
raw(data: Record<string, any>): void;
}

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

import type { LoggableValue } from "../domain";
export declare function getLoggableMessage(maxByteSize: number, ...values: LoggableValue[]): string;
export declare function getLoggableMessage(maxByteSize: number, ...values: any[]): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLoggableMessage = void 0;
var tslib_1 = require("tslib");
var json_stringify_safe_1 = (0, tslib_1.__importDefault)(require("json-stringify-safe"));
var size_of_1 = require("./size-of");
var is_error_1 = require("./is-error");
var to_loggable_value_1 = require("./to-loggable-value");
function getLoggableMessage(maxByteSize) {

@@ -14,5 +12,5 @@ var values = [];

var fixed = (0, size_of_1.fixWithLimit)(values, maxByteSize);
var optional = fixed.map(function (p) { return (0, is_error_1.isError)(p) ? "" + p : (0, json_stringify_safe_1.default)(p); });
var optional = fixed.map(function (p) { return (0, to_loggable_value_1.toLoggableValue)(p); });
return optional.length > 0 ? " " + optional.join(", ") : "";
}
exports.getLoggableMessage = getLoggableMessage;
{
"name": "@rarible/logger",
"version": "0.9.14",
"version": "0.9.15",
"private": false,

@@ -42,3 +42,3 @@ "description": "Logging utility for ts projects",

},
"gitHead": "1890ef30e3d4bc4b6e001117871d3aa1f5196efc"
"gitHead": "f3dff7c9f493a0c5c0520afa7a867cbb3d8217e0"
}

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