Remove filters container and ilevel related models. (#8)

With the new proposed changes to SDK and event details there is no longer a need for filter levels/target and filters containers.
This commit is contained in:
Matt Mazzola 2016-07-26 10:55:01 -07:00 коммит произвёл GitHub
Родитель f7266802c1
Коммит afbc05c7d2
6 изменённых файлов: 0 добавлений и 257 удалений

Просмотреть файл

@ -2,14 +2,10 @@ declare var require: Function;
export const advancedFilterSchema = require('./schemas/advancedFilter.json');
export const filterSchema = require('./schemas/filter.json');
export const filtersContainerSchema = require('./schemas/filtersContainer.json');
export const loadSchema = require('./schemas/load.json');
export const pageSchema = require('./schemas/page.json');
export const pageLevelSchema = require('./schemas/pageLevel.json');
export const settingsSchema = require('./schemas/settings.json');
export const levelSchema = require('./schemas/level.json');
export const basicFilterSchema = require('./schemas/basicFilter.json');
export const visualLevelSchema = require('./schemas/visualLevel.json');
import * as jsen from 'jsen';
@ -80,26 +76,6 @@ export const validateLoad = validate(loadSchema, {
}
});
export interface IPageLevel {
type: "page";
name: string;
}
export interface IVisualLevel {
type: "visual";
id: string;
}
export declare type ILevel = (IPageLevel | IVisualLevel);
export const validateLevel = validate(levelSchema, {
schemas: {
pageLevel: pageLevelSchema,
visualLevel: visualLevelSchema
}
});
export interface IPage {
name: string;
displayName: string;
@ -111,17 +87,6 @@ export interface IVisual {
export const validatePage = validate(pageSchema);
export const validateFiltersContainer = validate(filtersContainerSchema, {
schemas: {
level: levelSchema,
pageLevel: pageLevelSchema,
visualLevel: visualLevelSchema,
filter: filterSchema,
basicFilter: basicFilterSchema,
advancedFilter: advancedFilterSchema
}
})
export const validateFilter = validate(filterSchema, {
schemas: {
basicFilter: basicFilterSchema,
@ -151,11 +116,6 @@ export interface IFilterMeasureTarget extends IBaseFilterTarget {
export declare type IFilterTarget = (IFilterColumnTarget | IFilterHierarchyTarget | IFilterMeasureTarget);
export interface IFiltersContainer {
level?: ILevel,
filters: (IBasicFilter | IAdvancedFilter)[]
}
export interface IFilter {
$schema: string;
target: IFilterTarget;

Просмотреть файл

@ -1,18 +0,0 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"level": {
"$ref": "#level"
},
"filters": {
"type": "array",
"items": {
"$ref": "#filter"
}
}
},
"required": [
"filters"
]
}

Просмотреть файл

@ -1,11 +0,0 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"oneOf": [
{
"$ref": "#pageLevel"
},
{
"$ref": "#visualLevel"
}
]
}

Просмотреть файл

@ -1,28 +0,0 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"page"
],
"messages": {
"type": "type must be a string",
"enum": "type must be 'page'",
"required": "type is required"
}
},
"name": {
"type": "string",
"messages": {
"type": "name must be a string",
"required": "name is required"
}
}
},
"required": [
"type",
"name"
]
}

Просмотреть файл

@ -1,28 +0,0 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"visual"
],
"messages": {
"type": "type must be a string",
"enum": "type must be 'visual'",
"required": "type is required"
}
},
"id": {
"type": "string",
"messages": {
"type": "id must be a string",
"required": "id is required"
}
}
},
"required": [
"type",
"id"
]
}

Просмотреть файл

@ -473,138 +473,6 @@ describe("Unit | Filters", function () {
});
});
describe('validateLevel', function () {
it("validator should return false if object does not validate against page level schema", function () {
// Arrange
const malformedPageLevel = {
type: 'page',
};
// Act
const errors = models.validateLevel(malformedPageLevel);
// Assert
expect(errors).toBeDefined();
});
it("validator should return false if object does not validate against visual level schema", function () {
// Arrange
const malformedVisualLevel = {
type: 'visual',
};
// Act
const errors = models.validateLevel(malformedVisualLevel);
// Assert
expect(errors).toBeDefined();
});
it(`should return no error if visual level is valid`, function () {
// Arrange
let validVisualLevel: models.IVisualLevel = {
type: 'visual',
id: 'visualId'
};
// Act
const errors = models.validateLevel(validVisualLevel);
// Assert
expect(errors).toBeUndefined();
});
it(`should return no error if page level is valid`, function () {
// Arrange
const validPageLevel: models.IPageLevel = {
type: 'page',
name: 'page1'
};
// Act
const errors = models.validateLevel(validPageLevel);
// Assert
expect(errors).toBeUndefined();
});
});
describe('validateFiltersContainer', function () {
it("validator should return errors if object does NOT validate against filtersContainer schema", function () {
// Arrange
const malformedFiltersContainer = {
abc: '123'
};
// Act
const errors = models.validateFiltersContainer(malformedFiltersContainer);
// Assert
expect(errors).toBeDefined();
});
it("validator should return no errors if object does validate against filtersContainer schema", function () {
// Arrange
const basicFilter: models.IBasicFilter = {
$schema: "a",
target: {
table: "table",
column: "column"
},
operator: "In",
values: [
"A",
"B"
]
};
const advancedFilter: models.IAdvancedFilter = {
$schema: "a",
target: {
table: "table",
hierarchy: "hierachy",
hierarchyLevel: "hierachyLevel"
},
logicalOperator: "Or",
conditions: [
{
value: "a",
operator: "Contains"
},
{
value: "b",
operator: "Contains"
}
]
};
const wellformedFiltersContainer: models.IFiltersContainer = {
level: {
type: "page",
name: ""
},
filters: [
basicFilter,
advancedFilter
]
};
const wellformedFiltersContainerWithoutLevel: models.IFiltersContainer = {
filters: [
basicFilter,
advancedFilter
]
};
// Act
const errors = models.validateFiltersContainer(wellformedFiltersContainer);
const errorsNoLevel = models.validateFiltersContainer(wellformedFiltersContainerWithoutLevel);
// Assert
expect(errors).toBeUndefined();
expect(errorsNoLevel).toBeUndefined();
});
});
describe('determine filter type', function () {
it('getFilterType should return type of filter given a filter object', function () {
// Arrange