mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 03:32:52 +00:00
refactor: mapping generation for `Elasticsearch 8.4
This commit is contained in:
committed by
Rainer Killinger
parent
08ec4e4381
commit
61fee2bbf3
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,7 +21,7 @@ export interface MapAggTestOptions {
|
||||
agg?: {
|
||||
fields?: string[];
|
||||
globals?: string[];
|
||||
}
|
||||
};
|
||||
map?: MinimalMappingDescription;
|
||||
err?: string[];
|
||||
ignoredTags?: string[];
|
||||
@@ -14,21 +14,23 @@
|
||||
*/
|
||||
import {ElasticsearchDataType} from '../../src/config/typemap';
|
||||
import {generateTemplate} from '../../src/mapping';
|
||||
import {resolve} from "path";
|
||||
import {expect} from "chai";
|
||||
import path 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 {MapAggTestOptions, MinimalMappingDescription} from './map-agg-test-options';
|
||||
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);
|
||||
constructor(directory: string) {
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.mapping_model_path = path.resolve(__dirname, directory);
|
||||
this.reflection = getProjectReflection(this.mapping_model_path);
|
||||
}
|
||||
|
||||
@@ -37,14 +39,18 @@ export class MapAggTest {
|
||||
|
||||
if (typeof options.err !== 'undefined') {
|
||||
for (const error of template.errors) {
|
||||
expect(options.err).to.include(error, "Unexpected Error!")
|
||||
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)
|
||||
const expectedAggSchema = MapAggTest.buildAggregation(
|
||||
options.name,
|
||||
options.agg.fields,
|
||||
options.agg.globals,
|
||||
);
|
||||
expect(template.aggregations).to.be.deep.equal(expectedAggSchema, 'Aggregation schema not equal!');
|
||||
}
|
||||
|
||||
@@ -59,8 +65,8 @@ export class MapAggTest {
|
||||
'@all': {
|
||||
aggs: {},
|
||||
filter: {
|
||||
match_all: {}
|
||||
}
|
||||
match_all: {},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -69,8 +75,8 @@ export class MapAggTest {
|
||||
terms: {
|
||||
field: `${global}.raw`,
|
||||
size: 1000,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof fields === 'undefined' || fields.length === 0) {
|
||||
@@ -80,19 +86,19 @@ export class MapAggTest {
|
||||
out[name] = {
|
||||
aggs: {},
|
||||
filter: {
|
||||
type: {
|
||||
value: name,
|
||||
}
|
||||
}
|
||||
}
|
||||
term: {
|
||||
type: name,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
for (const field of fields) {
|
||||
(out[name]! as ESNestedAggregation).aggs[field] = {
|
||||
terms: {
|
||||
field: `${field}.raw`,
|
||||
size: 1000,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return out;
|
||||
@@ -107,28 +113,30 @@ export class MapAggTest {
|
||||
const out: ElasticsearchTemplateCollection = {};
|
||||
const templateName = `template_${typeNameWithoutSpaces}`;
|
||||
out[templateName] = {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore empty object
|
||||
mappings: {},
|
||||
settings: settings,
|
||||
template: `stapps_${typeNameWithoutSpaces}*`,
|
||||
}
|
||||
index_patterns: [`stapps_${typeNameWithoutSpaces}*`],
|
||||
};
|
||||
const maps = map.maps ?? {};
|
||||
maps.type = {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
type: ElasticsearchDataType.text,
|
||||
};
|
||||
maps.creation_date = {
|
||||
type: ElasticsearchDataType.date
|
||||
}
|
||||
out[templateName].mappings[name] = {
|
||||
type: ElasticsearchDataType.date,
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore can be used to index
|
||||
out[templateName].mappings = {
|
||||
_source: {
|
||||
excludes: [
|
||||
'creation_date'
|
||||
]
|
||||
excludes: ['creation_date'],
|
||||
},
|
||||
date_detection: false,
|
||||
dynamic: 'strict',
|
||||
properties: maps,
|
||||
dynamic_templates: map.dynamicTemplates ?? [],
|
||||
}
|
||||
};
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -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: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
export type SCISO8601Date = string
|
||||
export type SCISO8601Date = string;
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -33,7 +33,7 @@ export interface DateAndRange {
|
||||
|
||||
dateAlias: SCISO8601Date;
|
||||
|
||||
type: ThingType.Date
|
||||
type: ThingType.Date;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -47,6 +47,6 @@ export const testConfig: MapAggTestOptions = {
|
||||
dateAlias: {
|
||||
type: ElasticsearchDataType.date,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -39,13 +39,11 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.parse_error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.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!`],
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
@@ -42,15 +42,15 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
stringDoubleTypeConflict: {
|
||||
type: ElasticsearchDataType.type_conflict
|
||||
type: ElasticsearchDataType.type_conflict,
|
||||
},
|
||||
numberDoubleTypeConflict: {
|
||||
type: ElasticsearchDataType.type_conflict
|
||||
}
|
||||
}
|
||||
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"`
|
||||
]
|
||||
`At "${ThingType.DoubleTypeConflict}::numberDoubleTypeConflict" for type "number": Type conflict; "integer" would override "float"`,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface Enum {
|
||||
foo: Bar,
|
||||
foo: Bar;
|
||||
|
||||
bar: Baz,
|
||||
bar: Baz;
|
||||
|
||||
type: ThingType.Enum;
|
||||
}
|
||||
@@ -36,6 +36,7 @@ enum Bar {
|
||||
|
||||
enum Baz {
|
||||
d = 'd',
|
||||
// eslint-disable-next-line unicorn/prevent-abbreviations
|
||||
e = 'e',
|
||||
f = 'f',
|
||||
}
|
||||
@@ -48,11 +49,11 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
export type FilterableEnumType = 'a' | 'b' | 'c';
|
||||
@@ -38,14 +38,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 = {
|
||||
@@ -57,34 +57,34 @@ export const testConfig: MapAggTestOptions = {
|
||||
type: ElasticsearchDataType.text,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
},
|
||||
buz: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -22,7 +22,7 @@ import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
*/
|
||||
export interface Generics {
|
||||
foo: InterfaceWithDefaultGeneric<number>;
|
||||
baz: InterfaceWithStringGeneric<string>
|
||||
baz: InterfaceWithStringGeneric<string>;
|
||||
|
||||
type: ThingType.Generics;
|
||||
}
|
||||
@@ -44,18 +44,18 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.integer
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
},
|
||||
},
|
||||
baz: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,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 +32,11 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.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`,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,6 @@ export interface DoubleTypeConflict {
|
||||
*/
|
||||
floatString: string;
|
||||
|
||||
|
||||
type: ThingType.IncompatibleType;
|
||||
}
|
||||
|
||||
@@ -51,23 +50,23 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
keywordNumber: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
textNumber: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
integerString: {
|
||||
type: ElasticsearchDataType.text
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
floatString: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
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`,
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -25,8 +25,8 @@ export interface IndexSignature {
|
||||
[key: string]: {
|
||||
bar: number;
|
||||
baz: string;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
type: ThingType.IndexSignature;
|
||||
}
|
||||
@@ -38,8 +38,8 @@ export const testConfig: MapAggTestOptions = {
|
||||
maps: {
|
||||
foo: {
|
||||
dynamic: true,
|
||||
properties: {}
|
||||
}
|
||||
properties: {},
|
||||
},
|
||||
},
|
||||
dynamicTemplates: [
|
||||
{
|
||||
@@ -48,18 +48,18 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
bar: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
},
|
||||
match: '*',
|
||||
match_mapping_type: '*',
|
||||
path_match: 'foo.*'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
path_match: 'foo.*',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ThingType} from './types';
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ export interface InferredTypeFilterable {
|
||||
*/
|
||||
bar: SCISO8601Date;
|
||||
|
||||
type: ThingType.InferredTypeFilterable
|
||||
type: ThingType.InferredTypeFilterable;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -49,12 +49,12 @@ export const testConfig: MapAggTestOptions = {
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.date,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ThingType} from './types';
|
||||
|
||||
/**
|
||||
@@ -24,14 +24,14 @@ export interface InheritTags {
|
||||
/**
|
||||
* @inheritTags inherit tags::bar.baz
|
||||
*/
|
||||
foo: number,
|
||||
foo: number;
|
||||
|
||||
bar: {
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
baz: number
|
||||
}
|
||||
baz: number;
|
||||
};
|
||||
|
||||
type: ThingType.InheritTags;
|
||||
}
|
||||
@@ -42,16 +42,16 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: ElasticsearchDataType.float,
|
||||
},
|
||||
bar: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.float,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface InheritedProperty extends Bar{
|
||||
foo: number,
|
||||
export interface InheritedProperty extends Bar {
|
||||
foo: number;
|
||||
|
||||
type: ThingType.InheritedProperty;
|
||||
}
|
||||
@@ -44,14 +44,14 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.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
|
||||
@@ -14,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -35,11 +36,9 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
},
|
||||
err: [
|
||||
`At "${ThingType.InvalidTag}::foo" for tag "aninvalidtag": Not implemented tag`
|
||||
]
|
||||
err: [`At "${ThingType.InvalidTag}::foo" for tag "aninvalidtag": Not implemented tag`],
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -44,12 +44,12 @@ export interface MapExplicitTypes {
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
esEpochMsDate: number
|
||||
esEpochMsDate: number;
|
||||
|
||||
/**
|
||||
* @date
|
||||
*/
|
||||
esStringDate: string
|
||||
esStringDate: string;
|
||||
|
||||
type: ThingType.MapExplicitTypes;
|
||||
}
|
||||
@@ -60,23 +60,23 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
esInteger: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
esFloat: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: ElasticsearchDataType.float,
|
||||
},
|
||||
esKeyword: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
esText: {
|
||||
type: ElasticsearchDataType.text
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
esEpochMsDate: {
|
||||
type: ElasticsearchDataType.date
|
||||
type: ElasticsearchDataType.date,
|
||||
},
|
||||
esStringDate: {
|
||||
type: ElasticsearchDataType.date
|
||||
type: ElasticsearchDataType.date,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -35,11 +35,9 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.missing_premap
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.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`],
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -29,10 +29,10 @@ export interface Nested {
|
||||
* @keyword
|
||||
*/
|
||||
depth3_2: string;
|
||||
}
|
||||
};
|
||||
depth2_2: boolean;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
type: ThingType.Nested;
|
||||
}
|
||||
@@ -52,20 +52,20 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
depth3_1: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
depth3_2: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
},
|
||||
depth2_2: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.boolean,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,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 +49,16 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
a: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
type: ElasticsearchDataType.boolean,
|
||||
},
|
||||
b: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
intersection: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -46,23 +46,24 @@ export const testConfig: MapAggTestOptions = {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text,
|
||||
fields: {
|
||||
raw: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation_keyword',
|
||||
variant: '@collation=phonebook',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -37,23 +37,23 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
numberDefault: {
|
||||
type: ElasticsearchDataType.integer
|
||||
type: ElasticsearchDataType.integer,
|
||||
},
|
||||
stringDefault: {
|
||||
type: ElasticsearchDataType.text
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
booleanDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
type: ElasticsearchDataType.boolean,
|
||||
},
|
||||
stringLiteralDefault: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
booleanTrueLiteralDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
type: ElasticsearchDataType.boolean,
|
||||
},
|
||||
booleanFalseLiteralDefault: {
|
||||
type: ElasticsearchDataType.boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.boolean,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ export interface SortableTag {
|
||||
*/
|
||||
baz: number;
|
||||
|
||||
type: ThingType.SortableTag
|
||||
type: ThingType.SortableTag;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -48,32 +48,35 @@ export const testConfig: MapAggTestOptions = {
|
||||
type: ElasticsearchDataType.text,
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation_keyword',
|
||||
variant: '@collation=phonebook',
|
||||
},
|
||||
},
|
||||
},
|
||||
bar: {
|
||||
type: ElasticsearchDataType.text,
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation_keyword',
|
||||
variant: '@collation=phonebook',
|
||||
},
|
||||
},
|
||||
},
|
||||
baz: {
|
||||
type: ElasticsearchDataType.integer,
|
||||
fields: {
|
||||
sort: {
|
||||
analyzer: 'ducet_sort',
|
||||
fielddata: true,
|
||||
type: 'text'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
country: 'DE',
|
||||
language: 'de',
|
||||
type: 'icu_collation_keyword',
|
||||
variant: '@collation=phonebook',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -23,19 +23,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 +46,19 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
camelCase: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: ElasticsearchDataType.float,
|
||||
},
|
||||
lowerCase: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: ElasticsearchDataType.float,
|
||||
},
|
||||
bar: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.float,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -24,17 +24,17 @@ export interface TypeAlias {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
textProperty: ATextAlias,
|
||||
textProperty: ATextAlias;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
keywordProperty: AKeywordAlias,
|
||||
keywordProperty: AKeywordAlias;
|
||||
|
||||
/**
|
||||
* @keyword
|
||||
*/
|
||||
overriddenTextAsKeyword: ATextAlias
|
||||
overriddenTextAsKeyword: ATextAlias;
|
||||
|
||||
type: ThingType.TypeAlias;
|
||||
}
|
||||
@@ -63,6 +63,6 @@ export const testConfig: MapAggTestOptions = {
|
||||
overriddenTextAsKeyword: {
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
export interface SCISO8601DateRange {
|
||||
@@ -27,7 +27,7 @@ export interface SCISO8601DateRange {
|
||||
export interface TypeOverrides {
|
||||
foo: SCISO8601DateRange;
|
||||
|
||||
type: ThingType.TypeOverrides
|
||||
type: ThingType.TypeOverrides;
|
||||
}
|
||||
|
||||
export const testConfig: MapAggTestOptions = {
|
||||
@@ -38,6 +38,6 @@ export const testConfig: MapAggTestOptions = {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.date_range,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ export interface TypeQuery {
|
||||
enum Bar {
|
||||
'a',
|
||||
'b',
|
||||
'c'
|
||||
'c',
|
||||
}
|
||||
|
||||
// https://gitlab.com/openstapps/core-tools/-/issues/47
|
||||
@@ -39,8 +39,8 @@ export const testConfig: MapAggTestOptions = {
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ export interface TypeWrapperInheritance {
|
||||
*/
|
||||
stringLiteralWrapper: StringLiteralWrapper;
|
||||
|
||||
type: ThingType.TypeWrapperInheritance
|
||||
type: ThingType.TypeWrapperInheritance;
|
||||
}
|
||||
|
||||
type NumberWrapper = number;
|
||||
@@ -53,16 +53,16 @@ export const testConfig: MapAggTestOptions = {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
numberWrapper: {
|
||||
type: ElasticsearchDataType.float
|
||||
type: ElasticsearchDataType.float,
|
||||
},
|
||||
stringWrapper: {
|
||||
type: ElasticsearchDataType.keyword
|
||||
type: ElasticsearchDataType.keyword,
|
||||
},
|
||||
stringLiteralWrapper: {
|
||||
type: ElasticsearchDataType.text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
type: ElasticsearchDataType.text,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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