Skip to content

Commit

Permalink
chore: Update major dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fguitton committed Sep 11, 2024
1 parent acd57e4 commit a254e01
Show file tree
Hide file tree
Showing 43 changed files with 296 additions and 274 deletions.
File renamed without changes.
21 changes: 18 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ const javascriptRules = {
'comma-dangle': ['error', 'never'],
'no-trailing-spaces': 'error',
'no-extra-semi': 'error',
'no-unused-vars': ['error', { args: 'after-used', varsIgnorePattern: '^__unused' }],
'no-unused-vars': ['error', {
args: 'after-used',
argsIgnorePattern: '^__unused',
caughtErrorsIgnorePattern: '^__unused',
destructuredArrayIgnorePattern: '^__unused',
varsIgnorePattern: '^__unused',
ignoreRestSiblings: true
}],
'semi': ['error', 'always']
};

Expand All @@ -41,7 +48,14 @@ const typescriptRules = {
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'after-used', varsIgnorePattern: '^__unused' }
{
args: 'after-used',
argsIgnorePattern: '^__unused',
caughtErrorsIgnorePattern: '^__unused',
destructuredArrayIgnorePattern: '^__unused',
varsIgnorePattern: '^__unused',
ignoreRestSiblings: true
}
],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/promise-function-async': 'error',
Expand All @@ -54,7 +68,8 @@ module.exports = {
parserOptions: {
ecmaVersion: 2022,
tsconfigRootDir: __dirname,
EXPERIMENTAL_useProjectService: true,
projectService: true,
allowDefaultProject: true,
warnOnUnsupportedTypeScriptVersion: false,
project: [
'./tsconfig.eslint.json',
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"inputs": [
"default",
"^default",
"{workspaceRoot}/jest.preset.js"
"{workspaceRoot}/jest.preset.cjs"
],
"cache": true,
"options": {
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@svgr/webpack": "8.1.0",
"@swc/cli": "0.4.0",
"@swc/core": "1.7.25",
"@swc/core": "1.7.26",
"@swc/jest": "0.2.36",
"@testing-library/react": "16.0.1",
"@types/bcrypt": "5.0.2",
Expand All @@ -56,7 +56,7 @@
"@types/jest": "29.5.12",
"@types/json2csv": "5.0.7",
"@types/jsonwebtoken": "9.0.6",
"@types/node": "^20.16.5",
"@types/node": "^22.5.4",
"@types/nodemailer": "6.4.15",
"@types/passport": "1.0.16",
"@types/qrcode": "1.5.5",
Expand All @@ -67,8 +67,8 @@
"@types/tmp": "0.2.6",
"@types/uuid": "10.0.0",
"@types/webpack-env": "1.18.5",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"@typescript-eslint/eslint-plugin": "8.5.0",
"@typescript-eslint/parser": "8.5.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.30.0",
Expand All @@ -81,19 +81,19 @@
"husky": "^9.1.5",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"mongodb-memory-server": "9.4.1",
"mongodb-memory-server": "10.0.0",
"nx": "19.7.2",
"prettier": "^3.3.3",
"react-refresh": "^0.14.2",
"supertest": "6.3.4",
"supertest": "7.0.0",
"swc-loader": "0.2.6",
"ts-essentials": "10.0.2",
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
"typescript": "5.6.2",
"url-loader": "^4.1.1",
"webpack": "^5.94.0",
"webpack-merge": "^5.10.0"
"webpack-merge": "^6.0.1"
},
"dependencies": {
"@ant-design/icons": "5.4.0",
Expand Down Expand Up @@ -138,7 +138,7 @@
"jstat": "1.9.6",
"lint-staged": "15.2.10",
"lodash-es": "4.17.21",
"minio": "7.1.3",
"minio": "8.0.1",
"mongodb": "6.8.1",
"multer": "1.4.4",
"nodemailer": "6.9.15",
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-apis/express-user.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare global {

namespace Express {

// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type
interface User extends IUserWithoutToken { }

interface Request {
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-apis/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { exclude: _, ...swcJestConfig } = JSON.parse(
);
export default {
displayName: 'itmat-apis',
preset: '../../jest.preset.js',
preset: '../../jest.preset.cjs',
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class StudyResolvers {
uploadedBy: el.life.createdUser
};
});
} catch (e) {
} catch (__unused__exception) {
return [];
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-commons/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { exclude: _, ...swcJestConfig } = JSON.parse(
);
export default {
displayName: 'itmat-commons',
preset: '../../jest.preset.js',
preset: '../../jest.preset.cjs',
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
Expand Down
10 changes: 5 additions & 5 deletions packages/itmat-commons/src/utils/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ export class Database<configType extends IDatabaseBaseConfig, C = Record<keyof c
): Promise<MongoClient> {
this.config = config;
const shouldOutput = process.env['JEST_WORKER_ID'] !== undefined;
shouldOutput && Logger.log('Connecting to the database..');
if (shouldOutput) Logger.log('Connecting to the database..');
/* any error throw here will be caught by the server */
this.localClient = await (new mongoClient(config.mongo_url)).connect();
shouldOutput && Logger.log('Connected to database.');
if (shouldOutput) Logger.log('Connected to database.');

shouldOutput && Logger.log('Performing basic checks..');
if (shouldOutput) Logger.log('Performing basic checks..');
await this.checkAllCollectionsArePresent();
shouldOutput && Logger.log('Done basic checks.');
if (shouldOutput) Logger.log('Done basic checks.');

this.assignCollections();

shouldOutput && Logger.log('Finished with database initialisation.');
if (shouldOutput) Logger.log('Finished with database initialisation.');
return this.localClient;
}

Expand Down
12 changes: 8 additions & 4 deletions packages/itmat-commons/src/utils/objStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export class ObjectStore {

public async isConnected(): Promise<boolean> {
try {
this.client && await this.client.listBuckets();
if (this.client)
await this.client.listBuckets();
return true;
} catch (e) {
} catch (__unused__exception) {
return false;
}
}
Expand Down Expand Up @@ -59,7 +60,7 @@ export class ObjectStore {
try {
await this.client.statObject(lowercasestudyid, uri);
fileExists = true;
} catch (e) {
} catch (__unused__exception) {
fileExists = false;
}

Expand Down Expand Up @@ -87,7 +88,10 @@ export class ObjectStore {
// Copy the object
const conds = new Minio.CopyConditions();
const result = await this.client.copyObject(lowerTargetBucket, targetUri, `/${lowerSourceBucket}/${sourceUri}`, conds);
return result.etag;
if (Object.hasOwn(result, 'Etag'))
return (result as Record<string, unknown>)?.['Etag'];
else
return (result as Record<string, unknown>)?.['etag'];
}

public async downloadFile(studyId: string, uri: string): Promise<Readable> {
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-cores/express-user.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare global {

namespace Express {

// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type
interface User extends IUserWithoutToken { }

interface Request {
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-cores/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { exclude: _, ...swcJestConfig } = JSON.parse(
);
export default {
displayName: 'itmat-cores',
preset: '../../jest.preset.js',
preset: '../../jest.preset.cjs',
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
Expand Down
3 changes: 2 additions & 1 deletion packages/itmat-cores/src/coreFunc/dataCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,8 @@ export class DataCore {
bulk = this.db.collections.data_collection.initializeUnorderedBulkOp();
}
}
bulk.batches.length !== 0 && await bulk.execute();
if (bulk.batches.length !== 0)
await bulk.execute();
return response;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-cores/src/coreFunc/studyCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class StudyCore {
}
fileEntry = await this.fileCore.uploadFile(requester, studyId, null, profile, enumFileTypes[(profile.filename.split('.').pop() || '').toUpperCase() as keyof typeof enumFileTypes], enumFileCategories.PROFILE_FILE);
setObj['profile'] = fileEntry.id;
} catch (error) {
} catch (__unused__exception) {
setObj['profile'] = study.profile;
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/itmat-cores/src/coreFunc/userCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class UserCore {
let email;
try {
email = await decryptEmail(this.config.aesSecret, encryptedEmail, salt, iv);
} catch (e) {
} catch (__unused__exception) {
throw new CoreError(
enumCoreErrors.CLIENT_MALFORMED_INPUT,
'Token is not valid.'
Expand Down Expand Up @@ -642,7 +642,7 @@ export class UserCore {
try {
const reGenPubkey = pubkeycrypto.reGenPkfromSk(privateKey);
messageToBeSigned = pubkeycrypto.hashdigest(reGenPubkey);
} catch (error) {
} catch (__unused__exception) {
throw new CoreError(
enumCoreErrors.CLIENT_MALFORMED_INPUT,
'Error: private-key incorrect!'
Expand Down Expand Up @@ -707,7 +707,7 @@ export class UserCore {
'Signature vs Public-key mismatched.'
);
}
} catch (error) {
} catch (__unused__exception) {
throw new CoreError(
enumCoreErrors.CLIENT_MALFORMED_INPUT,
'Error: Signature or Public-key is incorrect.'
Expand Down Expand Up @@ -1194,7 +1194,7 @@ export class UserCore {
let email;
try {
email = await decryptEmail(this.config.aesSecret, encryptedEmail, salt, iv);
} catch (e) {
} catch (__unused__exception) {
throw new CoreError(
enumCoreErrors.CLIENT_MALFORMED_INPUT,
'Token is invalid.'
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-cores/src/utils/configManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ConfigurationManager {
config = merge(config, JSON.parse(content));
Logger.log(`Applied configuration from ${path.resolve(configurationFile)}.`);
}
} catch (e) {
} catch (__unused__exception) {
Logger.error(chalk.red('Cannot parse configuration file.'));
}
});
Expand Down
10 changes: 7 additions & 3 deletions packages/itmat-cores/src/webdav/dmpWebDAV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,14 @@ export class DMPWebDAVAuthentication implements HTTPAuthentication {
this.realm = realm ?? 'realm';
this.db = db;
}

askForAuthentication(): { 'WWW-Authenticate': string; } {
return {
'WWW-Authenticate': 'Basic realm="' + this.realm + '"'
};
}

async getUser(ctx: webdav.HTTPRequestContext, callback: (error: Error | null, user?: IUserWithoutToken) => void): Promise<void> {
getUser(ctx: webdav.HTTPRequestContext, callback: (error: Error | null, user?: IUserWithoutToken) => void): void {
try {
const token = ctx.headers.find('authorization') ?? '';
const decodedPayload = jwt.decode(token);
Expand All @@ -473,8 +474,11 @@ export class DMPWebDAVAuthentication implements HTTPAuthentication {
}
});
try {
const associatedUser = await userRetrieval(this.db, pubkey);
callback(null, associatedUser);
userRetrieval(this.db, pubkey).then((associatedUser) => {
callback(null, associatedUser);
}).catch(() => {
callback(new Error('Invalid credentials'));
});
} catch {
callback(new Error('Invalid credentials'));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-docker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"express": "4.20.0",
"express-rate-limit": "7.4.0",
"isobject": "4.0.0",
"minio": "7.1.3",
"minio": "8.0.1",
"mongodb": "6.8.1",
"sanitize-filename": "1.6.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-interface/express-user.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare global {

namespace Express {

// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type
interface User extends IUserWithoutToken { }

interface MulterFile {
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-interface/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable */
export default {
displayName: 'itmat-interface',
preset: '../../jest.preset.js',
preset: '../../jest.preset.cjs',
verbose: true,
transform: {
'^.+\\.[tj]s$': ['ts-jest', {
Expand Down
2 changes: 1 addition & 1 deletion packages/itmat-interface/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"main": "packages/itmat-interface/src/index.ts",
"tsConfig": "packages/itmat-interface/tsconfig.app.json",
"assets": [],
"webpackConfig": "packages/itmat-interface/webpack.config.js"
"webpackConfig": "packages/itmat-interface/webpack.config.cjs"
},
"configurations": {
"production": {
Expand Down
3 changes: 2 additions & 1 deletion packages/itmat-interface/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ function serverSpinning() {
console.info(`Shuting down api server ${process.pid} ...`);
interfaceRouter?.on('close', () => {
serverStart();
}) || serverStart();
});
serverStart();
});
} else {
serverStart();
Expand Down
5 changes: 2 additions & 3 deletions packages/itmat-interface/src/server/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import configManager from '../utils/configManager';
import { CreateNextContextOptions } from '@trpc/server/adapters/next';
import { inferAsyncReturnType, initTRPC } from '@trpc/server';


export class APICalls {
permissionCore: PermissionCore;
fileCore: FileCore;
Expand Down Expand Up @@ -53,15 +52,15 @@ export class APICalls {
}

_listOfTRPCRouters() {
const createtRPCContext = async (opts: CreateNextContextOptions) => {
const __unusedCreatetRPCContext = async (opts: CreateNextContextOptions) => {
return {
user: opts.req.user,
req: opts.req,
res: opts.res
};
};

type Context = inferAsyncReturnType<typeof createtRPCContext>;
type Context = inferAsyncReturnType<typeof __unusedCreatetRPCContext>;
const t = initTRPC.context<Context>().create();
const baseProcedure = t.procedure.use(async (opts) => {
return await tRPCBaseProcedureMilldeware(db, opts);
Expand Down
Loading

0 comments on commit a254e01

Please sign in to comment.