@8base/utils
Advanced tools
Comparing version 1.1.1 to 1.1.2
import { PACKAGES } from './packages'; | ||
export declare const throwIfMissingRequiredParameters: (requiredParameterPaths: (string | string[])[], packageName: PACKAGES, parameters?: {}) => void; | ||
export declare const showWarningIfDeprecatedParameters: (deprecatedParameterPaths: (string | string[])[], packageName: PACKAGES, parameters?: {}) => void; | ||
//# sourceMappingURL=helpers.d.ts.map |
@@ -23,2 +23,11 @@ "use strict"; | ||
}; | ||
exports.showWarningIfDeprecatedParameters = (deprecatedParameterPaths, packageName, parameters = {}) => { | ||
deprecatedParameterPaths.forEach(parameterPath => { | ||
const isExist = hasParameter(parameterPath)(parameters); | ||
if (isExist) { | ||
// tslint:disable-next-line:no-console | ||
console.warn(`Deprecated parameter: ${stringifyPath(parameterPath)}. Please, replace it with appropriate API https://www.npmjs.com/package/${packageName}`); | ||
} | ||
}); | ||
}; | ||
//# sourceMappingURL=helpers.js.map |
export { SDKError } from './SDKError'; | ||
export { ERROR_CODES } from './codes'; | ||
export { PACKAGES } from './packages'; | ||
export { throwIfMissingRequiredParameters } from './helpers'; | ||
export { throwIfMissingRequiredParameters, showWarningIfDeprecatedParameters } from './helpers'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.throwIfMissingRequiredParameters = helpers_1.throwIfMissingRequiredParameters; | ||
exports.showWarningIfDeprecatedParameters = helpers_1.showWarningIfDeprecatedParameters; | ||
//# sourceMappingURL=index.js.map |
@@ -54,7 +54,9 @@ "use strict"; | ||
} | ||
else if (verifiers.isNumberField(fieldSchema) && !verifiers.isBigInt(fieldSchema)) { | ||
else if (verifiers.isNumberField(fieldSchema)) { | ||
if (verifiers.isListField(fieldSchema)) { | ||
if (Array.isArray(nextData)) { | ||
nextData = R.reject(verifiers.isEmptyNumber, nextData); | ||
nextData = R.map(Number, nextData); | ||
if (!verifiers.isBigInt(fieldSchema)) { | ||
nextData = R.map(Number, nextData); | ||
} | ||
} | ||
@@ -66,3 +68,3 @@ } | ||
} | ||
else { | ||
else if (!verifiers.isBigInt(fieldSchema)) { | ||
nextData = Number(nextData); | ||
@@ -69,0 +71,0 @@ } |
@@ -1,6 +0,6 @@ | ||
import { IStorage } from './types'; | ||
export declare class StorageAPI<T> { | ||
import { IStorage, IStorageAPI } from './types'; | ||
export declare class StorageAPI<T> implements IStorageAPI<T> { | ||
private storage; | ||
private storageKey; | ||
constructor(storage: IStorage, storageKey: string); | ||
private readonly storageKey; | ||
constructor(storage: IStorage, storageKey: string, initialState?: T); | ||
getState(): T; | ||
@@ -7,0 +7,0 @@ setState(newState: T): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class StorageAPI { | ||
constructor(storage, storageKey) { | ||
constructor(storage, storageKey, initialState) { | ||
this.storage = storage; | ||
this.storageKey = storageKey; | ||
if (!!initialState) { | ||
this.setState(initialState); | ||
} | ||
} | ||
@@ -8,0 +11,0 @@ getState() { |
@@ -103,2 +103,7 @@ import { FIELD_TYPE, SWITCH_FORMATS, TEXT_FORMATS, NUMBER_FORMATS, FILE_FORMATS, DATE_FORMATS, MUTATION_TYPE, SMART_FORMATS, APP_STATUS, FIELD_KINDS, TABLE_ORIGIN_TYPES } from './constants'; | ||
} | ||
export interface IStorageOptions<T> { | ||
storage?: IStorage; | ||
storageKey?: string; | ||
initialState?: T; | ||
} | ||
export interface IAuthClient { | ||
@@ -116,2 +121,7 @@ getState: () => IAuthState; | ||
} | ||
export interface IStorageAPI<T> { | ||
getState(): T; | ||
setState(newState: T): void; | ||
purgeState(): void; | ||
} | ||
export declare type Unsubscribe = () => void; | ||
@@ -118,0 +128,0 @@ export declare type ISubscriber = (state: any) => void; |
{ | ||
"name": "@8base/utils", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"repository": "https://github.com/8base/sdk", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/8base/sdk/tree/master/packages/utils#readme", |
@@ -27,1 +27,20 @@ import * as R from 'ramda'; | ||
}; | ||
export const showWarningIfDeprecatedParameters = ( | ||
deprecatedParameterPaths: Array<string[] | string>, | ||
packageName: PACKAGES, | ||
parameters: {} = {}, | ||
): void => { | ||
deprecatedParameterPaths.forEach(parameterPath => { | ||
const isExist = hasParameter(parameterPath)(parameters); | ||
if (isExist) { | ||
// tslint:disable-next-line:no-console | ||
console.warn( | ||
`Deprecated parameter: ${stringifyPath( | ||
parameterPath, | ||
)}. Please, replace it with appropriate API https://www.npmjs.com/package/${packageName}`, | ||
); | ||
} | ||
}); | ||
}; |
export { SDKError } from './SDKError'; | ||
export { ERROR_CODES } from './codes'; | ||
export { PACKAGES } from './packages'; | ||
export { throwIfMissingRequiredParameters } from './helpers'; | ||
export { throwIfMissingRequiredParameters, showWarningIfDeprecatedParameters } from './helpers'; |
@@ -55,3 +55,3 @@ import * as R from 'ramda'; | ||
} | ||
} else if (verifiers.isNumberField(fieldSchema) && !verifiers.isBigInt(fieldSchema)) { | ||
} else if (verifiers.isNumberField(fieldSchema)) { | ||
if (verifiers.isListField(fieldSchema)) { | ||
@@ -61,3 +61,5 @@ if (Array.isArray(nextData)) { | ||
nextData = R.map(Number, nextData); | ||
if (!verifiers.isBigInt(fieldSchema)) { | ||
nextData = R.map(Number, nextData); | ||
} | ||
} | ||
@@ -67,3 +69,3 @@ } else { | ||
nextData = null; | ||
} else { | ||
} else if (!verifiers.isBigInt(fieldSchema)) { | ||
nextData = Number(nextData); | ||
@@ -70,0 +72,0 @@ } |
@@ -1,10 +0,14 @@ | ||
import { IStorage } from './types'; | ||
import { IStorage, IStorageAPI } from './types'; | ||
export class StorageAPI<T> { | ||
export class StorageAPI<T> implements IStorageAPI<T> { | ||
private storage: IStorage; | ||
private storageKey: string; | ||
private readonly storageKey: string; | ||
constructor(storage: IStorage, storageKey: string) { | ||
constructor(storage: IStorage, storageKey: string, initialState?: T) { | ||
this.storage = storage; | ||
this.storageKey = storageKey; | ||
if (!!initialState) { | ||
this.setState(initialState); | ||
} | ||
} | ||
@@ -11,0 +15,0 @@ |
@@ -131,2 +131,8 @@ import { | ||
export interface IStorageOptions<T> { | ||
storage?: IStorage; | ||
storageKey?: string; | ||
initialState?: T; | ||
} | ||
export interface IAuthClient { | ||
@@ -146,2 +152,8 @@ getState: () => IAuthState; | ||
export interface IStorageAPI<T> { | ||
getState(): T; | ||
setState(newState: T): void; | ||
purgeState(): void; | ||
} | ||
export type Unsubscribe = () => void; | ||
@@ -148,0 +160,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 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
279488
4549