@finos/legend-shared
Advanced tools
Comparing version 0.0.1 to 0.0.2
# @finos/legend-shared | ||
## 0.0.2 | ||
### Patch Changes | ||
- [#439](https://github.com/finos/legend-studio/pull/439) [`4bcb2af5`](https://github.com/finos/legend-studio/commit/4bcb2af5ea2ddc0bfa77b24582b8cf504456ee97) ([@akphi](https://github.com/akphi)) - Fix a potential circular-dependency issue with the package that could mess up usage with `Webpack`. | ||
## 0.0.1 | ||
@@ -7,12 +13,12 @@ | ||
- [#410](https://github.com/finos/legend-studio/pull/410) [`a1dfc165`](https://github.com/finos/legend-studio/commit/a1dfc165dcf98eeea624400abc9f3c97eb2fda52) Thanks [@akphi](https://github.com/akphi)! - Improve error message in URL builder for case where base URL is not specified and a non-absolute URL is provided. | ||
- [#410](https://github.com/finos/legend-studio/pull/410) [`a1dfc165`](https://github.com/finos/legend-studio/commit/a1dfc165dcf98eeea624400abc9f3c97eb2fda52) ([@akphi](https://github.com/akphi)) - Improve error message in URL builder for case where base URL is not specified and a non-absolute URL is provided. | ||
- [#410](https://github.com/finos/legend-studio/pull/410) [`a1dfc165`](https://github.com/finos/legend-studio/commit/a1dfc165dcf98eeea624400abc9f3c97eb2fda52) Thanks [@akphi](https://github.com/akphi)! - Make `Logger` requires `LogEvent` instead of log event name as the first argument. This will make logger implementation more extensible as we can support features like `channel`, `timestamp`, etc. | ||
- [#410](https://github.com/finos/legend-studio/pull/410) [`a1dfc165`](https://github.com/finos/legend-studio/commit/a1dfc165dcf98eeea624400abc9f3c97eb2fda52) ([@akphi](https://github.com/akphi)) - Make `Logger` requires `LogEvent` instead of log event name as the first argument. This will make logger implementation more extensible as we can support features like `channel`, `timestamp`, etc. | ||
- [#422](https://github.com/finos/legend-studio/pull/422) [`985eef5d`](https://github.com/finos/legend-studio/commit/985eef5def2e4c115ba2ac25dbb851e084758ddc) Thanks [@akphi](https://github.com/akphi)! - `Randomizer` now exports a class instead of a collection of functions. | ||
- [#422](https://github.com/finos/legend-studio/pull/422) [`985eef5d`](https://github.com/finos/legend-studio/commit/985eef5def2e4c115ba2ac25dbb851e084758ddc) ([@akphi](https://github.com/akphi)) - `Randomizer` now exports a class instead of a collection of functions. | ||
- [#422](https://github.com/finos/legend-studio/pull/422) [`985eef5d`](https://github.com/finos/legend-studio/commit/985eef5def2e4c115ba2ac25dbb851e084758ddc) Thanks [@akphi](https://github.com/akphi)! - Rename package from `@finos/legend-studio-shared` to `@finos/legend-shared`. | ||
- [#422](https://github.com/finos/legend-studio/pull/422) [`985eef5d`](https://github.com/finos/legend-studio/commit/985eef5def2e4c115ba2ac25dbb851e084758ddc) ([@akphi](https://github.com/akphi)) - Rename package from `@finos/legend-studio-shared` to `@finos/legend-shared`. | ||
- [#418](https://github.com/finos/legend-studio/pull/418) [`bb8cd369`](https://github.com/finos/legend-studio/commit/bb8cd369da33fe58523d8eddf6bb0991da72edf1) Thanks [@akphi](https://github.com/akphi)! - Document the auto re-authentication feature using `<iframe>` in `AbstractServerClient`. Due to its situational usage, we realise that we should also rename the config for it. | ||
- [#418](https://github.com/finos/legend-studio/pull/418) [`bb8cd369`](https://github.com/finos/legend-studio/commit/bb8cd369da33fe58523d8eddf6bb0991da72edf1) ([@akphi](https://github.com/akphi)) - Document the auto re-authentication feature using `<iframe>` in `AbstractServerClient`. Due to its situational usage, we realise that we should also rename the config for it. | ||
Merge `@finos/legend-studio-network` into `@finos/legend-shared`. |
@@ -48,7 +48,2 @@ /** | ||
export declare const generateEnumerableNameFromToken: (existingNames: string[], token: string) => string; | ||
export declare const compareLabelFn: (a: { | ||
label: string; | ||
}, b: { | ||
label: string; | ||
}) => number; | ||
export declare const getNullableFirstElement: <T>(array: T[]) => T | undefined; | ||
@@ -73,4 +68,4 @@ /** | ||
export declare const printObject: (value: unknown, options?: { | ||
deep?: boolean | undefined; | ||
deep?: boolean; | ||
} | undefined) => string; | ||
//# sourceMappingURL=CommonUtils.d.ts.map |
@@ -19,3 +19,2 @@ /** | ||
import { format as prettyPrintObject } from 'pretty-format'; | ||
import { assertTrue } from './error/AssertionUtils'; | ||
// NOTE: We re-export lodash utilities like this so we centralize utility usage in our app | ||
@@ -93,3 +92,5 @@ // in case we want to swap out the implementation | ||
export const generateEnumerableNameFromToken = (existingNames, token) => { | ||
assertTrue(Boolean(token.match(/^[\w_-]+$/)), 'Token must only contain digits, letters, or special characters _ and -'); | ||
if (!token.match(/^[\w_-]+$/)) { | ||
throw new Error(`Token must only contain digits, letters, or special characters _ and -`); | ||
} | ||
const maxCounter = existingNames | ||
@@ -105,3 +106,2 @@ .map((name) => { | ||
}; | ||
export const compareLabelFn = (a, b) => a.label.localeCompare(b.label); | ||
export const getNullableFirstElement = (array) => array.length ? array[0] : undefined; | ||
@@ -108,0 +108,0 @@ /** |
@@ -41,4 +41,4 @@ /** | ||
enableCompression: boolean; | ||
baseUrl?: string; | ||
autoReAuthenticateUrl?: string; | ||
baseUrl?: string | undefined; | ||
autoReAuthenticateUrl?: string | undefined; | ||
constructor(config: ServerClientConfig); | ||
@@ -56,4 +56,4 @@ setBaseUrl(val: string | undefined): void; | ||
deleteWithTracing<T>(traceData: TraceData, url: string, data?: unknown, options?: RequestInit, headers?: RequestHeaders, parameters?: Parameters, requestProcessConfig?: RequestProcessConfig, responseProcessConfig?: ResponseProcessConfig): Promise<T>; | ||
request<T>(method: HttpMethod, url: string, data: unknown, options: RequestInit, headers?: RequestHeaders, parameters?: Parameters, requestProcessConfig?: RequestProcessConfig, responseProcessConfig?: ResponseProcessConfig, traceData?: TraceData): Promise<T>; | ||
request<T>(method: HttpMethod, url: string, data: unknown, options: RequestInit, headers?: RequestHeaders | undefined, parameters?: Parameters | undefined, requestProcessConfig?: RequestProcessConfig | undefined, responseProcessConfig?: ResponseProcessConfig | undefined, traceData?: TraceData | undefined): Promise<T>; | ||
} | ||
//# sourceMappingURL=AbstractServerClient.d.ts.map |
@@ -63,3 +63,3 @@ /** | ||
}; | ||
payload?: Payload; | ||
payload?: Payload | undefined; | ||
constructor(response: Response, payload: Payload | undefined); | ||
@@ -69,13 +69,13 @@ } | ||
export interface ResponseProcessConfig { | ||
skipProcessing?: boolean; | ||
preprocess?: (response: Response) => void; | ||
autoReAuthenticateUrl?: string; | ||
skipProcessing?: boolean | undefined; | ||
preprocess?: (response: Response) => void | undefined; | ||
autoReAuthenticateUrl?: string | undefined; | ||
} | ||
export interface RequestProcessConfig { | ||
enableCompression?: boolean; | ||
enableCompression?: boolean | undefined; | ||
} | ||
export declare const createRequestHeaders: (method: HttpMethod, headers?: RequestHeaders | undefined) => RequestHeaders; | ||
interface NetworkClientConfig { | ||
options?: Record<PropertyKey, unknown>; | ||
baseUrl?: string; | ||
options?: Record<PropertyKey, unknown> | undefined; | ||
baseUrl?: string | undefined; | ||
} | ||
@@ -88,3 +88,3 @@ /** | ||
private options; | ||
baseUrl?: string; | ||
baseUrl?: string | undefined; | ||
constructor(config?: NetworkClientConfig); | ||
@@ -95,3 +95,3 @@ get<T>(url: string, options?: RequestInit, headers?: RequestHeaders, parameters?: Parameters, requestProcessConfig?: RequestProcessConfig, responseProcessConfig?: ResponseProcessConfig): Promise<T>; | ||
delete<T>(url: string, data?: unknown, options?: RequestInit, headers?: RequestHeaders, parameters?: Parameters, requestProcessConfig?: RequestProcessConfig, responseProcessConfig?: ResponseProcessConfig): Promise<T>; | ||
request<T>(method: HttpMethod, url: string, data: unknown, options: RequestInit, headers?: RequestHeaders, parameters?: Parameters, requestProcessConfig?: RequestProcessConfig, responseProcessConfig?: ResponseProcessConfig): Promise<T>; | ||
request<T>(method: HttpMethod, url: string, data: unknown, options: RequestInit, headers?: RequestHeaders | undefined, parameters?: Parameters | undefined, requestProcessConfig?: RequestProcessConfig | undefined, responseProcessConfig?: ResponseProcessConfig | undefined): Promise<T>; | ||
} | ||
@@ -98,0 +98,0 @@ /** |
@@ -266,3 +266,3 @@ /** | ||
method, | ||
body, | ||
body: body, | ||
headers: createRequestHeaders(method, headers), | ||
@@ -269,0 +269,0 @@ }; |
{ | ||
"name": "@finos/legend-shared", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Legend Studio shared utilities and helpers", | ||
@@ -49,6 +49,6 @@ "keywords": [ | ||
"lossless-json": "1.0.5", | ||
"mobx": "6.3.2", | ||
"mobx": "6.3.3", | ||
"object-hash": "2.2.0", | ||
"pako": "2.0.4", | ||
"pretty-format": "27.0.6", | ||
"pretty-format": "27.1.0", | ||
"query-string": "7.0.1", | ||
@@ -60,9 +60,9 @@ "seedrandom": "3.0.5", | ||
"devDependencies": { | ||
"@finos/legend-dev-utils": "0.0.1", | ||
"@finos/legend-dev-utils": "0.0.4", | ||
"cross-env": "7.0.3", | ||
"eslint": "7.32.0", | ||
"jest": "27.0.6", | ||
"jest": "27.1.0", | ||
"lodash": "4.17.21", | ||
"rimraf": "3.0.2", | ||
"typescript": "4.3.5" | ||
"typescript": "4.4.2" | ||
}, | ||
@@ -69,0 +69,0 @@ "publishConfig": { |
@@ -20,3 +20,2 @@ /** | ||
import { format as prettyPrintObject } from 'pretty-format'; | ||
import { assertTrue } from './error/AssertionUtils'; | ||
@@ -137,3 +136,6 @@ // NOTE: We re-export lodash utilities like this so we centralize utility usage in our app | ||
): Record<PropertyKey, unknown> => | ||
pickBy(obj, (val: unknown): boolean => val !== undefined); | ||
pickBy(obj, (val: unknown): boolean => val !== undefined) as Record< | ||
PropertyKey, | ||
unknown | ||
>; | ||
@@ -155,6 +157,7 @@ // Stringify object shallowly | ||
): string => { | ||
assertTrue( | ||
Boolean(token.match(/^[\w_-]+$/)), | ||
'Token must only contain digits, letters, or special characters _ and -', | ||
); | ||
if (!token.match(/^[\w_-]+$/)) { | ||
throw new Error( | ||
`Token must only contain digits, letters, or special characters _ and -`, | ||
); | ||
} | ||
const maxCounter = existingNames | ||
@@ -171,7 +174,2 @@ .map((name) => { | ||
export const compareLabelFn = ( | ||
a: { label: string }, | ||
b: { label: string }, | ||
): number => a.label.localeCompare(b.label); | ||
export const getNullableFirstElement = <T>(array: T[]): T | undefined => | ||
@@ -213,3 +211,3 @@ array.length ? array[0] : undefined; | ||
resolve(func()); | ||
} catch (error: unknown) { | ||
} catch (error) { | ||
reject(error); | ||
@@ -216,0 +214,0 @@ } |
@@ -60,3 +60,3 @@ /** | ||
// otherwise, use the non-standard but defacto stack trace (available in most browser) | ||
this.stack = new Error(error).stack; | ||
this.stack = new Error(error).stack as string; | ||
} | ||
@@ -127,3 +127,3 @@ } | ||
return fn(); | ||
} catch (error: unknown) { | ||
} catch (error) { | ||
assertErrorThrown(error); | ||
@@ -130,0 +130,0 @@ error.message = errorMessageDecorator(error.message); |
@@ -55,4 +55,4 @@ /** | ||
enableCompression: boolean; | ||
baseUrl?: string; | ||
autoReAuthenticateUrl?: string; | ||
baseUrl?: string | undefined; | ||
autoReAuthenticateUrl?: string | undefined; | ||
@@ -263,7 +263,7 @@ constructor(config: ServerClientConfig) { | ||
options: RequestInit, | ||
headers?: RequestHeaders, | ||
parameters?: Parameters, | ||
requestProcessConfig?: RequestProcessConfig, | ||
responseProcessConfig?: ResponseProcessConfig, | ||
traceData?: TraceData, | ||
headers?: RequestHeaders | undefined, | ||
parameters?: Parameters | undefined, | ||
requestProcessConfig?: RequestProcessConfig | undefined, | ||
responseProcessConfig?: ResponseProcessConfig | undefined, | ||
traceData?: TraceData | undefined, | ||
): Promise<T> { | ||
@@ -270,0 +270,0 @@ const requestUrl = makeUrl( |
@@ -145,3 +145,3 @@ /** | ||
response: Response & { data?: Record<PropertyKey, unknown> }; | ||
payload?: Payload; | ||
payload?: Payload | undefined; | ||
@@ -157,3 +157,3 @@ constructor(response: Response, payload: Payload | undefined) { | ||
// otherwise, use the non-standard but defacto stack trace (available in most browser) | ||
this.stack = new Error().stack; | ||
this.stack = new Error().stack as string; | ||
} | ||
@@ -207,9 +207,9 @@ this.name = 'Network Client Error'; | ||
export interface ResponseProcessConfig { | ||
skipProcessing?: boolean; | ||
preprocess?: (response: Response) => void; | ||
autoReAuthenticateUrl?: string; | ||
skipProcessing?: boolean | undefined; | ||
preprocess?: (response: Response) => void | undefined; | ||
autoReAuthenticateUrl?: string | undefined; | ||
} | ||
export interface RequestProcessConfig { | ||
enableCompression?: boolean; | ||
enableCompression?: boolean | undefined; | ||
} | ||
@@ -301,4 +301,4 @@ | ||
interface NetworkClientConfig { | ||
options?: Record<PropertyKey, unknown>; | ||
baseUrl?: string; | ||
options?: Record<PropertyKey, unknown> | undefined; | ||
baseUrl?: string | undefined; | ||
} | ||
@@ -312,3 +312,3 @@ | ||
private options = {}; | ||
baseUrl?: string; | ||
baseUrl?: string | undefined; | ||
@@ -412,6 +412,6 @@ constructor(config?: NetworkClientConfig) { | ||
options: RequestInit, | ||
headers?: RequestHeaders, | ||
parameters?: Parameters, | ||
requestProcessConfig?: RequestProcessConfig, | ||
responseProcessConfig?: ResponseProcessConfig, | ||
headers?: RequestHeaders | undefined, | ||
parameters?: Parameters | undefined, | ||
requestProcessConfig?: RequestProcessConfig | undefined, | ||
responseProcessConfig?: ResponseProcessConfig | undefined, | ||
): Promise<T> { | ||
@@ -443,7 +443,7 @@ const requestUrl = makeUrl(this.baseUrl, url, parameters ?? {}); | ||
} | ||
const requestInit = { | ||
const requestInit: RequestInit = { | ||
...this.options, | ||
...options, | ||
method, | ||
body, | ||
body: body as BodyInit, | ||
headers: createRequestHeaders(method, headers), | ||
@@ -450,0 +450,0 @@ }; |
@@ -23,4 +23,5 @@ { | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"strict": true, | ||
"exactOptionalPropertyTypes": true, | ||
"forceConsistentCasingInFileNames": true, | ||
@@ -27,0 +28,0 @@ "outDir": "./lib", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
282243
4
4976
+ Addedmobx@6.3.3(transitive)
+ Addedpretty-format@27.1.0(transitive)
- Removedmobx@6.3.2(transitive)
- Removedpretty-format@27.0.6(transitive)
Updatedmobx@6.3.3
Updatedpretty-format@27.1.0