mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 17:12:43 +00:00
feat: migrate to esm
This commit is contained in:
2
backend/backend/app.js
Normal file
2
backend/backend/app.js
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
import './lib/cli.js'
|
||||
@@ -1,7 +1,7 @@
|
||||
// tslint:disable:no-default-export
|
||||
// tslint:disable:no-magic-numbers
|
||||
import {RecursivePartial} from '@openstapps/logger/lib/common';
|
||||
import {ElasticsearchConfigFile} from '../src/storage/elasticsearch/types/elasticsearch';
|
||||
import {ElasticsearchConfigFile} from '../src/storage/elasticsearch/types/elasticsearch.js';
|
||||
|
||||
/**
|
||||
* This is the database configuration for the technical university of berlin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// tslint:disable:no-default-export
|
||||
// tslint:disable:no-magic-numbers
|
||||
import {ElasticsearchConfigFile} from '../src/storage/elasticsearch/types/elasticsearch-config';
|
||||
import {ElasticsearchConfigFile} from '../src/storage/elasticsearch/types/elasticsearch-config.js';
|
||||
|
||||
/**
|
||||
* This is the default configuration for elasticsearch (a database)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "@openstapps/backend",
|
||||
"description": "A reference implementation for a StApps backend",
|
||||
"version": "2.1.0",
|
||||
"type": "module",
|
||||
"license": "AGPL-3.0-only",
|
||||
"author": "André Bierlein <andre.mt.bierlein@gmail.com>",
|
||||
"contributors": [
|
||||
@@ -97,8 +98,8 @@
|
||||
"sinon": "14.0.2",
|
||||
"sinon-express-mock": "2.2.1",
|
||||
"supertest": "6.3.3",
|
||||
"typedoc": "0.22.18",
|
||||
"typescript": "4.4.4"
|
||||
"typedoc": "0.23.26",
|
||||
"typescript": "4.8.4"
|
||||
},
|
||||
"nyc": {
|
||||
"all": true,
|
||||
@@ -124,5 +125,12 @@
|
||||
"ts-node/register"
|
||||
],
|
||||
"statements": 95
|
||||
},
|
||||
"pnpm": {
|
||||
"peerDependencyRules": {
|
||||
"allowedVersions": {
|
||||
"rxjs": "7.x"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,20 +25,20 @@ import cors from 'cors';
|
||||
import {Express} from 'express';
|
||||
import morgan from 'morgan';
|
||||
import path from 'path';
|
||||
import {configFile, DEFAULT_TIMEOUT, isTestEnvironment, mailer, plugins, validator} from './common';
|
||||
import {getPrometheusMiddleware} from './middleware/prometheus';
|
||||
import {MailQueue} from './notification/mail-queue';
|
||||
import {bulkAddRouter} from './routes/bulk-add-route';
|
||||
import {bulkDoneRouter} from './routes/bulk-done-route';
|
||||
import {bulkRouter} from './routes/bulk-route';
|
||||
import {indexRouter} from './routes/index-route';
|
||||
import {multiSearchRouter} from './routes/multi-search-route';
|
||||
import {pluginRegisterRouter} from './routes/plugin-register-route';
|
||||
import {searchRouter} from './routes/search-route';
|
||||
import {thingUpdateRouter} from './routes/thing-update-route';
|
||||
import {virtualPluginRoute} from './routes/virtual-plugin-route';
|
||||
import {BulkStorage} from './storage/bulk-storage';
|
||||
import {DatabaseConstructor} from './storage/database';
|
||||
import {configFile, DEFAULT_TIMEOUT, isTestEnvironment, mailer, plugins, validator} from './common.js';
|
||||
import {getPrometheusMiddleware} from './middleware/prometheus.js';
|
||||
import {MailQueue} from './notification/mail-queue.js';
|
||||
import {bulkAddRouter} from './routes/bulk-add-route.js';
|
||||
import {bulkDoneRouter} from './routes/bulk-done-route.js';
|
||||
import {bulkRouter} from './routes/bulk-route.js';
|
||||
import {indexRouter} from './routes/index-route.js';
|
||||
import {multiSearchRouter} from './routes/multi-search-route.js';
|
||||
import {pluginRegisterRouter} from './routes/plugin-register-route.js';
|
||||
import {searchRouter} from './routes/search-route.js';
|
||||
import {thingUpdateRouter} from './routes/thing-update-route.js';
|
||||
import {virtualPluginRoute} from './routes/virtual-plugin-route.js';
|
||||
import {BulkStorage} from './storage/bulk-storage.js';
|
||||
import {DatabaseConstructor} from './storage/database.js';
|
||||
|
||||
/**
|
||||
* Configure the backend
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
* Copyright (C) 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -18,8 +16,8 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import express from 'express';
|
||||
import http from 'http';
|
||||
import {configureApp} from './app';
|
||||
import {Elasticsearch} from './storage/elasticsearch/elasticsearch';
|
||||
import {configureApp} from './app.js';
|
||||
import {Elasticsearch} from './storage/elasticsearch/elasticsearch.js';
|
||||
|
||||
const app = express();
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCConfigFile, SCPluginMetaData} from '@openstapps/core';
|
||||
import {Validator} from '@openstapps/core-tools/lib/validate';
|
||||
import {Validator} from '@openstapps/core-tools/lib/validate.js';
|
||||
import config from 'config';
|
||||
import {BackendTransport} from './notification/backend-transport';
|
||||
import {BackendTransport} from './notification/backend-transport.js';
|
||||
|
||||
/**
|
||||
* Instance of the transport for sending mails
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {SMTP} from '@openstapps/logger/lib/smtp';
|
||||
import {Transport, VerifiableTransport} from '@openstapps/logger/lib/transport';
|
||||
import {SMTP} from '@openstapps/logger/lib/smtp.js';
|
||||
import {Transport, VerifiableTransport} from '@openstapps/logger/lib/transport.js';
|
||||
|
||||
/**
|
||||
* Provides information if a transport is a verifiable transport
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {SMTP} from '@openstapps/logger/lib/smtp';
|
||||
import {SMTP} from '@openstapps/logger/lib/smtp.js';
|
||||
import {MailOptions} from 'nodemailer/lib/sendmail-transport';
|
||||
import Queue from 'promise-queue';
|
||||
/**
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
import {SCBulkAddRequest, SCBulkAddResponse, SCBulkAddRoute, SCNotFoundErrorResponse} from '@openstapps/core';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {isTestEnvironment} from '../common';
|
||||
import {BulkStorage} from '../storage/bulk-storage';
|
||||
import {createRoute} from './route';
|
||||
import {isTestEnvironment} from '../common.js';
|
||||
import {BulkStorage} from '../storage/bulk-storage.js';
|
||||
import {createRoute} from './route.js';
|
||||
|
||||
/**
|
||||
* Contains information for using the route for adding bulks
|
||||
|
||||
@@ -20,9 +20,9 @@ import {
|
||||
SCNotFoundErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {isTestEnvironment} from '../common';
|
||||
import {BulkStorage} from '../storage/bulk-storage';
|
||||
import {createRoute} from './route';
|
||||
import {isTestEnvironment} from '../common.js';
|
||||
import {BulkStorage} from '../storage/bulk-storage.js';
|
||||
import {createRoute} from './route.js';
|
||||
|
||||
/**
|
||||
* Contains information for using the route for closing bulks
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCBulkRequest, SCBulkResponse, SCBulkRoute} from '@openstapps/core';
|
||||
import {BulkStorage} from '../storage/bulk-storage';
|
||||
import {createRoute} from './route';
|
||||
import {BulkStorage} from '../storage/bulk-storage.js';
|
||||
import {createRoute} from './route.js';
|
||||
|
||||
/**
|
||||
* Contains information for using the route for creating bulks
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCIndexResponse, SCIndexRoute} from '@openstapps/core';
|
||||
import {configFile} from '../common';
|
||||
import {createRoute} from './route';
|
||||
import {configFile} from '../common.js';
|
||||
import {createRoute} from './route.js';
|
||||
|
||||
/**
|
||||
* Contains information for using the index route
|
||||
|
||||
@@ -20,9 +20,9 @@ import {
|
||||
SCSearchResponse,
|
||||
SCTooManyRequestsErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import {configFile, isTestEnvironment} from '../common';
|
||||
import {BulkStorage} from '../storage/bulk-storage';
|
||||
import {createRoute} from './route';
|
||||
import {configFile, isTestEnvironment} from '../common.js';
|
||||
import {BulkStorage} from '../storage/bulk-storage.js';
|
||||
import {createRoute} from './route.js';
|
||||
/**
|
||||
* Contains information for using the multi search route
|
||||
*/
|
||||
|
||||
@@ -23,8 +23,8 @@ import {
|
||||
} from '@openstapps/core';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {deepStrictEqual} from 'assert';
|
||||
import {configFile, isTestEnvironment, plugins} from '../common';
|
||||
import {createRoute} from './route';
|
||||
import {configFile, isTestEnvironment, plugins} from '../common.js';
|
||||
import {createRoute} from './route.js';
|
||||
|
||||
/**
|
||||
* Contains information for using the route for registering routes
|
||||
|
||||
@@ -19,12 +19,12 @@ import {
|
||||
SCRoute,
|
||||
SCValidationErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import {ValidationError} from '@openstapps/core-tools/src/types/validator';
|
||||
import {ValidationError} from '@openstapps/core-tools/src/types/validator.js';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {Application, Router} from 'express';
|
||||
import PromiseRouter from 'express-promise-router';
|
||||
import {isTestEnvironment, validator} from '../common';
|
||||
import {isHttpMethod} from './http-types';
|
||||
import {isTestEnvironment, validator} from '../common.js';
|
||||
import {isHttpMethod} from './http-types.js';
|
||||
|
||||
/**
|
||||
* Creates a router from a route class and a handler function which implements the logic
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCSearchRequest, SCSearchResponse, SCSearchRoute} from '@openstapps/core';
|
||||
import {BulkStorage} from '../storage/bulk-storage';
|
||||
import {createRoute} from './route';
|
||||
import {BulkStorage} from '../storage/bulk-storage.js';
|
||||
import {createRoute} from './route.js';
|
||||
|
||||
/**
|
||||
* Contains information for using the search route
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCThingUpdateRequest, SCThingUpdateResponse, SCThingUpdateRoute} from '@openstapps/core';
|
||||
import {BulkStorage} from '../storage/bulk-storage';
|
||||
import {createRoute} from './route';
|
||||
import {BulkStorage} from '../storage/bulk-storage.js';
|
||||
import {createRoute} from './route.js';
|
||||
|
||||
/**
|
||||
* Contains information for using the route for updating single things
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import {SCInternalServerErrorResponse, SCPluginMetaData, SCValidationErrorResponse} from '@openstapps/core';
|
||||
import {Request} from 'express';
|
||||
import got from 'got';
|
||||
import {configFile, isTestEnvironment, validator} from '../common';
|
||||
import {configFile, isTestEnvironment, validator} from '../common.js';
|
||||
|
||||
/**
|
||||
* Generic route function used to proxy actual requests to plugins
|
||||
@@ -27,7 +27,6 @@ import {configFile, isTestEnvironment, validator} from '../common';
|
||||
* @throws {SCInternalServerErrorResponse} On request/response validation or response from the plugin errors
|
||||
*/
|
||||
export async function virtualPluginRoute(request: Request, plugin: SCPluginMetaData): Promise<object> {
|
||||
let responseBody: object;
|
||||
try {
|
||||
const requestValidation = validator.validate(request.body, plugin.requestSchema);
|
||||
if (requestValidation.errors.length > 0) {
|
||||
@@ -35,22 +34,23 @@ export async function virtualPluginRoute(request: Request, plugin: SCPluginMetaD
|
||||
throw new SCValidationErrorResponse(requestValidation.errors, isTestEnvironment);
|
||||
}
|
||||
// send the request to the plugin (forward the body) and save the response
|
||||
const pluginResponse = await got.post(plugin.route.replace(/^\//gi, ''), {
|
||||
const response = await got.post(plugin.route.replace(/^\//gi, ''), {
|
||||
prefixUrl: plugin.address,
|
||||
json: request.body,
|
||||
timeout: configFile.backend.externalRequestTimeout,
|
||||
timeout: {
|
||||
response: configFile.backend.externalRequestTimeout
|
||||
},
|
||||
responseType: 'json',
|
||||
});
|
||||
responseBody = pluginResponse.body as object;
|
||||
const responseBody = response.body
|
||||
const responseValidation = validator.validate(responseBody, plugin.responseSchema);
|
||||
if (responseValidation.errors.length > 0) {
|
||||
// noinspection ExceptionCaughtLocallyJS
|
||||
throw new SCValidationErrorResponse(responseValidation.errors, isTestEnvironment);
|
||||
}
|
||||
return response
|
||||
} catch (error) {
|
||||
// wrap exact error inside of the internal server error response
|
||||
throw new SCInternalServerErrorResponse(error, isTestEnvironment);
|
||||
}
|
||||
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import {Logger} from '@openstapps/logger';
|
||||
import moment from 'moment';
|
||||
import NodeCache from 'node-cache';
|
||||
import {v4} from 'uuid';
|
||||
import {Database} from './database';
|
||||
import {Database} from './database.js';
|
||||
|
||||
/**
|
||||
* Possible operations with a bulk
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCConfigFile, SCSearchQuery, SCSearchResponse, SCThings, SCUuid} from '@openstapps/core';
|
||||
import {MailQueue} from '../notification/mail-queue';
|
||||
import {Bulk} from './bulk-storage';
|
||||
import {MailQueue} from '../notification/mail-queue.js';
|
||||
import {Bulk} from './bulk-storage.js';
|
||||
|
||||
/**
|
||||
* Creates an instance of a database
|
||||
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
ElasticsearchConfig,
|
||||
ElasticsearchQueryDisMaxConfig,
|
||||
ElasticsearchQueryQueryStringConfig,
|
||||
} from './types/elasticsearch-config';
|
||||
} from './types/elasticsearch-config.js';
|
||||
import {
|
||||
ACTIVE_INDICES_ALIAS,
|
||||
getThingIndexName,
|
||||
@@ -44,8 +44,8 @@ import {
|
||||
matchIndexByType,
|
||||
VALID_INDEX_REGEX,
|
||||
} from './util';
|
||||
import {noUndefined} from './util/no-undefined';
|
||||
import {retryCatch, RetryOptions} from './util/retry';
|
||||
import {noUndefined} from './util/no-undefined.js';
|
||||
import {retryCatch, RetryOptions} from './util/retry.js';
|
||||
|
||||
/**
|
||||
* A database interface for elasticsearch
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from '@openstapps/core';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import cron from 'node-cron';
|
||||
import {MailQueue} from '../../notification/mail-queue';
|
||||
import {MailQueue} from '../../notification/mail-queue.js';
|
||||
|
||||
/**
|
||||
* Check if the given condition fails on the given number of results and the condition
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
import {Client} from '@elastic/elasticsearch';
|
||||
import {SCThingType} from '@openstapps/core';
|
||||
import {AggregationSchema} from '@openstapps/es-mapping-generator/src/types/aggregation';
|
||||
import {ElasticsearchTemplateCollection} from '@openstapps/es-mapping-generator/src/types/mapping';
|
||||
import {AggregationSchema} from '@openstapps/es-mapping-generator/src/types/aggregation.js';
|
||||
import {ElasticsearchTemplateCollection} from '@openstapps/es-mapping-generator/src/types/mapping.js';
|
||||
import {readFileSync} from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import {
|
||||
SCUnsupportedMediaTypeErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {configFile, DEFAULT_TIMEOUT} from '../src/common';
|
||||
import {DEFAULT_TEST_TIMEOUT} from './common';
|
||||
import {testApp} from './tests-setup';
|
||||
import {configFile, DEFAULT_TIMEOUT} from '../src/common.js';
|
||||
import {DEFAULT_TEST_TIMEOUT} from './common.js';
|
||||
import {testApp} from './tests-setup.js';
|
||||
import sinon from 'sinon';
|
||||
import mockedEnv from 'mocked-env';
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {yearSlice} from '../config/default';
|
||||
import {yearSlice} from '../config/default.js';
|
||||
import {expect} from 'chai';
|
||||
|
||||
describe('Common', function () {
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
import {SCConfigFile, SCSearchQuery, SCSearchResponse, SCThings, SCThingType, SCUuid} from '@openstapps/core';
|
||||
import {Express} from 'express';
|
||||
import moment from 'moment';
|
||||
import {getIndexUID} from '../src/storage/elasticsearch/util';
|
||||
import {configureApp} from '../src/app';
|
||||
import {getIndexUID} from '../src/storage/elasticsearch/util.js';
|
||||
import {configureApp} from '../src/app.js';
|
||||
import express from 'express';
|
||||
import http from 'http';
|
||||
import {configFile} from '../src/common';
|
||||
import {MailQueue} from '../src/notification/mail-queue';
|
||||
import {Bulk, BulkStorage} from '../src/storage/bulk-storage';
|
||||
import {configFile} from '../src/common.js';
|
||||
import {MailQueue} from '../src/notification/mail-queue.js';
|
||||
import {Bulk, BulkStorage} from '../src/storage/bulk-storage.js';
|
||||
import getPort from 'get-port';
|
||||
import {Database} from '../src/storage/database';
|
||||
import {Database} from '../src/storage/database.js';
|
||||
import {v4} from 'uuid';
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ import {SMTP} from '@openstapps/logger/lib/smtp';
|
||||
import {Transport} from '@openstapps/logger/lib/transport';
|
||||
import {expect} from 'chai';
|
||||
import mockedEnv from 'mocked-env';
|
||||
import {BackendTransport, isTransportWithVerification} from '../../src/notification/backend-transport';
|
||||
import {BackendTransport, isTransportWithVerification} from '../../src/notification/backend-transport.js';
|
||||
import sinon from 'sinon';
|
||||
|
||||
describe('Backend transport', function () {
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
*/
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import sinon from 'sinon';
|
||||
import {MailQueue} from '../../src/notification/mail-queue';
|
||||
import {MailQueue} from '../../src/notification/mail-queue.js';
|
||||
import {expect} from 'chai';
|
||||
import Queue from 'promise-queue';
|
||||
import {MailOptions} from 'nodemailer/lib/sendmail-transport';
|
||||
import {getTransport, TRANSPORT_SEND_RESPONSE} from '../common';
|
||||
import {getTransport, TRANSPORT_SEND_RESPONSE} from '../common.js';
|
||||
|
||||
describe('MailQueue', async function () {
|
||||
const sandbox = sinon.createSandbox();
|
||||
|
||||
@@ -22,8 +22,8 @@ import {
|
||||
} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {instance as book} from '@openstapps/core/test/resources/indexable/Book.1.json';
|
||||
import {bulk, DEFAULT_TEST_TIMEOUT} from '../common';
|
||||
import {testApp} from '../tests-setup';
|
||||
import {bulk, DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
|
||||
describe('Bulk routes', async function () {
|
||||
// increase timeout for the suite
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
import {SCRouteHttpVerbs} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {isHttpMethod} from '../../src/routes/http-types';
|
||||
import {isHttpMethod} from '../../src/routes/http-types.js';
|
||||
|
||||
describe('Is HTTP method', async function () {
|
||||
it('should allow valid (predefined) http methods', async function () {
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common';
|
||||
import {testApp} from '../tests-setup';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
import {SCIndexRequest, SCIndexRoute} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ import {
|
||||
SCValidationErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import nock from 'nock';
|
||||
import {configFile, plugins} from '../../src/common';
|
||||
import {pluginRegisterHandler} from '../../src/routes/plugin-register-route';
|
||||
import {configFile, plugins} from '../../src/common.js';
|
||||
import {pluginRegisterHandler} from '../../src/routes/plugin-register-route.js';
|
||||
import {expect, use} from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import {instance as registerRequest} from '@openstapps/core/test/resources/PluginRegisterRequest.1.json';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common';
|
||||
import {testApp} from '../tests-setup';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
|
||||
// for using promises in expectations (to.eventually.be...)
|
||||
use(chaiAsPromised);
|
||||
|
||||
@@ -25,12 +25,12 @@ import * as bodyParser from 'body-parser';
|
||||
import sinon from 'sinon';
|
||||
import {expect} from 'chai';
|
||||
import {Application} from 'express';
|
||||
import {validator} from '../../src/common';
|
||||
import {createRoute} from '../../src/routes/route';
|
||||
import {validator} from '../../src/common.js';
|
||||
import {createRoute} from '../../src/routes/route.js';
|
||||
import express, {Express} from 'express';
|
||||
import supertest from 'supertest';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
|
||||
interface ReturnType {
|
||||
foo: boolean;
|
||||
|
||||
@@ -21,9 +21,9 @@ import {
|
||||
SCTooManyRequestsErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {configFile} from '../../src/common';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common';
|
||||
import {testApp} from '../tests-setup';
|
||||
import {configFile} from '../../src/common.js';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
import sinon from 'sinon';
|
||||
|
||||
describe('Search route', async function () {
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
import {SCThingUpdateRoute} from '@openstapps/core';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import {bulkStorageMock, DEFAULT_TEST_TIMEOUT} from '../common';
|
||||
import {bulkStorageMock, DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {expect, use} from 'chai';
|
||||
import {instance as book} from '@openstapps/core/test/resources/indexable/Book.1.json';
|
||||
import {testApp} from '../tests-setup';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import got, {Options} from 'got';
|
||||
import nock from 'nock';
|
||||
import sinon from 'sinon';
|
||||
import {mockReq} from 'sinon-express-mock';
|
||||
import {plugins, validator} from '../../src/common';
|
||||
import {virtualPluginRoute} from '../../src/routes/virtual-plugin-route';
|
||||
import {DEFAULT_TEST_TIMEOUT, FooError} from '../common';
|
||||
import {plugins, validator} from '../../src/common.js';
|
||||
import {virtualPluginRoute} from '../../src/routes/virtual-plugin-route.js';
|
||||
import {DEFAULT_TEST_TIMEOUT, FooError} from '../common.js';
|
||||
import {registerAddRequest} from './plugin-register-route.spec';
|
||||
import {testApp} from '../tests-setup';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ import {SCBulkRequest, SCThingType} from '@openstapps/core';
|
||||
import moment from 'moment';
|
||||
// eslint-disable-next-line unicorn/import-style
|
||||
import util from 'util';
|
||||
import {configFile} from '../../src/common';
|
||||
import {Bulk, BulkStorage} from '../../src/storage/bulk-storage';
|
||||
import {configFile} from '../../src/common.js';
|
||||
import {Bulk, BulkStorage} from '../../src/storage/bulk-storage.js';
|
||||
import {expect} from 'chai';
|
||||
import {ElasticsearchMock} from '../common';
|
||||
import {ElasticsearchMock} from '../common.js';
|
||||
import sinon from 'sinon';
|
||||
import NodeCache from 'node-cache';
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import {AggregateName, AggregationsMultiTermsBucket} from '@elastic/elasticsearch/lib/api/types';
|
||||
import {SCFacet, SCThingType} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {parseAggregations} from '../../../src/storage/elasticsearch/aggregations';
|
||||
import {parseAggregations} from '../../../src/storage/elasticsearch/aggregations.js';
|
||||
|
||||
describe('Aggregations', function () {
|
||||
const aggregations: Record<AggregateName, Partial<AggregationsMultiTermsBucket>> = {
|
||||
|
||||
@@ -43,20 +43,20 @@ import {
|
||||
ACTIVE_INDICES_ALIAS,
|
||||
INACTIVE_INDICES_ALIAS,
|
||||
parseIndexName,
|
||||
} from '../../../src/storage/elasticsearch/util';
|
||||
import * as queryModule from '../../../src/storage/elasticsearch/query/query';
|
||||
import * as sortModule from '../../../src/storage/elasticsearch/query/sort';
|
||||
} from '../../../src/storage/elasticsearch/util.js';
|
||||
import * as queryModule from '../../../src/storage/elasticsearch/query/query.js';
|
||||
import * as sortModule from '../../../src/storage/elasticsearch/query/sort.js';
|
||||
import sinon, {SinonStub} from 'sinon';
|
||||
import {getIndexUID, getThingIndexName, INDEX_UID_LENGTH} from '../../../src/storage/elasticsearch/util';
|
||||
import * as utilModule from '../../../src/storage/elasticsearch/util';
|
||||
import {removeInvalidAliasChars} from '../../../src/storage/elasticsearch/util/alias';
|
||||
import {configFile} from '../../../src/common';
|
||||
import {MailQueue} from '../../../src/notification/mail-queue';
|
||||
import {aggregations} from '../../../src/storage/elasticsearch/templating';
|
||||
import {Elasticsearch} from '../../../src/storage/elasticsearch/elasticsearch';
|
||||
import * as Monitoring from '../../../src/storage/elasticsearch/monitoring';
|
||||
import * as templating from '../../../src/storage/elasticsearch/templating';
|
||||
import {bulk, DEFAULT_TEST_TIMEOUT, getTransport, getIndex} from '../../common';
|
||||
import {getIndexUID, getThingIndexName, INDEX_UID_LENGTH} from '../../../src/storage/elasticsearch/util.js';
|
||||
import * as utilModule from '../../../src/storage/elasticsearch/util.js';
|
||||
import {removeInvalidAliasChars} from '../../../src/storage/elasticsearch/util/alias.js';
|
||||
import {configFile} from '../../../src/common.js';
|
||||
import {MailQueue} from '../../../src/notification/mail-queue.js';
|
||||
import {aggregations} from '../../../src/storage/elasticsearch/templating.js';
|
||||
import {Elasticsearch} from '../../../src/storage/elasticsearch/elasticsearch.js';
|
||||
import * as Monitoring from '../../../src/storage/elasticsearch/monitoring.js';
|
||||
import * as templating from '../../../src/storage/elasticsearch/templating.js';
|
||||
import {bulk, DEFAULT_TEST_TIMEOUT, getTransport, getIndex} from '../../common.js';
|
||||
import fs from 'fs';
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
@@ -24,10 +24,10 @@ import {
|
||||
SCThings,
|
||||
} from '@openstapps/core';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {MailQueue} from '../../../src/notification/mail-queue';
|
||||
import {setUp} from '../../../src/storage/elasticsearch/monitoring';
|
||||
import {MailQueue} from '../../../src/notification/mail-queue.js';
|
||||
import {setUp} from '../../../src/storage/elasticsearch/monitoring.js';
|
||||
|
||||
import {getTransport} from '../../common';
|
||||
import {getTransport} from '../../common.js';
|
||||
import {expect} from 'chai';
|
||||
import sinon from 'sinon';
|
||||
import cron from 'node-cron';
|
||||
|
||||
@@ -25,13 +25,13 @@ import {
|
||||
SCThingType,
|
||||
} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {buildFilter} from '../../../src/storage/elasticsearch/query/filter';
|
||||
import {buildBooleanFilter} from '../../../src/storage/elasticsearch/query/filters/boolean';
|
||||
import {buildQuery} from '../../../src/storage/elasticsearch/query/query';
|
||||
import {buildSort} from '../../../src/storage/elasticsearch/query/sort';
|
||||
import {ElasticsearchConfig} from '../../../src/storage/elasticsearch/types/elasticsearch-config';
|
||||
import {QueryDslSpecificQueryContainer} from '../../../src/storage/elasticsearch/types/util';
|
||||
import {configFile} from '../../../src/common';
|
||||
import {buildFilter} from '../../../src/storage/elasticsearch/query/filter.js';
|
||||
import {buildBooleanFilter} from '../../../src/storage/elasticsearch/query/filters/boolean.js';
|
||||
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 {configFile} from '../../../src/common.js';
|
||||
import {SortCombinations} from '@elastic/elasticsearch/lib/api/types';
|
||||
|
||||
describe('Query', function () {
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {DEFAULT_TIMEOUT} from '../src/common';
|
||||
import {startApp} from './common';
|
||||
import {DEFAULT_TIMEOUT} from '../src/common.js';
|
||||
import {startApp} from './common.js';
|
||||
import supertest from 'supertest';
|
||||
|
||||
before(async function () {
|
||||
|
||||
Reference in New Issue
Block a user