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

@finos/legend-shared

Package Overview
Dependencies
Maintainers
4
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@finos/legend-shared - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

lib/application/BrowserUtils.d.ts

10

CHANGELOG.md
# @finos/legend-shared
## 1.1.0
### Minor Changes
- [#755](https://github.com/finos/legend-studio/pull/755) [`61821cd6`](https://github.com/finos/legend-studio/commit/61821cd62c3b8b1a16124a092038ab963311de17) ([@akphi](https://github.com/akphi)) - Allow configuring base headers for `AbstractServerClient`.
### Patch Changes
- [#769](https://github.com/finos/legend-studio/pull/769) [`57b9d9c9`](https://github.com/finos/legend-studio/commit/57b9d9c9915b7d7707c7f15568ee3620a1e309d7) ([@akphi](https://github.com/akphi)) - Fix a problem with text-editor not showing tooltip for error with empty message ([#708](https://github.com/finos/legend-studio/issues/708)).
## 1.0.2

@@ -4,0 +14,0 @@

5

lib/application/SerializationUtils.d.ts

@@ -16,5 +16,4 @@ /**

*/
import type { PlainObject } from '../CommonUtils';
import type { ClazzOrModelSchema, ModelSchema, PropSchema } from 'serializr';
import { SKIP } from 'serializr';
import { type PlainObject } from '../CommonUtils';
import { type ClazzOrModelSchema, type ModelSchema, type PropSchema, SKIP } from 'serializr';
export declare const deseralizeMap: <T>(val: Record<string, T>, schema?: ClazzOrModelSchema<T> | undefined) => Map<string, T>;

@@ -21,0 +20,0 @@ export declare const serializeMap: <T>(val: Map<string, T> | undefined, schema?: ClazzOrModelSchema<T> | undefined) => Record<PropertyKey, unknown>;

2

lib/application/SerializationUtils.js

@@ -17,3 +17,3 @@ /**

import { pruneNullValues } from '../CommonUtils';
import { custom, SKIP, deserialize, serialize } from 'serializr';
import { custom, SKIP, deserialize, serialize, } from 'serializr';
// NOTE: we need these methods because `map()` of `serializr` tries to smartly determines if it should produce object or ES6 Map

@@ -20,0 +20,0 @@ // but we always want ES6 Map, so we would use this function

@@ -16,4 +16,3 @@ /**

*/
export { cloneDeep as deepClone, isEqual as deepEqual, findLast, isEmpty, pickBy, uniqBy, uniq, debounce, throttle, } from 'lodash-es';
export type { DebouncedFunc } from 'lodash-es';
export { cloneDeep as deepClone, isEqual as deepEqual, findLast, isEmpty, pickBy, uniqBy, uniq, debounce, throttle, type DebouncedFunc, } from 'lodash-es';
export { v4 as uuid } from 'uuid';

@@ -33,3 +32,3 @@ export declare type Clazz<T> = {

export declare const getClass: <T>(obj: object) => Clazz<T>;
export declare const getSuperClass: <V>(_class: GenericClazz<unknown>) => GenericClazz<V> | undefined;
export declare const getSuperclass: <V>(_class: GenericClazz<unknown>) => GenericClazz<V> | undefined;
/**

@@ -36,0 +35,0 @@ * Check if the specified class is either the same as, or is a superclass of the provided class.

@@ -26,8 +26,8 @@ /**

export const getClass = (obj) => obj.constructor;
export const getSuperClass = (_class) => {
export const getSuperclass = (_class) => {
if (!_class.name) {
throw new UnsupportedOperationError(`Cannot get super class for non user-defined classes`);
throw new UnsupportedOperationError(`Cannot get superclass for non user-defined classes`);
}
// eslint-disable-next-line @typescript-eslint/ban-types
const superClass = Object.getPrototypeOf(_class);
const superclass = Object.getPrototypeOf(_class);
/**

@@ -42,3 +42,3 @@ * When it comes to inheritance, JavaScript only has one construct: objects.

*/
return superClass?.name ? superClass : undefined;
return superclass?.name ? superclass : undefined;
};

@@ -54,3 +54,3 @@ /**

}
currentPrototype = getSuperClass(currentPrototype);
currentPrototype = getSuperclass(currentPrototype);
}

@@ -57,0 +57,0 @@ return false;

@@ -16,4 +16,3 @@ /**

*/
import type { AbstractPluginManager, PluginConsumer } from '../application/AbstractPluginManager';
import { AbstractPlugin } from '../application/AbstractPluginManager';
import { AbstractPlugin, type AbstractPluginManager, type PluginConsumer } from '../application/AbstractPluginManager';
export interface EventData {

@@ -20,0 +19,0 @@ [key: string]: unknown;

@@ -16,3 +16,3 @@ /**

*/
import { AbstractPlugin } from '../application/AbstractPluginManager';
import { AbstractPlugin, } from '../application/AbstractPluginManager';
export class EventNotifierPlugin extends AbstractPlugin {

@@ -19,0 +19,0 @@ install(pluginManager) {

@@ -16,4 +16,3 @@ /**

*/
import type { EventData } from './EventNotifierService';
import { EventNotifierPlugin } from './EventNotifierService';
import { type EventData, EventNotifierPlugin } from './EventNotifierService';
export declare class IframeEventNotifierPlugin extends EventNotifierPlugin {

@@ -20,0 +19,0 @@ constructor();

@@ -16,4 +16,3 @@ /**

*/
import type { AbstractPluginManager, PluginConsumer } from '../application/AbstractPluginManager';
import { AbstractPlugin } from '../application/AbstractPluginManager';
import { AbstractPlugin, type AbstractPluginManager, type PluginConsumer } from '../application/AbstractPluginManager';
export interface TelemetryData {

@@ -20,0 +19,0 @@ [key: string]: unknown;

@@ -16,3 +16,3 @@ /**

*/
import { AbstractPlugin } from '../application/AbstractPluginManager';
import { AbstractPlugin, } from '../application/AbstractPluginManager';
export class TelemetryServicePlugin extends AbstractPlugin {

@@ -19,0 +19,0 @@ install(pluginManager) {

@@ -16,3 +16,3 @@ /**

*/
import type { SuperGenericFunction } from '../CommonUtils';
import { type SuperGenericFunction } from '../CommonUtils';
/**

@@ -31,4 +31,8 @@ * A generic error that can be used for building other errors in the application

export declare abstract class ApplicationError extends Error {
message: string;
getFullErrorMessage: () => string;
constructor(message: string | undefined);
/**
* This provides more detail (better context) about the error, including the error message
* stack trace, etc.
*/
get detail(): string;
}

@@ -35,0 +39,0 @@ export declare class EnrichedError extends Error {

@@ -30,4 +30,14 @@ /**

export class ApplicationError extends Error {
message = '';
getFullErrorMessage = () => this.message;
constructor(message) {
super();
this.message =
message === undefined || message === '' ? '(no error message)' : message;
}
/**
* This provides more detail (better context) about the error, including the error message
* stack trace, etc.
*/
get detail() {
return this.message;
}
}

@@ -34,0 +44,0 @@ // Since Javascript does not fully support rethrowing error, we need to customize and manipulate the stack trace

@@ -33,2 +33,3 @@ /**

export * from './application/AbstractPluginManager';
export * from './application/BrowserUtils';
export * from './data-structure/Pair';

@@ -35,0 +36,0 @@ export * from './data-structure/Stack';

@@ -33,2 +33,3 @@ /**

export * from './application/AbstractPluginManager';
export * from './application/BrowserUtils';
export * from './data-structure/Pair';

@@ -35,0 +36,0 @@ export * from './data-structure/Stack';

@@ -16,4 +16,3 @@ /**

*/
import type { AbstractPluginManager, PluginConsumer } from '../application/AbstractPluginManager';
import { AbstractPlugin } from '../application/AbstractPluginManager';
import { AbstractPlugin, type AbstractPluginManager, type PluginConsumer } from '../application/AbstractPluginManager';
export declare enum LOG_LEVEL {

@@ -20,0 +19,0 @@ DEBUG = 1,

@@ -16,3 +16,3 @@ /**

*/
import { AbstractPlugin } from '../application/AbstractPluginManager';
import { AbstractPlugin, } from '../application/AbstractPluginManager';
// We use numeric enum here for because we want to do comparison

@@ -19,0 +19,0 @@ // In order to retrieve the name of the enum we can do reverse mapping, for example: LogLevel[LogLevel.INFO] -> INFO

@@ -16,4 +16,3 @@ /**

*/
import type { LogEvent } from './Logger';
import { LoggerPlugin } from './Logger';
import { type LogEvent, LoggerPlugin } from './Logger';
export declare class WebConsole extends LoggerPlugin {

@@ -20,0 +19,0 @@ constructor();

@@ -16,4 +16,3 @@ /**

*/
import type { Parameters, RequestHeaders, RequestProcessConfig, ResponseProcessConfig } from './NetworkUtils';
import { HttpMethod, NetworkClient } from './NetworkUtils';
import { type Parameters, type RequestHeaders, type RequestProcessConfig, type ResponseProcessConfig, HttpMethod } from './NetworkUtils';
import type { TraceData, TracerService } from './TracerService';

@@ -24,2 +23,3 @@ export interface ServerClientConfig {

enableCompression?: boolean;
baseHeaders?: RequestHeaders | undefined;
/**

@@ -40,6 +40,7 @@ * This supports a basic re-authenticate mechanism using <iframe>.

export declare abstract class AbstractServerClient {
protected networkClient: NetworkClient;
private networkClient;
private _tracerService?;
enableCompression: boolean;
baseUrl?: string | undefined;
baseHeaders?: RequestHeaders | undefined;
autoReAuthenticateUrl?: string | undefined;

@@ -46,0 +47,0 @@ constructor(config: ServerClientConfig);

@@ -27,2 +27,3 @@ /**

baseUrl;
baseHeaders;
autoReAuthenticateUrl;

@@ -36,2 +37,3 @@ constructor(config) {

this.enableCompression = Boolean(config.enableCompression);
this.baseHeaders = config.baseHeaders;
this.autoReAuthenticateUrl = config.autoReAuthenticateUrl;

@@ -83,3 +85,5 @@ }

return this.networkClient
.request(method, url, data, options, headers, parameters, {
.request(method, url, data, options, this.baseHeaders
? { ...this.baseHeaders, ...(headers ?? {}) }
: headers, parameters, {
...(requestProcessConfig ?? {}),

@@ -86,0 +90,0 @@ enableCompression: requestProcessConfig?.enableCompression && this.enableCompression,

@@ -98,3 +98,3 @@ /**

*/
export declare const downloadFile: (fileName: string, content: string, contentType: ContentType) => void;
export declare const downloadFileUsingDataURI: (fileName: string, content: string, contentType: ContentType) => void;
export declare const createUrlStringFromData: (data: string, contentType: ContentType, base64: boolean) => string;

@@ -101,0 +101,0 @@ export declare const getQueryParameters: <T>(url: string, isFullUrl?: boolean) => T;

@@ -274,3 +274,4 @@ /**

* Modern browsers should already have native support for `fetch`.
* In case they don't, there are several ways to go about this, but we recommend using `whatwg-fetch` polyfill.
* In case they don't (such as in test where we use `jsdom` for example),
* there are several ways to go about this,but we recommend using `whatwg-fetch` polyfill.
*

@@ -298,3 +299,3 @@ * Why favor `whatwg-fetch`?

*/
export const downloadFile = (fileName, content, contentType) => {
export const downloadFileUsingDataURI = (fileName, content, contentType) => {
const blob = new Blob([content], { type: contentType });

@@ -301,0 +302,0 @@ const url = URL.createObjectURL(blob);

@@ -16,4 +16,3 @@ /**

*/
import type { AbstractPluginManager, PluginConsumer } from '../application/AbstractPluginManager';
import { AbstractPlugin } from '../application/AbstractPluginManager';
import { AbstractPlugin, type AbstractPluginManager, type PluginConsumer } from '../application/AbstractPluginManager';
export interface TraceData {

@@ -20,0 +19,0 @@ spanName: string;

@@ -16,3 +16,3 @@ /**

*/
import { AbstractPlugin } from '../application/AbstractPluginManager';
import { AbstractPlugin, } from '../application/AbstractPluginManager';
export var CORE_TRACER_TAG;

@@ -19,0 +19,0 @@ (function (CORE_TRACER_TAG) {

{
"name": "@finos/legend-shared",
"version": "1.0.2",
"version": "1.1.0",
"description": "Legend Studio shared utilities and helpers",

@@ -30,3 +30,5 @@ "keywords": [

"build:tsc": "tsc --project ./tsconfig.build.json",
"clean": "rimraf \"lib\" \"build\"",
"clean": "npm-run-all clean:cache clean:lib",
"clean:cache": "rimraf \"build\"",
"clean:lib": "rimraf \"lib\"",
"dev": "yarn dev:tsc",

@@ -44,14 +46,14 @@ "dev:tsc": "tsc --watch --preserveWatchOutput",

"@types/object-hash": "2.2.1",
"@types/pako": "1.0.2",
"@types/pako": "1.0.3",
"@types/seedrandom": "3.0.1",
"@types/uuid": "8.3.3",
"@types/uuid": "8.3.4",
"hash.js": "1.1.7",
"http-status-codes": "2.1.4",
"http-status-codes": "2.2.0",
"lodash-es": "4.17.21",
"lossless-json": "1.0.5",
"mobx": "6.3.9",
"mobx": "6.3.12",
"object-hash": "2.2.0",
"pako": "2.0.4",
"pretty-format": "27.4.2",
"query-string": "7.0.1",
"pretty-format": "27.4.6",
"query-string": "7.1.0",
"seedrandom": "3.0.5",

@@ -62,7 +64,8 @@ "serializr": "2.0.5",

"devDependencies": {
"@finos/legend-dev-utils": "0.3.3",
"@finos/legend-dev-utils": "0.3.4",
"cross-env": "7.0.3",
"eslint": "8.4.1",
"jest": "27.4.5",
"eslint": "8.7.0",
"jest": "27.4.7",
"lodash": "4.17.21",
"npm-run-all": "4.1.5",
"rimraf": "3.0.2",

@@ -69,0 +72,0 @@ "typescript": "4.5.4"

@@ -17,6 +17,12 @@ /**

import type { PlainObject } from '../CommonUtils';
import { pruneNullValues } from '../CommonUtils';
import type { ClazzOrModelSchema, ModelSchema, PropSchema } from 'serializr';
import { custom, SKIP, deserialize, serialize } from 'serializr';
import { type PlainObject, pruneNullValues } from '../CommonUtils';
import {
type ClazzOrModelSchema,
type ModelSchema,
type PropSchema,
custom,
SKIP,
deserialize,
serialize,
} from 'serializr';

@@ -23,0 +29,0 @@ // NOTE: we need these methods because `map()` of `serializr` tries to smartly determines if it should produce object or ES6 Map

@@ -33,4 +33,4 @@ /**

throttle,
type DebouncedFunc,
} from 'lodash-es';
export type { DebouncedFunc } from 'lodash-es';

@@ -61,3 +61,3 @@ // NOTE: we can use the `rng` option in UUID V4 to control the random seed during testing

export const getSuperClass = <V>(
export const getSuperclass = <V>(
_class: GenericClazz<unknown>,

@@ -67,7 +67,7 @@ ): GenericClazz<V> | undefined => {

throw new UnsupportedOperationError(
`Cannot get super class for non user-defined classes`,
`Cannot get superclass for non user-defined classes`,
);
}
// eslint-disable-next-line @typescript-eslint/ban-types
const superClass = Object.getPrototypeOf(_class) as Function | null;
const superclass = Object.getPrototypeOf(_class) as Function | null;
/**

@@ -82,3 +82,3 @@ * When it comes to inheritance, JavaScript only has one construct: objects.

*/
return superClass?.name ? (superClass as GenericClazz<V>) : undefined;
return superclass?.name ? (superclass as GenericClazz<V>) : undefined;
};

@@ -98,3 +98,3 @@

}
currentPrototype = getSuperClass(currentPrototype);
currentPrototype = getSuperclass(currentPrototype);
}

@@ -101,0 +101,0 @@ return false;

@@ -17,7 +17,7 @@ /**

import type {
AbstractPluginManager,
PluginConsumer,
import {
AbstractPlugin,
type AbstractPluginManager,
type PluginConsumer,
} from '../application/AbstractPluginManager';
import { AbstractPlugin } from '../application/AbstractPluginManager';

@@ -24,0 +24,0 @@ // NOTE: here, we keep event data at a very generic shape

@@ -18,4 +18,3 @@ /**

import packageJson from '../../package.json';
import type { EventData } from './EventNotifierService';
import { EventNotifierPlugin } from './EventNotifierService';
import { type EventData, EventNotifierPlugin } from './EventNotifierService';

@@ -22,0 +21,0 @@ export class IframeEventNotifierPlugin extends EventNotifierPlugin {

@@ -17,7 +17,7 @@ /**

import type {
AbstractPluginManager,
PluginConsumer,
import {
AbstractPlugin,
type AbstractPluginManager,
type PluginConsumer,
} from '../application/AbstractPluginManager';
import { AbstractPlugin } from '../application/AbstractPluginManager';

@@ -24,0 +24,0 @@ export interface TelemetryData {

@@ -17,4 +17,3 @@ /**

import type { SuperGenericFunction } from '../CommonUtils';
import { printObject } from '../CommonUtils';
import { type SuperGenericFunction, printObject } from '../CommonUtils';

@@ -34,5 +33,15 @@ /**

export abstract class ApplicationError extends Error {
override message = '';
constructor(message: string | undefined) {
super();
this.message =
message === undefined || message === '' ? '(no error message)' : message;
}
getFullErrorMessage = (): string => this.message;
/**
* This provides more detail (better context) about the error, including the error message
* stack trace, etc.
*/
get detail(): string {
return this.message;
}
}

@@ -39,0 +48,0 @@

@@ -39,2 +39,3 @@ /**

export * from './application/AbstractPluginManager';
export * from './application/BrowserUtils';

@@ -41,0 +42,0 @@ export * from './data-structure/Pair';

@@ -17,7 +17,7 @@ /**

import type {
AbstractPluginManager,
PluginConsumer,
import {
AbstractPlugin,
type AbstractPluginManager,
type PluginConsumer,
} from '../application/AbstractPluginManager';
import { AbstractPlugin } from '../application/AbstractPluginManager';

@@ -24,0 +24,0 @@ // We use numeric enum here for because we want to do comparison

@@ -18,4 +18,3 @@ /**

import packageJson from '../../package.json';
import type { LogEvent } from './Logger';
import { LoggerPlugin } from './Logger';
import { type LogEvent, LoggerPlugin } from './Logger';

@@ -22,0 +21,0 @@ const { debug, info, warn, error } = console;

@@ -18,9 +18,7 @@ /**

import { guaranteeNonNullable } from '../error/AssertionUtils';
import type {
Parameters,
RequestHeaders,
RequestProcessConfig,
ResponseProcessConfig,
} from './NetworkUtils';
import {
type Parameters,
type RequestHeaders,
type RequestProcessConfig,
type ResponseProcessConfig,
HttpMethod,

@@ -37,2 +35,3 @@ makeUrl,

enableCompression?: boolean;
baseHeaders?: RequestHeaders | undefined;
/**

@@ -54,6 +53,7 @@ * This supports a basic re-authenticate mechanism using <iframe>.

export abstract class AbstractServerClient {
protected networkClient: NetworkClient;
private networkClient: NetworkClient;
private _tracerService?: TracerService;
enableCompression: boolean;
baseUrl?: string | undefined;
baseHeaders?: RequestHeaders | undefined;
autoReAuthenticateUrl?: string | undefined;

@@ -68,2 +68,3 @@

this.enableCompression = Boolean(config.enableCompression);
this.baseHeaders = config.baseHeaders;
this.autoReAuthenticateUrl = config.autoReAuthenticateUrl;

@@ -297,3 +298,5 @@ }

options,
headers,
this.baseHeaders
? { ...this.baseHeaders, ...(headers ?? {}) }
: headers,
parameters,

@@ -300,0 +303,0 @@ {

@@ -449,3 +449,4 @@ /**

* Modern browsers should already have native support for `fetch`.
* In case they don't, there are several ways to go about this, but we recommend using `whatwg-fetch` polyfill.
* In case they don't (such as in test where we use `jsdom` for example),
* there are several ways to go about this,but we recommend using `whatwg-fetch` polyfill.
*

@@ -478,3 +479,3 @@ * Why favor `whatwg-fetch`?

*/
export const downloadFile = (
export const downloadFileUsingDataURI = (
fileName: string,

@@ -481,0 +482,0 @@ content: string,

@@ -17,7 +17,7 @@ /**

import type {
AbstractPluginManager,
PluginConsumer,
import {
AbstractPlugin,
type AbstractPluginManager,
type PluginConsumer,
} from '../application/AbstractPluginManager';
import { AbstractPlugin } from '../application/AbstractPluginManager';

@@ -24,0 +24,0 @@ export interface TraceData {

@@ -42,2 +42,3 @@ {

"./src/application/ActionState.ts",
"./src/application/BrowserUtils.ts",
"./src/application/HashUtils.ts",

@@ -44,0 +45,0 @@ "./src/application/RandomizerUtils.ts",

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

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

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

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