Merge branch '15-filter-tags-override-inherited-type-tags' into 'master'

Resolve "Filter tags override inherited type tags"

Closes #15

See merge request openstapps/es-mapping-generator!4
This commit is contained in:
Wieland Schöbl
2021-09-28 12:49:03 +00:00
41 changed files with 218 additions and 257 deletions

24
package-lock.json generated
View File

@@ -274,9 +274,9 @@
"dev": true
},
"@types/mocha": {
"version": "8.2.3",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz",
"integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==",
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.0.0.tgz",
"integrity": "sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA==",
"dev": true
},
"@types/node": {
@@ -355,15 +355,15 @@
}
},
"acorn": {
"version": "8.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.4.1.tgz",
"integrity": "sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA==",
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz",
"integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==",
"dev": true
},
"acorn-walk": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.1.1.tgz",
"integrity": "sha512-FbJdceMlPHEAWJOILDk1fXD8lnTlEIWFkqtfk+MvmL5q/qlHfN7GEHcsFZWt/Tea9jRNPWUZG4G976nqAAmU9w==",
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"dev": true
},
"add-stream": {
@@ -1850,9 +1850,9 @@
}
},
"mocha": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.3.tgz",
"integrity": "sha512-hnYFrSefHxYS2XFGtN01x8un0EwNu2bzKvhpRFhgoybIvMaOkkL60IVPmkb5h6XDmUl4IMSB+rT5cIO4/4bJgg==",
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.1.tgz",
"integrity": "sha512-0wE74YMgOkCgBUj8VyIDwmLUjTsS13WV1Pg7l0SHea2qzZzlq7MDnfbPsHKcELBRk3+izEVkRofjmClpycudCA==",
"dev": true,
"requires": {
"@ungap/promise-all-settled": "1.1.2",

View File

@@ -35,11 +35,11 @@
"@openstapps/configuration": "0.27.0",
"@testdeck/mocha": "0.1.2",
"@types/chai": "4.2.21",
"@types/mocha": "8.2.3",
"@types/mocha": "9.0.0",
"@types/node": "14.17.9",
"@types/rimraf": "3.0.1",
"conventional-changelog-cli": "2.1.1",
"mocha": "9.0.3",
"mocha": "9.1.1",
"chai": "4.3.4",
"nock": "13.1.1",
"prepend-file-cli": "1.0.6",

View File

@@ -67,4 +67,17 @@ export const typemap: ElasticsearchTypemap = {
},
};
/**
* If the string is a tag type
*/
export function isTagType(str: string): boolean {
for (const key in typemap) {
if (typemap.hasOwnProperty(key) && typeof typemap[key][str] !== 'undefined') {
return true;
}
}
return false;
}
export const dynamicTypes = ['any', 'unknown'];

View File

@@ -31,7 +31,7 @@ import {
import {fieldmap, filterableMap, filterableTagName} from './config/fieldmap';
import {premaps} from './config/premap';
import {settings} from './config/settings';
import {dynamicTypes, ElasticsearchDataType, typemap} from './config/typemap';
import {dynamicTypes, ElasticsearchDataType, isTagType, typemap} from './config/typemap';
import {AggregationSchema, ESNestedAggregation} from './types/aggregation';
import {
ElasticsearchDynamicTemplate,
@@ -275,7 +275,11 @@ function handleDeclarationReflection(decl: DeclarationReflection,
}
} else if (decl.type instanceof Type) { // if the object is a type, so we are dealing with a PROPERTY
// get inherited tags
const tags = (inheritedTags ?? []).length > 0 ? inheritedTags! : getCommentTags(decl, path, topTypeName);
const tags = (inheritedTags ?? []).length > 0
? (typeof inheritedTags!.find(it => isTagType(it.tagName)) !== 'undefined'
? inheritedTags!
: [...inheritedTags ?? [], ...getCommentTags(decl, path, topTypeName)])
: getCommentTags(decl, path, topTypeName);
return handleType(decl.type, new Map(generics), path, topTypeName, tags);
} else if (decl.kindString === 'Enumeration member') {

View File

@@ -13,59 +13,38 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Logger} from '@openstapps/logger';
import {slow, suite, test, timeout} from '@testdeck/mocha';
import {readdirSync, statSync} from 'fs';
import path from 'path';
import {MapAggTest} from './mapping-model/MapAggTest';
import {aggArrayTest} from './mapping-model/aggregations/src/agg-array';
import {aggNestedTest} from './mapping-model/aggregations/src/agg-nested';
import {aggGlobalTest} from './mapping-model/aggregations/src/agg-global';
import {aggGlobalNestedTest} from './mapping-model/aggregations/src/agg-global-nested';
import {aggInheritedTest} from './mapping-model/aggregations/src/agg-inherited';
import {aggInheritedGlobalTest} from './mapping-model/aggregations/src/agg-inherited-global';
import {aggInheritedOverwrittenTest} from './mapping-model/aggregations/src/agg-inherited-overwritten';
import {MapAggTestOptions} from './mapping-model/MapAggTestOptions';
process.on('unhandledRejection', (error: unknown) => {
if (error instanceof Error) {
void Logger.error('UNHANDLED REJECTION', error.stack);
}
process.exit(1);
});
describe('ES Aggregation Gen', async () => {
const magAppInstance = new MapAggTest('aggregations');
const magAppInstance = new MapAggTest('aggregations');
/**
* Expand a path to a list of all files deeply contained in it
*/
function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
const fullPath = path.resolve(sourcePath);
const directory = statSync(fullPath);
@suite(timeout(20000), slow(10000))
export class AggregationsSpec {
@test
async 'Aggregation tag should propagate on arrays'() {
magAppInstance.testInterfaceAgainstPath(aggArrayTest);
return directory.isDirectory()
? ([] as string[]).concat(...readdirSync(fullPath).map(fragment =>
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
))
: [fullPath].filter(accept);
}
@test
async 'Should work on nested properties'() {
magAppInstance.testInterfaceAgainstPath(aggNestedTest);
}
for (const file of expandPathToFilesSync('./test/mapping-model/aggregations/', file => file.endsWith('agg-test.ts'))) {
try {
const test = (await import(file))['testConfig'] as MapAggTestOptions;
@test
async 'Global option should work'() {
magAppInstance.testInterfaceAgainstPath(aggGlobalTest);
it(test.testName, function () {
magAppInstance.testInterfaceAgainstPath(test);
});
} catch (error) {
await Logger.error('UNHANDLED REJECTION', error.stack);
process.exit(1);
}
}
@test
async 'Global aggregations when nested'() {
magAppInstance.testInterfaceAgainstPath(aggGlobalNestedTest);
}
@test
async 'Inherited aggregations should work'() {
magAppInstance.testInterfaceAgainstPath(aggInheritedTest);
}
@test
async 'Inherited global aggregations should work'() {
magAppInstance.testInterfaceAgainstPath(aggInheritedGlobalTest);
}
@test
async 'Inherited aggregations should work when overwritten'() {
magAppInstance.testInterfaceAgainstPath(aggInheritedOverwrittenTest);
}
}
}).timeout(20_000).slow(10_000);

View File

@@ -16,6 +16,7 @@
import {ElasticsearchDynamicTemplate, ElasticsearchValue} from '../../src/types/mapping';
export interface MapAggTestOptions {
testName: string;
name: string;
agg?: {
fields?: string[];

View File

@@ -29,7 +29,8 @@ export interface AggArray {
}
type Foo = 'A' | 'B' | 'C';
export const aggArrayTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Aggregation tag should propagate on arrays',
name: ThingType.AggArray,
agg: {
fields: ['array'],

View File

@@ -30,7 +30,8 @@ export interface AggGlobalNested {
type: ThingType.AggGlobalNested;
}
export const aggGlobalNestedTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Global aggregations when nested',
name: ThingType.AggGlobalNested,
agg: {
globals: ['foo'],

View File

@@ -28,7 +28,8 @@ export interface AggGlobal {
type: ThingType.AggGlobal;
}
export const aggGlobalTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Global option should work',
name: ThingType.AggGlobal,
agg: {
globals: ['foo'],

View File

@@ -31,7 +31,8 @@ interface Foo {
bar: string;
}
export const aggInheritedGlobalTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Inherited global aggregations should work',
name: ThingType.AggInheritedGlobal,
agg: {
globals: ['bar'],

View File

@@ -36,7 +36,8 @@ interface Foo {
bar: string;
}
export const aggInheritedOverwrittenTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Inherited aggregations should work when overwritten',
name: ThingType.AggInherited,
agg: {
fields: ['bar'],

View File

@@ -31,7 +31,8 @@ interface Foo {
bar: string;
}
export const aggInheritedTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Inherited aggregations should work',
name: ThingType.AggInherited,
agg: {
fields: ['bar'],

View File

@@ -30,7 +30,8 @@ export interface AggNested {
type: ThingType.AggNested;
}
export const aggNestedTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Should work on nested properties',
name: ThingType.AggNested,
agg: {
fields: ['nested.foo'],

View File

@@ -27,7 +27,8 @@ export interface AnyUnknown {
type: ThingType.AnyUnknown
}
export const anyUnknownTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Any or unknown should create a dynamic field',
name: ThingType.AnyUnknown,
map: {
maps: {

View File

@@ -36,7 +36,8 @@ export interface DateAndRange {
type: ThingType.Date
}
export const dateAndRangeTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Dates and date ranges should have the correct type',
name: ThingType.Date,
map: {
maps: {

View File

@@ -30,7 +30,8 @@ interface InterfaceWithDefaultGeneric<T = number> {
bar: T;
}
export const defaultGenericTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Default generics should fail',
name: ThingType.DefaultGeneric,
map: {
maps: {

View File

@@ -36,7 +36,8 @@ export interface DoubleTypeConflict {
type: ThingType.DoubleTypeConflict;
}
export const doubleTypeConflictTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Double type annotations should cause an error',
name: ThingType.DoubleTypeConflict,
map: {
maps: {

View File

@@ -40,7 +40,10 @@ enum Baz {
f = 'f',
}
export const enumTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
// Known issue: Enums only use text
// https://gitlab.com/openstapps/core-tools/-/issues/46
testName: 'Emums should work',
name: ThingType.Enum,
map: {
maps: {

View File

@@ -48,7 +48,8 @@ export interface FilterableTag {
type: ThingType.FilterableTag
}
export const filterableTagTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Filterable tag should add raw field to strings',
name: ThingType.FilterableTag,
map: {
maps: {

View File

@@ -35,7 +35,8 @@ interface InterfaceWithStringGeneric<T> {
bar: T;
}
export const genericTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Generics should work',
name: ThingType.Generics,
map: {
maps: {

View File

@@ -26,7 +26,8 @@ export interface ImpossibleUnion {
type: ThingType.ImpossibleUnion
}
export const impossibleUnionTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Impossible union should cause an error',
name: ThingType.ImpossibleUnion,
map: {
maps: {

View File

@@ -45,7 +45,8 @@ export interface DoubleTypeConflict {
type: ThingType.IncompatibleType;
}
export const incompatibleTypeTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Incompatible type annotations should cause an error and use defaults',
name: ThingType.IncompatibleType,
map: {
maps: {

View File

@@ -31,7 +31,8 @@ export interface IndexSignature {
type: ThingType.IndexSignature;
}
export const indexSignatureTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Index Signatures should work',
name: ThingType.IndexSignature,
map: {
maps: {

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2020 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {ElasticsearchDataType} from '../../../../src/config/typemap';
import {MapAggTestOptions} from '../../MapAggTestOptions';
import {ThingType} from './types';
/**
* @date
*/
export type SCISO8601Date = string;
/**
* @indexable
*/
export interface InferredTypeFilterable {
/**
* @filterable
*/
foo: SCISO8601Date;
/**
* // no tag
*/
bar: SCISO8601Date;
type: ThingType.InferredTypeFilterable
}
export const testConfig: MapAggTestOptions = {
testName: 'filterable tags should not override inferred tags',
name: ThingType.InferredTypeFilterable,
map: {
maps: {
foo: {
type: ElasticsearchDataType.date,
fields: {
raw: {
type: ElasticsearchDataType.keyword,
}
}
},
bar: {
type: ElasticsearchDataType.date,
}
}
}
};

View File

@@ -36,7 +36,8 @@ export interface InheritTags {
type: ThingType.InheritTags;
}
export const inheritTagsTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Inherit tags tag should work',
name: ThingType.InheritTags,
map: {
maps: {

View File

@@ -38,7 +38,8 @@ interface Bar {
baz: number;
}
export const inheritedPropertyTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Inherited properties should inherit tags',
name: ThingType.InheritedProperty,
map: {
maps: {

View File

@@ -29,7 +29,8 @@ export interface InvalidTag {
type: ThingType.InvalidTag;
}
export const invalidTagTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Invalid tags should cause an error',
name: ThingType.InvalidTag,
map: {
maps: {

View File

@@ -54,7 +54,8 @@ export interface MapExplicitTypes {
type: ThingType.MapExplicitTypes;
}
export const mapExplicitTypesTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Explicit type annotations should work',
name: ThingType.MapExplicitTypes,
map: {
maps: {

View File

@@ -29,7 +29,8 @@ export interface MissingPremap {
type: ThingType.MissingPremap;
}
export const missingPremapTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Missing premap should cause an error',
name: ThingType.MissingPremap,
map: {
maps: {

View File

@@ -37,7 +37,8 @@ export interface Nested {
type: ThingType.Nested;
}
export const nestedTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Nested properties should work',
name: ThingType.Nested,
map: {
maps: {

View File

@@ -40,7 +40,8 @@ interface Buu {
intersection: string;
}
export const objectUnionTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Object union types should work',
name: ThingType.ObjectUnion,
map: {
maps: {

View File

@@ -37,7 +37,8 @@ export interface PairedTags {
type: ThingType.PairedTags;
}
export const pairedTagsTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Tags should be able to be paired',
name: ThingType.PairedTags,
map: {
maps: {

View File

@@ -31,7 +31,8 @@ export interface SensibleDefaults {
type: ThingType.SensibleDefaultType;
}
export const sensibleDefaultsTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Primitive types should have sensible defaults',
name: ThingType.SensibleDefaultType,
map: {
maps: {

View File

@@ -39,7 +39,8 @@ export interface SortableTag {
type: ThingType.SortableTag
}
export const sortableTagTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Sortable tag should work',
name: ThingType.SortableTag,
map: {
maps: {

View File

@@ -40,7 +40,8 @@ export interface TagsIgnoreCase {
type: ThingType.TagsIgnoreCase;
}
export const tagsIgnoreCaseTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Tags should ignore case',
name: ThingType.TagsIgnoreCase,
map: {
maps: {

View File

@@ -49,7 +49,8 @@ type ATextAlias = string;
*/
type AKeywordAlias = string;
export const typeAliasTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Type alias annotations should work',
name: ThingType.TypeAlias,
map: {
maps: {

View File

@@ -30,7 +30,8 @@ export interface TypeOverrides {
type: ThingType.TypeOverrides
}
export const typeOverridesTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Premaps should support non-external types',
name: ThingType.TypeOverrides,
map: {
maps: {

View File

@@ -32,7 +32,9 @@ enum Bar {
'c'
}
export const typeQueryTest: MapAggTestOptions = {
// https://gitlab.com/openstapps/core-tools/-/issues/47
export const testConfig: MapAggTestOptions = {
testName: 'Type queries should work',
name: ThingType.TypeQuery,
map: {
maps: {

View File

@@ -43,7 +43,9 @@ type NumberWrapper = number;
type StringWrapper = string;
type StringLiteralWrapper = 'foo';
export const typeWrapperInheritanceTest: MapAggTestOptions = {
// https://gitlab.com/openstapps/core-tools/-/merge_requests/29
export const testConfig: MapAggTestOptions = {
testName: 'Wrapper types should inherit tags',
name: ThingType.TypeWrapperInheritance,
map: {
maps: {

View File

@@ -34,6 +34,7 @@ export enum ThingType {
PairedTags = 'paired tags',
FilterableTag = 'filterable tag',
AnyUnknown = 'any unknown',
InferredTypeFilterable = 'inferred type filterable',
Date = 'date',
InheritTags = 'inherit tags',
TagsIgnoreCase = 'tags ignore case',

View File

@@ -13,171 +13,38 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Logger} from '@openstapps/logger';
import {slow, suite, test, timeout} from '@testdeck/mocha';
import {readdirSync, statSync} from 'fs';
import path from 'path';
import {MapAggTest} from './mapping-model/MapAggTest';
import {inheritTagsTest} from './mapping-model/mappings/src/inherit-tags';
import {mapExplicitTypesTest} from './mapping-model/mappings/src/map-explicit-types';
import {doubleTypeConflictTest} from './mapping-model/mappings/src/double-type-conflict';
import {incompatibleTypeTest} from './mapping-model/mappings/src/incompatible-type';
import {sensibleDefaultsTest} from './mapping-model/mappings/src/sensible-defaults';
import {invalidTagTest} from './mapping-model/mappings/src/invalid-tag';
import {missingPremapTest} from './mapping-model/mappings/src/missing-premap';
import {defaultGenericTest} from './mapping-model/mappings/src/default-generics';
import {genericTest} from './mapping-model/mappings/src/generics';
import {nestedTest} from './mapping-model/mappings/src/nested';
import {indexSignatureTest} from './mapping-model/mappings/src/index-signature';
import {impossibleUnionTest} from './mapping-model/mappings/src/impossible-union';
import {objectUnionTest} from './mapping-model/mappings/src/object-union';
import {sortableTagTest} from './mapping-model/mappings/src/sortable-tag';
import {enumTest} from './mapping-model/mappings/src/enum';
import {inheritedPropertyTest} from './mapping-model/mappings/src/inherited-property';
import {pairedTagsTest} from './mapping-model/mappings/src/paired-tags';
import {filterableTagTest} from './mapping-model/mappings/src/filterable-tag';
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';
import {MapAggTestOptions} from './mapping-model/MapAggTestOptions';
process.on('unhandledRejection', (error: unknown) => {
if (error instanceof Error) {
void Logger.error('UNHANDLED REJECTION', error.stack);
}
process.exit(1);
});
describe('ES Mapping Gen', async () => {
const magAppInstance = new MapAggTest('mappings');
const magAppInstance = new MapAggTest('mappings');
/**
* Expand a path to a list of all files deeply contained in it
*/
function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
const fullPath = path.resolve(sourcePath);
const directory = statSync(fullPath);
@suite(timeout(20000), slow(10000))
export class MappingSpec {
@test
async 'Any or unknown should create a dynamic field'() {
magAppInstance.testInterfaceAgainstPath(anyUnknownTest);
return directory.isDirectory()
? ([] as string[]).concat(...readdirSync(fullPath).map(fragment =>
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
))
: [fullPath].filter(accept);
}
@test
async 'Filterable tag should add raw field to strings'() {
magAppInstance.testInterfaceAgainstPath(filterableTagTest);
for (const file of expandPathToFilesSync('./test/mapping-model/mappings/', file => file.endsWith('mapping-test.ts'))) {
try {
const test = (await import(file))['testConfig'] as MapAggTestOptions;
it(test.testName, function () {
magAppInstance.testInterfaceAgainstPath(test)
})
} catch (error) {
await Logger.error('UNHANDLED REJECTION', error.stack);
process.exit(1);
}
}
@test
async 'Tags should be able to be paired'() {
magAppInstance.testInterfaceAgainstPath(pairedTagsTest);
}
@test
async 'Inherited properties should inherit tags'() {
magAppInstance.testInterfaceAgainstPath(inheritedPropertyTest);
}
@test
async 'Tags should ignore case'() {
magAppInstance.testInterfaceAgainstPath(tagsIgnoreCaseTest);
}
@test
async 'Emums should work'() {
// Known issue: Enums only use text
// https://gitlab.com/openstapps/core-tools/-/issues/46
magAppInstance.testInterfaceAgainstPath(enumTest);
}
@test
async 'Sortable tag should work'() {
magAppInstance.testInterfaceAgainstPath(sortableTagTest);
}
/*
https://gitlab.com/openstapps/core-tools/-/merge_requests/29
@test
async 'Wrapper types should inherit tags'() {
this.testInterfaceAgainstPath(typeWrapperInheritanceTest);
}*/
@test
async 'Inherit tags tag should work'() {
magAppInstance.testInterfaceAgainstPath(inheritTagsTest);
}
@test
async 'Object union types should work'() {
magAppInstance.testInterfaceAgainstPath(objectUnionTest);
}
/*
https://gitlab.com/openstapps/core-tools/-/issues/47
@test
async 'Type queries should work'() {
magAppInstance.testInterfaceAgainstPath(typeQueryTest);
}*/
@test
async 'Type alias annotations should work'(){
magAppInstance.testInterfaceAgainstPath(typeAliasTest);
}
@test
async 'Impossible union should cause an error'() {
magAppInstance.testInterfaceAgainstPath(impossibleUnionTest);
}
@test
async 'Index Signatures should work'() {
magAppInstance.testInterfaceAgainstPath(indexSignatureTest);
}
@test
async 'Nested properties should work'() {
magAppInstance.testInterfaceAgainstPath(nestedTest);
}
@test
async 'Generics should work'() {
magAppInstance.testInterfaceAgainstPath(genericTest);
}
@test
async 'Missing premap should cause an error'() {
magAppInstance.testInterfaceAgainstPath(missingPremapTest);
}
@test
async 'Default generics should fail'() {
magAppInstance.testInterfaceAgainstPath(defaultGenericTest);
}
@test
async 'Explicit type annotations should work'() {
magAppInstance.testInterfaceAgainstPath(mapExplicitTypesTest);
}
@test
async 'Double type annotations should cause an error'() {
magAppInstance.testInterfaceAgainstPath(doubleTypeConflictTest);
}
@test
async 'Incompatible type annotations should cause an error and use defaults'() {
magAppInstance.testInterfaceAgainstPath(incompatibleTypeTest);
}
@test
async 'Primitive types should have sensible defaults'() {
magAppInstance.testInterfaceAgainstPath(sensibleDefaultsTest);
}
@test
async 'Invalid tags should cause an error'() {
magAppInstance.testInterfaceAgainstPath(invalidTagTest);
}
@test
async 'Dates and date ranges should have the correct type'() {
magAppInstance.testInterfaceAgainstPath(dateAndRangeTest);
}
@test
async 'Premaps should support non-external types'() {
magAppInstance.testInterfaceAgainstPath(typeOverridesTest);
}
}
}).timeout(20_000).slow(10_000);