fix: pipeline

This commit is contained in:
2023-05-31 15:30:25 +02:00
parent 68400f2480
commit 45444d9373
31 changed files with 74 additions and 120 deletions

View File

@@ -3,7 +3,7 @@
/**
* This is the database configuration for the technical university of berlin
*
* @type {import('@openstapps/logger').RecursivePartial<import('../../src/storage/elasticsearch/types/elasticsearch.js').ElasticsearchConfigFile>}
* @type {import('@openstapps/logger').RecursivePartial<import('../../src/storage/elasticsearch/types/elasticsearch-config.js').ElasticsearchConfigFile>}
*/
const config = {
internal: {

View File

@@ -11,7 +11,7 @@
*
* To get more information about the meaning of specific fields, please use your IDE to read the TSDoc documentation.
*
* @type {import('../../src/storage/elasticsearch/types/elasticsearch.js')}
* @type {import('../../src/storage/elasticsearch/types/elasticsearch-config.js')}
*/
const config = {
internal: {

View File

@@ -1,5 +1,6 @@
declare global {
namespace NodeJS {
// eslint-disable-next-line unicorn/prevent-abbreviations
interface ProcessEnv {
NODE_APP_INSTANCE: 'default' | 'b-tu' | 'f-u' | 'fb-fh' | 'ks-ug' | string | undefined;
NODE_CONFIG_ENV: 'elasticsearch' | string | undefined;
@@ -12,3 +13,5 @@ declare global {
}
}
}
export {};

View File

@@ -18,7 +18,7 @@ import {
AggregationsAggregate,
AggregationsFiltersAggregate,
AggregationsMultiTermsBucket,
} from '@elastic/elasticsearch/lib/api/types';
} from '@elastic/elasticsearch/lib/api/types.js';
import {SCFacet, SCThingType} from '@openstapps/core';
/**

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {QueryDslFunctionScoreContainer} from '@elastic/elasticsearch/lib/api/types';
import {QueryDslFunctionScoreContainer} from '@elastic/elasticsearch/lib/api/types.js';
import {SCBackendConfigurationSearchBoostingType} from '@openstapps/core';
import {QueryDslSpecificQueryContainer} from '../../types/util.js';

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {QueryDslFunctionScoreContainer} from '@elastic/elasticsearch/lib/api/types';
import {QueryDslFunctionScoreContainer} from '@elastic/elasticsearch/lib/api/types.js';
import {SCBackendConfigurationSearchBoostingContext, SCSearchContext} from '@openstapps/core';
import {buildFunctionsForBoostingTypes} from './boost-functions.js';

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {QueryDslQueryContainer} from '@elastic/elasticsearch/lib/api/types';
import {QueryDslQueryContainer} from '@elastic/elasticsearch/lib/api/types.js';
import {SCSearchFilter} from '@openstapps/core';
import {buildBooleanFilter} from './filters/boolean.js';
import {buildAvailabilityFilter} from './filters/availability.js';
@@ -29,19 +29,26 @@ import {buildValueFilter} from './filters/value.js';
*/
export function buildFilter(filter: SCSearchFilter): QueryDslQueryContainer {
switch (filter.type) {
case 'value':
case 'value': {
return buildValueFilter(filter);
case 'availability':
}
case 'availability': {
return buildAvailabilityFilter(filter);
case 'distance':
}
case 'distance': {
return buildDistanceFilter(filter);
case 'boolean':
}
case 'boolean': {
return buildBooleanFilter(filter);
case 'numeric range':
}
case 'numeric range': {
return buildNumericRangeFilter(filter);
case 'date range':
}
case 'date range': {
return buildDateRangeFilter(filter);
case 'geo':
}
case 'geo': {
return buildGeoFilter(filter);
}
}
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {QueryDslBoolQuery} from '@elastic/elasticsearch/lib/api/types';
import {QueryDslBoolQuery} from '@elastic/elasticsearch/lib/api/types.js';
import {SCSearchBooleanFilter} from '@openstapps/core';
import {QueryDslSpecificQueryContainer} from '../../types/util.js';
import {buildFilter} from '../filter.js';

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {QueryDslDateRangeQuery} from '@elastic/elasticsearch/lib/api/types';
import {QueryDslDateRangeQuery} from '@elastic/elasticsearch/lib/api/types.js';
import {SCSearchDateRangeFilter} from '@openstapps/core';
import {QueryDslSpecificQueryContainer} from '../../types/util.js';

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {QueryDslGeoDistanceQuery} from '@elastic/elasticsearch/lib/api/types';
import {QueryDslGeoDistanceQuery} from '@elastic/elasticsearch/lib/api/types.js';
import {SCSearchDistanceFilter} from '@openstapps/core';
import {QueryDslSpecificQueryContainer} from '../../types/util.js';

View File

@@ -12,8 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {QueryDslNumberRangeQuery} from '@elastic/elasticsearch/lib/api/types';
import {QueryDslNumberRangeQuery} from '@elastic/elasticsearch/lib/api/types.js';
import {SCSearchNumericRangeFilter} from '@openstapps/core';
import {QueryDslSpecificQueryContainer} from '../../types/util.js';

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SortOptions} from '@elastic/elasticsearch/lib/api/types';
import {SortOptions} from '@elastic/elasticsearch/lib/api/types.js';
import {SCDistanceSort} from '@openstapps/core';
/**

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SortOptions} from '@elastic/elasticsearch/lib/api/types';
import {SortOptions} from '@elastic/elasticsearch/lib/api/types.js';
import {SCDucetSort} from '@openstapps/core';
/**

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {SortOptions} from '@elastic/elasticsearch/lib/api/types';
import {SortOptions} from '@elastic/elasticsearch/lib/api/types.js';
import {SCPriceSort, SCSportCoursePriceGroup, SCThingsField} from '@openstapps/core';
/**

View File

@@ -12,8 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {QueryDslQueryContainer} from '@elastic/elasticsearch/lib/api/types';
import {QueryDslQueryContainer} from '@elastic/elasticsearch/lib/api/types.js';
export type QueryDslSpecificQueryContainer<T extends keyof QueryDslQueryContainer> = Required<
Pick<QueryDslQueryContainer, T>

View File

@@ -31,7 +31,7 @@ import {buildQuery} from '../../../src/storage/elasticsearch/query/query.js';
import {buildSort} from '../../../src/storage/elasticsearch/query/sort.js';
import {ElasticsearchConfig} from '../../../src/storage/elasticsearch/types/elasticsearch-config.js';
import {QueryDslSpecificQueryContainer} from '../../../src/storage/elasticsearch/types/util.js';
import {SortCombinations} from '@elastic/elasticsearch/lib/api/types.js';
import {QueryDslRangeQuery, SortCombinations} from '@elastic/elasticsearch/lib/api/types.js';
import {backendConfig} from '../../../src/config.js';
describe('Query', function () {
@@ -363,8 +363,10 @@ describe('Query', function () {
const filter = buildFilter(rawFilter) as QueryDslSpecificQueryContainer<'range'>;
expect(filter).to.deep.equal(expectedFilter);
for (const bound of ['g', 'l']) {
const inclusiveExists = typeof filter.range.price[`${bound}t`] !== 'undefined';
const exclusiveExists = typeof filter.range.price[`${bound}te`] !== 'undefined';
const inclusiveExists =
typeof filter.range.price?.[`${bound}t` as keyof QueryDslRangeQuery] !== 'undefined';
const exclusiveExists =
typeof filter.range.price?.[`${bound}te` as keyof QueryDslRangeQuery] !== 'undefined';
// only one should exist at the same time
expect(inclusiveExists && exclusiveExists).to.be.false;