mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
Merge remote-tracking branch 'es-mapping-generator/master'
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable unicorn/consistent-function-scoping */
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -15,8 +16,8 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {readdirSync, statSync} from 'fs';
|
||||
import path from 'path';
|
||||
import {MapAggTest} from './mapping-model/MapAggTest';
|
||||
import {MapAggTestOptions} from './mapping-model/MapAggTestOptions';
|
||||
import {MapAggTest} from './mapping-model/map-agg-test';
|
||||
import {MapAggTestOptions} from './mapping-model/map-agg-test-options';
|
||||
|
||||
describe('ES Aggregation Gen', async () => {
|
||||
const magAppInstance = new MapAggTest('aggregations');
|
||||
@@ -29,14 +30,20 @@ describe('ES Aggregation Gen', async () => {
|
||||
const directory = statSync(fullPath);
|
||||
|
||||
return directory.isDirectory()
|
||||
? ([] as string[]).concat(...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
))
|
||||
? // eslint-disable-next-line unicorn/prefer-spread
|
||||
([] as string[]).concat(
|
||||
...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
),
|
||||
)
|
||||
: [fullPath].filter(accept);
|
||||
}
|
||||
|
||||
for (const file of expandPathToFilesSync('./test/mapping-model/aggregations/', file => file.endsWith('agg-test.ts'))) {
|
||||
for (const file of expandPathToFilesSync('./test/mapping-model/aggregations/', file =>
|
||||
file.endsWith('agg-test.ts'),
|
||||
)) {
|
||||
try {
|
||||
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||
|
||||
it(test.testName, function () {
|
||||
@@ -47,4 +54,6 @@ describe('ES Aggregation Gen', async () => {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}).timeout(20_000).slow(10_000);
|
||||
})
|
||||
.timeout(20_000)
|
||||
.slow(10_000);
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* 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/config/typemap';
|
||||
import {generateTemplate} from '../../src/mapping';
|
||||
import {resolve} from "path";
|
||||
import {expect} from "chai";
|
||||
import {ProjectReflection} from 'typedoc';
|
||||
import {getProjectReflection} from '../../src/project-reflection';
|
||||
import {AggregationSchema, ESNestedAggregation} from '../../src/types/aggregation';
|
||||
import {ElasticsearchTemplateCollection} from '../../src/types/mapping';
|
||||
import {MapAggTestOptions, MinimalMappingDescription} from './MapAggTestOptions';
|
||||
import {settings} from '../../src/config/settings';
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* 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/types/mapping';
|
||||
|
||||
export interface MapAggTestOptions {
|
||||
testName: string;
|
||||
name: string;
|
||||
agg?: {
|
||||
fields?: string[];
|
||||
globals?: string[];
|
||||
}
|
||||
map?: MinimalMappingDescription;
|
||||
err?: string[];
|
||||
ignoredTags?: string[];
|
||||
}
|
||||
|
||||
export interface MinimalMappingDescription {
|
||||
maps?: {
|
||||
[name: string]: ElasticsearchValue;
|
||||
};
|
||||
dynamicTemplates?: ElasticsearchDynamicTemplate[];
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -23,7 +23,6 @@ export interface AggInheritedGlobal extends Foo {
|
||||
type: ThingType.AggInheritedGlobal;
|
||||
}
|
||||
|
||||
|
||||
interface Foo {
|
||||
/**
|
||||
* @aggregatable global
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -28,7 +28,6 @@ export interface AggInherited extends Foo {
|
||||
type: ThingType.AggInheritedOverwritten;
|
||||
}
|
||||
|
||||
|
||||
interface Foo {
|
||||
/**
|
||||
* @aggregatable
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -23,7 +23,6 @@ export interface AggInherited extends Foo {
|
||||
type: ThingType.AggInherited;
|
||||
}
|
||||
|
||||
|
||||
interface Foo {
|
||||
/**
|
||||
* @aggregatable
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json"
|
||||
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,17 +14,18 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface AnyUnknown {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
foo: any;
|
||||
|
||||
bar: unknown;
|
||||
|
||||
type: ThingType.AnyUnknown
|
||||
type: ThingType.AnyUnknown;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -34,12 +35,12 @@ export const testConfig: MapAggTestOptions = {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: true,
|
||||
properties: {}
|
||||
properties: {},
|
||||
},
|
||||
bar: {
|
||||
dynamic: true,
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
properties: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,15 +12,13 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
export type SCISO8601Date = string
|
||||
export type SCISO8601Date = string;
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -33,7 +31,7 @@ export interface DateAndRange {
|
||||
|
||||
dateAlias: SCISO8601Date;
|
||||
|
||||
type: ThingType.Date
|
||||
type: ThingType.Date;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -42,11 +40,11 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
directDate: {
|
||||
type: ElasticsearchDataType.date,
|
||||
type: 'date',
|
||||
},
|
||||
dateAlias: {
|
||||
type: ElasticsearchDataType.date,
|
||||
type: 'date',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
* 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/config/typemap';
|
||||
import {PARSE_ERROR} from '../../../../lib/config/typemap';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -39,13 +38,11 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.parse_error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: PARSE_ERROR,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.DefaultGeneric}::foo.bar" for Generic "T": Missing reflection, please report!`
|
||||
]
|
||||
err: [`At "${ThingType.DefaultGeneric}::foo.bar" for Generic "T": Missing reflection, please report!`],
|
||||
};
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
* 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/config/typemap';
|
||||
import {TYPE_CONFLICT} from '../../../../lib/config/typemap';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -42,15 +41,15 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
stringDoubleTypeConflict: {
|
||||
type: ElasticsearchDataType.type_conflict
|
||||
type: TYPE_CONFLICT,
|
||||
},
|
||||
numberDoubleTypeConflict: {
|
||||
type: ElasticsearchDataType.type_conflict
|
||||
}
|
||||
}
|
||||
type: 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"`
|
||||
]
|
||||
`At "${ThingType.DoubleTypeConflict}::numberDoubleTypeConflict" for type "number": Type conflict; "integer" would override "float"`,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -12,18 +12,16 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface Enum {
|
||||
foo: Bar,
|
||||
foo: Bar;
|
||||
|
||||
bar: Baz,
|
||||
bar: Baz;
|
||||
|
||||
type: ThingType.Enum;
|
||||
}
|
||||
@@ -36,6 +34,7 @@ enum Bar {
|
||||
|
||||
enum Baz {
|
||||
d = 'd',
|
||||
// eslint-disable-next-line unicorn/prevent-abbreviations
|
||||
e = 'e',
|
||||
f = 'f',
|
||||
}
|
||||
@@ -48,11 +47,11 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
type: 'text',
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
export type FilterableEnumType = 'a' | 'b' | 'c';
|
||||
|
||||
@@ -38,14 +36,14 @@ export interface FilterableTag {
|
||||
/**
|
||||
* @filterable
|
||||
*/
|
||||
baz: 'some literal'
|
||||
baz: 'some literal';
|
||||
|
||||
/**
|
||||
* @filterable
|
||||
*/
|
||||
buz: FilterableEnumType
|
||||
buz: FilterableEnumType;
|
||||
|
||||
type: ThingType.FilterableTag
|
||||
type: ThingType.FilterableTag;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -54,37 +52,37 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text,
|
||||
type: 'text',
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
type: 'keyword',
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
type: 'keyword',
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
buz: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
type: 'keyword',
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,17 +12,15 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface Generics {
|
||||
foo: InterfaceWithDefaultGeneric<number>;
|
||||
baz: InterfaceWithStringGeneric<string>
|
||||
baz: InterfaceWithStringGeneric<string>;
|
||||
|
||||
type: ThingType.Generics;
|
||||
}
|
||||
@@ -44,18 +42,18 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.integer
|
||||
}
|
||||
}
|
||||
type: 'integer',
|
||||
},
|
||||
},
|
||||
},
|
||||
baz: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -23,7 +21,7 @@ import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
export interface ImpossibleUnion {
|
||||
foo: 'a' | 1 | boolean;
|
||||
|
||||
type: ThingType.ImpossibleUnion
|
||||
type: ThingType.ImpossibleUnion;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -32,11 +30,11 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.ImpossibleUnion}::foo" for type "[{"type":"1","name":"2"},"unknown","1"]": Not implemented type`
|
||||
]
|
||||
`At "${ThingType.ImpossibleUnion}::foo" for type "[{"type":"1","name":"2"},"unknown","1"]": Not implemented type`,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -41,7 +39,6 @@ export interface DoubleTypeConflict {
|
||||
*/
|
||||
floatString: string;
|
||||
|
||||
|
||||
type: ThingType.IncompatibleType;
|
||||
}
|
||||
|
||||
@@ -51,23 +48,23 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
keywordNumber: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: 'integer',
|
||||
},
|
||||
textNumber: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: 'integer',
|
||||
},
|
||||
integerString: {
|
||||
type: ElasticsearchDataType.text
|
||||
type: 'text',
|
||||
},
|
||||
floatString: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
type: '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`,
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -25,8 +23,8 @@ export interface IndexSignature {
|
||||
[key: string]: {
|
||||
bar: number;
|
||||
baz: string;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
type: ThingType.IndexSignature;
|
||||
}
|
||||
@@ -38,8 +36,8 @@ export const testConfig: MapAggTestOptions = {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: true,
|
||||
properties: {}
|
||||
}
|
||||
properties: {},
|
||||
},
|
||||
},
|
||||
dynamicTemplates: [
|
||||
{
|
||||
@@ -48,18 +46,18 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: 'integer',
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
match: '*',
|
||||
match_mapping_type: '*',
|
||||
path_match: 'foo.*'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
path_match: 'foo.*',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
* 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/config/typemap';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ThingType} from './types';
|
||||
|
||||
/**
|
||||
@@ -36,7 +34,7 @@ export interface InferredTypeFilterable {
|
||||
*/
|
||||
bar: SCISO8601Date;
|
||||
|
||||
type: ThingType.InferredTypeFilterable
|
||||
type: ThingType.InferredTypeFilterable;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -45,16 +43,16 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.date,
|
||||
type: 'date',
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
}
|
||||
}
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.date,
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'date',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
* 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/config/typemap';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ThingType} from './types';
|
||||
|
||||
/**
|
||||
@@ -24,14 +22,14 @@ export interface InheritTags {
|
||||
/**
|
||||
* @inheritTags inherit tags::bar.baz
|
||||
*/
|
||||
foo: number,
|
||||
foo: number;
|
||||
|
||||
bar: {
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
baz: number
|
||||
}
|
||||
baz: number;
|
||||
};
|
||||
|
||||
type: ThingType.InheritTags;
|
||||
}
|
||||
@@ -42,16 +40,16 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: 'float',
|
||||
},
|
||||
bar: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
type: 'float',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,16 +12,14 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface InheritedProperty extends Bar{
|
||||
foo: number,
|
||||
export interface InheritedProperty extends Bar {
|
||||
foo: number;
|
||||
|
||||
type: ThingType.InheritedProperty;
|
||||
}
|
||||
@@ -44,14 +42,14 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: 'integer',
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: 'keyword',
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'float',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable jsdoc/check-tag-names */
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -12,10 +13,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -35,11 +34,9 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.InvalidTag}::foo" for tag "aninvalidtag": Not implemented tag`
|
||||
]
|
||||
err: [`At "${ThingType.InvalidTag}::foo" for tag "aninvalidtag": Not implemented tag`],
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -44,12 +42,12 @@ export interface MapExplicitTypes {
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
esEpochMsDate: number
|
||||
esEpochMsDate: number;
|
||||
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
esStringDate: string
|
||||
esStringDate: string;
|
||||
|
||||
type: ThingType.MapExplicitTypes;
|
||||
}
|
||||
@@ -60,23 +58,23 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
esInteger: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: 'integer',
|
||||
},
|
||||
esFloat: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: 'float',
|
||||
},
|
||||
esKeyword: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: 'keyword',
|
||||
},
|
||||
esText: {
|
||||
type: ElasticsearchDataType.text
|
||||
type: 'text',
|
||||
},
|
||||
esEpochMsDate: {
|
||||
type: ElasticsearchDataType.date
|
||||
type: 'date',
|
||||
},
|
||||
esStringDate: {
|
||||
type: ElasticsearchDataType.date
|
||||
type: 'date',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
* 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 {MISSING_PREMAP} from '../../../../lib/config/typemap';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -35,11 +34,9 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.missing_premap
|
||||
}
|
||||
}
|
||||
type: MISSING_PREMAP,
|
||||
},
|
||||
},
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.MissingPremap}::foo" for external type "HTMLAllCollection": Missing pre-map`
|
||||
]
|
||||
err: [`At "${ThingType.MissingPremap}::foo" for external type "HTMLAllCollection": Missing pre-map`],
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -29,10 +27,10 @@ export interface Nested {
|
||||
* @keyword
|
||||
*/
|
||||
depth3_2: string;
|
||||
}
|
||||
};
|
||||
depth2_2: boolean;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
type: ThingType.Nested;
|
||||
}
|
||||
@@ -52,20 +50,20 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
depth3_1: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: 'integer',
|
||||
},
|
||||
depth3_2: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
depth2_2: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -23,7 +21,7 @@ import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
export interface ObjectUnion {
|
||||
foo: Boo | Buu;
|
||||
|
||||
type: ThingType.ObjectUnion
|
||||
type: ThingType.ObjectUnion;
|
||||
}
|
||||
|
||||
// we can't name them Bar or Baz, look here for more info:
|
||||
@@ -49,16 +47,16 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
a: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
type: 'boolean',
|
||||
},
|
||||
b: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: 'integer',
|
||||
},
|
||||
intersection: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -43,26 +41,28 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
type: 'keyword',
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: 'keyword',
|
||||
},
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text,
|
||||
type: 'text',
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: 'keyword',
|
||||
},
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation_keyword',
|
||||
variant: '@collation=phonebook',
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -37,23 +35,23 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
numberDefault: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: 'integer',
|
||||
},
|
||||
stringDefault: {
|
||||
type: ElasticsearchDataType.text
|
||||
type: 'text',
|
||||
},
|
||||
booleanDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
type: 'boolean',
|
||||
},
|
||||
stringLiteralDefault: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: 'keyword',
|
||||
},
|
||||
booleanTrueLiteralDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
type: 'boolean',
|
||||
},
|
||||
booleanFalseLiteralDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -36,7 +34,7 @@ export interface SortableTag {
|
||||
*/
|
||||
baz: number;
|
||||
|
||||
type: ThingType.SortableTag
|
||||
type: ThingType.SortableTag;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -45,35 +43,41 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text,
|
||||
type: 'text',
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation_keyword',
|
||||
variant: '@collation=phonebook',
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any,
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text,
|
||||
type: 'text',
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation_keyword',
|
||||
variant: '@collation=phonebook',
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any,
|
||||
},
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.integer,
|
||||
type: 'integer',
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation_keyword',
|
||||
variant: '@collation=phonebook',
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -23,19 +22,19 @@ export interface TagsIgnoreCase {
|
||||
/**
|
||||
* @inheritTags inherit tags::bar.baz
|
||||
*/
|
||||
camelCase: number,
|
||||
camelCase: number;
|
||||
|
||||
/**
|
||||
* @inherittags inherit tags::bar.baz
|
||||
* @inheritTags inherit tags::bar.baz
|
||||
*/
|
||||
lowerCase: number,
|
||||
lowerCase: number;
|
||||
|
||||
bar: {
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
baz: number
|
||||
}
|
||||
baz: number;
|
||||
};
|
||||
|
||||
type: ThingType.TagsIgnoreCase;
|
||||
}
|
||||
@@ -46,19 +45,19 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
camelCase: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: 'float',
|
||||
},
|
||||
lowerCase: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: 'float',
|
||||
},
|
||||
bar: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
type: 'float',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -24,17 +22,17 @@ export interface TypeAlias {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
textProperty: ATextAlias,
|
||||
textProperty: ATextAlias;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
keywordProperty: AKeywordAlias,
|
||||
keywordProperty: AKeywordAlias;
|
||||
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
overriddenTextAsKeyword: ATextAlias
|
||||
overriddenTextAsKeyword: ATextAlias;
|
||||
|
||||
type: ThingType.TypeAlias;
|
||||
}
|
||||
@@ -55,14 +53,14 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
textProperty: {
|
||||
type: ElasticsearchDataType.text,
|
||||
type: 'text',
|
||||
},
|
||||
keywordProperty: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
type: 'keyword',
|
||||
},
|
||||
overriddenTextAsKeyword: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
type: 'keyword',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
export interface SCISO8601DateRange {
|
||||
bar: string;
|
||||
@@ -27,7 +25,7 @@ export interface SCISO8601DateRange {
|
||||
export interface TypeOverrides {
|
||||
foo: SCISO8601DateRange;
|
||||
|
||||
type: ThingType.TypeOverrides
|
||||
type: ThingType.TypeOverrides;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -36,8 +34,8 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.date_range,
|
||||
type: 'date_range',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -29,7 +27,7 @@ export interface TypeQuery {
|
||||
enum Bar {
|
||||
'a',
|
||||
'b',
|
||||
'c'
|
||||
'c',
|
||||
}
|
||||
|
||||
// https://gitlab.com/openstapps/core-tools/-/issues/47
|
||||
@@ -39,8 +37,8 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -36,7 +34,7 @@ export interface TypeWrapperInheritance {
|
||||
*/
|
||||
stringLiteralWrapper: StringLiteralWrapper;
|
||||
|
||||
type: ThingType.TypeWrapperInheritance
|
||||
type: ThingType.TypeWrapperInheritance;
|
||||
}
|
||||
|
||||
type NumberWrapper = number;
|
||||
@@ -53,16 +51,16 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
numberWrapper: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: 'float',
|
||||
},
|
||||
stringWrapper: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: 'keyword',
|
||||
},
|
||||
stringLiteralWrapper: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json"
|
||||
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {readdirSync, statSync} from 'fs';
|
||||
import path from 'path';
|
||||
import {MapAggTest} from './mapping-model/MapAggTest';
|
||||
import {MapAggTestOptions} from './mapping-model/MapAggTestOptions';
|
||||
import {MapAggTest} from './mapping-model/map-agg-test';
|
||||
import {MapAggTestOptions} from './mapping-model/map-agg-test-options';
|
||||
|
||||
describe('ES Mapping Gen', async () => {
|
||||
const magAppInstance = new MapAggTest('mappings');
|
||||
@@ -24,27 +24,36 @@ describe('ES Mapping Gen', async () => {
|
||||
/**
|
||||
* Expand a path to a list of all files deeply contained in it
|
||||
*/
|
||||
// eslint-disable-next-line unicorn/consistent-function-scoping
|
||||
function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
|
||||
const fullPath = path.resolve(sourcePath);
|
||||
const directory = statSync(fullPath);
|
||||
|
||||
return directory.isDirectory()
|
||||
? ([] as string[]).concat(...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
))
|
||||
? // eslint-disable-next-line unicorn/prefer-spread
|
||||
([] as string[]).concat(
|
||||
...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
),
|
||||
)
|
||||
: [fullPath].filter(accept);
|
||||
}
|
||||
|
||||
for (const file of expandPathToFilesSync('./test/mapping-model/mappings/', file => file.endsWith('mapping-test.ts'))) {
|
||||
for (const file of expandPathToFilesSync('./test/mapping-model/mappings/', file =>
|
||||
file.endsWith('mapping-test.ts'),
|
||||
)) {
|
||||
try {
|
||||
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||
|
||||
it(test.testName, function () {
|
||||
magAppInstance.testInterfaceAgainstPath(test)
|
||||
})
|
||||
magAppInstance.testInterfaceAgainstPath(test);
|
||||
});
|
||||
} catch (error) {
|
||||
await Logger.error('UNHANDLED REJECTION', error.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}).timeout(20_000).slow(10_000);
|
||||
})
|
||||
.timeout(20_000)
|
||||
.slow(10_000);
|
||||
|
||||
Reference in New Issue
Block a user