mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +00:00
feat: add support for @filterable tag
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
|||||||
Type, TypeParameterType,
|
Type, TypeParameterType,
|
||||||
UnionType,
|
UnionType,
|
||||||
} from 'typedoc/dist/lib/models';
|
} from 'typedoc/dist/lib/models';
|
||||||
import {fieldmap} from './mappings/definitions/fieldmap';
|
import {fieldmap, filterableMap, filterableTagName} from './mappings/definitions/fieldmap';
|
||||||
import {premaps} from './mappings/definitions/premap';
|
import {premaps} from './mappings/definitions/premap';
|
||||||
import {settings} from './mappings/definitions/settings';
|
import {settings} from './mappings/definitions/settings';
|
||||||
import {dynamicTypes, ElasticsearchDataType, typemap} from './mappings/definitions/typemap';
|
import {dynamicTypes, ElasticsearchDataType, typemap} from './mappings/definitions/typemap';
|
||||||
@@ -335,7 +335,6 @@ function readFieldTags(prev: ElasticsearchValue, path: string, tags?: CommentTag
|
|||||||
prev.fields = {};
|
prev.fields = {};
|
||||||
}
|
}
|
||||||
if (tag.text.trim() === '') {
|
if (tag.text.trim() === '') {
|
||||||
// merge the fields
|
|
||||||
prev.fields = {...prev.fields, ...fieldmap[tag.tagName].default};
|
prev.fields = {...prev.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 the fields
|
// merge the fields
|
||||||
@@ -343,6 +342,20 @@ function readFieldTags(prev: ElasticsearchValue, path: string, tags?: CommentTag
|
|||||||
} else if (!fieldmap[tag.tagName].ignore.includes(tag.text.trim())) {
|
} else if (!fieldmap[tag.tagName].ignore.includes(tag.text.trim())) {
|
||||||
composeErrorMessage(path, 'tag', tag.tagName, `Not implemented tag param "${tag.text.trim()}"`);
|
composeErrorMessage(path, 'tag', tag.tagName, `Not implemented tag param "${tag.text.trim()}"`);
|
||||||
}
|
}
|
||||||
|
} else if (tag.tagName === filterableTagName) {
|
||||||
|
if (typeof prev.fields === 'undefined') {
|
||||||
|
prev.fields = {};
|
||||||
|
}
|
||||||
|
if ('type' in prev) {
|
||||||
|
const type = filterableMap[prev.type];
|
||||||
|
if (typeof type !== 'undefined') {
|
||||||
|
prev.fields = {...prev.fields, ...{raw: {type: type}}};
|
||||||
|
} else {
|
||||||
|
composeErrorMessage(path, 'tag', tag.tagName, `Not implemented for ${prev.type}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
composeErrorMessage(path, 'tag', tag.tagName, 'Not applicable for object types');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
composeErrorMessage(path, 'tag', tag.tagName, `Not implemented tag`);
|
composeErrorMessage(path, 'tag', tag.tagName, `Not implemented tag`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +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 {ElasticsearchFieldmap} from '../mapping-definitions';
|
import {ElasticsearchFieldmap, ElasticsearchFilterableMap} from '../mapping-definitions';
|
||||||
import {ElasticsearchDataType} from './typemap';
|
import {ElasticsearchDataType} from './typemap';
|
||||||
|
|
||||||
export enum analyzers {
|
export enum analyzers {
|
||||||
@@ -48,3 +48,10 @@ export const fieldmap: ElasticsearchFieldmap = {
|
|||||||
ignore: ['price'],
|
ignore: ['price'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const filterableTagName = 'filterable';
|
||||||
|
|
||||||
|
export const filterableMap: ElasticsearchFilterableMap = {
|
||||||
|
date: ElasticsearchDataType.keyword,
|
||||||
|
text: ElasticsearchDataType.keyword,
|
||||||
|
};
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ export interface ElasticsearchDynamicTemplate {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ElasticsearchFilterableMap {
|
||||||
|
[name: string]: ElasticsearchDataType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Fieldmap contains all tag names for fields and the corresponding fields
|
* The Fieldmap contains all tag names for fields and the corresponding fields
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user