mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-03-14 02:32:50 +00:00
Merge remote-tracking branch 'es-mapping-generator/master'
This commit is contained in:
0
packages/es-mapping-generator/.eslintignore
Normal file
0
packages/es-mapping-generator/.eslintignore
Normal file
3
packages/es-mapping-generator/.eslintrc
Normal file
3
packages/es-mapping-generator/.eslintrc
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "@openstapps"
|
||||||
|
}
|
||||||
3
packages/es-mapping-generator/.gitignore
vendored
3
packages/es-mapping-generator/.gitignore
vendored
@@ -96,3 +96,6 @@ docs/
|
|||||||
|
|
||||||
# ignore openapi resources
|
# ignore openapi resources
|
||||||
openapi/
|
openapi/
|
||||||
|
|
||||||
|
# generated mappings
|
||||||
|
/mappings
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
# [0.6.0](https://gitlab.com/openstapps/es-mapping-generator/compare/v0.5.0...v0.6.0) (2023-04-28)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.5.0](https://gitlab.com/openstapps/es-mapping-generator/compare/v0.4.0...v0.5.0) (2023-04-27)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [0.4.0](https://gitlab.com/openstapps/es-mapping-generator/compare/v0.3.0...v0.4.0) (2023-01-12)
|
# [0.4.0](https://gitlab.com/openstapps/es-mapping-generator/compare/v0.3.0...v0.4.0) (2023-01-12)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1519
packages/es-mapping-generator/package-lock.json
generated
1519
packages/es-mapping-generator/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/es-mapping-generator",
|
"name": "@openstapps/es-mapping-generator",
|
||||||
"version": "0.4.0",
|
"version": "0.6.0",
|
||||||
"description": "Tool to convert TypeScript Interfaces to Elasticsearch Mappings",
|
"description": "Tool to convert TypeScript Interfaces to Elasticsearch Mappings",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
@@ -8,21 +8,23 @@
|
|||||||
"bin": {
|
"bin": {
|
||||||
"openstapps-es-mapping-generator": "./lib/cli.js"
|
"openstapps-es-mapping-generator": "./lib/cli.js"
|
||||||
},
|
},
|
||||||
"author": "Wieland Schöbl <wulkanat@gmail.com>",
|
"author": "Thea Schöbl <dev@theaninova.de>",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run tslint && npm run compile",
|
"build": "npm run lint && npm run compile",
|
||||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
|
||||||
"check-configuration": "openstapps-configuration",
|
"check-configuration": "openstapps-configuration",
|
||||||
"compile": "rimraf lib && tsc && prepend lib/cli.js '#!/usr/bin/env node\n'",
|
"compile": "rimraf lib && tsc && prepend lib/cli.js '#!/usr/bin/env node\n'",
|
||||||
"documentation": "typedoc --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks src",
|
"documentation": "typedoc --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks src",
|
||||||
"postversion": "npm run changelog",
|
"version": "npm run changelog",
|
||||||
"prepublishOnly": "npm ci && npm run build",
|
"prepublishOnly": "npm ci && npm run build",
|
||||||
"preversion": "npm run prepublishOnly",
|
"preversion": "npm run prepublishOnly",
|
||||||
"push": "git push && git push origin \"v$npm_package_version\"",
|
"push": "git push && git push origin \"v$npm_package_version\"",
|
||||||
"test": "mocha --require ts-node/register test/*.spec.ts",
|
"test": "mocha --require ts-node/register test/*.spec.ts",
|
||||||
"tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'"
|
"lint": "eslint -c .eslintrc --ignore-path .eslintignore --ext .ts src/ test/",
|
||||||
|
"lint:fix": "eslint --fix -c .eslintrc --ignore-path .eslintignore --ext .ts src/ test/"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@elastic/elasticsearch": "8.4.0",
|
||||||
"@openstapps/logger": "1.1.1",
|
"@openstapps/logger": "1.1.1",
|
||||||
"commander": "9.5.0",
|
"commander": "9.5.0",
|
||||||
"deepmerge": "4.2.2",
|
"deepmerge": "4.2.2",
|
||||||
@@ -32,7 +34,9 @@
|
|||||||
"typescript": "3.8.3"
|
"typescript": "3.8.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@openstapps/configuration": "0.34.0",
|
||||||
"@testdeck/mocha": "0.3.3",
|
"@testdeck/mocha": "0.3.3",
|
||||||
|
"@openstapps/eslint-config": "1.1.0",
|
||||||
"@types/chai": "4.3.4",
|
"@types/chai": "4.3.4",
|
||||||
"@types/mocha": "9.1.1",
|
"@types/mocha": "9.1.1",
|
||||||
"@types/node": "14.18.36",
|
"@types/node": "14.18.36",
|
||||||
@@ -44,7 +48,13 @@
|
|||||||
"prepend-file-cli": "1.0.6",
|
"prepend-file-cli": "1.0.6",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"ts-node": "10.9.1",
|
"ts-node": "10.9.1",
|
||||||
"tslint": "6.1.3",
|
"@typescript-eslint/eslint-plugin": "5.40.0",
|
||||||
"tslint-eslint-rules": "5.4.0"
|
"@typescript-eslint/parser": "5.40.0",
|
||||||
|
"eslint": "8.25.0",
|
||||||
|
"eslint-config-prettier": "8.5.0",
|
||||||
|
"eslint-plugin-jsdoc": "39.3.6",
|
||||||
|
"eslint-plugin-prettier": "4.2.1",
|
||||||
|
"eslint-plugin-unicorn": "44.0.2",
|
||||||
|
"prettier": "2.7.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable unicorn/no-null */
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2021 StApps
|
* Copyright (C) 2018-2021 StApps
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
@@ -16,7 +17,7 @@ import {Logger} from '@openstapps/logger';
|
|||||||
import {Command} from 'commander';
|
import {Command} from 'commander';
|
||||||
import {readFileSync, writeFileSync} from 'fs';
|
import {readFileSync, writeFileSync} from 'fs';
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
import {resolve} from 'path';
|
import path from 'path';
|
||||||
import {exit} from 'process';
|
import {exit} from 'process';
|
||||||
import {generateTemplate} from './mapping';
|
import {generateTemplate} from './mapping';
|
||||||
import {getProjectReflection} from './project-reflection';
|
import {getProjectReflection} from './project-reflection';
|
||||||
@@ -33,11 +34,8 @@ process.on('unhandledRejection', async (reason: unknown) => {
|
|||||||
|
|
||||||
const commander = new Command('openstapps-core-tools');
|
const commander = new Command('openstapps-core-tools');
|
||||||
|
|
||||||
commander
|
// eslint-disable-next-line unicorn/prefer-module
|
||||||
.version(JSON.parse(
|
commander.version(JSON.parse(readFileSync(path.resolve(__dirname, '..', 'package.json')).toString()).version);
|
||||||
readFileSync(resolve(__dirname, '..', 'package.json'))
|
|
||||||
.toString(),
|
|
||||||
).version);
|
|
||||||
|
|
||||||
commander
|
commander
|
||||||
.command('mapping <relativeSrcPath>')
|
.command('mapping <relativeSrcPath>')
|
||||||
@@ -45,9 +43,9 @@ commander
|
|||||||
.option('-i, --ignoredTags <ignoredTags>', 'Ignored Tags (comma-separated)')
|
.option('-i, --ignoredTags <ignoredTags>', 'Ignored Tags (comma-separated)')
|
||||||
.option('-a, --aggPath <relativeAggregationPath>', 'Aggregations Path')
|
.option('-a, --aggPath <relativeAggregationPath>', 'Aggregations Path')
|
||||||
.option('-e, --errorPath <relativeErrorPath>', 'Error Path')
|
.option('-e, --errorPath <relativeErrorPath>', 'Error Path')
|
||||||
.action(async (relativeSrcPath, options) => {
|
.action(async (relativeSourcePath, options) => {
|
||||||
// get absolute paths
|
// get absolute paths
|
||||||
const srcPath = resolve(relativeSrcPath);
|
const sourcePath = path.resolve(relativeSourcePath);
|
||||||
|
|
||||||
let ignoredTagsList: string[] = [];
|
let ignoredTagsList: string[] = [];
|
||||||
if (typeof options.ignoredTags === 'string') {
|
if (typeof options.ignoredTags === 'string') {
|
||||||
@@ -55,10 +53,10 @@ commander
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get project reflection
|
// get project reflection
|
||||||
const projectReflection = getProjectReflection(srcPath);
|
const projectReflection = getProjectReflection(sourcePath);
|
||||||
|
|
||||||
const result = generateTemplate(projectReflection, ignoredTagsList, true);
|
const result = generateTemplate(projectReflection, ignoredTagsList, true);
|
||||||
if (result.errors.length !== 0) {
|
if (result.errors.length > 0) {
|
||||||
await Logger.error('Mapping generated with errors!');
|
await Logger.error('Mapping generated with errors!');
|
||||||
} else {
|
} else {
|
||||||
Logger.ok('Mapping generated without errors!');
|
Logger.ok('Mapping generated without errors!');
|
||||||
@@ -66,22 +64,22 @@ commander
|
|||||||
|
|
||||||
// write documentation to file
|
// write documentation to file
|
||||||
if (typeof options.aggPath !== 'undefined') {
|
if (typeof options.aggPath !== 'undefined') {
|
||||||
const aggPath = resolve(options.aggPath);
|
const aggPath = path.resolve(options.aggPath);
|
||||||
// tslint:disable-next-line:no-magic-numbers
|
// tslint:disable-next-line:no-magic-numbers
|
||||||
writeFileSync(aggPath, JSON.stringify(result.aggregations, null, 2));
|
writeFileSync(aggPath, JSON.stringify(result.aggregations, null, 2));
|
||||||
Logger.ok(`Elasticsearch aggregations written to ${aggPath}.`);
|
Logger.ok(`Elasticsearch aggregations written to ${aggPath}.`);
|
||||||
}
|
}
|
||||||
if (typeof options.mappingPath !== 'undefined') {
|
if (typeof options.mappingPath !== 'undefined') {
|
||||||
const mappingPath = resolve(options.mappingPath);
|
const mappingPath = path.resolve(options.mappingPath);
|
||||||
// tslint:disable-next-line:no-magic-numbers
|
// tslint:disable-next-line:no-magic-numbers
|
||||||
writeFileSync(mappingPath, JSON.stringify(result.mappings, null, 2));
|
writeFileSync(mappingPath, JSON.stringify(result.mappings, null, 2));
|
||||||
Logger.ok(`Elasticsearch mappings written to ${mappingPath}.`);
|
Logger.ok(`Elasticsearch mappings written to ${mappingPath}.`);
|
||||||
}
|
}
|
||||||
if (typeof options.errorPath !== 'undefined') {
|
if (typeof options.errorPath !== 'undefined') {
|
||||||
const errPath = resolve(options.errorPath);
|
const errorPath = path.resolve(options.errorPath);
|
||||||
// tslint:disable-next-line:no-magic-numbers
|
// tslint:disable-next-line:no-magic-numbers
|
||||||
writeFileSync(errPath, JSON.stringify(result.errors, null, 2));
|
writeFileSync(errorPath, JSON.stringify(result.errors, null, 2));
|
||||||
Logger.ok(`Mapping errors written to ${errPath}.`);
|
Logger.ok(`Mapping errors written to ${errorPath}.`);
|
||||||
} else if (result.errors.length > 0) {
|
} else if (result.errors.length > 0) {
|
||||||
for (const error of result.errors) {
|
for (const error of result.errors) {
|
||||||
await Logger.error(error);
|
await Logger.error(error);
|
||||||
@@ -93,12 +91,13 @@ commander
|
|||||||
|
|
||||||
commander
|
commander
|
||||||
.command('put-es-templates <srcPath> <esAddress> [ignoredTags]')
|
.command('put-es-templates <srcPath> <esAddress> [ignoredTags]')
|
||||||
.action(async (relativeSrcPath, esAddress) => {
|
.action(async (relativeSourcePath, esAddress) => {
|
||||||
// get absolute paths
|
// get absolute paths
|
||||||
const srcPath = resolve(relativeSrcPath);
|
const sourcePath = path.resolve(relativeSourcePath);
|
||||||
|
|
||||||
// get project reflection
|
// get project reflection
|
||||||
const templates = require(srcPath) as ElasticsearchTemplateCollection;
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,unicorn/prefer-module
|
||||||
|
const templates = require(sourcePath) as ElasticsearchTemplateCollection;
|
||||||
|
|
||||||
for (const template in templates) {
|
for (const template in templates) {
|
||||||
if (!templates.hasOwnProperty(template)) {
|
if (!templates.hasOwnProperty(template)) {
|
||||||
@@ -111,7 +110,9 @@ commander
|
|||||||
|
|
||||||
const HTTP_STATUS_OK = 200;
|
const HTTP_STATUS_OK = 200;
|
||||||
if (response.statusCode !== HTTP_STATUS_OK) {
|
if (response.statusCode !== HTTP_STATUS_OK) {
|
||||||
await Logger.error(`Template for "${template}" failed in Elasticsearch:\n${JSON.stringify(response.body)}`);
|
await Logger.error(
|
||||||
|
`Template for "${template}" failed in Elasticsearch:\n${JSON.stringify(response.body)}`,
|
||||||
|
);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,38 +12,34 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {ElasticsearchFieldmap, ElasticsearchFilterableMap} from '../types/mapping';
|
import {MappingProperty} from '@elastic/elasticsearch/lib/api/types';
|
||||||
import {ElasticsearchDataType} from './typemap';
|
import {ElasticsearchFieldmap, SimpleType} from '../types/mapping';
|
||||||
|
|
||||||
export enum analyzers {
|
const ducetSort = {
|
||||||
ducet_sort = 'ducet_sort',
|
type: 'icu_collation_keyword',
|
||||||
search_german = 'search_german',
|
language: 'de',
|
||||||
}
|
country: 'DE',
|
||||||
|
variant: '@collation=phonebook',
|
||||||
|
};
|
||||||
|
|
||||||
|
const keyword: MappingProperty['type'] = 'keyword';
|
||||||
|
|
||||||
export const fieldmap: ElasticsearchFieldmap = {
|
export const fieldmap: ElasticsearchFieldmap = {
|
||||||
aggregatable: {
|
aggregatable: {
|
||||||
default: {
|
default: {
|
||||||
raw: {
|
raw: {
|
||||||
ignore_above: 10000,
|
ignore_above: 10_000,
|
||||||
type: ElasticsearchDataType.keyword,
|
type: keyword,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ignore: ['global'],
|
ignore: ['global'],
|
||||||
},
|
},
|
||||||
sortable: {
|
sortable: {
|
||||||
default: {
|
default: {
|
||||||
sort: {
|
sort: ducetSort,
|
||||||
analyzer: analyzers.ducet_sort,
|
|
||||||
fielddata: true,
|
|
||||||
type: ElasticsearchDataType.text,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
ducet: {
|
ducet: {
|
||||||
sort: {
|
sort: ducetSort,
|
||||||
analyzer: analyzers.ducet_sort,
|
|
||||||
fielddata: true,
|
|
||||||
type: ElasticsearchDataType.text,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
ignore: ['price'],
|
ignore: ['price'],
|
||||||
},
|
},
|
||||||
@@ -51,9 +47,9 @@ export const fieldmap: ElasticsearchFieldmap = {
|
|||||||
|
|
||||||
export const filterableTagName = 'filterable';
|
export const filterableTagName = 'filterable';
|
||||||
|
|
||||||
export const filterableMap: ElasticsearchFilterableMap = {
|
export const filterableMap: Record<string, SimpleType> = {
|
||||||
date: ElasticsearchDataType.keyword,
|
date: 'keyword',
|
||||||
keyword: ElasticsearchDataType.keyword,
|
keyword: 'keyword',
|
||||||
text: ElasticsearchDataType.keyword,
|
text: 'keyword',
|
||||||
integer: ElasticsearchDataType.integer,
|
integer: 'integer',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,57 +12,52 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {ElasticsearchPremap} from '../types/mapping';
|
import {MappingProperty} from '@elastic/elasticsearch/lib/api/types';
|
||||||
import {ElasticsearchDataType} from './typemap';
|
|
||||||
|
|
||||||
export const premaps: ElasticsearchPremap = {
|
export const premaps: Record<string, MappingProperty> = {
|
||||||
CoordinateReferenceSystem: {
|
'CoordinateReferenceSystem': {
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
properties: {
|
properties: {
|
||||||
type: {
|
type: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
LineString: {
|
'LineString': {
|
||||||
precision: '1m',
|
type: 'geo_shape',
|
||||||
tree: 'quadtree',
|
|
||||||
type: ElasticsearchDataType.geo_shape,
|
|
||||||
},
|
},
|
||||||
Point: {
|
'Point': {
|
||||||
properties: {
|
properties: {
|
||||||
type: {
|
type: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
coordinates: {
|
coordinates: {
|
||||||
type: ElasticsearchDataType.geo_point,
|
type: 'geo_point',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
},
|
},
|
||||||
Polygon: {
|
'Polygon': {
|
||||||
precision: '1m',
|
type: 'geo_shape',
|
||||||
tree: 'quadtree',
|
|
||||||
type: ElasticsearchDataType.geo_shape,
|
|
||||||
},
|
},
|
||||||
SCISO8601DateRange: {
|
'SCISO8601DateRange': {
|
||||||
type: ElasticsearchDataType.date_range,
|
type: 'date_range',
|
||||||
},
|
},
|
||||||
'jsonpatch.OpPatch': {
|
'jsonpatch.OpPatch': {
|
||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
from: {
|
from: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
op: {
|
op: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
path: {
|
path: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
// this is actually an 'any' type, however ES does not really support that.
|
// this is actually an 'any' type; however, ES does not really support that.
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,54 +12,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {ElasticsearchSettings} from '../types/mapping';
|
import {IndicesPutTemplateRequest} from '@elastic/elasticsearch/lib/api/types';
|
||||||
|
|
||||||
export const settings: ElasticsearchSettings = {
|
export const settings: IndicesPutTemplateRequest['settings'] = {
|
||||||
analysis: {
|
'mapping.total_fields.limit': 10_000,
|
||||||
analyzer: {
|
'max_result_window': 30_000,
|
||||||
ducet_sort: {
|
'number_of_replicas': 0,
|
||||||
filter: [
|
'number_of_shards': 1,
|
||||||
'german_phonebook',
|
|
||||||
],
|
|
||||||
tokenizer: 'keyword',
|
|
||||||
type: 'custom',
|
|
||||||
},
|
|
||||||
search_german: {
|
|
||||||
filter: [
|
|
||||||
'lowercase',
|
|
||||||
'german_stop',
|
|
||||||
'german_stemmer',
|
|
||||||
],
|
|
||||||
tokenizer: 'stapps_ngram',
|
|
||||||
type: 'custom',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
german_phonebook: {
|
|
||||||
country: 'DE',
|
|
||||||
language: 'de',
|
|
||||||
type: 'icu_collation',
|
|
||||||
variant: '@collation=phonebook',
|
|
||||||
},
|
|
||||||
german_stemmer: {
|
|
||||||
language: 'german',
|
|
||||||
type: 'stemmer',
|
|
||||||
},
|
|
||||||
german_stop: {
|
|
||||||
stopwords: '_german_',
|
|
||||||
type: 'stop',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tokenizer: {
|
|
||||||
stapps_ngram: {
|
|
||||||
max_gram: 7,
|
|
||||||
min_gram: 4,
|
|
||||||
type: 'ngram',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'mapping.total_fields.limit': 10000,
|
|
||||||
max_result_window: 30000,
|
|
||||||
number_of_replicas: 0,
|
|
||||||
number_of_shards: 1,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,67 +12,46 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {MappingFloatNumberProperty} from '@elastic/elasticsearch/lib/api/types';
|
||||||
import {ElasticsearchTypemap} from '../types/mapping';
|
import {ElasticsearchTypemap} from '../types/mapping';
|
||||||
|
|
||||||
export enum ElasticsearchDataType {
|
export const PARSE_ERROR = 'PARSE_ERROR' as MappingFloatNumberProperty['type'];
|
||||||
missing_premap = 'MISSING_PREMAP',
|
export const MISSING_PREMAP = 'MISSING_PREMAP' as MappingFloatNumberProperty['type'];
|
||||||
parse_error = 'PARSE_ERROR',
|
export const TYPE_CONFLICT = 'TYPE_CONFLICT' as MappingFloatNumberProperty['type'];
|
||||||
type_conflict = 'TYPE_CONFLICT',
|
|
||||||
text = 'text',
|
|
||||||
keyword = 'keyword',
|
|
||||||
date = 'date',
|
|
||||||
// long = 'long',
|
|
||||||
// double = 'double',
|
|
||||||
float = 'float',
|
|
||||||
boolean = 'boolean',
|
|
||||||
ip = 'ip',
|
|
||||||
integer = 'integer',
|
|
||||||
object = 'object',
|
|
||||||
nested = 'nested',
|
|
||||||
geo_point = 'geo_point',
|
|
||||||
geo_shape = 'geo_shape',
|
|
||||||
completion = 'completion',
|
|
||||||
date_range = 'date_range',
|
|
||||||
// integer_range = 'integer_range',
|
|
||||||
// float_range = 'float_range',
|
|
||||||
// long_range = 'long_range',
|
|
||||||
// double_range = 'double_range',
|
|
||||||
// ip_range = 'ip_range',
|
|
||||||
}
|
|
||||||
|
|
||||||
export const typemap: ElasticsearchTypemap = {
|
export const typemap: ElasticsearchTypemap = {
|
||||||
boolean: {
|
boolean: {
|
||||||
default: ElasticsearchDataType.boolean,
|
default: 'boolean',
|
||||||
},
|
},
|
||||||
false: {
|
false: {
|
||||||
default: ElasticsearchDataType.boolean,
|
default: 'boolean',
|
||||||
},
|
},
|
||||||
number: {
|
number: {
|
||||||
default: ElasticsearchDataType.integer,
|
default: 'integer',
|
||||||
float: ElasticsearchDataType.float,
|
float: 'float',
|
||||||
integer: ElasticsearchDataType.integer,
|
integer: 'integer',
|
||||||
date: ElasticsearchDataType.date,
|
date: 'date',
|
||||||
},
|
},
|
||||||
string: {
|
string: {
|
||||||
default: ElasticsearchDataType.text,
|
default: 'text',
|
||||||
keyword: ElasticsearchDataType.keyword,
|
keyword: 'keyword',
|
||||||
text: ElasticsearchDataType.text,
|
text: 'text',
|
||||||
date: ElasticsearchDataType.date,
|
date: 'date',
|
||||||
},
|
},
|
||||||
stringLiteral: {
|
stringLiteral: {
|
||||||
default: ElasticsearchDataType.keyword,
|
default: 'keyword',
|
||||||
},
|
},
|
||||||
true: {
|
true: {
|
||||||
default: ElasticsearchDataType.boolean,
|
default: 'boolean',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the string is a tag type
|
* If the string is a tag type
|
||||||
*/
|
*/
|
||||||
export function isTagType(str: string): boolean {
|
export function isTagType(string_: string): boolean {
|
||||||
for (const key in typemap) {
|
for (const key in typemap) {
|
||||||
if (typemap.hasOwnProperty(key) && typeof typemap[key][str] !== 'undefined') {
|
if (typemap.hasOwnProperty(key) && typeof typemap[key][string_] !== 'undefined') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {
|
||||||
|
MappingDynamicTemplate,
|
||||||
|
MappingObjectProperty,
|
||||||
|
MappingProperty,
|
||||||
|
} from '@elastic/elasticsearch/lib/api/types';
|
||||||
import {Logger} from '@openstapps/logger';
|
import {Logger} from '@openstapps/logger';
|
||||||
import merge from 'deepmerge';
|
import merge from 'deepmerge';
|
||||||
import {stringify} from 'flatted';
|
import {stringify} from 'flatted';
|
||||||
@@ -31,17 +36,11 @@ import {
|
|||||||
import {fieldmap, filterableMap, filterableTagName} from './config/fieldmap';
|
import {fieldmap, filterableMap, filterableTagName} from './config/fieldmap';
|
||||||
import {premaps} from './config/premap';
|
import {premaps} from './config/premap';
|
||||||
import {settings} from './config/settings';
|
import {settings} from './config/settings';
|
||||||
import {dynamicTypes, ElasticsearchDataType, isTagType, typemap} from './config/typemap';
|
import {dynamicTypes, isTagType, MISSING_PREMAP, PARSE_ERROR, TYPE_CONFLICT, typemap} from './config/typemap';
|
||||||
import {AggregationSchema, ESNestedAggregation} from './types/aggregation';
|
import {AggregationSchema, ESNestedAggregation} from './types/aggregation';
|
||||||
import {
|
import {ElasticsearchTemplateCollection, MappingGenTemplate} from './types/mapping';
|
||||||
ElasticsearchDynamicTemplate,
|
|
||||||
ElasticsearchObject,
|
|
||||||
ElasticsearchTemplateCollection,
|
|
||||||
ElasticsearchType,
|
|
||||||
ElasticsearchValue, MappingGenTemplate,
|
|
||||||
} from './types/mapping';
|
|
||||||
|
|
||||||
let dynamicTemplates: ElasticsearchDynamicTemplate[] = [];
|
let dynamicTemplates: Record<string, MappingDynamicTemplate>[] = [];
|
||||||
let errors: string[] = [];
|
let errors: string[] = [];
|
||||||
let showErrors = true;
|
let showErrors = true;
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ const inheritTagsName = 'inherittags';
|
|||||||
const maxErrorObjectChars = 1000;
|
const maxErrorObjectChars = 1000;
|
||||||
|
|
||||||
let ignoredTagsList = ['indexable', 'validatable', inheritTagsName];
|
let ignoredTagsList = ['indexable', 'validatable', inheritTagsName];
|
||||||
let inheritTagsMap: { [path: string]: CommentTag[]; } = {};
|
let inheritTagsMap: {[path: string]: CommentTag[]} = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all interfaces that have an @indexable tag
|
* Gets all interfaces that have an @indexable tag
|
||||||
@@ -64,7 +63,6 @@ let inheritTagsMap: { [path: string]: CommentTag[]; } = {};
|
|||||||
* @param projectReflection the project reflection from which to extract the indexable interfaces
|
* @param projectReflection the project reflection from which to extract the indexable interfaces
|
||||||
*/
|
*/
|
||||||
export function getAllIndexableInterfaces(projectReflection: ProjectReflection): DeclarationReflection[] {
|
export function getAllIndexableInterfaces(projectReflection: ProjectReflection): DeclarationReflection[] {
|
||||||
|
|
||||||
let indexableInterfaces: DeclarationReflection[] = [];
|
let indexableInterfaces: DeclarationReflection[] = [];
|
||||||
|
|
||||||
if (!Array.isArray(projectReflection.children) || projectReflection.children.length === 0) {
|
if (!Array.isArray(projectReflection.children) || projectReflection.children.length === 0) {
|
||||||
@@ -72,14 +70,14 @@ export function getAllIndexableInterfaces(projectReflection: ProjectReflection):
|
|||||||
}
|
}
|
||||||
|
|
||||||
// push all declaration reflections into one array
|
// push all declaration reflections into one array
|
||||||
projectReflection.children.forEach((declarationReflection) => {
|
for (const declarationReflection of projectReflection.children) {
|
||||||
if (Array.isArray(declarationReflection.children)) {
|
if (Array.isArray(declarationReflection.children)) {
|
||||||
indexableInterfaces = indexableInterfaces.concat(declarationReflection.children);
|
indexableInterfaces = [...indexableInterfaces, ...declarationReflection.children];
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// filter all declaration reflections with an @indexable tag
|
// filter all declaration reflections with an @indexable tag
|
||||||
indexableInterfaces = indexableInterfaces.filter((declarationReflection) => {
|
indexableInterfaces = indexableInterfaces.filter(declarationReflection => {
|
||||||
if (
|
if (
|
||||||
typeof declarationReflection.comment === 'undefined' ||
|
typeof declarationReflection.comment === 'undefined' ||
|
||||||
typeof declarationReflection.comment.tags === 'undefined'
|
typeof declarationReflection.comment.tags === 'undefined'
|
||||||
@@ -87,9 +85,11 @@ export function getAllIndexableInterfaces(projectReflection: ProjectReflection):
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return typeof declarationReflection.comment.tags.find((commentTag) => {
|
return (
|
||||||
return commentTag.tagName === indexableTag;
|
typeof declarationReflection.comment.tags.find(commentTag => {
|
||||||
}) !== 'undefined';
|
return commentTag.tagName === indexableTag;
|
||||||
|
}) !== 'undefined'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return indexableInterfaces;
|
return indexableInterfaces;
|
||||||
@@ -104,8 +104,17 @@ export function getAllIndexableInterfaces(projectReflection: ProjectReflection):
|
|||||||
* @param object the object or name
|
* @param object the object or name
|
||||||
* @param message the error message
|
* @param message the error message
|
||||||
*/
|
*/
|
||||||
function composeErrorMessage(path: string, topTypeName: string, typeName: string, object: string, message: string) {
|
function composeErrorMessage(
|
||||||
const error = `At "${topTypeName}::${path.substr(0, path.length - 1)}" for ${typeName} "${trimString(object, maxErrorObjectChars)}": ${message}`;
|
path: string,
|
||||||
|
topTypeName: string,
|
||||||
|
typeName: string,
|
||||||
|
object: string,
|
||||||
|
message: string,
|
||||||
|
) {
|
||||||
|
const error = `At "${topTypeName}::${path.slice(
|
||||||
|
0,
|
||||||
|
Math.max(0, path.length - 1),
|
||||||
|
)}" for ${typeName} "${trimString(object, maxErrorObjectChars)}": ${message}`;
|
||||||
errors.push(error);
|
errors.push(error);
|
||||||
if (showErrors) {
|
if (showErrors) {
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// tslint:disable-next-line:no-floating-promises
|
||||||
@@ -120,9 +129,7 @@ function composeErrorMessage(path: string, topTypeName: string, typeName: string
|
|||||||
* @param maxLength the maximum allowed length before it is clamped
|
* @param maxLength the maximum allowed length before it is clamped
|
||||||
*/
|
*/
|
||||||
function trimString(value: string, maxLength: number): string {
|
function trimString(value: string, maxLength: number): string {
|
||||||
return value.length > maxLength ?
|
return value.length > maxLength ? `${value.slice(0, Math.max(0, maxLength))}...` : value;
|
||||||
`${value.substring(0, maxLength)}...` :
|
|
||||||
value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,18 +144,24 @@ function trimString(value: string, maxLength: number): string {
|
|||||||
* @param path the current path to the object we are in
|
* @param path the current path to the object we are in
|
||||||
* @param tags any tags attached to the type
|
* @param tags any tags attached to the type
|
||||||
*/
|
*/
|
||||||
function getReflectionGeneric(type: ReferenceType,
|
function getReflectionGeneric(
|
||||||
out: Map<string, ElasticsearchValue>,
|
type: ReferenceType,
|
||||||
topTypeName: string,
|
out: Map<string, MappingProperty>,
|
||||||
path: string,
|
topTypeName: string,
|
||||||
tags: CommentTag[]): Map<string, ElasticsearchValue> {
|
path: string,
|
||||||
if (typeof type.typeArguments !== 'undefined'
|
tags: CommentTag[],
|
||||||
&& type.reflection instanceof DeclarationReflection
|
): Map<string, MappingProperty> {
|
||||||
&& typeof type.reflection.typeParameters !== 'undefined') {
|
if (
|
||||||
|
typeof type.typeArguments !== 'undefined' &&
|
||||||
|
type.reflection instanceof DeclarationReflection &&
|
||||||
|
typeof type.reflection.typeParameters !== 'undefined'
|
||||||
|
) {
|
||||||
for (let i = 0; i < type.reflection.typeParameters.length; i++) {
|
for (let i = 0; i < type.reflection.typeParameters.length; i++) {
|
||||||
if (i < type.typeArguments.length) {
|
if (i < type.typeArguments.length) {
|
||||||
out
|
out.set(
|
||||||
.set(type.reflection.typeParameters[i].name, handleType(type.typeArguments[i], out, topTypeName, path, tags));
|
type.reflection.typeParameters[i].name,
|
||||||
|
handleType(type.typeArguments[i], out, topTypeName, path, tags),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// this can happen due to a bug in TypeDoc https://github.com/TypeStrong/typedoc/issues/1061
|
// this can happen due to a bug in TypeDoc https://github.com/TypeStrong/typedoc/issues/1061
|
||||||
// we have no way to know the type here, so we have to use this.
|
// we have no way to know the type here, so we have to use this.
|
||||||
@@ -157,8 +170,10 @@ function getReflectionGeneric(type: ReferenceType,
|
|||||||
properties: {},
|
properties: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
Logger.warn(`Type "${type.name}": Defaults of generics (Foo<T = any>) currently don't work due to a bug` +
|
Logger.warn(
|
||||||
` in TypeDoc. It has been replaced by a dynamic type.`);
|
`Type "${type.name}": Defaults of generics (Foo<T = any>) currently don't work due to a bug` +
|
||||||
|
` in TypeDoc. It has been replaced by a dynamic type.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,29 +192,42 @@ function getReflectionGeneric(type: ReferenceType,
|
|||||||
* @param topTypeName the name of the SCThingType
|
* @param topTypeName the name of the SCThingType
|
||||||
* @param tags any tags attached to the type
|
* @param tags any tags attached to the type
|
||||||
*/
|
*/
|
||||||
function handleExternalType(ref: ReferenceType, generics: Map<string, ElasticsearchValue>,
|
function handleExternalType(
|
||||||
path: string, topTypeName: string, tags: CommentTag[]): ElasticsearchValue {
|
ref: ReferenceType,
|
||||||
|
generics: Map<string, MappingProperty>,
|
||||||
|
path: string,
|
||||||
|
topTypeName: string,
|
||||||
|
tags: CommentTag[],
|
||||||
|
): MappingProperty {
|
||||||
for (const premap of Object.keys(premaps)) {
|
for (const premap of Object.keys(premaps)) {
|
||||||
if (premap === ref.name) {
|
if (premap === ref.name) {
|
||||||
return readFieldTags(premaps[premap], path, topTypeName, tags);
|
return readFieldTags(premaps[premap], path, topTypeName, tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref.name === 'Array') { // basically an external type, but Array is quite common, especially with generics
|
if (ref.name === 'Array') {
|
||||||
|
// basically an external type, but Array is quite common, especially with generics
|
||||||
if (typeof ref.typeArguments === 'undefined' || typeof ref.typeArguments[0] === 'undefined') {
|
if (typeof ref.typeArguments === 'undefined' || typeof ref.typeArguments[0] === 'undefined') {
|
||||||
composeErrorMessage(path, topTypeName, 'Array with generics', 'array', 'Failed to parse');
|
composeErrorMessage(path, topTypeName, 'Array with generics', 'array', 'Failed to parse');
|
||||||
|
|
||||||
return {type: ElasticsearchDataType.parse_error};
|
return {type: PARSE_ERROR};
|
||||||
}
|
}
|
||||||
|
|
||||||
return readFieldTags(
|
return readFieldTags(
|
||||||
handleType(
|
handleType(
|
||||||
ref.typeArguments[0], getReflectionGeneric(
|
ref.typeArguments[0],
|
||||||
ref, new Map(generics), path, topTypeName, tags),
|
getReflectionGeneric(ref, new Map(generics), path, topTypeName, tags),
|
||||||
path, topTypeName, tags),
|
path,
|
||||||
path, topTypeName, tags);
|
topTypeName,
|
||||||
|
tags,
|
||||||
|
),
|
||||||
|
path,
|
||||||
|
topTypeName,
|
||||||
|
tags,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (ref.name === '__type') { // empty object
|
if (ref.name === '__type') {
|
||||||
|
// empty object
|
||||||
return {
|
return {
|
||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -208,7 +236,7 @@ function handleExternalType(ref: ReferenceType, generics: Map<string, Elasticsea
|
|||||||
|
|
||||||
composeErrorMessage(path, topTypeName, 'external type', ref.name, 'Missing pre-map');
|
composeErrorMessage(path, topTypeName, 'external type', ref.name, 'Missing pre-map');
|
||||||
|
|
||||||
return readFieldTags({type: ElasticsearchDataType.missing_premap}, path, topTypeName, tags);
|
return readFieldTags({type: MISSING_PREMAP}, path, topTypeName, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,22 +248,22 @@ function handleExternalType(ref: ReferenceType, generics: Map<string, Elasticsea
|
|||||||
* @param topTypeName the name of the SCThingType
|
* @param topTypeName the name of the SCThingType
|
||||||
* @param inheritedTags the inherited tags
|
* @param inheritedTags the inherited tags
|
||||||
*/
|
*/
|
||||||
function handleDeclarationReflection(decl: DeclarationReflection,
|
function handleDeclarationReflection(
|
||||||
generics: Map<string, ElasticsearchValue>,
|
decl: DeclarationReflection,
|
||||||
path: string,
|
generics: Map<string, MappingProperty>,
|
||||||
topTypeName: string,
|
path: string,
|
||||||
inheritedTags?: CommentTag[]):
|
topTypeName: string,
|
||||||
ElasticsearchValue {
|
inheritedTags?: CommentTag[],
|
||||||
|
): MappingProperty {
|
||||||
// check if we have an object referencing a generic
|
// check if we have an object referencing a generic
|
||||||
if (generics.has(decl.name)) { // if the object name is the same as the generic name
|
if (generics.has(decl.name)) {
|
||||||
return readFieldTags(generics.get(decl.name) as ElasticsearchObject | ElasticsearchType, path, topTypeName,
|
// if the object name is the same as the generic name
|
||||||
decl.comment?.tags ?? []);
|
return readFieldTags(generics.get(decl.name)!, path, topTypeName, decl.comment?.tags ?? []);
|
||||||
// use the value defined by the generic
|
// use the value defined by the generic
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the actual handling process
|
// start the actual handling process
|
||||||
const out: ElasticsearchObject = {
|
const out: MappingProperty = {
|
||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {},
|
properties: {},
|
||||||
};
|
};
|
||||||
@@ -247,11 +275,13 @@ function handleDeclarationReflection(decl: DeclarationReflection,
|
|||||||
|
|
||||||
if (typeof decl.indexSignature.type !== 'undefined') {
|
if (typeof decl.indexSignature.type !== 'undefined') {
|
||||||
empty = false;
|
empty = false;
|
||||||
const template: ElasticsearchDynamicTemplate = {};
|
const template: Record<string, MappingDynamicTemplate> = {};
|
||||||
template[decl.name] = {
|
template[decl.name] = {
|
||||||
mapping: handleType(
|
mapping: handleType(
|
||||||
decl.indexSignature.type,
|
decl.indexSignature.type,
|
||||||
new Map(generics), path, topTypeName,
|
new Map(generics),
|
||||||
|
path,
|
||||||
|
topTypeName,
|
||||||
getCommentTags(decl.indexSignature, path, topTypeName),
|
getCommentTags(decl.indexSignature, path, topTypeName),
|
||||||
),
|
),
|
||||||
match: '*',
|
match: '*',
|
||||||
@@ -270,21 +300,31 @@ function handleDeclarationReflection(decl: DeclarationReflection,
|
|||||||
if (typeof decl.children !== 'undefined' && decl.children.length > 0) {
|
if (typeof decl.children !== 'undefined' && decl.children.length > 0) {
|
||||||
for (const child of decl.children) {
|
for (const child of decl.children) {
|
||||||
empty = false;
|
empty = false;
|
||||||
out.properties[child.name] =
|
out.properties![child.name] = handleDeclarationReflection(
|
||||||
handleDeclarationReflection(child, new Map(generics), `${path}${child.name}.`, topTypeName);
|
child,
|
||||||
|
new Map(generics),
|
||||||
|
`${path}${child.name}.`,
|
||||||
|
topTypeName,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else if (decl.type instanceof Type) { // if the object is a type, so we are dealing with a PROPERTY
|
} else if (decl.type instanceof Type) {
|
||||||
|
// if the object is a type, so we are dealing with a PROPERTY
|
||||||
// get inherited tags
|
// get inherited tags
|
||||||
const tags = (inheritedTags ?? []).length > 0
|
const tags =
|
||||||
? (typeof inheritedTags!.find(it => isTagType(it.tagName)) !== 'undefined'
|
(inheritedTags ?? []).length > 0
|
||||||
? inheritedTags!
|
? typeof inheritedTags!.find(it => isTagType(it.tagName)) !== 'undefined'
|
||||||
: [...inheritedTags ?? [], ...getCommentTags(decl, path, topTypeName)])
|
? inheritedTags!
|
||||||
: getCommentTags(decl, path, topTypeName);
|
: [...(inheritedTags ?? []), ...getCommentTags(decl, path, topTypeName)]
|
||||||
|
: getCommentTags(decl, path, topTypeName);
|
||||||
|
|
||||||
return handleType(decl.type, new Map(generics), path, topTypeName, tags);
|
return handleType(decl.type, new Map(generics), path, topTypeName, tags);
|
||||||
} else if (decl.kindString === 'Enumeration member') {
|
} else if (decl.kindString === 'Enumeration member') {
|
||||||
return readTypeTags(typeof decl.defaultValue, path, topTypeName,
|
return readTypeTags(
|
||||||
getCommentTags(decl, path, topTypeName, inheritedTags));
|
typeof decl.defaultValue,
|
||||||
|
path,
|
||||||
|
topTypeName,
|
||||||
|
getCommentTags(decl, path, topTypeName, inheritedTags),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty) {
|
if (empty) {
|
||||||
@@ -315,19 +355,33 @@ function getCommentTags(
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
let out: CommentTag[] = decl.comment instanceof Comment ?
|
let out: CommentTag[] =
|
||||||
typeof decl.comment.tags !== 'undefined' ? decl.comment.tags : inheritedTags : inheritedTags;
|
decl.comment instanceof Comment
|
||||||
if (decl.overwrites instanceof ReferenceType && decl.overwrites.reflection instanceof DeclarationReflection) {
|
? typeof decl.comment.tags !== 'undefined'
|
||||||
|
? decl.comment.tags
|
||||||
|
: inheritedTags
|
||||||
|
: inheritedTags;
|
||||||
|
if (
|
||||||
|
decl.overwrites instanceof ReferenceType &&
|
||||||
|
decl.overwrites.reflection instanceof DeclarationReflection
|
||||||
|
) {
|
||||||
out = arrayPriorityJoin(
|
out = arrayPriorityJoin(
|
||||||
getCommentTags(decl.overwrites.reflection, path, topTypeName, inheritedTags, decl.id), out);
|
getCommentTags(decl.overwrites.reflection, path, topTypeName, inheritedTags, decl.id),
|
||||||
|
out,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (decl.inheritedFrom instanceof ReferenceType && decl.inheritedFrom.reflection instanceof DeclarationReflection) {
|
if (
|
||||||
|
decl.inheritedFrom instanceof ReferenceType &&
|
||||||
|
decl.inheritedFrom.reflection instanceof DeclarationReflection
|
||||||
|
) {
|
||||||
out = arrayPriorityJoin(
|
out = arrayPriorityJoin(
|
||||||
getCommentTags(decl.inheritedFrom.reflection, path, topTypeName, inheritedTags, decl.id), out);
|
getCommentTags(decl.inheritedFrom.reflection, path, topTypeName, inheritedTags, decl.id),
|
||||||
|
out,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCommentTags(out, path, topTypeName);
|
saveCommentTags(out, path, topTypeName);
|
||||||
const inheritTag = out.find(((value) => value.tagName === inheritTagsName));
|
const inheritTag = out.find(value => value.tagName === inheritTagsName);
|
||||||
if (typeof inheritTag !== 'undefined') {
|
if (typeof inheritTag !== 'undefined') {
|
||||||
out = arrayPriorityJoin(out, retrieveCommentTags(inheritTag.text.trim(), path, topTypeName));
|
out = arrayPriorityJoin(out, retrieveCommentTags(inheritTag.text.trim(), path, topTypeName));
|
||||||
}
|
}
|
||||||
@@ -343,8 +397,9 @@ function getCommentTags(
|
|||||||
* @param topTypeName the name of the SCThingType
|
* @param topTypeName the name of the SCThingType
|
||||||
*/
|
*/
|
||||||
function saveCommentTags(tags: CommentTag[], path: string, topTypeName: string) {
|
function saveCommentTags(tags: CommentTag[], path: string, topTypeName: string) {
|
||||||
inheritTagsMap[`${topTypeName}::${path.substr(0, path.length - 1)}`] =
|
inheritTagsMap[`${topTypeName}::${path.slice(0, Math.max(0, path.length - 1))}`] = tags.filter(
|
||||||
tags.filter(((value) => value.tagName !== 'see' && value.tagName !== inheritTagsName));
|
value => value.tagName !== 'see' && value.tagName !== inheritTagsName,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -373,14 +428,14 @@ function retrieveCommentTags(path: string, currentPath: string, topTypeName: str
|
|||||||
function arrayPriorityJoin(originals: CommentTag[], overrider: CommentTag[]): CommentTag[] {
|
function arrayPriorityJoin(originals: CommentTag[], overrider: CommentTag[]): CommentTag[] {
|
||||||
const out: CommentTag[] = overrider;
|
const out: CommentTag[] = overrider;
|
||||||
|
|
||||||
originals.forEach((original) => {
|
for (const original of originals) {
|
||||||
const result = overrider.find((element) => original.tagName === element.tagName);
|
const result = overrider.find(element => original.tagName === element.tagName);
|
||||||
|
|
||||||
// no support for multiple tags with the same name
|
// no support for multiple tags with the same name
|
||||||
if (!(result instanceof CommentTag)) {
|
if (!(result instanceof CommentTag)) {
|
||||||
out.push(original);
|
out.push(original);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -397,12 +452,14 @@ function arrayPriorityJoin(originals: CommentTag[], overrider: CommentTag[]): Co
|
|||||||
* @param topTypeName the name of the SCThingType
|
* @param topTypeName the name of the SCThingType
|
||||||
* @param tags any tags attached to the type
|
* @param tags any tags attached to the type
|
||||||
*/
|
*/
|
||||||
function handleUnionType(type: UnionType,
|
function handleUnionType(
|
||||||
generics: Map<string, ElasticsearchValue>,
|
type: UnionType,
|
||||||
path: string,
|
generics: Map<string, MappingProperty>,
|
||||||
topTypeName: string,
|
path: string,
|
||||||
tags: CommentTag[]): ElasticsearchValue {
|
topTypeName: string,
|
||||||
const list: ElasticsearchValue[] = [];
|
tags: CommentTag[],
|
||||||
|
): MappingProperty {
|
||||||
|
const list: MappingProperty[] = [];
|
||||||
|
|
||||||
for (const subType of type.types) {
|
for (const subType of type.types) {
|
||||||
if (subType instanceof IntrinsicType && subType.name === 'undefined') {
|
if (subType instanceof IntrinsicType && subType.name === 'undefined') {
|
||||||
@@ -415,16 +472,21 @@ function handleUnionType(type: UnionType,
|
|||||||
let out = list[0];
|
let out = list[0];
|
||||||
|
|
||||||
for (const item of list) {
|
for (const item of list) {
|
||||||
out = merge<ElasticsearchValue>(out, item);
|
out = merge<MappingProperty>(out, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
composeErrorMessage(path, topTypeName, 'Union Type', stringify(list),
|
composeErrorMessage(
|
||||||
'Empty union type. This is likely not a user error.');
|
path,
|
||||||
|
topTypeName,
|
||||||
|
'Union Type',
|
||||||
|
stringify(list),
|
||||||
|
'Empty union type. This is likely not a user error.',
|
||||||
|
);
|
||||||
|
|
||||||
return {type: ElasticsearchDataType.parse_error};
|
return {type: PARSE_ERROR};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -436,37 +498,50 @@ function handleUnionType(type: UnionType,
|
|||||||
* @param topTypeName the name of the SCThingType
|
* @param topTypeName the name of the SCThingType
|
||||||
* @param tags any tags attached to the type
|
* @param tags any tags attached to the type
|
||||||
*/
|
*/
|
||||||
function handleType(type: Type, generics: Map<string, ElasticsearchValue>, path: string, topTypeName: string,
|
function handleType(
|
||||||
tags: CommentTag[]):
|
type: Type,
|
||||||
ElasticsearchValue {
|
generics: Map<string, MappingProperty>,
|
||||||
|
path: string,
|
||||||
|
topTypeName: string,
|
||||||
|
tags: CommentTag[],
|
||||||
|
): MappingProperty {
|
||||||
// logger.log((type as any).name);
|
// logger.log((type as any).name);
|
||||||
if (type instanceof ArrayType) { // array is irrelevant in Elasticsearch, so just go with the element type
|
if (type instanceof ArrayType) {
|
||||||
|
// array is irrelevant in Elasticsearch, so just go with the element type
|
||||||
const esType = handleType(type.elementType, new Map(generics), path, topTypeName, tags);
|
const esType = handleType(type.elementType, new Map(generics), path, topTypeName, tags);
|
||||||
// also merge tags of the array to the element type
|
// also merge tags of the array to the element type
|
||||||
// filter out the type tags lazily, this can lead to double messages for "Not implemented tag"
|
// filter out the type tags lazily, this can lead to double messages for "Not implemented tag"
|
||||||
let newTags = tags;
|
let newTags = tags;
|
||||||
if ('type' in esType) {
|
if ('type' in esType) {
|
||||||
newTags = tags.filter((tag) => {
|
newTags = tags.filter(tag => {
|
||||||
return !(tag.tagName === esType.type);
|
return !(tag.tagName === esType.type);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return readFieldTags(esType, path, topTypeName, newTags);
|
return readFieldTags(esType, path, topTypeName, newTags);
|
||||||
}
|
}
|
||||||
if (type.type === 'stringLiteral') { // a string literal, usually for type
|
if (type.type === 'stringLiteral') {
|
||||||
|
// a string literal, usually for type
|
||||||
return readTypeTags(type.type, path, topTypeName, tags);
|
return readTypeTags(type.type, path, topTypeName, tags);
|
||||||
}
|
}
|
||||||
if (type instanceof IntrinsicType) { // the absolute default type, like strings
|
if (type instanceof IntrinsicType) {
|
||||||
|
// the absolute default type, like strings
|
||||||
return readTypeTags(type.name, path, topTypeName, tags);
|
return readTypeTags(type.name, path, topTypeName, tags);
|
||||||
}
|
}
|
||||||
if (type instanceof UnionType) { // the union type...
|
if (type instanceof UnionType) {
|
||||||
|
// the union type...
|
||||||
return handleUnionType(type, new Map(generics), path, topTypeName, tags);
|
return handleUnionType(type, new Map(generics), path, topTypeName, tags);
|
||||||
}
|
}
|
||||||
if (type instanceof ReferenceType) {
|
if (type instanceof ReferenceType) {
|
||||||
if (typeof premaps[type.name] === 'undefined' && 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.
|
// there is really no way to make this typesafe, every element in DeclarationReflection is optional.
|
||||||
return handleDeclarationReflection(type.reflection as DeclarationReflection,
|
return handleDeclarationReflection(
|
||||||
getReflectionGeneric(type, new Map(generics), path, topTypeName, tags), path, topTypeName, tags);
|
type.reflection as DeclarationReflection,
|
||||||
|
getReflectionGeneric(type, new Map(generics), path, topTypeName, tags),
|
||||||
|
path,
|
||||||
|
topTypeName,
|
||||||
|
tags,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleExternalType(type, new Map(generics), path, topTypeName, tags);
|
return handleExternalType(type, new Map(generics), path, topTypeName, tags);
|
||||||
@@ -474,21 +549,24 @@ function handleType(type: Type, generics: Map<string, ElasticsearchValue>, path:
|
|||||||
if (type instanceof TypeParameterType) {
|
if (type instanceof TypeParameterType) {
|
||||||
// check if we have an object referencing a generic
|
// check if we have an object referencing a generic
|
||||||
if (generics.has(type.name)) {
|
if (generics.has(type.name)) {
|
||||||
return generics.get(type.name) as ElasticsearchObject | ElasticsearchType;
|
return generics.get(type.name)!;
|
||||||
}
|
}
|
||||||
composeErrorMessage(path, topTypeName, 'Generic', type.name, 'Missing reflection, please report!');
|
composeErrorMessage(path, topTypeName, 'Generic', type.name, 'Missing reflection, please report!');
|
||||||
|
|
||||||
return {type: ElasticsearchDataType.parse_error};
|
return {type: PARSE_ERROR};
|
||||||
|
|
||||||
}
|
}
|
||||||
if (type instanceof ReflectionType) {
|
if (type instanceof ReflectionType) {
|
||||||
return readFieldTags(handleDeclarationReflection(type.declaration, new Map(generics), path, topTypeName),
|
return readFieldTags(
|
||||||
path, topTypeName, tags);
|
handleDeclarationReflection(type.declaration, new Map(generics), path, topTypeName),
|
||||||
|
path,
|
||||||
|
topTypeName,
|
||||||
|
tags,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
composeErrorMessage(path, topTypeName, 'type', stringify(type), 'Not implemented type');
|
composeErrorMessage(path, topTypeName, 'type', stringify(type), 'Not implemented type');
|
||||||
|
|
||||||
return {type: ElasticsearchDataType.parse_error};
|
return {type: PARSE_ERROR};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -502,43 +580,42 @@ function addAggregatable(path: string, topTypeName: string, global: boolean) {
|
|||||||
// push type.path and remove the '.' at the end of the path
|
// push type.path and remove the '.' at the end of the path
|
||||||
|
|
||||||
if (global) {
|
if (global) {
|
||||||
const prop = path.slice(0, -1)
|
const property_ = path.slice(0, -1).split('.').pop() as string; // cannot be undefined
|
||||||
.split('.')
|
|
||||||
.pop() as string; // cannot be undefined
|
|
||||||
|
|
||||||
return (aggregations['@all'] as ESNestedAggregation).aggs[prop.split('.')
|
return ((aggregations['@all'] as ESNestedAggregation).aggs[property_.split('.').pop() as string] = {
|
||||||
.pop() as string] = {
|
|
||||||
terms: {
|
terms: {
|
||||||
field: `${prop}.raw`,
|
field: `${property_}.raw`,
|
||||||
size: 1000,
|
size: 1000,
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const property = path.slice(0, -1);
|
const property = path.slice(0, -1);
|
||||||
|
|
||||||
return (aggregations[topTypeName] as ESNestedAggregation).aggs[property] = {
|
return ((aggregations[topTypeName] as ESNestedAggregation).aggs[property] = {
|
||||||
terms: {
|
terms: {
|
||||||
field: `${property}.raw`,
|
field: `${property}.raw`,
|
||||||
size: 1000,
|
size: 1000,
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads all tags related to Elasticsearch fields from the fieldMap
|
* Reads all tags related to Elasticsearch fields from the fieldMap
|
||||||
*
|
*
|
||||||
* @param prev the previous ElasticsearchValue, for example and object
|
* @param previous the previous ElasticsearchValue, for example and object
|
||||||
* @param path the current path to the object we are in
|
* @param path the current path to the object we are in
|
||||||
* @param topTypeName the name of the SCThingType
|
* @param topTypeName the name of the SCThingType
|
||||||
* @param tags tags attached to the value
|
* @param tags tags attached to the value
|
||||||
* @param dataType the ElasticsearchDataType, for checking if a tag is a type tag
|
* @param dataType the ElasticsearchDataType, for checking if a tag is a type tag
|
||||||
*/
|
*/
|
||||||
function readFieldTags(prev: ElasticsearchValue,
|
function readFieldTags(
|
||||||
path: string,
|
previous: MappingProperty,
|
||||||
topTypeName: string,
|
path: string,
|
||||||
tags: CommentTag[],
|
topTypeName: string,
|
||||||
dataType?: string): ElasticsearchValue {
|
tags: CommentTag[],
|
||||||
|
dataType?: string,
|
||||||
|
): MappingProperty {
|
||||||
for (const tag of tags) {
|
for (const tag of tags) {
|
||||||
if (tag.tagName === aggregatableTag) {
|
if (tag.tagName === aggregatableTag) {
|
||||||
addAggregatable(path, topTypeName, tag.text.trim() === aggregatableTagParameterGlobal);
|
addAggregatable(path, topTypeName, tag.text.trim() === aggregatableTagParameterGlobal);
|
||||||
@@ -546,31 +623,43 @@ function readFieldTags(prev: ElasticsearchValue,
|
|||||||
|
|
||||||
if (!ignoredTagsList.includes(tag.tagName)) {
|
if (!ignoredTagsList.includes(tag.tagName)) {
|
||||||
if (typeof fieldmap[tag.tagName] !== 'undefined') {
|
if (typeof fieldmap[tag.tagName] !== 'undefined') {
|
||||||
if (typeof prev.fields === 'undefined') {
|
if (typeof previous.fields === 'undefined') {
|
||||||
// create in case it doesn't exist
|
// create in case it doesn't exist
|
||||||
prev.fields = {};
|
previous.fields = {};
|
||||||
}
|
}
|
||||||
if (tag.text.trim() === '') {
|
if (tag.text.trim() === '') {
|
||||||
// merge fields
|
// merge fields
|
||||||
prev.fields = {...prev.fields, ...fieldmap[tag.tagName].default};
|
previous.fields = {...previous.fields, ...fieldmap[tag.tagName].default};
|
||||||
} else if (typeof fieldmap[tag.tagName][tag.text.trim()] !== 'undefined') {
|
} else if (typeof fieldmap[tag.tagName][tag.text.trim()] !== 'undefined') {
|
||||||
// merge fields
|
// merge fields
|
||||||
prev.fields = {...prev.fields, ...fieldmap[tag.tagName][tag.text.trim()]};
|
previous.fields = {...previous.fields, ...fieldmap[tag.tagName][tag.text.trim()]};
|
||||||
} else if (!fieldmap[tag.tagName].ignore.includes(tag.text.trim())) {
|
} else if (!fieldmap[tag.tagName].ignore.includes(tag.text.trim())) {
|
||||||
// when there is an unidentified tag
|
// when there is an unidentified tag
|
||||||
composeErrorMessage(path, topTypeName, 'tag', tag.tagName, `Not implemented tag param "${tag.text.trim()}"`);
|
composeErrorMessage(
|
||||||
|
path,
|
||||||
|
topTypeName,
|
||||||
|
'tag',
|
||||||
|
tag.tagName,
|
||||||
|
`Not implemented tag param "${tag.text.trim()}"`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else if (tag.tagName === filterableTagName) {
|
} else if (tag.tagName === filterableTagName) {
|
||||||
if (typeof prev.fields === 'undefined') {
|
if (typeof previous.fields === 'undefined') {
|
||||||
prev.fields = {};
|
previous.fields = {};
|
||||||
}
|
}
|
||||||
if ('type' in prev) {
|
if ('type' in previous) {
|
||||||
const type = filterableMap[prev.type];
|
const type = filterableMap[previous.type!];
|
||||||
if (typeof type !== 'undefined') {
|
if (typeof type !== 'undefined') {
|
||||||
// merge fields
|
// merge fields
|
||||||
prev.fields = {...prev.fields, ...{raw: {type: type}}};
|
previous.fields = {...previous.fields, raw: {type: type}};
|
||||||
} else {
|
} else {
|
||||||
composeErrorMessage(path, topTypeName, 'tag', tag.tagName, `Not implemented for ${prev.type}`);
|
composeErrorMessage(
|
||||||
|
path,
|
||||||
|
topTypeName,
|
||||||
|
'tag',
|
||||||
|
tag.tagName,
|
||||||
|
`Not implemented for ${previous.type}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
composeErrorMessage(path, topTypeName, 'tag', tag.tagName, 'Not applicable for object types');
|
composeErrorMessage(path, topTypeName, 'tag', tag.tagName, 'Not applicable for object types');
|
||||||
@@ -581,7 +670,7 @@ function readFieldTags(prev: ElasticsearchValue,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return prev;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -592,32 +681,44 @@ function readFieldTags(prev: ElasticsearchValue,
|
|||||||
* @param topTypeName the name of the SCThingType
|
* @param topTypeName the name of the SCThingType
|
||||||
* @param tags tags attached to the value
|
* @param tags tags attached to the value
|
||||||
*/
|
*/
|
||||||
function readTypeTags(type: string, path: string, topTypeName: string, tags: CommentTag[]): ElasticsearchValue {
|
function readTypeTags(type: string, path: string, topTypeName: string, tags: CommentTag[]): MappingProperty {
|
||||||
let out: ElasticsearchValue = {type: ElasticsearchDataType.parse_error};
|
let out: MappingProperty = {type: PARSE_ERROR};
|
||||||
|
|
||||||
if (typeof typemap[type] !== 'undefined') { // first look if the value has a definition in the typemap
|
if (typeof typemap[type] !== 'undefined') {
|
||||||
|
// first look if the value has a definition in the typemap
|
||||||
for (let i = tags.length - 1; i >= 0; i--) {
|
for (let i = tags.length - 1; i >= 0; i--) {
|
||||||
if (!ignoredTagsList.includes(tags[i].tagName) && typeof typemap[type][tags[i].tagName] !== 'undefined') {
|
if (
|
||||||
|
!ignoredTagsList.includes(tags[i].tagName) &&
|
||||||
|
typeof typemap[type][tags[i].tagName] !== 'undefined'
|
||||||
|
) {
|
||||||
// if we have a tag that indicates a type
|
// if we have a tag that indicates a type
|
||||||
if (out.type !== ElasticsearchDataType.parse_error) {
|
if (out.type !== PARSE_ERROR) {
|
||||||
composeErrorMessage(path, topTypeName, 'type', type,
|
composeErrorMessage(
|
||||||
`Type conflict; "${typemap[type][tags[i].tagName]}" would override "${out.type}"`);
|
path,
|
||||||
out.type = ElasticsearchDataType.type_conflict;
|
topTypeName,
|
||||||
|
'type',
|
||||||
|
type,
|
||||||
|
`Type conflict; "${typemap[type][tags[i].tagName]}" would override "${
|
||||||
|
(out as MappingProperty).type
|
||||||
|
}"`,
|
||||||
|
);
|
||||||
|
(out as MappingProperty).type = TYPE_CONFLICT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
out.type = typemap[type][tags[i].tagName];
|
(out as MappingProperty).type = typemap[type][tags[i].tagName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out.type === ElasticsearchDataType.parse_error) {
|
if (out.type === PARSE_ERROR) {
|
||||||
out.type = typemap[type].default;
|
(out as MappingProperty).type = typemap[type].default;
|
||||||
}
|
}
|
||||||
|
|
||||||
out = readFieldTags(out, path, topTypeName, tags, type);
|
out = readFieldTags(out, path, topTypeName, tags, type);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
if (dynamicTypes.includes(type)) { // Elasticsearch dynamic type TODO: doesn't work for direct types
|
if (dynamicTypes.includes(type)) {
|
||||||
|
// Elasticsearch dynamic type TODO: doesn't work for direct types
|
||||||
return {
|
return {
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
properties: {},
|
properties: {},
|
||||||
@@ -666,15 +767,18 @@ function reset(resetInheritTags = true) {
|
|||||||
* @param showErrorOutput whether to print all errors in the command line or not
|
* @param showErrorOutput whether to print all errors in the command line or not
|
||||||
* @param interfaceFilter only parse specific interfaces, this is for testing purposes
|
* @param interfaceFilter only parse specific interfaces, this is for testing purposes
|
||||||
*/
|
*/
|
||||||
export function generateTemplate(projectReflection: ProjectReflection,
|
export function generateTemplate(
|
||||||
ignoredTags: string[],
|
projectReflection: ProjectReflection,
|
||||||
showErrorOutput = true,
|
ignoredTags: string[],
|
||||||
interfaceFilter: string[] = []): MappingGenTemplate {
|
showErrorOutput = true,
|
||||||
|
interfaceFilter: string[] = [],
|
||||||
|
): MappingGenTemplate {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
showErrors = showErrorOutput;
|
showErrors = showErrorOutput;
|
||||||
|
|
||||||
ignoredTagsList = ['indexable', 'validatable', inheritTagsName];
|
ignoredTagsList = ['indexable', 'validatable', inheritTagsName];
|
||||||
|
// eslint-disable-next-line prefer-spread
|
||||||
ignoredTagsList.push.apply(ignoredTagsList, ignoredTags);
|
ignoredTagsList.push.apply(ignoredTagsList, ignoredTags);
|
||||||
|
|
||||||
const indexableInterfaces = getAllIndexableInterfaces(projectReflection);
|
const indexableInterfaces = getAllIndexableInterfaces(projectReflection);
|
||||||
@@ -687,37 +791,42 @@ export function generateTemplate(projectReflection: ProjectReflection,
|
|||||||
throw new Error('Interface needs at least some properties to be indexable');
|
throw new Error('Interface needs at least some properties to be indexable');
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeObject = _interface.children.find((declarationReflection) => {
|
const typeObject = _interface.children.find(declarationReflection => {
|
||||||
return declarationReflection.name === 'type';
|
return declarationReflection.name === 'type';
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof typeObject === 'undefined' || typeof typeObject.type === 'undefined') {
|
if (typeof typeObject === 'undefined' || typeof typeObject.type === 'undefined') {
|
||||||
throw new Error('Interface needs a type to be indexable');
|
throw new TypeError('Interface needs a type to be indexable');
|
||||||
}
|
}
|
||||||
|
|
||||||
let typeName = 'INVALID_TYPE';
|
let typeName = 'INVALID_TYPE';
|
||||||
if (typeObject.type instanceof ReferenceType) {
|
if (typeObject.type instanceof ReferenceType) {
|
||||||
if (typeObject.type.reflection instanceof DeclarationReflection
|
if (
|
||||||
&& typeof typeObject.type.reflection.defaultValue === 'string') {
|
typeObject.type.reflection instanceof DeclarationReflection &&
|
||||||
typeName = typeObject.type.reflection.defaultValue.replace('"', '')
|
typeof typeObject.type.reflection.defaultValue === 'string'
|
||||||
.replace('"', '');
|
) {
|
||||||
|
typeName = typeObject.type.reflection.defaultValue.replace('"', '').replace('"', '');
|
||||||
} else {
|
} else {
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// tslint:disable-next-line:no-floating-promises
|
||||||
void Logger.error('Your input files seem to be incorrect, or there is a major bug in the mapping generator.');
|
void Logger.error(
|
||||||
|
'Your input files seem to be incorrect, or there is a major bug in the mapping generator.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else if (typeObject.type instanceof StringLiteralType) {
|
} else if (typeObject.type instanceof StringLiteralType) {
|
||||||
Logger.warn(`The interface ${_interface.name} uses a string literal as type, please use SCThingType.`);
|
Logger.warn(`The interface ${_interface.name} uses a string literal as type, please use SCThingType.`);
|
||||||
typeName = typeObject.type.value;
|
typeName = typeObject.type.value;
|
||||||
} else {
|
} else {
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// tslint:disable-next-line:no-floating-promises
|
||||||
void Logger.error(`The interface ${_interface.name} is required to use an SCThingType as a type, please do so.`);
|
void Logger.error(
|
||||||
|
`The interface ${_interface.name} is required to use an SCThingType as a type, please do so.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// init aggregation schema for type
|
// init aggregation schema for type
|
||||||
aggregations[typeName] = {
|
aggregations[typeName] = {
|
||||||
aggs: {},
|
aggs: {},
|
||||||
filter: {
|
filter: {
|
||||||
type: {
|
term: {
|
||||||
value: typeName,
|
type: typeName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -732,45 +841,48 @@ export function generateTemplate(projectReflection: ProjectReflection,
|
|||||||
throw new Error('Interface needs at least some properties to be indexable');
|
throw new Error('Interface needs at least some properties to be indexable');
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeObject = _interface.children.find((declarationReflection) => {
|
const typeObject = _interface.children.find(declarationReflection => {
|
||||||
return declarationReflection.name === 'type';
|
return declarationReflection.name === 'type';
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof typeObject === 'undefined' || typeof typeObject.type === 'undefined') {
|
if (typeof typeObject === 'undefined' || typeof typeObject.type === 'undefined') {
|
||||||
throw new Error('Interface needs a type to be indexable');
|
throw new TypeError('Interface needs a type to be indexable');
|
||||||
}
|
}
|
||||||
|
|
||||||
let typeName = 'INVALID_TYPE';
|
let typeName = 'INVALID_TYPE';
|
||||||
if (typeObject.type instanceof ReferenceType) {
|
if (typeObject.type instanceof ReferenceType) {
|
||||||
if (typeObject.type.reflection instanceof DeclarationReflection
|
if (
|
||||||
&& typeof typeObject.type.reflection.defaultValue === 'string') {
|
typeObject.type.reflection instanceof DeclarationReflection &&
|
||||||
typeName = typeObject.type.reflection.defaultValue.replace('"', '')
|
typeof typeObject.type.reflection.defaultValue === 'string'
|
||||||
.replace('"', '');
|
) {
|
||||||
|
typeName = typeObject.type.reflection.defaultValue.replace('"', '').replace('"', '');
|
||||||
} else {
|
} else {
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// tslint:disable-next-line:no-floating-promises
|
||||||
void Logger.error('Your input files seem to be incorrect, or there is a major bug in the mapping generator.');
|
void Logger.error(
|
||||||
|
'Your input files seem to be incorrect, or there is a major bug in the mapping generator.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else if (typeObject.type instanceof StringLiteralType) {
|
} else if (typeObject.type instanceof StringLiteralType) {
|
||||||
Logger.warn(`The interface ${_interface.name} uses a string literal as type, please use SCThingType.`);
|
Logger.warn(`The interface ${_interface.name} uses a string literal as type, please use SCThingType.`);
|
||||||
typeName = typeObject.type.value;
|
typeName = typeObject.type.value;
|
||||||
} else {
|
} else {
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// tslint:disable-next-line:no-floating-promises
|
||||||
void Logger.error(`The interface ${_interface.name} is required to use an SCThingType as a type, please do so.`);
|
void Logger.error(
|
||||||
|
`The interface ${_interface.name} is required to use an SCThingType as a type, please do so.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter out
|
// filter out
|
||||||
if (interfaceFilter.length !== 0) {
|
if (interfaceFilter.length > 0 && typeof interfaceFilter.find(it => it === typeName) === 'undefined') {
|
||||||
if (typeof interfaceFilter.find((it) => it === typeName) === 'undefined') {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// init aggregation schema for type
|
// init aggregation schema for type
|
||||||
aggregations[typeName] = {
|
aggregations[typeName] = {
|
||||||
aggs: {},
|
aggs: {},
|
||||||
filter: {
|
filter: {
|
||||||
type: {
|
term: {
|
||||||
value: typeName,
|
type: typeName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -782,26 +894,21 @@ export function generateTemplate(projectReflection: ProjectReflection,
|
|||||||
const templateName = `template_${typeNameWithoutSpaces}`;
|
const templateName = `template_${typeNameWithoutSpaces}`;
|
||||||
|
|
||||||
out[templateName] = {
|
out[templateName] = {
|
||||||
mappings: {
|
mappings: handleDeclarationReflection(_interface, new Map(), '', typeName) as MappingObjectProperty,
|
||||||
[typeName]: handleDeclarationReflection(_interface, new Map(), '', typeName) as ElasticsearchObject,
|
|
||||||
},
|
|
||||||
settings: settings,
|
settings: settings,
|
||||||
template: `stapps_${typeNameWithoutSpaces}*`,
|
index_patterns: [`stapps_${typeNameWithoutSpaces}*`],
|
||||||
}
|
};
|
||||||
;
|
out[templateName].mappings!.properties!.creation_date = {
|
||||||
out[templateName].mappings[typeName].properties.creation_date = {
|
type: 'date',
|
||||||
type: ElasticsearchDataType.date,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
out[templateName].mappings[typeName].dynamic_templates = dynamicTemplates;
|
out[templateName].mappings!.dynamic_templates = dynamicTemplates;
|
||||||
|
|
||||||
// Set some properties
|
// Set some properties
|
||||||
out[templateName].mappings[typeName]._source = {
|
out[templateName].mappings!._source = {
|
||||||
excludes: [
|
excludes: ['creation_date'],
|
||||||
'creation_date',
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
out[templateName].mappings[typeName].date_detection = false;
|
out[templateName].mappings!.date_detection = false;
|
||||||
|
|
||||||
dynamicTemplates = [];
|
dynamicTemplates = [];
|
||||||
|
|
||||||
|
|||||||
@@ -15,36 +15,36 @@
|
|||||||
import {Logger} from '@openstapps/logger';
|
import {Logger} from '@openstapps/logger';
|
||||||
import {existsSync, PathLike} from 'fs';
|
import {existsSync, PathLike} from 'fs';
|
||||||
import {platform} from 'os';
|
import {platform} from 'os';
|
||||||
import {join, sep} from 'path';
|
import path from 'path';
|
||||||
import {Application, ProjectReflection} from 'typedoc';
|
import {Application, ProjectReflection} from 'typedoc';
|
||||||
import {ModuleKind, ScriptTarget} from 'typescript';
|
import {ModuleKind, ScriptTarget} from 'typescript';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a project reflection from a path
|
* Get a project reflection from a path
|
||||||
*
|
*
|
||||||
* @param srcPath Path to get reflection from
|
* @param sourcePath Path to get reflection from
|
||||||
* @param excludeExternals Exclude external dependencies
|
* @param excludeExternals Exclude external dependencies
|
||||||
*/
|
*/
|
||||||
export function getProjectReflection(srcPath: PathLike, excludeExternals = true): ProjectReflection {
|
export function getProjectReflection(sourcePath: PathLike, excludeExternals = true): ProjectReflection {
|
||||||
Logger.info(`Generating project reflection for ${srcPath.toString()}.`);
|
Logger.info(`Generating project reflection for ${sourcePath.toString()}.`);
|
||||||
|
|
||||||
const tsconfigPath = getTsconfigPath(srcPath.toString());
|
const tsconfigPath = getTsconfigPath(sourcePath.toString());
|
||||||
|
|
||||||
// initialize new Typedoc application
|
// initialize new Typedoc application
|
||||||
const app = new Application();
|
const app = new Application();
|
||||||
|
|
||||||
app.bootstrap({
|
app.bootstrap({
|
||||||
excludeExternals: excludeExternals,
|
excludeExternals: excludeExternals,
|
||||||
ignoreCompilerErrors: false, // TODO: true
|
ignoreCompilerErrors: true,
|
||||||
includeDeclarations: true,
|
includeDeclarations: true,
|
||||||
module: ModuleKind.CommonJS,
|
module: ModuleKind.CommonJS,
|
||||||
target: ScriptTarget.Latest,
|
target: ScriptTarget.Latest,
|
||||||
tsconfig: join(tsconfigPath, 'tsconfig.json'),
|
tsconfig: path.join(tsconfigPath, 'tsconfig.json'),
|
||||||
});
|
});
|
||||||
|
|
||||||
let inputFilePath = srcPath;
|
let inputFilePath = sourcePath;
|
||||||
if (inputFilePath === tsconfigPath) {
|
if (inputFilePath === tsconfigPath) {
|
||||||
inputFilePath = join(tsconfigPath, 'src');
|
inputFilePath = path.join(tsconfigPath, 'src');
|
||||||
}
|
}
|
||||||
|
|
||||||
// get input files
|
// get input files
|
||||||
@@ -54,7 +54,7 @@ export function getProjectReflection(srcPath: PathLike, excludeExternals = true)
|
|||||||
const result = app.convert(inputFiles);
|
const result = app.convert(inputFiles);
|
||||||
|
|
||||||
if (typeof result === 'undefined') {
|
if (typeof result === 'undefined') {
|
||||||
throw new Error('Project reflection could not be generated.');
|
throw new TypeError('Project reflection could not be generated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -69,12 +69,10 @@ export function getTsconfigPath(startPath: string): string {
|
|||||||
let tsconfigPath = startPath;
|
let tsconfigPath = startPath;
|
||||||
|
|
||||||
// see https://stackoverflow.com/questions/9652043/identifying-the-file-system-root-with-node-js
|
// see https://stackoverflow.com/questions/9652043/identifying-the-file-system-root-with-node-js
|
||||||
const root = (platform() === 'win32') ? process
|
const root = platform() === 'win32' ? process.cwd().split(path.sep)[0] : '/';
|
||||||
.cwd()
|
|
||||||
.split(sep)[0] : '/';
|
|
||||||
|
|
||||||
// repeat until a tsconfig.json is found
|
// repeat until a tsconfig.json is found
|
||||||
while (!existsSync(join(tsconfigPath, 'tsconfig.json'))) {
|
while (!existsSync(path.join(tsconfigPath, 'tsconfig.json'))) {
|
||||||
if (tsconfigPath === root) {
|
if (tsconfigPath === root) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Reached file system root ${root} while searching for 'tsconfig.json' in ${startPath}!`,
|
`Reached file system root ${root} while searching for 'tsconfig.json' in ${startPath}!`,
|
||||||
@@ -82,9 +80,9 @@ export function getTsconfigPath(startPath: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pop last directory
|
// pop last directory
|
||||||
const tsconfigPathParts = tsconfigPath.split(sep);
|
const tsconfigPathParts = tsconfigPath.split(path.sep);
|
||||||
tsconfigPathParts.pop();
|
tsconfigPathParts.pop();
|
||||||
tsconfigPath = tsconfigPathParts.join(sep);
|
tsconfigPath = tsconfigPathParts.join(path.sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.info(`Using 'tsconfig.json' from ${tsconfigPath}.`);
|
Logger.info(`Using 'tsconfig.json' from ${tsconfigPath}.`);
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019-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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An elasticsearch bucket aggregation
|
|
||||||
* @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations-bucket.html
|
|
||||||
*/
|
|
||||||
export interface AggregationSchema {
|
|
||||||
[aggregationName: string]: ESTermsFilter | ESNestedAggregation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An elasticsearch terms filter
|
|
||||||
*/
|
|
||||||
export interface ESTermsFilter {
|
|
||||||
/**
|
|
||||||
* Terms filter definition
|
|
||||||
*/
|
|
||||||
terms: {
|
|
||||||
/**
|
|
||||||
* Field to apply filter to
|
|
||||||
*/
|
|
||||||
field: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of results
|
|
||||||
*/
|
|
||||||
size?: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter that filters by name of the the field type
|
|
||||||
*/
|
|
||||||
export interface ESAggTypeFilter {
|
|
||||||
/**
|
|
||||||
* The type of the object to find
|
|
||||||
*/
|
|
||||||
type: {
|
|
||||||
/**
|
|
||||||
* The name of the type
|
|
||||||
*/
|
|
||||||
value: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter that matches everything
|
|
||||||
*/
|
|
||||||
export interface ESAggMatchAllFilter {
|
|
||||||
/**
|
|
||||||
* Filter that matches everything
|
|
||||||
*/
|
|
||||||
match_all: {};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* For nested aggregations
|
|
||||||
*/
|
|
||||||
export interface ESNestedAggregation {
|
|
||||||
/**
|
|
||||||
* Possible nested Aggregations
|
|
||||||
*/
|
|
||||||
aggs: AggregationSchema;
|
|
||||||
/**
|
|
||||||
* Possible filter for types
|
|
||||||
*/
|
|
||||||
filter: ESAggTypeFilter | ESAggMatchAllFilter;
|
|
||||||
}
|
|
||||||
345
packages/es-mapping-generator/src/types/mapping.d.ts
vendored
345
packages/es-mapping-generator/src/types/mapping.d.ts
vendored
@@ -1,345 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019-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 {ElasticsearchDataType} from '../config/typemap';
|
|
||||||
import {AggregationSchema} from './aggregation';
|
|
||||||
|
|
||||||
// tslint:disable:no-any
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Template output of the mapping generation
|
|
||||||
*/
|
|
||||||
export interface MappingGenTemplate {
|
|
||||||
/**
|
|
||||||
* All generated aggregations
|
|
||||||
*/
|
|
||||||
aggregations: AggregationSchema;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All errors that occurred
|
|
||||||
*/
|
|
||||||
errors: string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All mappings that were generated
|
|
||||||
*/
|
|
||||||
mappings: ElasticsearchTemplateCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ElasticsearchValue can be either a type or an object.
|
|
||||||
*
|
|
||||||
* Both are composed similarly, and can be the value of a property
|
|
||||||
* of an Elasticsearch Object.
|
|
||||||
*/
|
|
||||||
export type ElasticsearchValue = ElasticsearchType | ElasticsearchObject | ElasticsearchGeoShape;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Typemap is used to get the corresponding ElasticsearchDataType for a name provided by the ProjectReflection
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchTypemap {
|
|
||||||
/**
|
|
||||||
* The `stringLiteral` type must always be provided
|
|
||||||
*/
|
|
||||||
stringLiteral: {
|
|
||||||
/**
|
|
||||||
* The default can be chosen freely, but must be provided
|
|
||||||
*/
|
|
||||||
default: ElasticsearchDataType;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the JS type, so for `number` it would be number
|
|
||||||
*/
|
|
||||||
[name: string]: {
|
|
||||||
/**
|
|
||||||
* The default ElasticsearchDataType that should be used, if no tag or only not implemented tags are found
|
|
||||||
*/
|
|
||||||
default: ElasticsearchDataType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the tag, so for `@integer` it would be `integer`
|
|
||||||
*/
|
|
||||||
[name: string]: ElasticsearchDataType;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The representation of a `DynamicTemplate` in Elasticsearch
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/dynamic-templates.html
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchDynamicTemplate {
|
|
||||||
/**
|
|
||||||
* The name of the dynamicTemplate
|
|
||||||
*/
|
|
||||||
[name: string]: {
|
|
||||||
/**
|
|
||||||
* The mapping of the template
|
|
||||||
*/
|
|
||||||
mapping: ElasticsearchValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* With automatic mapping, we use `path_match` more or less out of convenience and because it is least error-prone
|
|
||||||
*
|
|
||||||
* This also means that match should match all ("*") interface names (because we provide the exact path of the
|
|
||||||
* interface)
|
|
||||||
*/
|
|
||||||
match: '*';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* With automatic mapping, we use `path_match` more or less out of convenience and because it is least error-prone
|
|
||||||
*
|
|
||||||
* This also means that match_mapping_type should match all ("*") names (because we provide the exact path of the
|
|
||||||
* interface)
|
|
||||||
*/
|
|
||||||
match_mapping_type: '*';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* With automatic mapping, we use `path_match` more or less out of convenience and because it is least error-prone
|
|
||||||
*/
|
|
||||||
path_match: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ElasticsearchFilterableMap {
|
|
||||||
[name: string]: ElasticsearchDataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Fieldmap contains all tag names for fields and the corresponding fields
|
|
||||||
*
|
|
||||||
* The Fieldmap works in a similar fashion to the Typemap
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchFieldmap {
|
|
||||||
/**
|
|
||||||
* The name of the tag, so for `@sortable` it would be `sortable`
|
|
||||||
*/
|
|
||||||
[name: string]: {
|
|
||||||
/**
|
|
||||||
* The default value if no parameter is provided
|
|
||||||
*/
|
|
||||||
default: {
|
|
||||||
/**
|
|
||||||
* To allow the usage of `prev.fields = {...prev.fields, ...fieldmap[tag.tagName].default}`
|
|
||||||
*
|
|
||||||
* We could also have used `default: any`, but this adds slightly more improved type-safety.
|
|
||||||
*/
|
|
||||||
[name: string]: any;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The tag parameters that will be ignored
|
|
||||||
*
|
|
||||||
* Some tag parameters might not be important for your implementation, so you can add their names here to not get
|
|
||||||
* any errors. The `default` will be used in that case.
|
|
||||||
*/
|
|
||||||
ignore: string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The parameters of the tag, so for `@sortable ducet` it would be `ducet`
|
|
||||||
*/
|
|
||||||
[name: string]: {
|
|
||||||
/**
|
|
||||||
* To allow the usage of `prev.fields = {...prev.fields, ...fieldmap[tag.tagName][tag.text.trim()]}`
|
|
||||||
*
|
|
||||||
* We could also have used `default: any`, but this adds slightly more improved type-safety.
|
|
||||||
*/
|
|
||||||
[name: string]: any;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A primitive data type
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping-types.html
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchType {
|
|
||||||
/**
|
|
||||||
* Fields for a type
|
|
||||||
*
|
|
||||||
* The fields are optional, they are used for things like sorting, which is not needed for every single type.
|
|
||||||
*/
|
|
||||||
fields?: {
|
|
||||||
[name: string]: any;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type as an ElasticsearchDataType
|
|
||||||
*/
|
|
||||||
type: ElasticsearchDataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A GeoShape data type
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/geo-shape.html
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchGeoShape {
|
|
||||||
/**
|
|
||||||
* Does not exist; here for TypeScript compiler
|
|
||||||
*/
|
|
||||||
fields?: undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This parameter may be used instead of tree_levels to set an appropriate value for the tree_levels parameter.
|
|
||||||
*
|
|
||||||
* The value specifies the desired precision and Elasticsearch will calculate the best tree_levels value to honor
|
|
||||||
* this precision. The value should be a number followed by an optional distance unit. Valid distance units include:
|
|
||||||
* in, inch, yd, yard, mi, miles, km, kilometers, m,meters, cm,centimeters, mm, millimeters.
|
|
||||||
*/
|
|
||||||
precision: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Name of the PrefixTree implementation to be used: geohash for GeohashPrefixTree and quadtree for QuadPrefixTree.
|
|
||||||
*/
|
|
||||||
tree: 'quadtree' | 'geohash';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of the object, obviously geo_shape
|
|
||||||
*/
|
|
||||||
type: ElasticsearchDataType.geo_shape;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An object data type
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/object.html
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchObject {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only for the top type
|
|
||||||
*/
|
|
||||||
_source?: {
|
|
||||||
/**
|
|
||||||
* Fields that should be excluded in the _source field
|
|
||||||
*/
|
|
||||||
excludes: [
|
|
||||||
'creation_date'
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the creation date should be set automatically
|
|
||||||
*/
|
|
||||||
date_detection?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the object is a dynamic
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/dynamic.html
|
|
||||||
* The default should be `'strict'`
|
|
||||||
*/
|
|
||||||
dynamic: true | false | 'strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dynamic_templates for an object
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/dynamic-templates.html
|
|
||||||
* This is a more complex topic, before touching this you should really know what you are doing.
|
|
||||||
*/
|
|
||||||
dynamic_templates?: ElasticsearchDynamicTemplate[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fields for a type
|
|
||||||
*
|
|
||||||
* The fields are optional, they are used for things like sorting, which is not needed for every single type.
|
|
||||||
*/
|
|
||||||
fields?: {
|
|
||||||
[name: string]: any;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Any properties of the object
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/properties.html
|
|
||||||
*/
|
|
||||||
properties: {
|
|
||||||
/**
|
|
||||||
* Each property can be any Elasticsearch value
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping-types.html
|
|
||||||
*/
|
|
||||||
[name: string]: ElasticsearchValue;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A collection of Elasticsearch Templates
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchTemplateCollection {
|
|
||||||
[indexName: string]: ElasticsearchTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An Elasticsearch template
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/mapping.html
|
|
||||||
* This is what you pass to Elasticsearch
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchTemplate {
|
|
||||||
/**
|
|
||||||
* This is a pre-defined structure you should use for your mapping
|
|
||||||
*/
|
|
||||||
mappings: {
|
|
||||||
[typeName: string]: ElasticsearchObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The settings for Elasticsearch
|
|
||||||
*/
|
|
||||||
settings: ElasticsearchSettings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the template, for referencing in Elasticsearch
|
|
||||||
*/
|
|
||||||
template: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A representation of ElasticsearchSettings used in Mappings
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchSettings {
|
|
||||||
/**
|
|
||||||
* The settings
|
|
||||||
*/
|
|
||||||
[name: string]: any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is where any analyzers go
|
|
||||||
*
|
|
||||||
* https://www.elastic.co/guide/en/elasticsearch/reference/5.6/analysis-analyzers.html
|
|
||||||
*/
|
|
||||||
analysis: {
|
|
||||||
[name: string]: any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A premap for a specific value in a ProjectReflection
|
|
||||||
*
|
|
||||||
* This is meant to be used for external types. To aid performance, you usually should not include external libs in the
|
|
||||||
* ProjectReflection. This means that there is no way the generator can generate a mapping for it, so you can use the
|
|
||||||
* premaps to map out a type manually.
|
|
||||||
*/
|
|
||||||
export interface ElasticsearchPremap {
|
|
||||||
/**
|
|
||||||
* The name of the type with the corresponding map
|
|
||||||
*
|
|
||||||
* So for `const a: B` the name would be `B`
|
|
||||||
*/
|
|
||||||
[name: string]: ElasticsearchValue;
|
|
||||||
}
|
|
||||||
119
packages/es-mapping-generator/src/types/mapping.ts
Normal file
119
packages/es-mapping-generator/src/types/mapping.ts
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
import {IndicesPutTemplateRequest, MappingProperty} from '@elastic/elasticsearch/lib/api/types';
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019-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 {AggregationSchema} from './aggregation';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template output of the mapping generation
|
||||||
|
*/
|
||||||
|
export interface MappingGenTemplate {
|
||||||
|
/**
|
||||||
|
* All generated aggregations
|
||||||
|
*/
|
||||||
|
aggregations: AggregationSchema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All errors that occurred
|
||||||
|
*/
|
||||||
|
errors: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All mappings that were generated
|
||||||
|
*/
|
||||||
|
mappings: ElasticsearchTemplateCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SimpleType = MappingProperty['type'] &
|
||||||
|
('keyword' | 'float' | 'boolean' | 'date' | 'integer' | 'text');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Typemap is used to get the corresponding ElasticsearchDataType for a name provided by the ProjectReflection
|
||||||
|
*/
|
||||||
|
export interface ElasticsearchTypemap {
|
||||||
|
/**
|
||||||
|
* The `stringLiteral` type must always be provided
|
||||||
|
*/
|
||||||
|
stringLiteral: {
|
||||||
|
/**
|
||||||
|
* The default can be chosen freely, but must be provided
|
||||||
|
*/
|
||||||
|
default: SimpleType;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the JS type, so for `number` it would be number
|
||||||
|
*/
|
||||||
|
[name: string]: {
|
||||||
|
/**
|
||||||
|
* The default ElasticsearchDataType that should be used, if no tag or only not implemented tags are found
|
||||||
|
*/
|
||||||
|
default: SimpleType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the tag, so for `@integer` it would be `integer`
|
||||||
|
*/
|
||||||
|
[name: string]: SimpleType;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Fieldmap contains all tag names for fields and the corresponding fields
|
||||||
|
*
|
||||||
|
* The Fieldmap works in a similar fashion to the Typemap
|
||||||
|
*/
|
||||||
|
export interface ElasticsearchFieldmap {
|
||||||
|
/**
|
||||||
|
* The name of the tag, so for `@sortable` it would be `sortable`
|
||||||
|
*/
|
||||||
|
[name: string]: {
|
||||||
|
/**
|
||||||
|
* The default value if no parameter is provided
|
||||||
|
*/
|
||||||
|
default: {
|
||||||
|
/**
|
||||||
|
* To allow the usage of `prev.fields = {...prev.fields, ...fieldmap[tag.tagName].default}`
|
||||||
|
*
|
||||||
|
* We could also have used `default: any`, but this adds slightly more improved type-safety.
|
||||||
|
*/
|
||||||
|
[name: string]: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tag parameters that will be ignored
|
||||||
|
*
|
||||||
|
* Some tag parameters might not be important for your implementation, so you can add their names here to not get
|
||||||
|
* any errors. The `default` will be used in that case.
|
||||||
|
*/
|
||||||
|
ignore: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parameters of the tag, so for `@sortable ducet` it would be `ducet`
|
||||||
|
*/
|
||||||
|
[name: string]: {
|
||||||
|
/**
|
||||||
|
* To allow the usage of `prev.fields = {...prev.fields, ...fieldmap[tag.tagName][tag.text.trim()]}`
|
||||||
|
*
|
||||||
|
* We could also have used `default: any`, but this adds slightly more improved type-safety.
|
||||||
|
*/
|
||||||
|
[name: string]: any;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection of Elasticsearch Templates
|
||||||
|
*/
|
||||||
|
export type ElasticsearchTemplateCollection = Record<string, Omit<IndicesPutTemplateRequest, 'name'>>;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable unicorn/consistent-function-scoping */
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 StApps
|
* Copyright (C) 2020 StApps
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
@@ -15,8 +16,8 @@
|
|||||||
import {Logger} from '@openstapps/logger';
|
import {Logger} from '@openstapps/logger';
|
||||||
import {readdirSync, statSync} from 'fs';
|
import {readdirSync, statSync} from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {MapAggTest} from './mapping-model/MapAggTest';
|
import {MapAggTest} from './mapping-model/map-agg-test';
|
||||||
import {MapAggTestOptions} from './mapping-model/MapAggTestOptions';
|
import {MapAggTestOptions} from './mapping-model/map-agg-test-options';
|
||||||
|
|
||||||
describe('ES Aggregation Gen', async () => {
|
describe('ES Aggregation Gen', async () => {
|
||||||
const magAppInstance = new MapAggTest('aggregations');
|
const magAppInstance = new MapAggTest('aggregations');
|
||||||
@@ -29,14 +30,20 @@ describe('ES Aggregation Gen', async () => {
|
|||||||
const directory = statSync(fullPath);
|
const directory = statSync(fullPath);
|
||||||
|
|
||||||
return directory.isDirectory()
|
return directory.isDirectory()
|
||||||
? ([] as string[]).concat(...readdirSync(fullPath).map(fragment =>
|
? // eslint-disable-next-line unicorn/prefer-spread
|
||||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
([] as string[]).concat(
|
||||||
))
|
...readdirSync(fullPath).map(fragment =>
|
||||||
|
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||||
|
),
|
||||||
|
)
|
||||||
: [fullPath].filter(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 {
|
try {
|
||||||
|
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||||
|
|
||||||
it(test.testName, function () {
|
it(test.testName, function () {
|
||||||
@@ -47,4 +54,6 @@ describe('ES Aggregation Gen', async () => {
|
|||||||
process.exit(1);
|
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 {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -23,7 +23,6 @@ export interface AggInheritedGlobal extends Foo {
|
|||||||
type: ThingType.AggInheritedGlobal;
|
type: ThingType.AggInheritedGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface Foo {
|
interface Foo {
|
||||||
/**
|
/**
|
||||||
* @aggregatable global
|
* @aggregatable global
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -28,7 +28,6 @@ export interface AggInherited extends Foo {
|
|||||||
type: ThingType.AggInheritedOverwritten;
|
type: ThingType.AggInheritedOverwritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface Foo {
|
interface Foo {
|
||||||
/**
|
/**
|
||||||
* @aggregatable
|
* @aggregatable
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -23,7 +23,6 @@ export interface AggInherited extends Foo {
|
|||||||
type: ThingType.AggInherited;
|
type: ThingType.AggInherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface Foo {
|
interface Foo {
|
||||||
/**
|
/**
|
||||||
* @aggregatable
|
* @aggregatable
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @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 {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
*/
|
*/
|
||||||
export interface AnyUnknown {
|
export interface AnyUnknown {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
foo: any;
|
foo: any;
|
||||||
|
|
||||||
bar: unknown;
|
bar: unknown;
|
||||||
|
|
||||||
type: ThingType.AnyUnknown
|
type: ThingType.AnyUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testConfig: MapAggTestOptions = {
|
export const testConfig: MapAggTestOptions = {
|
||||||
@@ -34,12 +35,12 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
properties: {}
|
properties: {},
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
properties: {}
|
properties: {},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,15 +12,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @date
|
* @date
|
||||||
*/
|
*/
|
||||||
export type SCISO8601Date = string
|
export type SCISO8601Date = string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -33,7 +31,7 @@ export interface DateAndRange {
|
|||||||
|
|
||||||
dateAlias: SCISO8601Date;
|
dateAlias: SCISO8601Date;
|
||||||
|
|
||||||
type: ThingType.Date
|
type: ThingType.Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testConfig: MapAggTestOptions = {
|
export const testConfig: MapAggTestOptions = {
|
||||||
@@ -42,11 +40,11 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
directDate: {
|
directDate: {
|
||||||
type: ElasticsearchDataType.date,
|
type: 'date',
|
||||||
},
|
},
|
||||||
dateAlias: {
|
dateAlias: {
|
||||||
type: ElasticsearchDataType.date,
|
type: 'date',
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {PARSE_ERROR} from '../../../../lib/config/typemap';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -39,13 +38,11 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.parse_error
|
type: PARSE_ERROR,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
err: [
|
err: [`At "${ThingType.DefaultGeneric}::foo.bar" for Generic "T": Missing reflection, please report!`],
|
||||||
`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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {TYPE_CONFLICT} from '../../../../lib/config/typemap';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -42,15 +41,15 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
stringDoubleTypeConflict: {
|
stringDoubleTypeConflict: {
|
||||||
type: ElasticsearchDataType.type_conflict
|
type: TYPE_CONFLICT,
|
||||||
},
|
},
|
||||||
numberDoubleTypeConflict: {
|
numberDoubleTypeConflict: {
|
||||||
type: ElasticsearchDataType.type_conflict
|
type: TYPE_CONFLICT,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
err: [
|
err: [
|
||||||
`At "${ThingType.DoubleTypeConflict}::stringDoubleTypeConflict" for type "string": Type conflict; "keyword" would override "text"`,
|
`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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
*/
|
*/
|
||||||
export interface Enum {
|
export interface Enum {
|
||||||
foo: Bar,
|
foo: Bar;
|
||||||
|
|
||||||
bar: Baz,
|
bar: Baz;
|
||||||
|
|
||||||
type: ThingType.Enum;
|
type: ThingType.Enum;
|
||||||
}
|
}
|
||||||
@@ -36,6 +34,7 @@ enum Bar {
|
|||||||
|
|
||||||
enum Baz {
|
enum Baz {
|
||||||
d = 'd',
|
d = 'd',
|
||||||
|
// eslint-disable-next-line unicorn/prevent-abbreviations
|
||||||
e = 'e',
|
e = 'e',
|
||||||
f = 'f',
|
f = 'f',
|
||||||
}
|
}
|
||||||
@@ -48,11 +47,11 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
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';
|
export type FilterableEnumType = 'a' | 'b' | 'c';
|
||||||
|
|
||||||
@@ -38,14 +36,14 @@ export interface FilterableTag {
|
|||||||
/**
|
/**
|
||||||
* @filterable
|
* @filterable
|
||||||
*/
|
*/
|
||||||
baz: 'some literal'
|
baz: 'some literal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @filterable
|
* @filterable
|
||||||
*/
|
*/
|
||||||
buz: FilterableEnumType
|
buz: FilterableEnumType;
|
||||||
|
|
||||||
type: ThingType.FilterableTag
|
type: ThingType.FilterableTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testConfig: MapAggTestOptions = {
|
export const testConfig: MapAggTestOptions = {
|
||||||
@@ -54,37 +52,37 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.text,
|
type: 'text',
|
||||||
fields: {
|
fields: {
|
||||||
raw: {
|
raw: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
fields: {
|
fields: {
|
||||||
raw: {
|
raw: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
baz: {
|
baz: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
fields: {
|
fields: {
|
||||||
raw: {
|
raw: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
buz: {
|
buz: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
fields: {
|
fields: {
|
||||||
raw: {
|
raw: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,17 +12,15 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
*/
|
*/
|
||||||
export interface Generics {
|
export interface Generics {
|
||||||
foo: InterfaceWithDefaultGeneric<number>;
|
foo: InterfaceWithDefaultGeneric<number>;
|
||||||
baz: InterfaceWithStringGeneric<string>
|
baz: InterfaceWithStringGeneric<string>;
|
||||||
|
|
||||||
type: ThingType.Generics;
|
type: ThingType.Generics;
|
||||||
}
|
}
|
||||||
@@ -44,18 +42,18 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
baz: {
|
baz: {
|
||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -23,7 +21,7 @@ import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|||||||
export interface ImpossibleUnion {
|
export interface ImpossibleUnion {
|
||||||
foo: 'a' | 1 | boolean;
|
foo: 'a' | 1 | boolean;
|
||||||
|
|
||||||
type: ThingType.ImpossibleUnion
|
type: ThingType.ImpossibleUnion;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testConfig: MapAggTestOptions = {
|
export const testConfig: MapAggTestOptions = {
|
||||||
@@ -32,11 +30,11 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.boolean
|
type: 'boolean',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
err: [
|
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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -41,7 +39,6 @@ export interface DoubleTypeConflict {
|
|||||||
*/
|
*/
|
||||||
floatString: string;
|
floatString: string;
|
||||||
|
|
||||||
|
|
||||||
type: ThingType.IncompatibleType;
|
type: ThingType.IncompatibleType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,23 +48,23 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
keywordNumber: {
|
keywordNumber: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
},
|
},
|
||||||
textNumber: {
|
textNumber: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
},
|
},
|
||||||
integerString: {
|
integerString: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
},
|
},
|
||||||
floatString: {
|
floatString: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
err: [
|
err: [
|
||||||
`At "${ThingType.IncompatibleType}::keywordNumber" for tag "keyword": Not implemented tag`,
|
`At "${ThingType.IncompatibleType}::keywordNumber" for tag "keyword": Not implemented tag`,
|
||||||
`At "${ThingType.IncompatibleType}::textNumber" for tag "text": 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}::floatString" for tag "float": Not implemented tag`,
|
||||||
`At "${ThingType.IncompatibleType}::integerString" for tag "integer": 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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -25,8 +23,8 @@ export interface IndexSignature {
|
|||||||
[key: string]: {
|
[key: string]: {
|
||||||
bar: number;
|
bar: number;
|
||||||
baz: string;
|
baz: string;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
type: ThingType.IndexSignature;
|
type: ThingType.IndexSignature;
|
||||||
}
|
}
|
||||||
@@ -38,8 +36,8 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
properties: {}
|
properties: {},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
dynamicTemplates: [
|
dynamicTemplates: [
|
||||||
{
|
{
|
||||||
@@ -48,18 +46,18 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
},
|
},
|
||||||
baz: {
|
baz: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
match: '*',
|
match: '*',
|
||||||
match_mapping_type: '*',
|
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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +34,7 @@ export interface InferredTypeFilterable {
|
|||||||
*/
|
*/
|
||||||
bar: SCISO8601Date;
|
bar: SCISO8601Date;
|
||||||
|
|
||||||
type: ThingType.InferredTypeFilterable
|
type: ThingType.InferredTypeFilterable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testConfig: MapAggTestOptions = {
|
export const testConfig: MapAggTestOptions = {
|
||||||
@@ -45,16 +43,16 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.date,
|
type: 'date',
|
||||||
fields: {
|
fields: {
|
||||||
raw: {
|
raw: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.date,
|
type: 'date',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,9 +12,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,14 +22,14 @@ export interface InheritTags {
|
|||||||
/**
|
/**
|
||||||
* @inheritTags inherit tags::bar.baz
|
* @inheritTags inherit tags::bar.baz
|
||||||
*/
|
*/
|
||||||
foo: number,
|
foo: number;
|
||||||
|
|
||||||
bar: {
|
bar: {
|
||||||
/**
|
/**
|
||||||
* @float
|
* @float
|
||||||
*/
|
*/
|
||||||
baz: number
|
baz: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
type: ThingType.InheritTags;
|
type: ThingType.InheritTags;
|
||||||
}
|
}
|
||||||
@@ -42,16 +40,16 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.float
|
type: 'float',
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
baz: {
|
baz: {
|
||||||
type: ElasticsearchDataType.float
|
type: 'float',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,16 +12,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
*/
|
*/
|
||||||
export interface InheritedProperty extends Bar{
|
export interface InheritedProperty extends Bar {
|
||||||
foo: number,
|
foo: number;
|
||||||
|
|
||||||
type: ThingType.InheritedProperty;
|
type: ThingType.InheritedProperty;
|
||||||
}
|
}
|
||||||
@@ -44,14 +42,14 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
baz: {
|
baz: {
|
||||||
type: ElasticsearchDataType.float
|
type: 'float',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable jsdoc/check-tag-names */
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 StApps
|
* Copyright (C) 2020 StApps
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* 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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -35,11 +34,9 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
err: [
|
err: [`At "${ThingType.InvalidTag}::foo" for tag "aninvalidtag": Not implemented tag`],
|
||||||
`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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -44,12 +42,12 @@ export interface MapExplicitTypes {
|
|||||||
/**
|
/**
|
||||||
* @date
|
* @date
|
||||||
*/
|
*/
|
||||||
esEpochMsDate: number
|
esEpochMsDate: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @date
|
* @date
|
||||||
*/
|
*/
|
||||||
esStringDate: string
|
esStringDate: string;
|
||||||
|
|
||||||
type: ThingType.MapExplicitTypes;
|
type: ThingType.MapExplicitTypes;
|
||||||
}
|
}
|
||||||
@@ -60,23 +58,23 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
esInteger: {
|
esInteger: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
},
|
},
|
||||||
esFloat: {
|
esFloat: {
|
||||||
type: ElasticsearchDataType.float
|
type: 'float',
|
||||||
},
|
},
|
||||||
esKeyword: {
|
esKeyword: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
esText: {
|
esText: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
},
|
},
|
||||||
esEpochMsDate: {
|
esEpochMsDate: {
|
||||||
type: ElasticsearchDataType.date
|
type: 'date',
|
||||||
},
|
},
|
||||||
esStringDate: {
|
esStringDate: {
|
||||||
type: ElasticsearchDataType.date
|
type: 'date',
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {MISSING_PREMAP} from '../../../../lib/config/typemap';
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -35,11 +34,9 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.missing_premap
|
type: MISSING_PREMAP,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
err: [
|
err: [`At "${ThingType.MissingPremap}::foo" for external type "HTMLAllCollection": Missing pre-map`],
|
||||||
`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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -29,10 +27,10 @@ export interface Nested {
|
|||||||
* @keyword
|
* @keyword
|
||||||
*/
|
*/
|
||||||
depth3_2: string;
|
depth3_2: string;
|
||||||
}
|
};
|
||||||
depth2_2: boolean;
|
depth2_2: boolean;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
type: ThingType.Nested;
|
type: ThingType.Nested;
|
||||||
}
|
}
|
||||||
@@ -52,20 +50,20 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
depth3_1: {
|
depth3_1: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
},
|
},
|
||||||
depth3_2: {
|
depth3_2: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
depth2_2: {
|
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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -23,7 +21,7 @@ import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|||||||
export interface ObjectUnion {
|
export interface ObjectUnion {
|
||||||
foo: Boo | Buu;
|
foo: Boo | Buu;
|
||||||
|
|
||||||
type: ThingType.ObjectUnion
|
type: ThingType.ObjectUnion;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can't name them Bar or Baz, look here for more info:
|
// we can't name them Bar or Baz, look here for more info:
|
||||||
@@ -49,16 +47,16 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
a: {
|
a: {
|
||||||
type: ElasticsearchDataType.boolean
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
b: {
|
b: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
},
|
},
|
||||||
intersection: {
|
intersection: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -43,26 +41,28 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
fields: {
|
fields: {
|
||||||
raw: {
|
raw: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.text,
|
type: 'text',
|
||||||
fields: {
|
fields: {
|
||||||
raw: {
|
raw: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
sort: {
|
sort: {
|
||||||
analyzer: 'ducet_sort',
|
country: 'DE',
|
||||||
fielddata: true,
|
language: 'de',
|
||||||
type: ElasticsearchDataType.text
|
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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -37,23 +35,23 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
numberDefault: {
|
numberDefault: {
|
||||||
type: ElasticsearchDataType.integer
|
type: 'integer',
|
||||||
},
|
},
|
||||||
stringDefault: {
|
stringDefault: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
},
|
},
|
||||||
booleanDefault: {
|
booleanDefault: {
|
||||||
type: ElasticsearchDataType.boolean
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
stringLiteralDefault: {
|
stringLiteralDefault: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
booleanTrueLiteralDefault: {
|
booleanTrueLiteralDefault: {
|
||||||
type: ElasticsearchDataType.boolean
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
booleanFalseLiteralDefault: {
|
booleanFalseLiteralDefault: {
|
||||||
type: ElasticsearchDataType.boolean
|
type: 'boolean',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -36,7 +34,7 @@ export interface SortableTag {
|
|||||||
*/
|
*/
|
||||||
baz: number;
|
baz: number;
|
||||||
|
|
||||||
type: ThingType.SortableTag
|
type: ThingType.SortableTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testConfig: MapAggTestOptions = {
|
export const testConfig: MapAggTestOptions = {
|
||||||
@@ -45,35 +43,41 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.text,
|
type: 'text',
|
||||||
fields: {
|
fields: {
|
||||||
sort: {
|
sort: {
|
||||||
analyzer: 'ducet_sort',
|
country: 'DE',
|
||||||
fielddata: true,
|
language: 'de',
|
||||||
type: 'text'
|
type: 'icu_collation_keyword',
|
||||||
}
|
variant: '@collation=phonebook',
|
||||||
}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
} as any,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
type: ElasticsearchDataType.text,
|
type: 'text',
|
||||||
fields: {
|
fields: {
|
||||||
sort: {
|
sort: {
|
||||||
analyzer: 'ducet_sort',
|
country: 'DE',
|
||||||
fielddata: true,
|
language: 'de',
|
||||||
type: 'text'
|
type: 'icu_collation_keyword',
|
||||||
}
|
variant: '@collation=phonebook',
|
||||||
}
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
} as any,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
baz: {
|
baz: {
|
||||||
type: ElasticsearchDataType.integer,
|
type: 'integer',
|
||||||
fields: {
|
fields: {
|
||||||
sort: {
|
sort: {
|
||||||
analyzer: 'ducet_sort',
|
country: 'DE',
|
||||||
fielddata: true,
|
language: 'de',
|
||||||
type: 'text'
|
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/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -23,19 +22,19 @@ export interface TagsIgnoreCase {
|
|||||||
/**
|
/**
|
||||||
* @inheritTags inherit tags::bar.baz
|
* @inheritTags inherit tags::bar.baz
|
||||||
*/
|
*/
|
||||||
camelCase: number,
|
camelCase: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inherittags inherit tags::bar.baz
|
* @inheritTags inherit tags::bar.baz
|
||||||
*/
|
*/
|
||||||
lowerCase: number,
|
lowerCase: number;
|
||||||
|
|
||||||
bar: {
|
bar: {
|
||||||
/**
|
/**
|
||||||
* @float
|
* @float
|
||||||
*/
|
*/
|
||||||
baz: number
|
baz: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
type: ThingType.TagsIgnoreCase;
|
type: ThingType.TagsIgnoreCase;
|
||||||
}
|
}
|
||||||
@@ -46,19 +45,19 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
camelCase: {
|
camelCase: {
|
||||||
type: ElasticsearchDataType.float
|
type: 'float',
|
||||||
},
|
},
|
||||||
lowerCase: {
|
lowerCase: {
|
||||||
type: ElasticsearchDataType.float
|
type: 'float',
|
||||||
},
|
},
|
||||||
bar: {
|
bar: {
|
||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
baz: {
|
baz: {
|
||||||
type: ElasticsearchDataType.float
|
type: 'float',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -24,17 +22,17 @@ export interface TypeAlias {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
textProperty: ATextAlias,
|
textProperty: ATextAlias;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
keywordProperty: AKeywordAlias,
|
keywordProperty: AKeywordAlias;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @keyword
|
* @keyword
|
||||||
*/
|
*/
|
||||||
overriddenTextAsKeyword: ATextAlias
|
overriddenTextAsKeyword: ATextAlias;
|
||||||
|
|
||||||
type: ThingType.TypeAlias;
|
type: ThingType.TypeAlias;
|
||||||
}
|
}
|
||||||
@@ -55,14 +53,14 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
textProperty: {
|
textProperty: {
|
||||||
type: ElasticsearchDataType.text,
|
type: 'text',
|
||||||
},
|
},
|
||||||
keywordProperty: {
|
keywordProperty: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
overriddenTextAsKeyword: {
|
overriddenTextAsKeyword: {
|
||||||
type: ElasticsearchDataType.keyword,
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
export interface SCISO8601DateRange {
|
export interface SCISO8601DateRange {
|
||||||
bar: string;
|
bar: string;
|
||||||
@@ -27,7 +25,7 @@ export interface SCISO8601DateRange {
|
|||||||
export interface TypeOverrides {
|
export interface TypeOverrides {
|
||||||
foo: SCISO8601DateRange;
|
foo: SCISO8601DateRange;
|
||||||
|
|
||||||
type: ThingType.TypeOverrides
|
type: ThingType.TypeOverrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testConfig: MapAggTestOptions = {
|
export const testConfig: MapAggTestOptions = {
|
||||||
@@ -36,8 +34,8 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -29,7 +27,7 @@ export interface TypeQuery {
|
|||||||
enum Bar {
|
enum Bar {
|
||||||
'a',
|
'a',
|
||||||
'b',
|
'b',
|
||||||
'c'
|
'c',
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://gitlab.com/openstapps/core-tools/-/issues/47
|
// https://gitlab.com/openstapps/core-tools/-/issues/47
|
||||||
@@ -39,8 +37,8 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
map: {
|
map: {
|
||||||
maps: {
|
maps: {
|
||||||
foo: {
|
foo: {
|
||||||
type: ElasticsearchDataType.text
|
type: 'text',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,10 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ThingType} from './types';
|
import {ThingType} from './types';
|
||||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||||
import {ElasticsearchDataType} from '../../../../src/config/typemap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @indexable
|
* @indexable
|
||||||
@@ -36,7 +34,7 @@ export interface TypeWrapperInheritance {
|
|||||||
*/
|
*/
|
||||||
stringLiteralWrapper: StringLiteralWrapper;
|
stringLiteralWrapper: StringLiteralWrapper;
|
||||||
|
|
||||||
type: ThingType.TypeWrapperInheritance
|
type: ThingType.TypeWrapperInheritance;
|
||||||
}
|
}
|
||||||
|
|
||||||
type NumberWrapper = number;
|
type NumberWrapper = number;
|
||||||
@@ -53,16 +51,16 @@ export const testConfig: MapAggTestOptions = {
|
|||||||
dynamic: 'strict',
|
dynamic: 'strict',
|
||||||
properties: {
|
properties: {
|
||||||
numberWrapper: {
|
numberWrapper: {
|
||||||
type: ElasticsearchDataType.float
|
type: 'float',
|
||||||
},
|
},
|
||||||
stringWrapper: {
|
stringWrapper: {
|
||||||
type: ElasticsearchDataType.keyword
|
type: 'keyword',
|
||||||
},
|
},
|
||||||
stringLiteralWrapper: {
|
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 {Logger} from '@openstapps/logger';
|
||||||
import {readdirSync, statSync} from 'fs';
|
import {readdirSync, statSync} from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {MapAggTest} from './mapping-model/MapAggTest';
|
import {MapAggTest} from './mapping-model/map-agg-test';
|
||||||
import {MapAggTestOptions} from './mapping-model/MapAggTestOptions';
|
import {MapAggTestOptions} from './mapping-model/map-agg-test-options';
|
||||||
|
|
||||||
describe('ES Mapping Gen', async () => {
|
describe('ES Mapping Gen', async () => {
|
||||||
const magAppInstance = new MapAggTest('mappings');
|
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
|
* 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[] {
|
function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
|
||||||
const fullPath = path.resolve(sourcePath);
|
const fullPath = path.resolve(sourcePath);
|
||||||
const directory = statSync(fullPath);
|
const directory = statSync(fullPath);
|
||||||
|
|
||||||
return directory.isDirectory()
|
return directory.isDirectory()
|
||||||
? ([] as string[]).concat(...readdirSync(fullPath).map(fragment =>
|
? // eslint-disable-next-line unicorn/prefer-spread
|
||||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
([] as string[]).concat(
|
||||||
))
|
...readdirSync(fullPath).map(fragment =>
|
||||||
|
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||||
|
),
|
||||||
|
)
|
||||||
: [fullPath].filter(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 {
|
try {
|
||||||
|
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||||
|
|
||||||
it(test.testName, function () {
|
it(test.testName, function () {
|
||||||
magAppInstance.testInterfaceAgainstPath(test)
|
magAppInstance.testInterfaceAgainstPath(test);
|
||||||
})
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await Logger.error('UNHANDLED REJECTION', error.stack);
|
await Logger.error('UNHANDLED REJECTION', error.stack);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).timeout(20_000).slow(10_000);
|
})
|
||||||
|
.timeout(20_000)
|
||||||
|
.slow(10_000);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"outDir": "./lib/",
|
"outDir": "./lib/",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
"target": "es6"
|
"target": "es6"
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
|||||||
4
packages/es-mapping-generator/tsconfig.spec.json
Normal file
4
packages/es-mapping-generator/tsconfig.spec.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"exclude": ["./lib/", "./src/"]
|
||||||
|
}
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
{
|
|
||||||
"defaultSeverity": "error",
|
|
||||||
"extends": [
|
|
||||||
"tslint:recommended",
|
|
||||||
"tslint-eslint-rules"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"array-type": [
|
|
||||||
true,
|
|
||||||
"array-simple"
|
|
||||||
],
|
|
||||||
"arrow-return-shorthand": true,
|
|
||||||
"await-promise": true,
|
|
||||||
"ban-comma-operator": true,
|
|
||||||
"ban-ts-ignore": true,
|
|
||||||
"completed-docs": true,
|
|
||||||
"curly": true,
|
|
||||||
"encoding": true,
|
|
||||||
"file-header": true,
|
|
||||||
"file-name-casing": [
|
|
||||||
true,
|
|
||||||
"kebab-case"
|
|
||||||
],
|
|
||||||
"forin": true,
|
|
||||||
"indent": [
|
|
||||||
true,
|
|
||||||
"spaces",
|
|
||||||
2
|
|
||||||
],
|
|
||||||
"interface-name": [
|
|
||||||
true,
|
|
||||||
"never-prefix"
|
|
||||||
],
|
|
||||||
"linebreak-style": [
|
|
||||||
true,
|
|
||||||
"LF"
|
|
||||||
],
|
|
||||||
"max-classes-per-file": false,
|
|
||||||
"member-access": false,
|
|
||||||
"member-ordering": [
|
|
||||||
true,
|
|
||||||
{
|
|
||||||
"alphabetize": true,
|
|
||||||
"order": [
|
|
||||||
"private-static-field",
|
|
||||||
"protected-static-field",
|
|
||||||
"public-static-field",
|
|
||||||
"private-instance-field",
|
|
||||||
"protected-instance-field",
|
|
||||||
"public-instance-field",
|
|
||||||
"private-static-method",
|
|
||||||
"protected-static-method",
|
|
||||||
"public-static-method",
|
|
||||||
"constructor",
|
|
||||||
"private-instance-method",
|
|
||||||
"protected-instance-method",
|
|
||||||
"public-instance-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"newline-before-return": true,
|
|
||||||
"newline-per-chained-call": true,
|
|
||||||
"no-angle-bracket-type-assertion": true,
|
|
||||||
"no-any": true,
|
|
||||||
"no-boolean-literal-compare": true,
|
|
||||||
"no-conditional-assignment": true,
|
|
||||||
"no-construct": true,
|
|
||||||
"no-default-export": true,
|
|
||||||
"no-default-import": true,
|
|
||||||
"no-duplicate-super": true,
|
|
||||||
"no-floating-promises": true,
|
|
||||||
"no-implicit-dependencies": true,
|
|
||||||
"no-inferrable-types": true,
|
|
||||||
"no-magic-numbers": true,
|
|
||||||
"no-parameter-reassignment": true,
|
|
||||||
"no-redundant-jsdoc": true,
|
|
||||||
"no-reference": true,
|
|
||||||
"no-return-await": true,
|
|
||||||
"no-shadowed-variable": true,
|
|
||||||
"no-sparse-arrays": true,
|
|
||||||
"no-string-throw": true,
|
|
||||||
"no-trailing-whitespace": [
|
|
||||||
true,
|
|
||||||
"ignore-comments",
|
|
||||||
"ignore-jsdoc"
|
|
||||||
],
|
|
||||||
"object-curly-spacing": [
|
|
||||||
true,
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"object-literal-key-quotes": false,
|
|
||||||
"object-literal-shorthand": false,
|
|
||||||
"one-variable-per-declaration": true,
|
|
||||||
"ordered-imports": [
|
|
||||||
true,
|
|
||||||
{
|
|
||||||
"import-sources-order": "case-insensitive",
|
|
||||||
"named-imports-order": "case-insensitive"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"prefer-const": true,
|
|
||||||
"prefer-for-of": true,
|
|
||||||
"prefer-function-over-method": true,
|
|
||||||
"prefer-object-spread": true,
|
|
||||||
"prefer-readonly": true,
|
|
||||||
"prefer-template": true,
|
|
||||||
"promise-function-async": true,
|
|
||||||
"quotemark": [
|
|
||||||
true,
|
|
||||||
"single",
|
|
||||||
"avoid-escape"
|
|
||||||
],
|
|
||||||
"semicolon": true,
|
|
||||||
"static-this": true,
|
|
||||||
"strict-boolean-expressions": true,
|
|
||||||
"trailing-comma": [
|
|
||||||
true,
|
|
||||||
{
|
|
||||||
"multiline": "always",
|
|
||||||
"singleline": "never"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type-literal-delimiter": [
|
|
||||||
true,
|
|
||||||
{
|
|
||||||
"singleLine": "always"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"unnecessary-bind": true,
|
|
||||||
"unnecessary-else": true,
|
|
||||||
"variable-name": [
|
|
||||||
true,
|
|
||||||
"ban-keywords",
|
|
||||||
"check-format",
|
|
||||||
"allow-leading-underscore"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"linterOptions": {
|
|
||||||
"exclude": [
|
|
||||||
"../../../test/**"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user