mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-11 12:12:55 +00:00
Initial Commit
This commit is contained in:
135
test/mapping-model/MapAggTest.ts
Normal file
135
test/mapping-model/MapAggTest.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {generateTemplate} from '../../src/mapping';
|
||||
import {resolve} from "path";
|
||||
import {expect} from "chai";
|
||||
import {ProjectReflection} from 'typedoc';
|
||||
import {getProjectReflection} from '../../src/common';
|
||||
import {AggregationSchema, ESNestedAggregation} from '../../src/mappings/aggregation-definitions';
|
||||
import {MapAggTestOptions, MinimalMappingDescription} from './MapAggTestOptions';
|
||||
import {ElasticsearchTemplateCollection} from '../../src/mappings/mapping-definitions';
|
||||
import {settings} from '../../src/mappings/definitions/settings';
|
||||
import {ElasticsearchDataType} from '../../src/mappings/definitions/typemap';
|
||||
|
||||
export class MapAggTest {
|
||||
mapping_model_path!: string;
|
||||
reflection!: ProjectReflection;
|
||||
|
||||
constructor(dir: string) {
|
||||
this.mapping_model_path = resolve(__dirname, dir);
|
||||
this.reflection = getProjectReflection(this.mapping_model_path);
|
||||
}
|
||||
|
||||
testInterfaceAgainstPath(options: MapAggTestOptions) {
|
||||
const template = generateTemplate(this.reflection, options.ignoredTags ?? [], false, [options.name]);
|
||||
|
||||
if (typeof options.err !== 'undefined') {
|
||||
for (const error of template.errors) {
|
||||
expect(options.err).to.include(error, "Unexpected Error!")
|
||||
}
|
||||
} else {
|
||||
expect(template.errors).to.be.deep.equal([], 'Unexpected Error!');
|
||||
}
|
||||
|
||||
if (typeof options.agg !== 'undefined') {
|
||||
const expectedAggSchema = MapAggTest.buildAggregation(options.name, options.agg.fields, options.agg.globals)
|
||||
expect(template.aggregations).to.be.deep.equal(expectedAggSchema, 'Aggregation schema not equal!');
|
||||
}
|
||||
|
||||
if (typeof options.map !== 'undefined') {
|
||||
const expectedMappingSchema = MapAggTest.buildMapping(options.name, options.map);
|
||||
expect(template.mappings).to.be.deep.equal(expectedMappingSchema, 'Mapping schema not equal!');
|
||||
}
|
||||
}
|
||||
|
||||
static buildAggregation(name: string, fields?: string[], globals?: string[]): AggregationSchema {
|
||||
const out: AggregationSchema = {
|
||||
'@all': {
|
||||
aggs: {},
|
||||
filter: {
|
||||
match_all: {}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
for (const global of globals ?? []) {
|
||||
(out['@all']! as ESNestedAggregation).aggs[global] = {
|
||||
terms: {
|
||||
field: `${global}.raw`,
|
||||
size: 1000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof fields === 'undefined' || fields.length === 0) {
|
||||
return out;
|
||||
}
|
||||
|
||||
out[name] = {
|
||||
aggs: {},
|
||||
filter: {
|
||||
type: {
|
||||
value: name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const field of fields) {
|
||||
(out[name]! as ESNestedAggregation).aggs[field] = {
|
||||
terms: {
|
||||
field: `${field}.raw`,
|
||||
size: 1000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static buildMapping(name: string, map: MinimalMappingDescription): ElasticsearchTemplateCollection {
|
||||
let typeNameWithoutSpaces = name.toLowerCase();
|
||||
while (typeNameWithoutSpaces.includes(' ')) {
|
||||
typeNameWithoutSpaces = typeNameWithoutSpaces.replace(' ', '_');
|
||||
}
|
||||
|
||||
const out: ElasticsearchTemplateCollection = {};
|
||||
const templateName = `template_${typeNameWithoutSpaces}`;
|
||||
out[templateName] = {
|
||||
mappings: {},
|
||||
settings: settings,
|
||||
template: `stapps_${typeNameWithoutSpaces}*`,
|
||||
}
|
||||
const maps = map.maps ?? {};
|
||||
maps.type = {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
maps.creation_date = {
|
||||
type: ElasticsearchDataType.date
|
||||
}
|
||||
out[templateName].mappings[name] = {
|
||||
_source: {
|
||||
excludes: [
|
||||
'creation_date'
|
||||
]
|
||||
},
|
||||
date_detection: false,
|
||||
dynamic: 'strict',
|
||||
properties: maps,
|
||||
dynamic_templates: map.dynamicTemplates ?? [],
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
36
test/mapping-model/MapAggTestOptions.ts
Normal file
36
test/mapping-model/MapAggTestOptions.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {
|
||||
ElasticsearchDynamicTemplate,
|
||||
ElasticsearchValue
|
||||
} from '../../src/mappings/mapping-definitions';
|
||||
|
||||
export interface MapAggTestOptions {
|
||||
name: string;
|
||||
agg?: {
|
||||
fields?: string[];
|
||||
globals?: string[];
|
||||
}
|
||||
map?: MinimalMappingDescription;
|
||||
err?: string[];
|
||||
ignoredTags?: string[];
|
||||
}
|
||||
|
||||
export interface MinimalMappingDescription {
|
||||
maps?: {
|
||||
[name: string]: ElasticsearchValue;
|
||||
};
|
||||
dynamicTemplates?: ElasticsearchDynamicTemplate[];
|
||||
}
|
||||
37
test/mapping-model/aggregations/src/agg-array.ts
Normal file
37
test/mapping-model/aggregations/src/agg-array.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AggArray {
|
||||
/**
|
||||
* @aggregatable
|
||||
*/
|
||||
array: Foo[];
|
||||
|
||||
type: ThingType.AggArray;
|
||||
}
|
||||
type Foo = 'A' | 'B' | 'C';
|
||||
|
||||
export const aggArrayTest: MapAggTestOptions = {
|
||||
name: ThingType.AggArray,
|
||||
agg: {
|
||||
fields: ['array'],
|
||||
},
|
||||
};
|
||||
38
test/mapping-model/aggregations/src/agg-global-nested.ts
Normal file
38
test/mapping-model/aggregations/src/agg-global-nested.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AggGlobalNested {
|
||||
nested: {
|
||||
/**
|
||||
* @aggregatable global
|
||||
*/
|
||||
foo: string;
|
||||
};
|
||||
|
||||
type: ThingType.AggGlobalNested;
|
||||
}
|
||||
|
||||
export const aggGlobalNestedTest: MapAggTestOptions = {
|
||||
name: ThingType.AggGlobalNested,
|
||||
agg: {
|
||||
globals: ['foo'],
|
||||
},
|
||||
};
|
||||
36
test/mapping-model/aggregations/src/agg-global.ts
Normal file
36
test/mapping-model/aggregations/src/agg-global.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AggGlobal {
|
||||
/**
|
||||
* @aggregatable global
|
||||
*/
|
||||
foo: string;
|
||||
|
||||
type: ThingType.AggGlobal;
|
||||
}
|
||||
|
||||
export const aggGlobalTest: MapAggTestOptions = {
|
||||
name: ThingType.AggGlobal,
|
||||
agg: {
|
||||
globals: ['foo'],
|
||||
},
|
||||
};
|
||||
39
test/mapping-model/aggregations/src/agg-inherited-global.ts
Normal file
39
test/mapping-model/aggregations/src/agg-inherited-global.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AggInheritedGlobal extends Foo {
|
||||
type: ThingType.AggInheritedGlobal;
|
||||
}
|
||||
|
||||
|
||||
interface Foo {
|
||||
/**
|
||||
* @aggregatable global
|
||||
*/
|
||||
bar: string;
|
||||
}
|
||||
|
||||
export const aggInheritedGlobalTest: MapAggTestOptions = {
|
||||
name: ThingType.AggInheritedGlobal,
|
||||
agg: {
|
||||
globals: ['bar'],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AggInherited extends Foo {
|
||||
/**
|
||||
* No tag here :)
|
||||
*/
|
||||
bar: 'some thing';
|
||||
|
||||
type: ThingType.AggInheritedOverwritten;
|
||||
}
|
||||
|
||||
|
||||
interface Foo {
|
||||
/**
|
||||
* @aggregatable
|
||||
*/
|
||||
bar: string;
|
||||
}
|
||||
|
||||
export const aggInheritedOverwrittenTest: MapAggTestOptions = {
|
||||
name: ThingType.AggInherited,
|
||||
agg: {
|
||||
fields: ['bar'],
|
||||
},
|
||||
};
|
||||
39
test/mapping-model/aggregations/src/agg-inherited.ts
Normal file
39
test/mapping-model/aggregations/src/agg-inherited.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AggInherited extends Foo {
|
||||
type: ThingType.AggInherited;
|
||||
}
|
||||
|
||||
|
||||
interface Foo {
|
||||
/**
|
||||
* @aggregatable
|
||||
*/
|
||||
bar: string;
|
||||
}
|
||||
|
||||
export const aggInheritedTest: MapAggTestOptions = {
|
||||
name: ThingType.AggInherited,
|
||||
agg: {
|
||||
fields: ['bar'],
|
||||
},
|
||||
};
|
||||
38
test/mapping-model/aggregations/src/agg-nested.ts
Normal file
38
test/mapping-model/aggregations/src/agg-nested.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AggNested {
|
||||
nested: {
|
||||
/**
|
||||
* @aggregatable
|
||||
*/
|
||||
foo: string;
|
||||
};
|
||||
|
||||
type: ThingType.AggNested;
|
||||
}
|
||||
|
||||
export const aggNestedTest: MapAggTestOptions = {
|
||||
name: ThingType.AggNested,
|
||||
agg: {
|
||||
fields: ['nested.foo'],
|
||||
},
|
||||
};
|
||||
24
test/mapping-model/aggregations/src/types.ts
Normal file
24
test/mapping-model/aggregations/src/types.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export enum ThingType {
|
||||
AggArray = 'agg array',
|
||||
AggGlobal = 'agg global',
|
||||
AggGlobalNested = 'agg global nested',
|
||||
AggNested = 'agg nested',
|
||||
AggInherited = 'agg inherited',
|
||||
AggInheritedGlobal = 'agg inherited global',
|
||||
AggInheritedOverwritten = 'agg inherited overwritten',
|
||||
}
|
||||
3
test/mapping-model/aggregations/tsconfig.json
Normal file
3
test/mapping-model/aggregations/tsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json"
|
||||
}
|
||||
44
test/mapping-model/mappings/src/any-unknown.ts
Normal file
44
test/mapping-model/mappings/src/any-unknown.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AnyUnknown {
|
||||
foo: any;
|
||||
|
||||
bar: unknown;
|
||||
|
||||
type: ThingType.AnyUnknown
|
||||
}
|
||||
|
||||
export const anyUnknownTest: MapAggTestOptions = {
|
||||
name: ThingType.AnyUnknown,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: true,
|
||||
properties: {}
|
||||
},
|
||||
bar: {
|
||||
dynamic: true,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
51
test/mapping-model/mappings/src/date.ts
Normal file
51
test/mapping-model/mappings/src/date.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
export type SCISO8601Date = string
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface DateAndRange {
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
directDate: string;
|
||||
|
||||
dateAlias: SCISO8601Date;
|
||||
|
||||
type: ThingType.Date
|
||||
}
|
||||
|
||||
export const dateAndRangeTest: MapAggTestOptions = {
|
||||
name: ThingType.Date,
|
||||
map: {
|
||||
maps: {
|
||||
directDate: {
|
||||
type: ElasticsearchDataType.date,
|
||||
},
|
||||
dateAlias: {
|
||||
type: ElasticsearchDataType.date,
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
50
test/mapping-model/mappings/src/default-generics.ts
Normal file
50
test/mapping-model/mappings/src/default-generics.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface DefaultGeneric {
|
||||
foo: InterfaceWithDefaultGeneric;
|
||||
|
||||
type: ThingType.DefaultGeneric;
|
||||
}
|
||||
|
||||
interface InterfaceWithDefaultGeneric<T = number> {
|
||||
bar: T;
|
||||
}
|
||||
|
||||
export const defaultGenericTest: MapAggTestOptions = {
|
||||
name: ThingType.DefaultGeneric,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.parse_error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.DefaultGeneric}::foo.bar" for Generic "T": Missing reflection, please report!`
|
||||
]
|
||||
};
|
||||
55
test/mapping-model/mappings/src/double-type-conflict.ts
Normal file
55
test/mapping-model/mappings/src/double-type-conflict.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface DoubleTypeConflict {
|
||||
/**
|
||||
* @keyword
|
||||
* @text
|
||||
*/
|
||||
stringDoubleTypeConflict: string;
|
||||
|
||||
/**
|
||||
* @integer
|
||||
* @float
|
||||
*/
|
||||
numberDoubleTypeConflict: number;
|
||||
|
||||
type: ThingType.DoubleTypeConflict;
|
||||
}
|
||||
|
||||
export const doubleTypeConflictTest: MapAggTestOptions = {
|
||||
name: ThingType.DoubleTypeConflict,
|
||||
map: {
|
||||
maps: {
|
||||
stringDoubleTypeConflict: {
|
||||
type: ElasticsearchDataType.type_conflict
|
||||
},
|
||||
numberDoubleTypeConflict: {
|
||||
type: ElasticsearchDataType.type_conflict
|
||||
}
|
||||
}
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.DoubleTypeConflict}::stringDoubleTypeConflict" for type "string": Type conflict; "keyword" would override "text"`,
|
||||
`At "${ThingType.DoubleTypeConflict}::numberDoubleTypeConflict" for type "number": Type conflict; "integer" would override "float"`
|
||||
]
|
||||
};
|
||||
55
test/mapping-model/mappings/src/enum.ts
Normal file
55
test/mapping-model/mappings/src/enum.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface Enum {
|
||||
foo: Bar,
|
||||
|
||||
bar: Baz,
|
||||
|
||||
type: ThingType.Enum;
|
||||
}
|
||||
|
||||
enum Bar {
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
}
|
||||
|
||||
enum Baz {
|
||||
d = 'd',
|
||||
e = 'e',
|
||||
f = 'f',
|
||||
}
|
||||
|
||||
export const enumTest: MapAggTestOptions = {
|
||||
name: ThingType.Enum,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
89
test/mapping-model/mappings/src/filterable-tag.ts
Normal file
89
test/mapping-model/mappings/src/filterable-tag.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
export type FilterableEnumType = 'a' | 'b' | 'c';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface FilterableTag {
|
||||
/**
|
||||
* @text
|
||||
* @filterable
|
||||
*/
|
||||
foo: string;
|
||||
|
||||
/**
|
||||
* @keyword
|
||||
* @filterable
|
||||
*/
|
||||
bar: string;
|
||||
|
||||
/**
|
||||
* @filterable
|
||||
*/
|
||||
baz: 'some literal'
|
||||
|
||||
/**
|
||||
* @filterable
|
||||
*/
|
||||
buz: FilterableEnumType
|
||||
|
||||
type: ThingType.FilterableTag
|
||||
}
|
||||
|
||||
export const filterableTagTest: MapAggTestOptions = {
|
||||
name: ThingType.FilterableTag,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
},
|
||||
buz: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
60
test/mapping-model/mappings/src/generics.ts
Normal file
60
test/mapping-model/mappings/src/generics.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface Generics {
|
||||
foo: InterfaceWithDefaultGeneric<number>;
|
||||
baz: InterfaceWithStringGeneric<string>
|
||||
|
||||
type: ThingType.Generics;
|
||||
}
|
||||
|
||||
interface InterfaceWithDefaultGeneric<T = number> {
|
||||
bar: T;
|
||||
}
|
||||
|
||||
interface InterfaceWithStringGeneric<T> {
|
||||
bar: T;
|
||||
}
|
||||
|
||||
export const genericTest: MapAggTestOptions = {
|
||||
name: ThingType.Generics,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.integer
|
||||
}
|
||||
}
|
||||
},
|
||||
baz: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
41
test/mapping-model/mappings/src/impossible-union.ts
Normal file
41
test/mapping-model/mappings/src/impossible-union.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface ImpossibleUnion {
|
||||
foo: 'a' | 1 | boolean;
|
||||
|
||||
type: ThingType.ImpossibleUnion
|
||||
}
|
||||
|
||||
export const impossibleUnionTest: MapAggTestOptions = {
|
||||
name: ThingType.ImpossibleUnion,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.ImpossibleUnion}::foo" for type "[{"type":"1","name":"2"},"unknown","1"]": Not implemented type`
|
||||
]
|
||||
};
|
||||
72
test/mapping-model/mappings/src/incompatible-type.ts
Normal file
72
test/mapping-model/mappings/src/incompatible-type.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface DoubleTypeConflict {
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
keywordNumber: number;
|
||||
|
||||
/**
|
||||
* @text
|
||||
*/
|
||||
textNumber: number;
|
||||
|
||||
/**
|
||||
* @integer
|
||||
*/
|
||||
integerString: string;
|
||||
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
floatString: string;
|
||||
|
||||
|
||||
type: ThingType.IncompatibleType;
|
||||
}
|
||||
|
||||
export const incompatibleTypeTest: MapAggTestOptions = {
|
||||
name: ThingType.IncompatibleType,
|
||||
map: {
|
||||
maps: {
|
||||
keywordNumber: {
|
||||
type: ElasticsearchDataType.integer
|
||||
},
|
||||
textNumber: {
|
||||
type: ElasticsearchDataType.integer
|
||||
},
|
||||
integerString: {
|
||||
type: ElasticsearchDataType.text
|
||||
},
|
||||
floatString: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.IncompatibleType}::keywordNumber" for tag "keyword": Not implemented tag`,
|
||||
`At "${ThingType.IncompatibleType}::textNumber" for tag "text": Not implemented tag`,
|
||||
`At "${ThingType.IncompatibleType}::floatString" for tag "float": Not implemented tag`,
|
||||
`At "${ThingType.IncompatibleType}::integerString" for tag "integer": Not implemented tag`,
|
||||
]
|
||||
};
|
||||
64
test/mapping-model/mappings/src/index-signature.ts
Normal file
64
test/mapping-model/mappings/src/index-signature.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface IndexSignature {
|
||||
foo: {
|
||||
[key: string]: {
|
||||
bar: number;
|
||||
baz: string;
|
||||
}
|
||||
}
|
||||
|
||||
type: ThingType.IndexSignature;
|
||||
}
|
||||
|
||||
export const indexSignatureTest: MapAggTestOptions = {
|
||||
name: ThingType.IndexSignature,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: true,
|
||||
properties: {}
|
||||
}
|
||||
},
|
||||
dynamicTemplates: [
|
||||
{
|
||||
__type: {
|
||||
mapping: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.integer
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
},
|
||||
match: '*',
|
||||
match_mapping_type: '*',
|
||||
path_match: 'foo.*'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
56
test/mapping-model/mappings/src/inherit-tags.ts
Normal file
56
test/mapping-model/mappings/src/inherit-tags.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ThingType} from './types';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface InheritTags {
|
||||
/**
|
||||
* @inheritTags inherit tags::bar.baz
|
||||
*/
|
||||
foo: number,
|
||||
|
||||
bar: {
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
baz: number
|
||||
}
|
||||
|
||||
type: ThingType.InheritTags;
|
||||
}
|
||||
|
||||
export const inheritTagsTest: MapAggTestOptions = {
|
||||
name: ThingType.InheritTags,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.float
|
||||
},
|
||||
bar: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
56
test/mapping-model/mappings/src/inherited-property.ts
Normal file
56
test/mapping-model/mappings/src/inherited-property.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface InheritedProperty extends Bar{
|
||||
foo: number,
|
||||
|
||||
type: ThingType.InheritedProperty;
|
||||
}
|
||||
|
||||
interface Bar {
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
bar: string;
|
||||
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
baz: number;
|
||||
}
|
||||
|
||||
export const inheritedPropertyTest: MapAggTestOptions = {
|
||||
name: ThingType.InheritedProperty,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.integer
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
44
test/mapping-model/mappings/src/invalid-tag.ts
Normal file
44
test/mapping-model/mappings/src/invalid-tag.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface InvalidTag {
|
||||
/**
|
||||
* @anInvalidTag
|
||||
*/
|
||||
foo: string;
|
||||
|
||||
type: ThingType.InvalidTag;
|
||||
}
|
||||
|
||||
export const invalidTagTest: MapAggTestOptions = {
|
||||
name: ThingType.InvalidTag,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.InvalidTag}::foo" for tag "aninvalidtag": Not implemented tag`
|
||||
]
|
||||
};
|
||||
81
test/mapping-model/mappings/src/map-explicit-types.ts
Normal file
81
test/mapping-model/mappings/src/map-explicit-types.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface MapExplicitTypes {
|
||||
/**
|
||||
* @integer
|
||||
*/
|
||||
esInteger: number;
|
||||
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
esFloat: number;
|
||||
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
esKeyword: string;
|
||||
|
||||
/**
|
||||
* @text
|
||||
*/
|
||||
esText: string;
|
||||
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
esEpochMsDate: number
|
||||
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
esStringDate: string
|
||||
|
||||
type: ThingType.MapExplicitTypes;
|
||||
}
|
||||
|
||||
export const mapExplicitTypesTest: MapAggTestOptions = {
|
||||
name: ThingType.MapExplicitTypes,
|
||||
map: {
|
||||
maps: {
|
||||
esInteger: {
|
||||
type: ElasticsearchDataType.integer
|
||||
},
|
||||
esFloat: {
|
||||
type: ElasticsearchDataType.float
|
||||
},
|
||||
esKeyword: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
},
|
||||
esText: {
|
||||
type: ElasticsearchDataType.text
|
||||
},
|
||||
esEpochMsDate: {
|
||||
type: ElasticsearchDataType.date
|
||||
},
|
||||
esStringDate: {
|
||||
type: ElasticsearchDataType.date
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
44
test/mapping-model/mappings/src/missing-premap.ts
Normal file
44
test/mapping-model/mappings/src/missing-premap.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface MissingPremap {
|
||||
// it really doesn't matter what we use here, as long as it is an external dependency
|
||||
// if you get an error here because you removed a dependency, feel free to change it around
|
||||
// to your heart's content
|
||||
foo: HTMLAllCollection;
|
||||
|
||||
type: ThingType.MissingPremap;
|
||||
}
|
||||
|
||||
export const missingPremapTest: MapAggTestOptions = {
|
||||
name: ThingType.MissingPremap,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.missing_premap
|
||||
}
|
||||
}
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.MissingPremap}::foo" for external type "HTMLAllCollection": Missing pre-map`
|
||||
]
|
||||
};
|
||||
70
test/mapping-model/mappings/src/nested.ts
Normal file
70
test/mapping-model/mappings/src/nested.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface Nested {
|
||||
foo: {
|
||||
depth1_1: {
|
||||
depth2_1: {
|
||||
depth3_1: number;
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
depth3_2: string;
|
||||
}
|
||||
depth2_2: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
type: ThingType.Nested;
|
||||
}
|
||||
|
||||
export const nestedTest: MapAggTestOptions = {
|
||||
name: ThingType.Nested,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
depth1_1: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
depth2_1: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
depth3_1: {
|
||||
type: ElasticsearchDataType.integer
|
||||
},
|
||||
depth3_2: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
},
|
||||
depth2_2: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
63
test/mapping-model/mappings/src/object-union.ts
Normal file
63
test/mapping-model/mappings/src/object-union.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface ObjectUnion {
|
||||
foo: Boo | Buu;
|
||||
|
||||
type: ThingType.ObjectUnion
|
||||
}
|
||||
|
||||
// we can't name them Bar or Baz, look here for more info:
|
||||
// https://gitlab.com/openstapps/core-tools/-/issues/48
|
||||
// or here
|
||||
// https://github.com/TypeStrong/typedoc/issues/1373
|
||||
interface Boo {
|
||||
a: boolean;
|
||||
intersection: string;
|
||||
}
|
||||
|
||||
interface Buu {
|
||||
b: number;
|
||||
intersection: string;
|
||||
}
|
||||
|
||||
export const objectUnionTest: MapAggTestOptions = {
|
||||
name: ThingType.ObjectUnion,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
a: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
},
|
||||
b: {
|
||||
type: ElasticsearchDataType.integer
|
||||
},
|
||||
intersection: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
67
test/mapping-model/mappings/src/paired-tags.ts
Normal file
67
test/mapping-model/mappings/src/paired-tags.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface PairedTags {
|
||||
/**
|
||||
* @keyword
|
||||
* @filterable
|
||||
*/
|
||||
foo: string;
|
||||
|
||||
/**
|
||||
* @text
|
||||
* @filterable
|
||||
* @sortable
|
||||
*/
|
||||
bar: string;
|
||||
|
||||
type: ThingType.PairedTags;
|
||||
}
|
||||
|
||||
export const pairedTagsTest: MapAggTestOptions = {
|
||||
name: ThingType.PairedTags,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
},
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
58
test/mapping-model/mappings/src/sensible-defaults.ts
Normal file
58
test/mapping-model/mappings/src/sensible-defaults.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface SensibleDefaults {
|
||||
numberDefault: number;
|
||||
stringDefault: string;
|
||||
booleanDefault: boolean;
|
||||
stringLiteralDefault: 'Hey there!';
|
||||
booleanTrueLiteralDefault: true;
|
||||
booleanFalseLiteralDefault: false;
|
||||
|
||||
type: ThingType.SensibleDefaultType;
|
||||
}
|
||||
|
||||
export const sensibleDefaultsTest: MapAggTestOptions = {
|
||||
name: ThingType.SensibleDefaultType,
|
||||
map: {
|
||||
maps: {
|
||||
numberDefault: {
|
||||
type: ElasticsearchDataType.integer
|
||||
},
|
||||
stringDefault: {
|
||||
type: ElasticsearchDataType.text
|
||||
},
|
||||
booleanDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
},
|
||||
stringLiteralDefault: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
},
|
||||
booleanTrueLiteralDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
},
|
||||
booleanFalseLiteralDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
78
test/mapping-model/mappings/src/sortable-tag.ts
Normal file
78
test/mapping-model/mappings/src/sortable-tag.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface SortableTag {
|
||||
/**
|
||||
* @sortable
|
||||
*/
|
||||
foo: string;
|
||||
|
||||
/**
|
||||
* @sortable ducet
|
||||
*/
|
||||
bar: string;
|
||||
|
||||
/**
|
||||
* @sortable
|
||||
*/
|
||||
baz: number;
|
||||
|
||||
type: ThingType.SortableTag
|
||||
}
|
||||
|
||||
export const sortableTagTest: MapAggTestOptions = {
|
||||
name: ThingType.SortableTag,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text,
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text,
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.integer,
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
63
test/mapping-model/mappings/src/tags-ignore-case.ts
Normal file
63
test/mapping-model/mappings/src/tags-ignore-case.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface TagsIgnoreCase {
|
||||
/**
|
||||
* @inheritTags inherit tags::bar.baz
|
||||
*/
|
||||
camelCase: number,
|
||||
|
||||
/**
|
||||
* @inherittags inherit tags::bar.baz
|
||||
*/
|
||||
lowerCase: number,
|
||||
|
||||
bar: {
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
baz: number
|
||||
}
|
||||
|
||||
type: ThingType.TagsIgnoreCase;
|
||||
}
|
||||
|
||||
export const tagsIgnoreCaseTest: MapAggTestOptions = {
|
||||
name: ThingType.TagsIgnoreCase,
|
||||
map: {
|
||||
maps: {
|
||||
camelCase: {
|
||||
type: ElasticsearchDataType.float
|
||||
},
|
||||
lowerCase: {
|
||||
type: ElasticsearchDataType.float
|
||||
},
|
||||
bar: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
67
test/mapping-model/mappings/src/type-alias.ts
Normal file
67
test/mapping-model/mappings/src/type-alias.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface TypeAlias {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
textProperty: ATextAlias,
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
keywordProperty: AKeywordAlias,
|
||||
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
overriddenTextAsKeyword: ATextAlias
|
||||
|
||||
type: ThingType.TypeAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* @text
|
||||
*/
|
||||
type ATextAlias = string;
|
||||
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
type AKeywordAlias = string;
|
||||
|
||||
export const typeAliasTest: MapAggTestOptions = {
|
||||
name: ThingType.TypeAlias,
|
||||
map: {
|
||||
maps: {
|
||||
textProperty: {
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
keywordProperty: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
overriddenTextAsKeyword: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
42
test/mapping-model/mappings/src/type-overrides.ts
Normal file
42
test/mapping-model/mappings/src/type-overrides.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
export interface SCISO8601DateRange {
|
||||
bar: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface TypeOverrides {
|
||||
foo: SCISO8601DateRange;
|
||||
|
||||
type: ThingType.TypeOverrides
|
||||
}
|
||||
|
||||
export const typeOverridesTest: MapAggTestOptions = {
|
||||
name: ThingType.TypeOverrides,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.date_range,
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
44
test/mapping-model/mappings/src/type-query.ts
Normal file
44
test/mapping-model/mappings/src/type-query.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface TypeQuery {
|
||||
foo: typeof Bar;
|
||||
|
||||
type: ThingType.TypeQuery;
|
||||
}
|
||||
|
||||
enum Bar {
|
||||
'a',
|
||||
'b',
|
||||
'c'
|
||||
}
|
||||
|
||||
export const typeQueryTest: MapAggTestOptions = {
|
||||
name: ThingType.TypeQuery,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
66
test/mapping-model/mappings/src/type-wrapper-inheritance.ts
Normal file
66
test/mapping-model/mappings/src/type-wrapper-inheritance.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface TypeWrapperInheritance {
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
numberWrapper: NumberWrapper;
|
||||
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
stringWrapper: StringWrapper;
|
||||
|
||||
/**
|
||||
* @text
|
||||
*/
|
||||
stringLiteralWrapper: StringLiteralWrapper;
|
||||
|
||||
type: ThingType.TypeWrapperInheritance
|
||||
}
|
||||
|
||||
type NumberWrapper = number;
|
||||
type StringWrapper = string;
|
||||
type StringLiteralWrapper = 'foo';
|
||||
|
||||
export const typeWrapperInheritanceTest: MapAggTestOptions = {
|
||||
name: ThingType.TypeWrapperInheritance,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
numberWrapper: {
|
||||
type: ElasticsearchDataType.float
|
||||
},
|
||||
stringWrapper: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
},
|
||||
stringLiteralWrapper: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
42
test/mapping-model/mappings/src/types.ts
Normal file
42
test/mapping-model/mappings/src/types.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export enum ThingType {
|
||||
MapExplicitTypes = 'map explicit types',
|
||||
DoubleTypeConflict = 'double type conflict',
|
||||
IncompatibleType = 'incompatible type',
|
||||
SensibleDefaultType = 'sensible default',
|
||||
InvalidTag = 'invalid tag',
|
||||
MissingPremap = 'missing premap',
|
||||
DefaultGeneric = 'default generic',
|
||||
Generics = 'generics',
|
||||
Nested = 'nested',
|
||||
IndexSignature = 'index signature',
|
||||
ImpossibleUnion = 'impossible union',
|
||||
TypeQuery = 'type query',
|
||||
ObjectUnion = 'object union',
|
||||
TypeWrapperInheritance = 'type wrapper inheritance',
|
||||
SortableTag = 'sortable tag',
|
||||
Enum = 'enum',
|
||||
InheritedProperty = 'inherited property',
|
||||
PairedTags = 'paired tags',
|
||||
FilterableTag = 'filterable tag',
|
||||
AnyUnknown = 'any unknown',
|
||||
Date = 'date',
|
||||
InheritTags = 'inherit tags',
|
||||
TagsIgnoreCase = 'tags ignore case',
|
||||
TypeAlias = 'type alias',
|
||||
TypeOverrides = 'type overrides',
|
||||
}
|
||||
3
test/mapping-model/mappings/tsconfig.json
Normal file
3
test/mapping-model/mappings/tsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json"
|
||||
}
|
||||
Reference in New Issue
Block a user