Resolve "Retype mapping generation using @elastic/elasticsearch"

This commit is contained in:
Thea Schöbl
2023-04-28 11:15:08 +00:00
committed by Rainer Killinger
parent fc850fe7ac
commit d90416e201
42 changed files with 441 additions and 596 deletions

View File

@@ -1,3 +1,6 @@
{
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json"
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
}
}

View File

@@ -12,8 +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 {ElasticsearchDynamicTemplate, ElasticsearchValue} from '../../src/types/mapping';
import {MappingDynamicTemplate, MappingProperty} from '@elastic/elasticsearch/lib/api/types';
export interface MapAggTestOptions {
testName: string;
@@ -29,7 +28,7 @@ export interface MapAggTestOptions {
export interface MinimalMappingDescription {
maps?: {
[name: string]: ElasticsearchValue;
[name: string]: MappingProperty;
};
dynamicTemplates?: ElasticsearchDynamicTemplate[];
dynamicTemplates?: Record<string, MappingDynamicTemplate>[];
}

View File

@@ -12,7 +12,6 @@
* 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 path from 'path';
import {expect} from 'chai';
@@ -121,10 +120,10 @@ export class MapAggTest {
};
const maps = map.maps ?? {};
maps.type = {
type: ElasticsearchDataType.text,
type: 'text',
};
maps.creation_date = {
type: ElasticsearchDataType.date,
type: 'date',
};
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore can be used to index

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @date
@@ -42,10 +40,10 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
directDate: {
type: ElasticsearchDataType.date,
type: 'date',
},
dateAlias: {
type: ElasticsearchDataType.date,
type: 'date',
},
},
},

View File

@@ -12,8 +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 {PARSE_ERROR} from '../../../../lib/config/typemap';
import {ThingType} from './types';
import {MapAggTestOptions} from '../../map-agg-test-options';
@@ -39,7 +38,7 @@ export const testConfig: MapAggTestOptions = {
dynamic: 'strict',
properties: {
bar: {
type: ElasticsearchDataType.parse_error,
type: PARSE_ERROR,
},
},
},

View File

@@ -12,8 +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 {TYPE_CONFLICT} from '../../../../lib/config/typemap';
import {ThingType} from './types';
import {MapAggTestOptions} from '../../map-agg-test-options';
@@ -42,10 +41,10 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
stringDoubleTypeConflict: {
type: ElasticsearchDataType.type_conflict,
type: TYPE_CONFLICT,
},
numberDoubleTypeConflict: {
type: ElasticsearchDataType.type_conflict,
type: TYPE_CONFLICT,
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -49,10 +47,10 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.text,
type: 'text',
},
bar: {
type: ElasticsearchDataType.text,
type: 'text',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
export type FilterableEnumType = 'a' | 'b' | 'c';
@@ -54,34 +52,34 @@ 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',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -44,7 +42,7 @@ export const testConfig: MapAggTestOptions = {
dynamic: 'strict',
properties: {
bar: {
type: ElasticsearchDataType.integer,
type: 'integer',
},
},
},
@@ -52,7 +50,7 @@ export const testConfig: MapAggTestOptions = {
dynamic: 'strict',
properties: {
bar: {
type: ElasticsearchDataType.text,
type: 'text',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -32,7 +30,7 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.boolean,
type: 'boolean',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -50,16 +48,16 @@ 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',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -48,10 +46,10 @@ export const testConfig: MapAggTestOptions = {
dynamic: 'strict',
properties: {
bar: {
type: ElasticsearchDataType.integer,
type: 'integer',
},
baz: {
type: ElasticsearchDataType.text,
type: 'text',
},
},
},

View File

@@ -12,8 +12,6 @@
* 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 '../../map-agg-test-options';
import {ThingType} from './types';
@@ -45,15 +43,15 @@ 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',
},
},
},

View File

@@ -12,8 +12,6 @@
* 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 '../../map-agg-test-options';
import {ThingType} from './types';
@@ -42,13 +40,13 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.float,
type: 'float',
},
bar: {
dynamic: 'strict',
properties: {
baz: {
type: ElasticsearchDataType.float,
type: 'float',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -44,13 +42,13 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.integer,
type: 'integer',
},
bar: {
type: ElasticsearchDataType.keyword,
type: 'keyword',
},
baz: {
type: ElasticsearchDataType.float,
type: 'float',
},
},
},

View File

@@ -13,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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -36,7 +34,7 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.text,
type: 'text',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -60,22 +58,22 @@ 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',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -35,7 +34,7 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.missing_premap,
type: MISSING_PREMAP,
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -52,15 +50,15 @@ 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',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -49,13 +47,13 @@ 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',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -43,25 +41,26 @@ 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: {
country: 'DE',
language: 'de',
type: 'icu_collation_keyword',
variant: '@collation=phonebook',
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -37,22 +35,22 @@ 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',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -45,36 +43,39 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.text,
type: 'text',
fields: {
sort: {
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: {
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: {
country: 'DE',
language: 'de',
type: 'icu_collation_keyword',
variant: '@collation=phonebook',
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
},
},
},

View File

@@ -14,7 +14,6 @@
*/
import {ThingType} from './types';
import {MapAggTestOptions} from '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -46,16 +45,16 @@ 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',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -55,13 +53,13 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
textProperty: {
type: ElasticsearchDataType.text,
type: 'text',
},
keywordProperty: {
type: ElasticsearchDataType.keyword,
type: 'keyword',
},
overriddenTextAsKeyword: {
type: ElasticsearchDataType.keyword,
type: 'keyword',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
export interface SCISO8601DateRange {
bar: string;
@@ -36,7 +34,7 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.date_range,
type: 'date_range',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -39,7 +37,7 @@ export const testConfig: MapAggTestOptions = {
map: {
maps: {
foo: {
type: ElasticsearchDataType.text,
type: 'text',
},
},
},

View File

@@ -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 '../../map-agg-test-options';
import {ElasticsearchDataType} from '../../../../src/config/typemap';
/**
* @indexable
@@ -53,13 +51,13 @@ 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',
},
},
},

View File

@@ -1,3 +1,6 @@
{
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json"
"extends": "../../../node_modules/@openstapps/configuration/tsconfig.json",
"compilerOptions": {
"skipLibCheck": true
}
}