Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankbrgowda committed Aug 23, 2023
2 parents 16b1107 + 58abc99 commit f32ef9f
Show file tree
Hide file tree
Showing 121 changed files with 1,904 additions and 1,446 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster
ARG VARIANT=16-buster
ARG VARIANT=18-buster
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

# Install MongoDB command line tools if on buster and x86_64 (arm64 not supported)
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
# Update 'VARIANT' to pick an LTS version of Node.js: 16, 14, 12.
# Append -bullseye or -buster to pin to an OS version.
# Use -bullseye variants on local arm64/Apple Silicon.
VARIANT: 16-buster
VARIANT: 18-buster

volumes:
- ..:/workspace:cached
Expand Down
55 changes: 54 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:unicorn/recommended',
'plugin:cypress/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/strict',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:prettier/recommended',
],
plugins: ['tsdoc'],
plugins: ['tsdoc', 'sort-destructure-keys'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
Expand Down Expand Up @@ -70,8 +71,16 @@ module.exports = {
'import/no-extraneous-dependencies': 'error',
// eslint-plugin-prettier rules (override recommended)
'prettier/prettier': 'warn',
// eslint-plugin-sort-destructure-keys rules
'sort-destructure-keys/sort-destructure-keys': 'warn',
// eslint-plugin-tsdoc rules
'tsdoc/syntax': 'warn',
// eslint-plugin-unicorn rules (override recommended)
'unicorn/filename-case': 'off', // Doesn't match our file naming, maybe can be configured later
'unicorn/no-empty-file': 'off', // False positives
'unicorn/no-null': 'off', // A lot of null in React and other libraries
'unicorn/prefer-module': 'off', // Cypress and apollo-collaboration-server need this
'unicorn/prevent-abbreviations': 'off', // Doesn't guess a lot of abbreviations correctly
// Special case @typescript-eslint/eslint-plugin rule
// Will be part of "plugin:@typescript-eslint/recommended-type-checked" when
// that extension is enabled. Remove from here at that time.
Expand Down Expand Up @@ -123,6 +132,50 @@ module.exports = {
env: { node: true },
},
// Don't enforce tsdoc syntax in JS files
{
files: ['./packages/jbrowse-plugin-apollo/**/*.{ts,tsx}'],
env: { browser: true },
extends: [
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
],
settings: {
// These settings are from eslint-plugin-react
react: {
// React version. "detect" automatically picks the version you have installed.
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
// It will default to "latest" and warn if missing, and to "detect" in the future
version: 'detect',
},
componentWrapperFunctions: [
// The name of any function used to wrap components, e.g. Mobx `observer` function. If this isn't set, components wrapped by these functions will be skipped.
'observer', // `property`
{ property: 'styled' }, // `object` is optional
{ property: 'observer', object: 'Mobx' },
{ property: 'observer', object: '<pragma>' }, // sets `object` to whatever value `settings.react.pragma` is set to
],
},
},
// Lint non-src files (e.g. jest.config.js) using a separate tsconfig
{
files: ['./packages/jbrowse-plugin-apollo/*.js'],
parserOptions: {
project: 'packages/jbrowse-plugin-apollo/tsconfig.eslint.json',
},
env: { node: true },
},
// Specify Node env for cypress testing files
{
files: ['./packages/jbrowse-plugin-apollo/cypress/**/*.js'],
env: { node: true },
},
// Specify Node env for apollo-collaboration-server/
{
files: ['./packages/apollo-collaboration-server/**/*.ts'],
env: { node: true },
},
// Don't enforce tsdoc syntax in JS files
{
files: ['**/*.js'],
rules: {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
steps:
- name: Check out
uses: actions/checkout@v3
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: yarn
- name: Install
run: yarn --immutable
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
steps:
- name: Check out
uses: actions/checkout@v3
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: yarn
- name: Install
run: yarn --immutable
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-sort-destructure-keys": "^1.5.0",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-unicorn": "^48.0.0",
"import-sort-parser-typescript": "^6.0.0",
"import-sort-style-module": "^6.0.0",
"jest": "^29.6.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-collaboration-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@types/express-session": "^1",
"@types/jest": "^27.0.1",
"@types/multer": "^1.4.7",
"@types/node": "^16.0.0",
"@types/node": "^18.11.9",
"@types/node-fetch": "^2.6.2",
"@types/passport-google-oauth20": "^2.0.11",
"@types/passport-jwt": "^3.0.6",
Expand All @@ -96,7 +96,7 @@
"rimraf": "^3.0.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",
"ts-jest": "^29.1.1",
"ts-loader": "^9.2.3",
"ts-node": "^10.3.0",
"ts-node-dev": "^1.1.8",
Expand Down
17 changes: 8 additions & 9 deletions packages/apollo-collaboration-server/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs/promises'
import path from 'path'
import fs from 'node:fs/promises'
import path from 'node:path'

import { Module } from '@nestjs/common'
import { ConfigModule, ConfigService } from '@nestjs/config'
Expand Down Expand Up @@ -59,7 +59,7 @@ const validationSchema = Joi.object({
const errorMessage =
'LOG_LEVELS must be a comma-separated list of log levels to output, where the possible values are: error, warn, log, debug, verbose'
if (typeof value !== 'string') {
throw new Error(errorMessage)
throw new TypeError(errorMessage)
}
const levels = value.split(',')
for (const level of levels) {
Expand All @@ -85,7 +85,7 @@ const validationSchema = Joi.object({
const errorMessage =
'PLUGIN_URLS must be a comma-separated list of plugin URLs'
if (typeof value !== 'string') {
throw new Error(errorMessage)
throw new TypeError(errorMessage)
}
const urls = value.split(',')
for (const url of urls) {
Expand Down Expand Up @@ -116,15 +116,14 @@ async function mongoDBURIFactory(
if (!uri) {
// We can use non-null assertion since joi already checks this for us
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const uriFile = configService.get('MONGODB_URI_FILE', {
infer: true,
})!
uri = (await fs.readFile(uriFile, 'utf-8')).trim()
const uriFile = configService.get('MONGODB_URI_FILE', { infer: true })!
const uriFileText = await fs.readFile(uriFile, 'utf8')
uri = uriFileText.trim()
}
return {
uri,
connectionFactory: (connection: Connection) => {
connection.set('maxTimeMS', 7200000)
connection.set('maxTimeMS', 7_200_000)
return connection
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs/promises'
import fs from 'node:fs/promises'

import { Module } from '@nestjs/common'
import { ConfigModule, ConfigService } from '@nestjs/config'
Expand All @@ -24,10 +24,9 @@ async function jwtConfigFactory(
if (!jwtSecret) {
// We can use non-null assertion since joi already checks this for us
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const uriFile = configService.get('JWT_SECRET_FILE', {
infer: true,
})!
jwtSecret = (await fs.readFile(uriFile, 'utf-8')).trim()
const jwtFile = configService.get('JWT_SECRET_FILE', { infer: true })!
const jwtFileText = await fs.readFile(jwtFile, 'utf8')
jwtSecret = jwtFileText.trim()
}
return { secret: jwtSecret, signOptions: { expiresIn: '1d' } }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ export class AuthenticationService {
private readonly usersService: UsersService,
private readonly jwtService: JwtService,
private readonly configService: ConfigService<
{
DEFAULT_NEW_USER_ROLE: Role | 'none'
ALLOW_GUEST_USER: boolean
},
{ DEFAULT_NEW_USER_ROLE: Role | 'none'; ALLOW_GUEST_USER: boolean },
true
>,
) {
Expand All @@ -40,7 +37,7 @@ export class AuthenticationService {
if (!profile._json.email) {
throw new UnauthorizedException('No email provided')
}
const { name, email } = profile._json
const { email, name } = profile._json
return this.logIn(name ?? 'N/A', email)
}

Expand Down Expand Up @@ -87,10 +84,7 @@ export class AuthenticationService {
const hasAdmin = userCount > 1 || (userCount === 1 && !guestUser)
// If there is not a non-guest user yet, the 1st user role will be admin
const newUserRole = hasAdmin ? this.defaultNewUserRole : Role.Admin
const newUser: CreateUserDto = {
email,
username: name,
}
const newUser: CreateUserDto = { email, username: name }
if (newUserRole !== 'none') {
newUser.role = newUserRole
}
Expand Down
27 changes: 10 additions & 17 deletions packages/apollo-collaboration-server/src/changes/changes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class ChangesService {
pluginsService: this.pluginsService,
user: uniqUserId,
})
} catch (e) {
} catch (error) {
// Clean up old "temporary document" -documents
// We cannot use Mongo 'session' / transaction here because Mongo has 16 MB limit for transaction
this.logger.debug(
Expand All @@ -134,16 +134,12 @@ export class ChangesService {
await this.refSeqChunkModel.deleteMany({
$and: [{ status: -1, user: uniqUserId }],
})
throw new UnprocessableEntityException(String(e))
throw new UnprocessableEntityException(String(error))
}

// Add entry to change collection
const [savedChangedLogDoc] = await this.changeModel.create([
{
...change,
user: user.email,
sequence,
},
{ ...change, user: user.email, sequence },
])
changeDoc = savedChangedLogDoc
const validationResult2 = await validationRegistry.backendPostValidate(
Expand Down Expand Up @@ -181,7 +177,7 @@ export class ChangesService {
{ $and: [{ status: -1, user: uniqUserId }] },
{ $set: { status: 0 } },
)
} catch (e) {
} catch (error) {
// Clean up old "temporary document" -documents
this.logger.debug(
'*** UPDATE STATUS EXCEPTION - Start to clean up old temporary documents...',
Expand All @@ -199,7 +195,7 @@ export class ChangesService {
await this.refSeqChunkModel.deleteMany({
$and: [{ status: -1, user: uniqUserId }],
})
throw new UnprocessableEntityException(String(e))
throw new UnprocessableEntityException(String(error))
}
})

Expand Down Expand Up @@ -240,10 +236,7 @@ export class ChangesService {
async findAll(changeFilter: FindChangeDto) {
const queryCond: FilterQuery<ChangeDocument> = { ...changeFilter }
if (changeFilter.user) {
queryCond.user = {
$regex: `${changeFilter.user}`,
$options: 'i',
}
queryCond.user = { $regex: `${changeFilter.user}`, $options: 'i' }
}
if (changeFilter.since) {
queryCond.sequence = { $gt: Number(changeFilter.since) }
Expand All @@ -252,12 +245,12 @@ export class ChangesService {
this.logger.debug(`Search criteria: "${JSON.stringify(queryCond)}"`)

let sortOrder: 1 | -1 = -1
if (changeFilter.sort) {
if (changeFilter.sort === '1') {
sortOrder = 1
}
if (changeFilter.sort && changeFilter.sort === '1') {
sortOrder = 1
}
let changeCursor = this.changeModel
// unicorn thinks this is an Array.prototype.find, so we ignore it
// eslint-disable-next-line unicorn/no-array-callback-reference
.find(queryCond)
.sort({ sequence: sortOrder })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ import { FeaturesService } from './features.service'
},
inject: [getConnectionToken()],
},
{
name: Export.name,
useFactory: () => ExportSchema,
},
{ name: Export.name, useFactory: () => ExportSchema },
]),
],
exports: [MongooseModule],
Expand Down
Loading

0 comments on commit f32ef9f

Please sign in to comment.