mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-06 05:22:52 +00:00
feat: add support for non-external premaps
This commit is contained in:
committed by
Jovan Krunić
parent
89bbb4ecf5
commit
74298065e0
@@ -457,7 +457,7 @@ function handleType(type: Type, generics: Map<string, ElasticsearchValue>, path:
|
||||
return handleUnionType(type, new Map(generics), path, topTypeName, tags);
|
||||
}
|
||||
if (type instanceof ReferenceType) {
|
||||
if (typeof type.reflection !== 'undefined') {
|
||||
if (typeof premaps[type.name] === 'undefined' && typeof type.reflection !== 'undefined') {
|
||||
// there is really no way to make this typesafe, every element in DeclarationReflection is optional.
|
||||
return handleDeclarationReflection(type.reflection as DeclarationReflection,
|
||||
getReflectionGeneric(type, new Map(generics), path, topTypeName, tags), path, topTypeName, tags);
|
||||
|
||||
@@ -32,7 +32,7 @@ export enum ElasticsearchDataType {
|
||||
geo_point = 'geo_point',
|
||||
geo_shape = 'geo_shape',
|
||||
completion = 'completion',
|
||||
date_range = 'date_rage',
|
||||
date_range = 'date_range',
|
||||
// integer_range = 'integer_range',
|
||||
// float_range = 'float_range',
|
||||
// long_range = 'long_range',
|
||||
|
||||
42
test/mapping-model/mappings/src/type-overrides.ts
Normal file
42
test/mapping-model/mappings/src/type-overrides.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
export interface SCISO8601DateRange {
|
||||
bar: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface TypeOverrides {
|
||||
foo: SCISO8601DateRange;
|
||||
|
||||
type: ThingType.TypeOverrides
|
||||
}
|
||||
|
||||
export const typeOverridesTest: MapAggTestOptions = {
|
||||
name: ThingType.TypeOverrides,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.date_range,
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* Copyright (C) 2020-2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -38,4 +38,5 @@ export enum ThingType {
|
||||
InheritTags = 'inherit tags',
|
||||
TagsIgnoreCase = 'tags ignore case',
|
||||
TypeAlias = 'type alias',
|
||||
TypeOverrides = 'type overrides',
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* Copyright (C) 2020-2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -37,6 +37,7 @@ import {anyUnknownTest} from './mapping-model/mappings/src/any-unknown';
|
||||
import {tagsIgnoreCaseTest} from './mapping-model/mappings/src/tags-ignore-case';
|
||||
import {typeAliasTest} from './mapping-model/mappings/src/type-alias';
|
||||
import {dateAndRangeTest} from './mapping-model/mappings/src/date';
|
||||
import {typeOverridesTest} from './mapping-model/mappings/src/type-overrides';
|
||||
|
||||
process.on('unhandledRejection', (error: unknown) => {
|
||||
if (error instanceof Error) {
|
||||
@@ -174,4 +175,9 @@ export class MappingSpec {
|
||||
async 'Dates and date ranges should have the correct type'() {
|
||||
magAppInstance.testInterfaceAgainstPath(dateAndRangeTest);
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Premaps should support non-external types'() {
|
||||
magAppInstance.testInterfaceAgainstPath(typeOverridesTest);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user