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

@gooddata/js-utils

Package Overview
Dependencies
Maintainers
56
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gooddata/js-utils - npm Package Compare versions

Comparing version 3.10.9-alpha-khanh-le-kl-sd-980-2020-07-16T09-01-17-571Z to 3.10.9-alpha-ptquang86-qp-sd-976-cfc-events-2020-07-17T03-20-32-168Z

10

dist/utils/filterUtils.d.ts

@@ -22,7 +22,5 @@ import { EmbeddedGdc } from '@gooddata/typings';

export declare type ITransformedFilterItem = ITransformedDateFilterItem | ITransformedAttributeFilterItem;
export declare function isValidDateFilterFormat(filterItem: EmbeddedGdc.DateFilterItem): boolean;
export declare function isValidFilterItemFormat(filterItem: any): boolean;
export declare function isValidFiltersFormat(filters: any[]): boolean;
export declare function isValidRemoveFilterItemFormat(filterItem: any): boolean;
export declare function isValidRemoveFiltersFormat(filters: any[]): boolean;
export declare function isValidDateFilterFormat(filterItem: EmbeddedGdc.DateFilterItem, shouldValidateDataSet?: boolean): boolean;
export declare function isValidFilterItemFormat(filterItem: any, shouldValidateDataSet?: boolean): boolean;
export declare function isValidFiltersFormat(filters: any[], shouldValidateDataSet?: boolean): boolean;
export declare function transformFilterContext(filters: EmbeddedGdc.FilterItem[]): IExternalFiltersObject;

@@ -33,3 +31,1 @@ export declare function isTransformedDateFilterItem(filterItem: ITransformedFilterItem): filterItem is ITransformedDateFilterItem;

export declare function isAllValueAttributeFilterItem(filterItem: ITransformedFilterItem): boolean;
export declare function isRemoveDateFilter(filter: any): filter is any;
export declare function isRemoveAttributeFilter(filter: any): filter is any;

@@ -9,7 +9,15 @@ "use strict";

exports.ALL_TIME_GRANULARITY = 'ALL_TIME_GRANULARITY';
function isValidDateFilterFormat(filterItem) {
function validateDataSet(dataSet) {
if (!dataSet) {
return false;
}
var _a = getObjectUriIdentifier(dataSet), uri = _a.uri, identifier = _a.identifier;
return lodash_1.isString(uri) || lodash_1.isString(identifier);
}
function isValidDateFilterFormat(filterItem, shouldValidateDataSet) {
if (shouldValidateDataSet === void 0) { shouldValidateDataSet = true; }
if (typings_1.EmbeddedGdc.isAbsoluteDateFilter(filterItem)) {
var _a = filterItem.absoluteDateFilter, from = _a.from, to = _a.to, dataSet = _a.dataSet;
var _b = getObjectUriIdentifier(dataSet), uri = _b.uri, identifier = _b.identifier;
return (lodash_1.isString(uri) || lodash_1.isString(identifier))
var isValidDataSet = shouldValidateDataSet ? validateDataSet(dataSet) : true;
return isValidDataSet
&& lodash_1.isString(from) && lodash_1.isString(to)

@@ -19,5 +27,5 @@ && DATE_FORMAT_REGEX.test(from) && DATE_FORMAT_REGEX.test(to);

else {
var _c = filterItem.relativeDateFilter, from = _c.from, to = _c.to, dataSet = _c.dataSet;
var _d = getObjectUriIdentifier(dataSet), uri = _d.uri, identifier = _d.identifier;
return (lodash_1.isString(uri) || lodash_1.isString(identifier)) && lodash_1.isNumber(from) && lodash_1.isNumber(to);
var _b = filterItem.relativeDateFilter, from = _b.from, to = _b.to, dataSet = _b.dataSet;
var isValidDataSet = shouldValidateDataSet ? validateDataSet(dataSet) : true;
return isValidDataSet && lodash_1.isNumber(from) && lodash_1.isNumber(to);
}

@@ -44,5 +52,9 @@ }

}
function isValidFilterItemFormat(filterItem) {
// `dataSet` is required in AD only.
// In AD, we call this function with `shouldValidateDataSet = true`
// In KD, we call this function with `shouldValidateDataSet = false`
function isValidFilterItemFormat(filterItem, shouldValidateDataSet) {
if (shouldValidateDataSet === void 0) { shouldValidateDataSet = true; }
if (typings_1.EmbeddedGdc.isDateFilter(filterItem)) {
return isValidDateFilterFormat(filterItem);
return isValidDateFilterFormat(filterItem, shouldValidateDataSet);
}

@@ -54,24 +66,11 @@ else {

exports.isValidFilterItemFormat = isValidFilterItemFormat;
function isValidFiltersFormat(filters) {
return !lodash_1.isEmpty(filters) && filters.every(isValidFilterItemFormat);
function isValidFiltersFormat(filters, shouldValidateDataSet) {
if (shouldValidateDataSet === void 0) { shouldValidateDataSet = true; }
return !lodash_1.isEmpty(filters) && filters.every(function (filter) { return isValidFilterItemFormat(filter, shouldValidateDataSet); });
}
exports.isValidFiltersFormat = isValidFiltersFormat;
function isValidRemoveFilterItemFormat(filterItem) {
if (isRemoveDateFilter(filterItem)) {
var dataSet = filterItem.dataSet;
var _a = getObjectUriIdentifier(dataSet), uri = _a.uri, identifier = _a.identifier;
return lodash_1.isString(uri) || lodash_1.isString(identifier);
function getObjectUriIdentifier(obj) {
if (!obj) {
return {};
}
else {
var displayForm = filterItem.displayForm;
var _b = getObjectUriIdentifier(displayForm), uri = _b.uri, identifier = _b.identifier;
return lodash_1.isString(uri) || lodash_1.isString(identifier);
}
}
exports.isValidRemoveFilterItemFormat = isValidRemoveFilterItemFormat;
function isValidRemoveFiltersFormat(filters) {
return !lodash_1.isEmpty(filters) && filters.every(isValidRemoveFilterItemFormat);
}
exports.isValidRemoveFiltersFormat = isValidRemoveFiltersFormat;
function getObjectUriIdentifier(obj) {
return {

@@ -169,10 +168,2 @@ uri: typings_1.EmbeddedGdc.isObjectUriQualifier(obj) ? obj.uri : undefined,

exports.isAllValueAttributeFilterItem = isAllValueAttributeFilterItem;
function isRemoveDateFilter(filter) {
return !lodash_1.isEmpty(filter) && filter.dataSet !== undefined;
}
exports.isRemoveDateFilter = isRemoveDateFilter;
function isRemoveAttributeFilter(filter) {
return !lodash_1.isEmpty(filter) && filter.displayForm !== undefined;
}
exports.isRemoveAttributeFilter = isRemoveAttributeFilter;
//# sourceMappingURL=filterUtils.js.map
{
"name": "@gooddata/js-utils",
"version": "3.10.9-alpha-khanh-le-kl-sd-980-2020-07-16T09-01-17-571Z",
"version": "3.10.9-alpha-ptquang86-qp-sd-976-cfc-events-2020-07-17T03-20-32-168Z",
"description": "Various utils shared on GoodData frontend",

@@ -49,3 +49,3 @@ "repository": {

"dependencies": {
"@gooddata/typings": "2.25.0-alpha-khanh-le-kl-sd-980-2020-07-16T08-58-49-507Z",
"@gooddata/typings": "2.26.0-alpha-ptquang86-qp-sd-976-cfc-events-2020-07-17T02-30-41-418Z",
"js-cookie": "^2.1.4",

@@ -52,0 +52,0 @@ "lodash": "^4.17.15"

@@ -32,3 +32,15 @@ // (C) 2020 GoodData Corporation

export function isValidDateFilterFormat(filterItem: EmbeddedGdc.DateFilterItem): boolean {
function validateDataSet(dataSet: EmbeddedGdc.ObjQualifier | undefined): boolean {
if (!dataSet) {
return false;
}
const { uri, identifier } = getObjectUriIdentifier(dataSet);
return isString(uri) || isString(identifier);
}
export function isValidDateFilterFormat(
filterItem: EmbeddedGdc.DateFilterItem,
shouldValidateDataSet: boolean = true
): boolean {
if (EmbeddedGdc.isAbsoluteDateFilter(filterItem)) {

@@ -38,4 +50,5 @@ const {

} = filterItem;
const { uri, identifier } = getObjectUriIdentifier(dataSet);
return (isString(uri) || isString(identifier))
const isValidDataSet = shouldValidateDataSet ? validateDataSet(dataSet) : true;
return isValidDataSet
&& isString(from) && isString(to)

@@ -47,4 +60,5 @@ && DATE_FORMAT_REGEX.test(from) && DATE_FORMAT_REGEX.test(to);

} = filterItem;
const { uri, identifier } = getObjectUriIdentifier(dataSet);
return (isString(uri) || isString(identifier)) && isNumber(from) && isNumber(to);
const isValidDataSet = shouldValidateDataSet ? validateDataSet(dataSet) : true;
return isValidDataSet && isNumber(from) && isNumber(to);
}

@@ -76,5 +90,8 @@ }

export function isValidFilterItemFormat(filterItem: any): boolean {
// `dataSet` is required in AD only.
// In AD, we call this function with `shouldValidateDataSet = true`
// In KD, we call this function with `shouldValidateDataSet = false`
export function isValidFilterItemFormat(filterItem: any, shouldValidateDataSet: boolean = true): boolean {
if (EmbeddedGdc.isDateFilter(filterItem)) {
return isValidDateFilterFormat(filterItem);
return isValidDateFilterFormat(filterItem, shouldValidateDataSet);
} else {

@@ -85,23 +102,11 @@ return isValidAttributeFilterFormat(filterItem);

export function isValidFiltersFormat(filters: any[]): boolean {
return !isEmpty(filters) && filters.every(isValidFilterItemFormat);
export function isValidFiltersFormat(filters: any[], shouldValidateDataSet: boolean = true): boolean {
return !isEmpty(filters) && filters.every((filter: any) => isValidFilterItemFormat(filter, shouldValidateDataSet));
}
export function isValidRemoveFilterItemFormat(filterItem: any): boolean {
if (isRemoveDateFilter(filterItem)) {
const { dataSet } = filterItem;
const { uri, identifier } = getObjectUriIdentifier(dataSet);
return isString(uri) || isString(identifier);
} else {
const { displayForm } = filterItem;
const { uri, identifier } = getObjectUriIdentifier(displayForm);
return isString(uri) || isString(identifier);
function getObjectUriIdentifier(obj: EmbeddedGdc.ObjQualifier | undefined): { uri?: string; identifier?: string } {
if (!obj) {
return {};
}
}
export function isValidRemoveFiltersFormat(filters: any[]): boolean {
return !isEmpty(filters) && filters.every(isValidRemoveFilterItemFormat);
}
function getObjectUriIdentifier(obj: EmbeddedGdc.ObjQualifier): { uri?: string; identifier?: string } {
return {

@@ -222,9 +227,1 @@ uri: EmbeddedGdc.isObjectUriQualifier(obj) ? obj.uri : undefined,

}
export function isRemoveDateFilter(filter: any): filter is any {
return !isEmpty(filter) && (filter as any).dataSet !== undefined;
}
export function isRemoveAttributeFilter(filter: any): filter is any {
return !isEmpty(filter) && (filter as any).displayForm !== undefined;
}

@@ -33,2 +33,15 @@ // (C) 2020 GoodData Corporation

};
const absoluteDateFilterWithoutDataSet = {
absoluteDateFilter: {
from: '2020-01-01',
to: '2020-02-01'
}
};
const absoluteDateFilterWithoutUriAndIdentifier = {
absoluteDateFilter: {
from: '2020-01-01',
to: '2020-02-01',
dataSet: {}
}
};
const negativeAttributeFilter = {

@@ -102,2 +115,14 @@ negativeAttributeFilter: {

it('should return false when date filter is missing dataSet', () => {
expect(isValidFiltersFormat([absoluteDateFilterWithoutDataSet])).toBe(false);
});
it('should return false when date filter is missing uri and identifier', () => {
expect(isValidFiltersFormat([absoluteDateFilterWithoutUriAndIdentifier])).toBe(false);
});
it('should return true when date filter is missing uri and identifier and ', () => {
expect(isValidFiltersFormat([absoluteDateFilterWithoutUriAndIdentifier], false)).toBe(true);
});
it('should check the attribute filter item format', () => {

@@ -104,0 +129,0 @@ expect(isValidFiltersFormat([negativeAttributeFilter, positiveAttributeFilter])).toBe(true);

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