From b8db72bac44a858ccc5319ddee2b6d83c81ed4a9 Mon Sep 17 00:00:00 2001 From: Caramel Date: Thu, 15 Jun 2023 13:09:23 +0200 Subject: [PATCH] Change some typescript compilation options and fix eslint --- .eslintrc.cjs | 19 ++++++ backend/.eslintrc.cjs | 20 +----- backend/package.json | 9 +-- backend/src/app.module.ts | 2 +- .../apikey-db/apikey-db.service.ts | 7 ++- .../collections/image-db/image-db.service.ts | 2 +- .../image-db/image-file-db.service.ts | 7 ++- .../preference-common.service.ts | 2 +- .../sys-preference-db.service.ts | 17 +++-- .../usr-preference-db.service.ts | 17 +++-- .../src/collections/role-db/role-db.module.ts | 2 +- .../collections/role-db/role-db.service.ts | 8 +-- .../system-state-db.service.ts | 2 +- .../src/collections/user-db/user-db.module.ts | 2 +- .../collections/user-db/user-db.service.ts | 6 +- .../config/early/type-orm.config.service.ts | 8 +-- .../src/config/late/info.config.service.ts | 2 +- backend/src/config/late/jwt.config.service.ts | 2 +- .../src/config/late/usage.config.service.ts | 7 ++- .../entities/system/sys-preference.entity.ts | 2 +- .../entities/system/usr-preference.entity.ts | 2 +- backend/src/database/migrations/index.ts | 4 +- .../decorators/image-id/image-full-id.pipe.ts | 6 +- .../src/decorators/image-id/image-id.pipe.ts | 6 +- .../src/decorators/multipart/postfile.pipe.ts | 4 +- .../decorators/multipart/postfiles.pipe.ts | 15 +---- .../src/decorators/permissions.decorator.ts | 2 +- .../src/decorators/request-user.decorator.ts | 2 +- backend/src/decorators/returns.decorator.ts | 4 +- .../src/layers/success/success.interceptor.ts | 8 +-- .../layers/throttler/PicsurThrottler.guard.ts | 6 +- .../src/layers/validate/zod-validator.pipe.ts | 4 +- backend/src/managers/auth/auth.service.ts | 2 +- .../managers/auth/guards/apikey.strategy.ts | 4 +- .../managers/auth/guards/guest.strategy.ts | 5 +- .../src/managers/auth/guards/jwt.strategy.ts | 2 +- .../auth/guards/local-auth.strategy.ts | 5 +- .../src/managers/auth/guards/main.guard.ts | 2 +- backend/src/managers/auth/guest.service.ts | 2 +- .../managers/image/image-converter.service.ts | 7 ++- .../managers/image/image-manager.module.ts | 2 +- .../managers/image/image-processor.service.ts | 7 ++- backend/src/managers/image/image.service.ts | 13 ++-- .../src/managers/image/webpinfo/webpinfo.ts | 6 +- backend/src/managers/usage/usage.service.ts | 4 +- backend/src/models/constants/roles.const.ts | 2 +- .../routes/api/apikeys/apikeys.controller.ts | 2 +- .../api/experiment/experiment.controller.ts | 2 - .../src/routes/api/info/info.controller.ts | 2 +- .../routes/api/pref/sys-pref.controller.ts | 2 +- .../routes/api/pref/usr-pref.controller.ts | 2 +- .../src/routes/api/roles/roles.controller.ts | 2 +- .../src/routes/api/usage/usage.controller.ts | 2 +- .../routes/api/user/user-manage.controller.ts | 2 +- .../src/routes/api/user/user.controller.ts | 2 +- .../routes/image/image-manage.controller.ts | 7 ++- backend/src/routes/image/image.controller.ts | 6 +- backend/src/util/branding.ts | 2 +- backend/src/util/iterator.ts | 2 +- backend/src/workers/sharp.wrapper.ts | 8 +-- backend/src/workers/sharp/sharp.worker.ts | 6 +- backend/tsconfig.json | 3 - frontend/.eslintrc.cjs | 9 +++ frontend/custom-webpack.config.js | 6 +- frontend/package.json | 6 +- frontend/src/app/app.component.ts | 12 ++-- .../copy-field/copy-field.component.ts | 16 ++--- .../copy-field/copy-field.module.ts | 3 +- .../components/fab/normal/fab.component.ts | 9 ++- .../fab/speed-dial/speed-dial.component.html | 2 +- .../fab/speed-dial/speed-dial.component.ts | 16 ++--- .../app/components/footer/footer.component.ts | 6 +- .../app/components/header/header.component.ts | 22 +++---- .../app/components/header/header.module.ts | 2 +- .../masonry/masonry-item.directive.ts | 7 +-- .../components/masonry/masonry.component.ts | 12 ++-- .../paginator/paginator.component.ts | 12 ++-- .../components/paginator/paginator.module.ts | 2 +- .../picsur-img/picsur-img.component.html | 4 +- .../picsur-img/picsur-img.component.ts | 19 +++--- .../pref-option/pref-option.component.ts | 16 ++--- .../pref-option/pref-option.module.ts | 2 +- .../values-picker/values-picker.component.ts | 8 +-- frontend/src/app/guards/permission.guard.ts | 14 ++--- ...s => images-upload-request.dto.exclude.ts} | 0 .../src/app/models/dto/server-info.dto.ts | 6 +- .../src/app/models/forms/login.control.ts | 2 +- .../src/app/models/forms/register.control.ts | 2 +- .../app/models/forms/update-user.control.ts | 2 +- frontend/src/app/pipes/truncate.pipe.ts | 4 +- .../routes/errors/errors.routing.module.ts | 2 +- .../src/app/routes/images/images.component.ts | 20 +++--- .../src/app/routes/images/images.module.ts | 12 ++-- .../routes/images/images.routing.module.ts | 4 +- .../routes/processing/processing.component.ts | 12 ++-- .../routes/processing/processing.module.ts | 2 +- .../processing/processing.routing.module.ts | 2 +- .../apikey-editor.component.html | 2 +- .../apikey-editor/apikey-editor.component.ts | 4 +- .../apikeys/settings-apikeys.component.ts | 22 +++---- .../apikeys/settings-apikeys.module.ts | 6 +- .../settings-apikeys.routing.module.ts | 2 +- .../general/settings-general.component.ts | 4 +- .../general/settings-general.module.ts | 2 +- .../settings-general.routing.module.ts | 2 +- .../settings-roles-edit.component.ts | 14 ++--- .../roles/settings-roles.component.ts | 16 ++--- .../settings/roles/settings-roles.module.ts | 8 +-- .../roles/settings-roles.routing.module.ts | 2 +- .../settings/settings.routing.module.ts | 6 +- .../sharex/settings-sharex.component.ts | 14 ++--- .../settings/sharex/settings-sharex.module.ts | 2 +- .../sharex/settings-sharex.routing.module.ts | 2 +- .../sidebar/settings-sidebar.component.ts | 4 +- .../sys-pref/settings-sys-pref.component.ts | 4 +- .../sys-pref/settings-sys-pref.module.ts | 2 +- .../settings-sys-pref.routing.module.ts | 2 +- .../settings-users-edit.component.ts | 16 ++--- .../users/settings-users.component.ts | 20 +++--- .../settings/users/settings-users.module.ts | 8 +-- .../users/settings-users.routing.module.ts | 2 +- .../src/app/routes/upload/upload.component.ts | 8 +-- .../src/app/routes/upload/upload.module.ts | 2 +- .../routes/upload/upload.routing.module.ts | 2 +- .../app/routes/user/login/login.component.ts | 12 ++-- .../user/register/register.component.ts | 12 ++-- frontend/src/app/routes/user/user.module.ts | 2 +- .../app/routes/user/user.routing.module.ts | 4 +- .../customize-dialog.component.ts | 10 ++- .../view/edit-dialog/edit-dialog.component.ts | 16 +++-- .../view-speeddial.component.ts | 20 +++--- .../src/app/routes/view/view.component.ts | 12 ++-- frontend/src/app/routes/view/view.module.ts | 12 ++-- .../app/routes/view/view.routing.module.ts | 4 +- frontend/src/app/services/api/api.service.ts | 11 ++-- .../src/app/services/api/apikeys.service.ts | 2 +- .../src/app/services/api/image.service.ts | 31 +++++----- frontend/src/app/services/api/info.service.ts | 7 ++- .../app/services/api/permission.service.ts | 8 +-- .../src/app/services/api/roles.service.ts | 4 +- .../app/services/api/static-info.service.ts | 2 +- .../src/app/services/api/sys-pref.service.ts | 8 +-- .../app/services/api/user-manage.service.ts | 2 +- frontend/src/app/services/api/user.service.ts | 6 +- .../src/app/services/api/usr-pref.service.ts | 8 +-- .../sidebar-resolver.service.ts | 2 +- .../src/app/services/storage/cache.service.ts | 6 +- .../services/storage/info-storage.service.ts | 2 +- .../api-error-manager/api-error.service.ts | 1 + frontend/src/app/util/bootstrap.service.ts | 2 +- .../compatibility.service.ts | 7 ++- .../app/util/dialog-manager/dialog.service.ts | 4 +- .../util/download-manager/download.service.ts | 6 +- .../app/util/error-manager/error.service.ts | 6 +- .../util/snackbar-manager/snackbar.service.ts | 6 +- frontend/src/app/util/util.service.ts | 6 +- frontend/src/app/workers/qoi-worker.dto.ts | 2 +- .../src/app/workers/qoi-worker.service.ts | 14 +++-- frontend/src/app/workers/qoi.job.ts | 2 +- frontend/src/scss/fonts.scss | 1 - frontend/tsconfig.base.json | 2 - package.json | 15 +++-- shared/.eslintrc.cjs | 8 +++ shared/package.json | 8 ++- shared/src/dto/api/api.dto.ts | 2 +- shared/src/dto/image-links.class.ts | 10 +-- shared/src/dto/mimes.dto.ts | 6 +- shared/src/entities/image.entity.ts | 4 -- shared/src/types/index.ts | 3 - shared/src/util/decorator.ts | 2 +- shared/src/util/parse-mime.ts | 2 +- shared/src/util/random.ts | 4 +- shared/tsconfig.json | 2 +- tsconfig.base.json | 3 +- yarn.lock | 62 ++++++++++++++----- 175 files changed, 627 insertions(+), 540 deletions(-) create mode 100644 frontend/.eslintrc.cjs rename frontend/src/app/models/dto/{images-upload-request.dto.ts => images-upload-request.dto.exclude.ts} (100%) create mode 100644 shared/.eslintrc.cjs delete mode 100644 shared/src/types/index.ts diff --git a/.eslintrc.cjs b/.eslintrc.cjs index e3513524..76d21564 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,3 +1,22 @@ module.exports = { + parser: '@typescript-eslint/parser', + + plugins: ['@typescript-eslint/eslint-plugin'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + env: { + node: true, + jest: true, + }, + ignorePatterns: ['.eslintrc.cjs', 'dist', '*.exclude.*'], + rules: { + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + }, root: true, }; diff --git a/backend/.eslintrc.cjs b/backend/.eslintrc.cjs index 1be65c78..2a74f49c 100644 --- a/backend/.eslintrc.cjs +++ b/backend/.eslintrc.cjs @@ -1,27 +1,9 @@ module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { project: './tsconfig.json', tsconfigRootDir: __dirname, sourceType: 'module', }, - plugins: ['@typescript-eslint/eslint-plugin', 'require-extensions'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - 'plugin:require-extensions/recommended', - ], + extends: ['../.eslintrc.cjs'], root: false, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.cjs'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - }, }; diff --git a/backend/package.json b/backend/package.json index 8eb4dd2d..962d049a 100644 --- a/backend/package.json +++ b/backend/package.json @@ -19,7 +19,6 @@ "migrate": "PICSUR_PRODUCTION=\"true\" yarn typeorm migration:generate -d ./src/datasource.ts", "format": "prettier --write \"src/**/*.ts\"", "clean": "rimraf dist", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "purge": "rm -rf dist && rm -rf node_modules" }, "dependencies": { @@ -40,10 +39,9 @@ "bcrypt": "^5.1.0", "bmp-img": "^1.2.1", "cors": "^2.8.5", - "eslint-plugin-require-extensions": "^0.1.3", "file-type": "^18.5.0", "is-docker": "^3.0.0", - "ms": "^2.1.3", + "ms": "3.0.0-canary.1", "node-fetch": "^3.3.1", "p-timeout": "^6.1.1", "passport": "^0.6.0", @@ -77,11 +75,6 @@ "@types/passport-strategy": "^0.2.35", "@types/sharp": "^0.32.0", "@types/supertest": "^2.0.12", - "@typescript-eslint/eslint-plugin": "^5.59.9", - "@typescript-eslint/parser": "^5.59.9", - "eslint": "^8.42.0", - "eslint-config-prettier": "^8.8.0", - "eslint-plugin-prettier": "^4.2.1", "prettier": "^2.8.8", "source-map-support": "^0.5.21", "ts-loader": "^9.4.3", diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 2db11b06..14858388 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -30,7 +30,7 @@ const imageCorsConfig = cors({ const imageCorsOverride = ( req: IncomingMessage, res: ServerResponse, - next: Function, + next: () => void, ) => { res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin'); diff --git a/backend/src/collections/apikey-db/apikey-db.service.ts b/backend/src/collections/apikey-db/apikey-db.service.ts index ae6a3197..a47e69d4 100644 --- a/backend/src/collections/apikey-db/apikey-db.service.ts +++ b/backend/src/collections/apikey-db/apikey-db.service.ts @@ -1,6 +1,11 @@ import { Injectable, Logger } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { FindResult } from 'picsur-shared/dist/types/find-result'; import { generateRandomString } from 'picsur-shared/dist/util/random'; import { Repository } from 'typeorm'; diff --git a/backend/src/collections/image-db/image-db.service.ts b/backend/src/collections/image-db/image-db.service.ts index 870b07ba..2dee106e 100644 --- a/backend/src/collections/image-db/image-db.service.ts +++ b/backend/src/collections/image-db/image-db.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types'; +import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types/failable'; import { FindResult } from 'picsur-shared/dist/types/find-result'; import { generateRandomString } from 'picsur-shared/dist/util/random'; import { In, LessThan, Repository } from 'typeorm'; diff --git a/backend/src/collections/image-db/image-file-db.service.ts b/backend/src/collections/image-db/image-file-db.service.ts index 7991a39b..2b3eaa8a 100644 --- a/backend/src/collections/image-db/image-file-db.service.ts +++ b/backend/src/collections/image-db/image-file-db.service.ts @@ -1,7 +1,12 @@ import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { ImageEntryVariant } from 'picsur-shared/dist/dto/image-entry-variant.enum'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { LessThan, Repository } from 'typeorm'; import { EImageDerivativeBackend } from '../../database/entities/images/image-derivative.entity'; import { EImageFileBackend } from '../../database/entities/images/image-file.entity'; diff --git a/backend/src/collections/preference-db/preference-common.service.ts b/backend/src/collections/preference-db/preference-common.service.ts index 8c5b0520..67670cb6 100644 --- a/backend/src/collections/preference-db/preference-common.service.ts +++ b/backend/src/collections/preference-db/preference-common.service.ts @@ -10,7 +10,7 @@ import { Failable, FT, HasFailed, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; type Enum = Record; type EnumValue = E[keyof E]; diff --git a/backend/src/collections/preference-db/sys-preference-db.service.ts b/backend/src/collections/preference-db/sys-preference-db.service.ts index c893b159..447a9843 100644 --- a/backend/src/collections/preference-db/sys-preference-db.service.ts +++ b/backend/src/collections/preference-db/sys-preference-db.service.ts @@ -11,7 +11,12 @@ import { SysPreferenceValidators, SysPreferenceValueTypes, } from 'picsur-shared/dist/dto/sys-preferences.enum'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { Repository } from 'typeorm'; import { ESysPreferenceBackend, @@ -37,7 +42,7 @@ export class SysPreferenceDbService { value: PrefValueType, ): AsyncFailable { // Validate - let sysPreference = await this.encodeSysPref(key, value); + const sysPreference = await this.encodeSysPref(key, value); if (HasFailed(sysPreference)) return sysPreference; // Set @@ -60,7 +65,7 @@ export class SysPreferenceDbService { public async getPreference(key: string): AsyncFailable { // Validate - let validatedKey = this.prefCommon.validatePrefKey(key, SysPreference); + const validatedKey = this.prefCommon.validatePrefKey(key, SysPreference); if (HasFailed(validatedKey)) return validatedKey; // See the comment in 'mutex-fallback.ts' for why we are using a mutex here @@ -112,7 +117,7 @@ export class SysPreferenceDbService { key: string, type: PrefValueTypeStrings, ): AsyncFailable { - let pref = await this.getPreference(key); + const pref = await this.getPreference(key); if (HasFailed(pref)) return pref; if (pref.type !== type) return Fail(FT.UsrValidation, 'Invalid preference type'); @@ -122,7 +127,7 @@ export class SysPreferenceDbService { public async getAllPreferences(): AsyncFailable { // TODO: We are fetching each value invidually, we should fetch all at once - let internalSysPrefs = await Promise.all( + const internalSysPrefs = await Promise.all( SysPreferenceList.map((key) => this.getPreference(key)), ); if (internalSysPrefs.some((pref) => HasFailed(pref))) { @@ -158,7 +163,7 @@ export class SysPreferenceDbService { return Fail(FT.UsrValidation, undefined, valueValidated.error); } - let verifySysPreference = new ESysPreferenceBackend(); + const verifySysPreference = new ESysPreferenceBackend(); verifySysPreference.key = validated.key; verifySysPreference.value = validated.value; diff --git a/backend/src/collections/preference-db/usr-preference-db.service.ts b/backend/src/collections/preference-db/usr-preference-db.service.ts index 392248ae..72f6cba1 100644 --- a/backend/src/collections/preference-db/usr-preference-db.service.ts +++ b/backend/src/collections/preference-db/usr-preference-db.service.ts @@ -11,7 +11,12 @@ import { UsrPreferenceValidators, UsrPreferenceValueTypes, } from 'picsur-shared/dist/dto/usr-preferences.enum'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { Repository } from 'typeorm'; import { EUsrPreferenceBackend, @@ -38,7 +43,7 @@ export class UsrPreferenceDbService { value: PrefValueType, ): AsyncFailable { // Validate - let usrPreference = await this.encodeUsrPref(userid, key, value); + const usrPreference = await this.encodeUsrPref(userid, key, value); if (HasFailed(usrPreference)) return usrPreference; // Set @@ -66,7 +71,7 @@ export class UsrPreferenceDbService { key: string, ): AsyncFailable { // Validate - let validatedKey = this.prefCommon.validatePrefKey(key, UsrPreference); + const validatedKey = this.prefCommon.validatePrefKey(key, UsrPreference); if (HasFailed(validatedKey)) return validatedKey; // See the comment in 'mutex-fallback.ts' for why we are using a mutex here @@ -145,7 +150,7 @@ export class UsrPreferenceDbService { key: string, type: PrefValueTypeStrings, ): AsyncFailable { - let pref = await this.getPreference(userid, key); + const pref = await this.getPreference(userid, key); if (HasFailed(pref)) return pref; if (pref.type !== type) return Fail(FT.UsrValidation, 'Invalid preference type'); @@ -157,7 +162,7 @@ export class UsrPreferenceDbService { userid: string, ): AsyncFailable { // TODO: We are fetching each value invidually, we should fetch all at once - let internalSysPrefs = await Promise.all( + const internalSysPrefs = await Promise.all( UsrPreferenceList.map((key) => this.getPreference(userid, key)), ); if (internalSysPrefs.some((pref) => HasFailed(pref))) { @@ -199,7 +204,7 @@ export class UsrPreferenceDbService { return Fail(FT.UsrValidation, undefined, valueValidated.error); } - let verifySysPreference = new EUsrPreferenceBackend(); + const verifySysPreference = new EUsrPreferenceBackend(); verifySysPreference.key = validated.key; verifySysPreference.value = validated.value; verifySysPreference.user_id = userid; diff --git a/backend/src/collections/role-db/role-db.module.ts b/backend/src/collections/role-db/role-db.module.ts index a4af867f..69cf9756 100644 --- a/backend/src/collections/role-db/role-db.module.ts +++ b/backend/src/collections/role-db/role-db.module.ts @@ -1,6 +1,6 @@ import { Logger, Module, OnModuleInit } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { EarlyConfigModule } from '../../config/early/early-config.module'; import { HostConfigService } from '../../config/early/host.config.service'; import { ERoleBackend } from '../../database/entities/users/role.entity'; diff --git a/backend/src/collections/role-db/role-db.service.ts b/backend/src/collections/role-db/role-db.service.ts index 1d2cb0a4..2057a328 100644 --- a/backend/src/collections/role-db/role-db.service.ts +++ b/backend/src/collections/role-db/role-db.service.ts @@ -7,7 +7,7 @@ import { FT, HasFailed, HasSuccess, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; import { makeUnique } from 'picsur-shared/dist/util/unique'; import { In, Repository } from 'typeorm'; import { ERoleBackend } from '../../database/entities/users/role.entity'; @@ -33,7 +33,7 @@ export class RoleDbService { if (await this.exists(name)) return Fail(FT.Conflict, 'Role already exists'); - let role = new ERoleBackend(); + const role = new ERoleBackend(); role.name = name; role.permissions = permissions; @@ -105,7 +105,7 @@ export class RoleDbService { role: string | ERoleBackend, permissions: Permissions, // Extra bypass for internal use - allowImmutable: boolean = false, + allowImmutable = false, ): AsyncFailable { const roleToModify = await this.resolve(role); if (HasFailed(roleToModify)) return roleToModify; @@ -166,7 +166,7 @@ export class RoleDbService { return HasSuccess(await this.findOne(name)); } - public async nukeSystemRoles(IAmSure: boolean = false): AsyncFailable { + public async nukeSystemRoles(IAmSure = false): AsyncFailable { if (!IAmSure) return Fail( FT.SysValidation, diff --git a/backend/src/collections/system-state-db/system-state-db.service.ts b/backend/src/collections/system-state-db/system-state-db.service.ts index 28a4be30..c32f4b5c 100644 --- a/backend/src/collections/system-state-db/system-state-db.service.ts +++ b/backend/src/collections/system-state-db/system-state-db.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types'; +import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types/failable'; import { Repository } from 'typeorm'; import { ESystemStateBackend } from '../../database/entities/system/system-state.entity'; diff --git a/backend/src/collections/user-db/user-db.module.ts b/backend/src/collections/user-db/user-db.module.ts index e405e114..c02e21f6 100644 --- a/backend/src/collections/user-db/user-db.module.ts +++ b/backend/src/collections/user-db/user-db.module.ts @@ -1,6 +1,6 @@ import { Logger, Module, OnModuleInit } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { generateRandomString } from 'picsur-shared/dist/util/random'; import { AuthConfigService } from '../../config/early/auth.config.service'; import { EarlyConfigModule } from '../../config/early/early-config.module'; diff --git a/backend/src/collections/user-db/user-db.service.ts b/backend/src/collections/user-db/user-db.service.ts index 0e2b3179..b94a30dc 100644 --- a/backend/src/collections/user-db/user-db.service.ts +++ b/backend/src/collections/user-db/user-db.service.ts @@ -8,7 +8,7 @@ import { FT, HasFailed, HasSuccess, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; import { FindResult } from 'picsur-shared/dist/types/find-result'; import { makeUnique } from 'picsur-shared/dist/util/unique'; import { Repository } from 'typeorm'; @@ -53,7 +53,7 @@ export class UserDbService { const strength = await this.getBCryptStrength(); const hashedPassword = await bcrypt.hash(password, strength); - let user = new EUserBackend(); + const user = new EUserBackend(); user.username = username; user.hashed_password = hashedPassword; if (byPassRoleCheck) { @@ -208,7 +208,7 @@ export class UserDbService { username: string, // Also fetch fields that aren't normally sent to the client // (e.g. hashed password) - getPrivate: boolean = false, + getPrivate = false, ): AsyncFailable { try { const found = await this.usersRepository.findOne({ diff --git a/backend/src/config/early/type-orm.config.service.ts b/backend/src/config/early/type-orm.config.service.ts index da8e9b2c..e39bb11f 100644 --- a/backend/src/config/early/type-orm.config.service.ts +++ b/backend/src/config/early/type-orm.config.service.ts @@ -2,8 +2,8 @@ import { Injectable, Logger } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm'; import { ParseInt, ParseString } from 'picsur-shared/dist/util/parse-simple'; -import { EntityList } from '../../database/entities'; -import { MigrationList } from '../../database/migrations'; +import { EntityList } from '../../database/entities/index'; +import { MigrationList } from '../../database/migrations/index'; import { DefaultName, EnvPrefix } from '../config.static'; import { HostConfigService } from './host.config.service'; @@ -48,10 +48,10 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory { return varOptions; } - public createTypeOrmOptions(connectionName?: string) { + public createTypeOrmOptions() { const varOptions = this.getTypeOrmServerOptions(); return { - type: 'postgres' as 'postgres', + type: 'postgres' as const, synchronize: !this.hostService.isProduction(), migrationsRun: true, diff --git a/backend/src/config/late/info.config.service.ts b/backend/src/config/late/info.config.service.ts index 891aadc9..7da1e179 100644 --- a/backend/src/config/late/info.config.service.ts +++ b/backend/src/config/late/info.config.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { SysPreferenceDbService } from '../../collections/preference-db/sys-preference-db.service'; @Injectable() diff --git a/backend/src/config/late/jwt.config.service.ts b/backend/src/config/late/jwt.config.service.ts index 966178d4..10f90222 100644 --- a/backend/src/config/late/jwt.config.service.ts +++ b/backend/src/config/late/jwt.config.service.ts @@ -1,7 +1,7 @@ import { FactoryProvider, Injectable, Logger } from '@nestjs/common'; import { JwtModuleOptions, JwtOptionsFactory } from '@nestjs/jwt'; import ms from 'ms'; -import { ThrowIfFailed } from 'picsur-shared/dist/types'; +import { ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { SysPreferenceDbService } from '../../collections/preference-db/sys-preference-db.service'; @Injectable() diff --git a/backend/src/config/late/usage.config.service.ts b/backend/src/config/late/usage.config.service.ts index 3ee05eec..1a4fb057 100644 --- a/backend/src/config/late/usage.config.service.ts +++ b/backend/src/config/late/usage.config.service.ts @@ -1,6 +1,11 @@ import { Injectable } from '@nestjs/common'; import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { URLRegex, UUIDRegex } from 'picsur-shared/dist/util/common-regex'; import { SysPreferenceDbService } from '../../collections/preference-db/sys-preference-db.service'; import { ReportInterval, ReportUrl } from '../config.static'; diff --git a/backend/src/database/entities/system/sys-preference.entity.ts b/backend/src/database/entities/system/sys-preference.entity.ts index 9f72f220..516aa906 100644 --- a/backend/src/database/entities/system/sys-preference.entity.ts +++ b/backend/src/database/entities/system/sys-preference.entity.ts @@ -1,6 +1,6 @@ import { IsEntityID } from 'picsur-shared/dist/validators/entity-id.validator'; import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'; -import z from 'zod'; +import * as z from 'zod'; export const ESysPreferenceSchema = z.object({ id: IsEntityID().optional(), diff --git a/backend/src/database/entities/system/usr-preference.entity.ts b/backend/src/database/entities/system/usr-preference.entity.ts index 8f7dd7ac..6a163b85 100644 --- a/backend/src/database/entities/system/usr-preference.entity.ts +++ b/backend/src/database/entities/system/usr-preference.entity.ts @@ -8,7 +8,7 @@ import { PrimaryGeneratedColumn, Unique, } from 'typeorm'; -import z from 'zod'; +import * as z from 'zod'; import { EUserBackend } from '../users/user.entity'; export const EUsrPreferenceSchema = z.object({ diff --git a/backend/src/database/migrations/index.ts b/backend/src/database/migrations/index.ts index f75529da..27017868 100644 --- a/backend/src/database/migrations/index.ts +++ b/backend/src/database/migrations/index.ts @@ -1,3 +1,4 @@ +import { MigrationInterface } from 'typeorm'; import { V030A1661692206479 } from './1661692206479-V_0_3_0_a'; import { V032A1662029904716 } from './1662029904716-V_0_3_2_a'; import { V040A1662314197741 } from './1662314197741-V_0_4_0_a'; @@ -5,8 +6,9 @@ import { V040B1662485374471 } from './1662485374471-V_0_4_0_b'; import { V040C1662535484200 } from './1662535484200-V_0_4_0_c'; import { V040D1662728275448 } from './1662728275448-V_0_4_0_d'; import { V050A1672154027079 } from './1672154027079-V_0_5_0_a'; +import { Newable } from 'picsur-shared/dist/types/newable.js'; -export const MigrationList: Function[] = [ +export const MigrationList: Newable[] = [ V030A1661692206479, V032A1662029904716, V040A1662314197741, diff --git a/backend/src/decorators/image-id/image-full-id.pipe.ts b/backend/src/decorators/image-id/image-full-id.pipe.ts index b76ae25e..28c6534f 100644 --- a/backend/src/decorators/image-id/image-full-id.pipe.ts +++ b/backend/src/decorators/image-id/image-full-id.pipe.ts @@ -1,12 +1,12 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; +import { Injectable, PipeTransform } from '@nestjs/common'; import { Ext2FileType } from 'picsur-shared/dist/dto/mimes.dto'; -import { Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { FT, Fail, HasFailed } from 'picsur-shared/dist/types/failable'; import { UUIDRegex } from 'picsur-shared/dist/util/common-regex'; import { ImageFullId } from '../../models/constants/image-full-id.const'; @Injectable() export class ImageFullIdPipe implements PipeTransform { - transform(value: string, metadata: ArgumentMetadata): ImageFullId { + transform(value: string): ImageFullId { const split = value.split('.'); if (split.length === 2) { const [id, ext] = split; diff --git a/backend/src/decorators/image-id/image-id.pipe.ts b/backend/src/decorators/image-id/image-id.pipe.ts index e35708bc..f5c51f8f 100644 --- a/backend/src/decorators/image-id/image-id.pipe.ts +++ b/backend/src/decorators/image-id/image-id.pipe.ts @@ -1,10 +1,10 @@ -import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { Injectable, PipeTransform } from '@nestjs/common'; +import { FT, Fail } from 'picsur-shared/dist/types/failable'; import { UUIDRegex } from 'picsur-shared/dist/util/common-regex'; @Injectable() export class ImageIdPipe implements PipeTransform { - transform(value: string, metadata: ArgumentMetadata): string { + transform(value: string): string { if (UUIDRegex.test(value)) return value; throw Fail(FT.UsrValidation, 'Invalid image id'); } diff --git a/backend/src/decorators/multipart/postfile.pipe.ts b/backend/src/decorators/multipart/postfile.pipe.ts index f14a3d79..6c2f48c5 100644 --- a/backend/src/decorators/multipart/postfile.pipe.ts +++ b/backend/src/decorators/multipart/postfile.pipe.ts @@ -1,7 +1,7 @@ import { Multipart, MultipartFile } from '@fastify/multipart'; import { Injectable, Logger, PipeTransform, Scope } from '@nestjs/common'; import { FastifyRequest } from 'fastify'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { Fail, FT } from 'picsur-shared/dist/types/failable'; import { MultipartConfigService } from '../../config/early/multipart.config.service'; @Injectable({ scope: Scope.REQUEST }) @@ -12,7 +12,7 @@ export class PostFilePipe implements PipeTransform { private readonly multipartConfigService: MultipartConfigService, ) {} - async transform({ request, data }: { data: any; request: FastifyRequest }) { + async transform({ request }: { request: FastifyRequest }) { if (!request.isMultipart()) throw Fail(FT.UsrValidation, 'Invalid file'); // Only one file is allowed diff --git a/backend/src/decorators/multipart/postfiles.pipe.ts b/backend/src/decorators/multipart/postfiles.pipe.ts index 69766932..531e52a2 100644 --- a/backend/src/decorators/multipart/postfiles.pipe.ts +++ b/backend/src/decorators/multipart/postfiles.pipe.ts @@ -1,13 +1,7 @@ import { MultipartFile } from '@fastify/multipart'; -import { - ArgumentMetadata, - Injectable, - Logger, - PipeTransform, - Scope, -} from '@nestjs/common'; +import { Injectable, Logger, PipeTransform, Scope } from '@nestjs/common'; import { FastifyRequest } from 'fastify'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { FT, Fail } from 'picsur-shared/dist/types/failable'; import { MultipartConfigService } from '../../config/early/multipart.config.service'; export type FileIterator = AsyncIterableIterator; @@ -20,10 +14,7 @@ export class MultiPartPipe implements PipeTransform { private readonly multipartConfigService: MultipartConfigService, ) {} - async transform( - { request, data }: { data: any; request: FastifyRequest }, - metadata: ArgumentMetadata, - ) { + async transform({ request, data }: { data: any; request: FastifyRequest }) { const filesLimit = typeof data === 'number' ? data : undefined; if (!request.isMultipart()) throw Fail(FT.UsrValidation, 'Invalid files'); diff --git a/backend/src/decorators/permissions.decorator.ts b/backend/src/decorators/permissions.decorator.ts index d1256982..59ff88ce 100644 --- a/backend/src/decorators/permissions.decorator.ts +++ b/backend/src/decorators/permissions.decorator.ts @@ -4,7 +4,7 @@ import { SetMetadata, UseGuards, } from '@nestjs/common'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { Fail, FT } from 'picsur-shared/dist/types/failable'; import { CombineFCDecorators } from 'picsur-shared/dist/util/decorator'; import { LocalAuthGuard } from '../managers/auth/guards/local-auth.guard'; import { Permission, Permissions } from '../models/constants/permissions.const'; diff --git a/backend/src/decorators/request-user.decorator.ts b/backend/src/decorators/request-user.decorator.ts index fdfa0c86..7fc7be92 100644 --- a/backend/src/decorators/request-user.decorator.ts +++ b/backend/src/decorators/request-user.decorator.ts @@ -1,5 +1,5 @@ import { createParamDecorator, ExecutionContext } from '@nestjs/common'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { Fail, FT } from 'picsur-shared/dist/types/failable'; import AuthFastifyRequest from '../models/interfaces/authrequest.dto'; export const ReqUser = createParamDecorator( diff --git a/backend/src/decorators/returns.decorator.ts b/backend/src/decorators/returns.decorator.ts index 3e32df7a..d623589b 100644 --- a/backend/src/decorators/returns.decorator.ts +++ b/backend/src/decorators/returns.decorator.ts @@ -6,12 +6,12 @@ import { Newable } from 'picsur-shared/dist/types/newable'; type ReturnsMethodDecorator = < T extends (...args: any) => ReturnType | Promise, >( - target: Object, + target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor, ) => TypedPropertyDescriptor | void; -export function Returns( +export function Returns( newable: Newable, ): ReturnsMethodDecorator { return SetMetadata('returns', newable); diff --git a/backend/src/layers/success/success.interceptor.ts b/backend/src/layers/success/success.interceptor.ts index b80c2b65..07fa7736 100644 --- a/backend/src/layers/success/success.interceptor.ts +++ b/backend/src/layers/success/success.interceptor.ts @@ -9,7 +9,7 @@ import { import { Reflector } from '@nestjs/core'; import { FastifyReply } from 'fastify'; import { ApiAnySuccessResponse } from 'picsur-shared/dist/dto/api/api.dto'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { Fail, FT } from 'picsur-shared/dist/types/failable'; import { ZodDtoStatic } from 'picsur-shared/dist/util/create-zod-dto'; import { map, Observable } from 'rxjs'; @@ -20,7 +20,7 @@ export interface ZodValidationInterceptorOptions { } @Injectable() -export class SuccessInterceptor implements NestInterceptor { +export class SuccessInterceptor implements NestInterceptor { private readonly logger = new Logger(); // TODO: make work @@ -82,7 +82,7 @@ export class SuccessInterceptor implements NestInterceptor { ); } - let schema = schemaStatic.zodSchema; + const schema = schemaStatic.zodSchema; const parseResult = schema.safeParse(data); if (!parseResult.success) { @@ -105,7 +105,7 @@ export class SuccessInterceptor implements NestInterceptor { const response = context.switchToHttp().getResponse(); const newResponse: ApiAnySuccessResponse = { - success: true as true, // really typescript + success: true as const, // really typescript statusCode: response.statusCode, timestamp: new Date().toISOString(), timeMs: Math.round(response.getResponseTime()), diff --git a/backend/src/layers/throttler/PicsurThrottler.guard.ts b/backend/src/layers/throttler/PicsurThrottler.guard.ts index bbfe2c7e..3b9c8807 100644 --- a/backend/src/layers/throttler/PicsurThrottler.guard.ts +++ b/backend/src/layers/throttler/PicsurThrottler.guard.ts @@ -1,10 +1,10 @@ -import { ExecutionContext, Injectable } from '@nestjs/common'; +import { Injectable } from '@nestjs/common'; import { ThrottlerGuard } from '@nestjs/throttler'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { FT, Fail } from 'picsur-shared/dist/types/failable'; @Injectable() export class PicsurThrottlerGuard extends ThrottlerGuard { - protected override throwThrottlingException(context: ExecutionContext): void { + protected override throwThrottlingException(): void { throw Fail(FT.RateLimit); } } diff --git a/backend/src/layers/validate/zod-validator.pipe.ts b/backend/src/layers/validate/zod-validator.pipe.ts index 2fdc803b..d9789561 100644 --- a/backend/src/layers/validate/zod-validator.pipe.ts +++ b/backend/src/layers/validate/zod-validator.pipe.ts @@ -9,7 +9,7 @@ import { Optional, PipeTransform, } from '@nestjs/common'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { Fail, FT } from 'picsur-shared/dist/types/failable'; import { ZodDtoStatic } from 'picsur-shared/dist/util/create-zod-dto'; export interface ZodValidationPipeOptions { @@ -30,7 +30,7 @@ export class ZodValidationPipe implements PipeTransform { public transform(value: unknown, metadata: ArgumentMetadata): unknown { if (!this.validateCustom && metadata.type === 'custom') return value; - let zodSchema = (metadata?.metatype as ZodDtoStatic)?.zodSchema; + const zodSchema = (metadata?.metatype as ZodDtoStatic)?.zodSchema; if (zodSchema) { const parseResult = zodSchema.safeParse(value); diff --git a/backend/src/managers/auth/auth.service.ts b/backend/src/managers/auth/auth.service.ts index 6f86bc3b..fb55f341 100644 --- a/backend/src/managers/auth/auth.service.ts +++ b/backend/src/managers/auth/auth.service.ts @@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; import { JwtData, JwtDataSchema } from 'picsur-shared/dist/dto/jwt.dto'; import { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types'; +import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types/failable'; @Injectable() export class AuthManagerService { diff --git a/backend/src/managers/auth/guards/apikey.strategy.ts b/backend/src/managers/auth/guards/apikey.strategy.ts index dd486d0f..5a43999c 100644 --- a/backend/src/managers/auth/guards/apikey.strategy.ts +++ b/backend/src/managers/auth/guards/apikey.strategy.ts @@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { HeaderAPIKeyStrategy } from 'passport-headerapikey'; import { EUser, EUserSchema } from 'picsur-shared/dist/entities/user.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { IsApiKey } from 'picsur-shared/dist/validators/api-key.validator'; import { ApiKeyDbService } from '../../../collections/apikey-db/apikey-db.service'; import { EUserBackend2EUser } from '../../../models/transformers/user.transformer'; @@ -23,7 +23,7 @@ export class ApiKeyStrategy extends PassportStrategy( false, ( apikey: string, - verified: (err: Error | null, user?: Object, info?: Object) => void, + verified: (err: Error | null, user?: object, info?: object) => void, ) => { this.validate(apikey) .then((user) => { diff --git a/backend/src/managers/auth/guards/guest.strategy.ts b/backend/src/managers/auth/guards/guest.strategy.ts index a90a56fe..ff08f5ef 100644 --- a/backend/src/managers/auth/guards/guest.strategy.ts +++ b/backend/src/managers/auth/guards/guest.strategy.ts @@ -8,11 +8,12 @@ import { ReqType } from './reqtype'; class GuestPassportStrategy extends Strategy { // Will be overridden by the nest implementation + // eslint-disable-next-line @typescript-eslint/no-unused-vars async validate(req: ReqType): Promise { return undefined; } - override async authenticate(req: ReqType, options?: any) { + override async authenticate(req: ReqType) { const user = await this.validate(req); this.success(user); } @@ -28,7 +29,7 @@ export class GuestStrategy extends PassportStrategy( } // Return the guest user created by the guestservice - override async validate(payload: any): Promise { + override async validate(): Promise { return EUserBackend2EUser(await this.guestService.getGuestUser()); } } diff --git a/backend/src/managers/auth/guards/jwt.strategy.ts b/backend/src/managers/auth/guards/jwt.strategy.ts index 1efda199..f1a6a0c2 100644 --- a/backend/src/managers/auth/guards/jwt.strategy.ts +++ b/backend/src/managers/auth/guards/jwt.strategy.ts @@ -3,7 +3,7 @@ import { PassportStrategy } from '@nestjs/passport'; import { ExtractJwt, Strategy as JwtPassportStrategy } from 'passport-jwt'; import { JwtDataSchema } from 'picsur-shared/dist/dto/jwt.dto'; import { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { ThrowIfFailed } from 'picsur-shared/dist/types'; +import { ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { UserDbService } from '../../../collections/user-db/user-db.service'; import { EUserBackend2EUser } from '../../../models/transformers/user.transformer'; diff --git a/backend/src/managers/auth/guards/local-auth.strategy.ts b/backend/src/managers/auth/guards/local-auth.strategy.ts index d4619932..dbc25b27 100644 --- a/backend/src/managers/auth/guards/local-auth.strategy.ts +++ b/backend/src/managers/auth/guards/local-auth.strategy.ts @@ -2,7 +2,10 @@ import { Injectable } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { Strategy } from 'passport-local'; import { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { AsyncFailable, ThrowIfFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + ThrowIfFailed, +} from 'picsur-shared/dist/types/failable'; import { UserDbService } from '../../../collections/user-db/user-db.service'; import { EUserBackend2EUser } from '../../../models/transformers/user.transformer'; diff --git a/backend/src/managers/auth/guards/main.guard.ts b/backend/src/managers/auth/guards/main.guard.ts index 3b02ccf0..ace80b9f 100644 --- a/backend/src/managers/auth/guards/main.guard.ts +++ b/backend/src/managers/auth/guards/main.guard.ts @@ -9,7 +9,7 @@ import { FT, HasFailed, ThrowIfFailed, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; import { makeUnique } from 'picsur-shared/dist/util/unique'; import { UserDbService } from '../../../collections/user-db/user-db.service'; import { Permissions } from '../../../models/constants/permissions.const'; diff --git a/backend/src/managers/auth/guest.service.ts b/backend/src/managers/auth/guest.service.ts index d81abcec..b53999c5 100644 --- a/backend/src/managers/auth/guest.service.ts +++ b/backend/src/managers/auth/guest.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { UserDbService } from '../../collections/user-db/user-db.service'; import { EUserBackend } from '../../database/entities/users/user.entity'; diff --git a/backend/src/managers/image/image-converter.service.ts b/backend/src/managers/image/image-converter.service.ts index a43c1783..69ed53db 100644 --- a/backend/src/managers/image/image-converter.service.ts +++ b/backend/src/managers/image/image-converter.service.ts @@ -6,7 +6,12 @@ import { SupportedFileTypeCategory, } from 'picsur-shared/dist/dto/mimes.dto'; import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { SharpOptions } from 'sharp'; import { SysPreferenceDbService } from '../../collections/preference-db/sys-preference-db.service'; import { SharpWrapper } from '../../workers/sharp.wrapper'; diff --git a/backend/src/managers/image/image-manager.module.ts b/backend/src/managers/image/image-manager.module.ts index a4104cff..d7afe802 100644 --- a/backend/src/managers/image/image-manager.module.ts +++ b/backend/src/managers/image/image-manager.module.ts @@ -2,7 +2,7 @@ import { Logger, Module, OnModuleInit } from '@nestjs/common'; import { Interval } from '@nestjs/schedule'; import ms from 'ms'; import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { ImageDBModule } from '../../collections/image-db/image-db.module'; import { ImageDBService } from '../../collections/image-db/image-db.service'; import { ImageFileDBService } from '../../collections/image-db/image-file-db.service'; diff --git a/backend/src/managers/image/image-processor.service.ts b/backend/src/managers/image/image-processor.service.ts index ee451d0b..8e0627f2 100644 --- a/backend/src/managers/image/image-processor.service.ts +++ b/backend/src/managers/image/image-processor.service.ts @@ -5,7 +5,12 @@ import { SupportedFileTypeCategory, } from 'picsur-shared/dist/dto/mimes.dto'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { ParseFileType } from 'picsur-shared/dist/util/parse-mime'; import { ImageConverterService } from './image-converter.service'; import { ImageResult } from './imageresult'; diff --git a/backend/src/managers/image/image.service.ts b/backend/src/managers/image/image.service.ts index 7b5f245b..9c96cd24 100644 --- a/backend/src/managers/image/image.service.ts +++ b/backend/src/managers/image/image.service.ts @@ -1,5 +1,5 @@ import { Injectable, Logger } from '@nestjs/common'; -import Crypto from 'crypto'; +import { createHash } from 'crypto'; import { fileTypeFromBuffer, FileTypeResult } from 'file-type'; import { ImageRequestParams } from 'picsur-shared/dist/dto/api/image.dto'; import { ImageEntryVariant } from 'picsur-shared/dist/dto/image-entry-variant.enum'; @@ -11,7 +11,12 @@ import { } from 'picsur-shared/dist/dto/mimes.dto'; import { SysPreference } from 'picsur-shared/dist/dto/sys-preferences.enum'; import { UsrPreference } from 'picsur-shared/dist/dto/usr-preferences.enum'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { FindResult } from 'picsur-shared/dist/types/find-result'; import { ParseFileType } from 'picsur-shared/dist/util/parse-mime'; import { IsQOI } from 'qoi-img'; @@ -229,7 +234,7 @@ export class ImageManagerService { } return { - [ImageEntryVariant.MASTER]: result[ImageEntryVariant.MASTER]!, + [ImageEntryVariant.MASTER]: result[ImageEntryVariant.MASTER], [ImageEntryVariant.ORIGINAL]: result[ImageEntryVariant.ORIGINAL], }; } @@ -268,7 +273,7 @@ export class ImageManagerService { private getConvertHash(options: object) { // Return a sha256 hash of the stringified options const stringified = JSON.stringify(options); - const hash = Crypto.createHash('sha256'); + const hash = createHash('sha256'); hash.update(stringified); const digest = hash.digest('hex'); return digest; diff --git a/backend/src/managers/image/webpinfo/webpinfo.ts b/backend/src/managers/image/webpinfo/webpinfo.ts index 977ad16e..cb941aac 100644 --- a/backend/src/managers/image/webpinfo/webpinfo.ts +++ b/backend/src/managers/image/webpinfo/webpinfo.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-empty-function */ // @ts-nocheck /* @@ -310,8 +312,8 @@ export class WebPInfo extends StreamParserWritable { ['VP8', 'VP8L', 'ANMF'].map((t) => [t, true] as [ChunkType, true]), ); - private offset: number = 0; - private maxSeekableOffset: number = -1; // same as file size - 1 + private offset = 0; + private maxSeekableOffset = -1; // same as file size - 1 private pending?: { size: number; diff --git a/backend/src/managers/usage/usage.service.ts b/backend/src/managers/usage/usage.service.ts index 237f8429..b5c6ba2f 100644 --- a/backend/src/managers/usage/usage.service.ts +++ b/backend/src/managers/usage/usage.service.ts @@ -1,8 +1,8 @@ import { Injectable, Logger } from '@nestjs/common'; import isDocker from 'is-docker'; import fetch from 'node-fetch'; -import os from 'os'; -import { FallbackIfFailed, HasFailed } from 'picsur-shared/dist/types'; +import * as os from 'os'; +import { FallbackIfFailed, HasFailed } from 'picsur-shared/dist/types/failable'; import { UUIDRegex } from 'picsur-shared/dist/util/common-regex'; import { ImageDBService } from '../../collections/image-db/image-db.service'; import { SystemStateDbService } from '../../collections/system-state-db/system-state-db.service'; diff --git a/backend/src/models/constants/roles.const.ts b/backend/src/models/constants/roles.const.ts index ca7dc89d..7fa85f92 100644 --- a/backend/src/models/constants/roles.const.ts +++ b/backend/src/models/constants/roles.const.ts @@ -24,7 +24,7 @@ export const UndeletableRolesList: string[] = UndeletableRolesTuple; export const SystemRolesList = UndeletableRolesList; // Defaults -type SystemRole = typeof UndeletableRolesTuple[number]; +type SystemRole = (typeof UndeletableRolesTuple)[number]; const SystemRoleDefaultsTyped: { [key in SystemRole]: Permissions; } = { diff --git a/backend/src/routes/api/apikeys/apikeys.controller.ts b/backend/src/routes/api/apikeys/apikeys.controller.ts index 02e58730..5bdf71d2 100644 --- a/backend/src/routes/api/apikeys/apikeys.controller.ts +++ b/backend/src/routes/api/apikeys/apikeys.controller.ts @@ -12,7 +12,7 @@ import { ApiKeyUpdateResponse, } from 'picsur-shared/dist/dto/api/apikeys.dto'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { ThrowIfFailed } from 'picsur-shared/dist/types'; +import { ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { ApiKeyDbService } from '../../../collections/apikey-db/apikey-db.service'; import { HasPermission, diff --git a/backend/src/routes/api/experiment/experiment.controller.ts b/backend/src/routes/api/experiment/experiment.controller.ts index 4aeaeb4e..6cae25ab 100644 --- a/backend/src/routes/api/experiment/experiment.controller.ts +++ b/backend/src/routes/api/experiment/experiment.controller.ts @@ -3,8 +3,6 @@ import { NoPermissions } from '../../../decorators/permissions.decorator'; @Controller('api/experiment') @NoPermissions() export class ExperimentController { - constructor() {} - // @Get() // @Returns(UserInfoResponse) // async testRoute( diff --git a/backend/src/routes/api/info/info.controller.ts b/backend/src/routes/api/info/info.controller.ts index 8d575b9c..2c973b9c 100644 --- a/backend/src/routes/api/info/info.controller.ts +++ b/backend/src/routes/api/info/info.controller.ts @@ -11,7 +11,7 @@ import { SupportedImageFileTypes, } from 'picsur-shared/dist/dto/mimes.dto'; import { TrackingState } from 'picsur-shared/dist/dto/tracking-state.enum'; -import { FallbackIfFailed } from 'picsur-shared/dist/types'; +import { FallbackIfFailed } from 'picsur-shared/dist/types/failable'; import { HostConfigService } from '../../../config/early/host.config.service'; import { InfoConfigService } from '../../../config/late/info.config.service'; import { UsageConfigService } from '../../../config/late/usage.config.service'; diff --git a/backend/src/routes/api/pref/sys-pref.controller.ts b/backend/src/routes/api/pref/sys-pref.controller.ts index 8992c2c4..67c521d4 100644 --- a/backend/src/routes/api/pref/sys-pref.controller.ts +++ b/backend/src/routes/api/pref/sys-pref.controller.ts @@ -6,7 +6,7 @@ import { UpdatePreferenceRequest, UpdatePreferenceResponse, } from 'picsur-shared/dist/dto/api/pref.dto'; -import { ThrowIfFailed } from 'picsur-shared/dist/types'; +import { ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { SysPreferenceDbService } from '../../../collections/preference-db/sys-preference-db.service'; import { RequiredPermissions } from '../../../decorators/permissions.decorator'; import { Returns } from '../../../decorators/returns.decorator'; diff --git a/backend/src/routes/api/pref/usr-pref.controller.ts b/backend/src/routes/api/pref/usr-pref.controller.ts index 9451c564..ac89f3da 100644 --- a/backend/src/routes/api/pref/usr-pref.controller.ts +++ b/backend/src/routes/api/pref/usr-pref.controller.ts @@ -6,7 +6,7 @@ import { UpdatePreferenceRequest, UpdatePreferenceResponse, } from 'picsur-shared/dist/dto/api/pref.dto'; -import { ThrowIfFailed } from 'picsur-shared/dist/types'; +import { ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { UsrPreferenceDbService } from '../../../collections/preference-db/usr-preference-db.service'; import { RequiredPermissions } from '../../../decorators/permissions.decorator'; import { ReqUserID } from '../../../decorators/request-user.decorator'; diff --git a/backend/src/routes/api/roles/roles.controller.ts b/backend/src/routes/api/roles/roles.controller.ts index 9c28cfd9..a0505dc8 100644 --- a/backend/src/routes/api/roles/roles.controller.ts +++ b/backend/src/routes/api/roles/roles.controller.ts @@ -12,7 +12,7 @@ import { RoleUpdateResponse, SpecialRolesResponse, } from 'picsur-shared/dist/dto/api/roles.dto'; -import { Fail, FT, ThrowIfFailed } from 'picsur-shared/dist/types'; +import { Fail, FT, ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { RoleDbService } from '../../../collections/role-db/role-db.service'; import { UserDbService } from '../../../collections/user-db/user-db.service'; import { RequiredPermissions } from '../../../decorators/permissions.decorator'; diff --git a/backend/src/routes/api/usage/usage.controller.ts b/backend/src/routes/api/usage/usage.controller.ts index 3321836a..9d47dbf7 100644 --- a/backend/src/routes/api/usage/usage.controller.ts +++ b/backend/src/routes/api/usage/usage.controller.ts @@ -1,7 +1,7 @@ import { Controller, Logger, Post, Req, Res } from '@nestjs/common'; import { Throttle } from '@nestjs/throttler'; import type { FastifyReply, FastifyRequest } from 'fastify'; -import { Fail, FT, ThrowIfFailed } from 'picsur-shared/dist/types'; +import { Fail, FT, ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { UsageConfigService } from '../../../config/late/usage.config.service'; import { NoPermissions } from '../../../decorators/permissions.decorator'; import { ReturnsAnything } from '../../../decorators/returns.decorator'; diff --git a/backend/src/routes/api/user/user-manage.controller.ts b/backend/src/routes/api/user/user-manage.controller.ts index 865c531f..2339f103 100644 --- a/backend/src/routes/api/user/user-manage.controller.ts +++ b/backend/src/routes/api/user/user-manage.controller.ts @@ -13,7 +13,7 @@ import { UserUpdateRequest, UserUpdateResponse, } from 'picsur-shared/dist/dto/api/user-manage.dto'; -import { ThrowIfFailed } from 'picsur-shared/dist/types'; +import { ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { UserDbService } from '../../../collections/user-db/user-db.service'; import { RequiredPermissions } from '../../../decorators/permissions.decorator'; import { Returns } from '../../../decorators/returns.decorator'; diff --git a/backend/src/routes/api/user/user.controller.ts b/backend/src/routes/api/user/user.controller.ts index 19781a7e..618522ca 100644 --- a/backend/src/routes/api/user/user.controller.ts +++ b/backend/src/routes/api/user/user.controller.ts @@ -10,7 +10,7 @@ import { UserRegisterResponse, } from 'picsur-shared/dist/dto/api/user.dto'; import type { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { ThrowIfFailed } from 'picsur-shared/dist/types'; +import { ThrowIfFailed } from 'picsur-shared/dist/types/failable'; import { UserDbService } from '../../../collections/user-db/user-db.service'; import { NoPermissions, diff --git a/backend/src/routes/image/image-manage.controller.ts b/backend/src/routes/image/image-manage.controller.ts index 765b0693..69ab3e4b 100644 --- a/backend/src/routes/image/image-manage.controller.ts +++ b/backend/src/routes/image/image-manage.controller.ts @@ -21,7 +21,12 @@ import { ImageUploadResponse, } from 'picsur-shared/dist/dto/api/image-manage.dto'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { Fail, FT, HasFailed, ThrowIfFailed } from 'picsur-shared/dist/types'; +import { + Fail, + FT, + HasFailed, + ThrowIfFailed, +} from 'picsur-shared/dist/types/failable'; import { PostFiles } from '../../decorators/multipart/multipart.decorator'; import type { FileIterator } from '../../decorators/multipart/postfiles.pipe'; import { diff --git a/backend/src/routes/image/image.controller.ts b/backend/src/routes/image/image.controller.ts index 6dda3afd..9ec1d5da 100644 --- a/backend/src/routes/image/image.controller.ts +++ b/backend/src/routes/image/image.controller.ts @@ -7,7 +7,11 @@ import { } from 'picsur-shared/dist/dto/api/image.dto'; import { ImageEntryVariant } from 'picsur-shared/dist/dto/image-entry-variant.enum'; import { FileType2Mime } from 'picsur-shared/dist/dto/mimes.dto'; -import { FT, IsFailure, ThrowIfFailed } from 'picsur-shared/dist/types'; +import { + FT, + IsFailure, + ThrowIfFailed, +} from 'picsur-shared/dist/types/failable'; import { UserDbService } from '../../collections/user-db/user-db.service'; import { ImageFullIdParam } from '../../decorators/image-id/image-full-id.decorator'; import { ImageIdParam } from '../../decorators/image-id/image-id.decorator'; diff --git a/backend/src/util/branding.ts b/backend/src/util/branding.ts index 5e140cd0..5d137e22 100644 --- a/backend/src/util/branding.ts +++ b/backend/src/util/branding.ts @@ -1,6 +1,6 @@ import { readFile } from 'fs/promises'; import { resolve } from 'path'; -import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types'; +import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types/failable'; import { PackageRoot } from '../config/config.static'; export const BrandingPath = resolve(PackageRoot, '../branding'); diff --git a/backend/src/util/iterator.ts b/backend/src/util/iterator.ts index 58502cd7..eb1af31a 100644 --- a/backend/src/util/iterator.ts +++ b/backend/src/util/iterator.ts @@ -1,4 +1,4 @@ -import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types'; +import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types/failable'; export async function GetNextAsync( iterator: AsyncIterableIterator, diff --git a/backend/src/workers/sharp.wrapper.ts b/backend/src/workers/sharp.wrapper.ts index 691a1354..172b30f4 100644 --- a/backend/src/workers/sharp.wrapper.ts +++ b/backend/src/workers/sharp.wrapper.ts @@ -1,7 +1,7 @@ import { Logger } from '@nestjs/common'; import { ChildProcess, fork } from 'child_process'; import pTimeout from 'p-timeout'; -import path from 'path'; +import { dirname, join as pathJoin } from 'path'; import { FileType } from 'picsur-shared/dist/dto/mimes.dto'; import { AsyncFailable, @@ -9,7 +9,7 @@ import { Failable, FT, HasFailed, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; import { Sharp, SharpOptions } from 'sharp'; import { SharpWorkerFinishOptions, @@ -22,13 +22,13 @@ import { import { SharpResult } from './sharp/universal-sharp'; const moduleURL = new URL(import.meta.url); -const __dirname = path.dirname(moduleURL.pathname); +const __dirname = dirname(moduleURL.pathname); export class SharpWrapper { private readonly workerID: number = Math.floor(Math.random() * 100000); private readonly logger: Logger = new Logger('SharpWrapper' + this.workerID); - private static readonly WORKER_PATH = path.join( + private static readonly WORKER_PATH = pathJoin( __dirname, './sharp', 'sharp.worker.js', diff --git a/backend/src/workers/sharp/sharp.worker.ts b/backend/src/workers/sharp/sharp.worker.ts index 84969b3a..d643a9df 100644 --- a/backend/src/workers/sharp/sharp.worker.ts +++ b/backend/src/workers/sharp/sharp.worker.ts @@ -1,5 +1,5 @@ import { FileType } from 'picsur-shared/dist/dto/mimes.dto'; -import posix from 'posix.js'; +import { setrlimit } from 'posix.js'; import { Sharp } from 'sharp'; import { SharpWorkerFinishOptions, @@ -11,7 +11,7 @@ import { import { UniversalSharpIn, UniversalSharpOut } from './universal-sharp'; export class SharpWorker { - private startTime: number = 0; + private startTime = 0; private sharpi: Sharp | null = null; constructor() { @@ -29,7 +29,7 @@ export class SharpWorker { return this.purge('MEMORY_LIMIT_MB environment variable is not set'); } - posix.setrlimit('data', { + setrlimit('data', { soft: 1000 * 1000 * memoryLimit, hard: 1000 * 1000 * memoryLimit, }); diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 5b86624c..c3ad73c3 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -11,8 +11,5 @@ "declaration": true, "sourceMap": true, "emitDecoratorMetadata": true - }, - "ts-node": { - "experimentalSpecifierResolution": "node" } } diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs new file mode 100644 index 00000000..def5c66c --- /dev/null +++ b/frontend/.eslintrc.cjs @@ -0,0 +1,9 @@ +module.exports = { + parserOptions: { + project: './tsconfig.base.json', + tsconfigRootDir: __dirname, + sourceType: 'module', + }, + ignorePatterns: ['src/environments', 'custom-webpack.config.js'], + root: false, +}; diff --git a/frontend/custom-webpack.config.js b/frontend/custom-webpack.config.js index d32b5023..f9b9845f 100644 --- a/frontend/custom-webpack.config.js +++ b/frontend/custom-webpack.config.js @@ -14,11 +14,7 @@ export default { use: { loader: 'babel-loader', options: { - presets: [ - [ - '@babel/preset-env', - ], - ], + presets: [['@babel/preset-env']], }, }, }, diff --git a/frontend/package.json b/frontend/package.json index 545c6fa8..00fd07b6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,7 +9,7 @@ "scripts": { "ng": "ng", "start": "ng serve --host 0.0.0.0", - "build": "ng build", + "build": "ng build --verbose", "watch": "ng build --watch --configuration development", "purge": "rm -rf dist && rm -rf node_modules && rm -rf .angular" }, @@ -47,7 +47,6 @@ "browserslist": "^4.21.7", "caniuse-lite": "^1.0.30001495", "fuse.js": "^6.6.2", - "jwt-decode": "^3.1.2", "material-icons": "^1.13.8", "moment": "^2.29.4", "ng-mat-select-infinite-scroll": "^4.0.0", @@ -62,5 +61,8 @@ "webpack-bundle-analyzer": "^4.9.0", "zod": "^3.21.4", "zone.js": "^0.13.0" + }, + "dependencies": { + "@leteu/jwt-decoder": "^1.0.4" } } diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index c82100f6..bf8d9554 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -25,14 +25,14 @@ export class AppComponent implements OnInit { @ViewChild(MatSidenav) sidebar: MatSidenav; - loading: boolean = false; + loading = false; private loadingTimeout: number | null = null; - wrapContentWithContainer: boolean = true; + wrapContentWithContainer = true; sidebarPortal: Portal | undefined = undefined; - isDesktop: boolean = false; - hasSidebar: boolean = false; + isDesktop = false; + hasSidebar = false; public constructor( private readonly router: Router, @@ -64,7 +64,7 @@ export class AppComponent implements OnInit { if (event instanceof NavigationEnd) { this.loadingEnd(); } - if (event instanceof NavigationEnd) this.onNavigationEnd(event); + if (event instanceof NavigationEnd) this.onNavigationEnd(); if (event instanceof NavigationError) this.onNavigationError(event); }); } @@ -84,7 +84,7 @@ export class AppComponent implements OnInit { this.router.navigate(['/error/404'], { replaceUrl: true }); } - private async onNavigationEnd(event: NavigationEnd) { + private async onNavigationEnd() { const data = this.routeData; this.wrapContentWithContainer = !data.noContainer; diff --git a/frontend/src/app/components/copy-field/copy-field.component.ts b/frontend/src/app/components/copy-field/copy-field.component.ts index 81062e9d..ca90818e 100644 --- a/frontend/src/app/components/copy-field/copy-field.component.ts +++ b/frontend/src/app/components/copy-field/copy-field.component.ts @@ -3,10 +3,10 @@ import { MatFormFieldAppearance, SubscriptSizing, } from '@angular/material/form-field'; -import { FT, Fail } from 'picsur-shared/dist/types'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ClipboardService } from 'src/app/util/clipboard.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { FT, Fail } from 'picsur-shared/dist/types/failable'; +import { Logger } from '../../services/logger/logger.service'; +import { ClipboardService } from '../../util/clipboard.service'; +import { ErrorService } from '../../util/error-manager/error.service'; @Component({ selector: 'copy-field', @@ -17,11 +17,11 @@ export class CopyFieldComponent { private readonly logger = new Logger(CopyFieldComponent.name); // Two parameters: name, value - @Input() label: string = 'Loading...'; - @Input() value: string = 'Loading...'; + @Input() label = 'Loading...'; + @Input() value = 'Loading...'; - @Input() showHideButton: boolean = false; - @Input() hidden: boolean = false; + @Input() showHideButton = false; + @Input() hidden = false; @Input() color: 'primary' | 'accent' | 'warn' = 'primary'; @Input() appearance: MatFormFieldAppearance = 'outline'; diff --git a/frontend/src/app/components/copy-field/copy-field.module.ts b/frontend/src/app/components/copy-field/copy-field.module.ts index f31fc261..b46ecfdf 100644 --- a/frontend/src/app/components/copy-field/copy-field.module.ts +++ b/frontend/src/app/components/copy-field/copy-field.module.ts @@ -3,8 +3,9 @@ import { NgModule } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { CopyFieldComponent } from './copy-field.component'; +import { ErrorManagerModule } from '../../util/error-manager/error-manager.module'; + @NgModule({ declarations: [CopyFieldComponent], imports: [ diff --git a/frontend/src/app/components/fab/normal/fab.component.ts b/frontend/src/app/components/fab/normal/fab.component.ts index 3264bd2d..436f1b1d 100644 --- a/frontend/src/app/components/fab/normal/fab.component.ts +++ b/frontend/src/app/components/fab/normal/fab.component.ts @@ -5,11 +5,10 @@ import { Component, Input } from '@angular/core'; templateUrl: './fab.component.html', }) export class FabComponent { - @Input('aria-label') ariaLabel: string = 'Floating Action Button'; - @Input() icon: string = 'add'; - @Input() color: string = 'primary'; + @Input('aria-label') ariaLabel = 'Floating Action Button'; + @Input() icon = 'add'; + @Input() color = 'primary'; @Input('tooltip') tooltip: string; + // eslint-disable-next-line @typescript-eslint/no-empty-function @Input() onClick: () => void = () => {}; - - constructor() {} } diff --git a/frontend/src/app/components/fab/speed-dial/speed-dial.component.html b/frontend/src/app/components/fab/speed-dial/speed-dial.component.html index 3f67ef7a..0607c671 100644 --- a/frontend/src/app/components/fab/speed-dial/speed-dial.component.html +++ b/frontend/src/app/components/fab/speed-dial/speed-dial.component.html @@ -22,7 +22,7 @@ [matTooltip]="tooltip" matTooltipPosition="left" [matTooltipDisabled]="!openManager.isOpen" - (click)="click($event)" + (click)="click()" aria-label="" > (); public openManager = new OpenManager(); - private touchUntil: number = 0; + private touchUntil = 0; @HostListener('document:touchstart', ['$event']) @HostListener('document:touchend', ['$event']) @@ -35,13 +35,13 @@ export class SpeedDialComponent { @HostListener('document:click', ['$event']) @HostListener('document:keydown.escape', ['$event']) - anyClick(e: Event) { + anyClick() { if (!this.openManager.isOpen || this.openManager.isAnimating) return; this.openManager.close(); } - click(e: MouseEvent) { + click() { if (!this.openManager.isOpen) { this.openManager.open(); } else { diff --git a/frontend/src/app/components/footer/footer.component.ts b/frontend/src/app/components/footer/footer.component.ts index 3ffb4d41..23ef12fa 100644 --- a/frontend/src/app/components/footer/footer.component.ts +++ b/frontend/src/app/components/footer/footer.component.ts @@ -5,7 +5,7 @@ import { OnInit, } from '@angular/core'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; -import { InfoService } from 'src/app/services/api/info.service'; +import { InfoService } from '../../services/api/info.service'; @Component({ selector: 'app-footer', @@ -19,8 +19,8 @@ export class FooterComponent implements OnInit { private readonly changeDetector: ChangeDetectorRef, ) {} - isDemo: boolean = false; - version: string = 'Unkown Version'; + isDemo = false; + version = 'Unkown Version'; ngOnInit(): void { this.subscribeInfo(); diff --git a/frontend/src/app/components/header/header.component.ts b/frontend/src/app/components/header/header.component.ts index cf4d2de3..d5ad30d2 100644 --- a/frontend/src/app/components/header/header.component.ts +++ b/frontend/src/app/components/header/header.component.ts @@ -11,11 +11,11 @@ import { Router } from '@angular/router'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; import { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; -import { PermissionService } from 'src/app/services/api/permission.service'; -import { UserService } from 'src/app/services/api/user.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; +import { UserService } from '../../services/api/user.service'; +import { PermissionService } from '../../services/api/permission.service'; +import { Logger } from '../../services/logger/logger.service'; +import { ErrorService } from '../../util/error-manager/error.service'; @Component({ selector: 'app-header', @@ -38,17 +38,17 @@ export class HeaderComponent implements OnInit { this._enableHamburger = value; this.changeDetector.markForCheck(); } - public _enableHamburger: boolean = true; + public _enableHamburger = true; @Output('onHamburgerClick') onHamburgerClick = new EventEmitter(); - @Input('loading') public loading: boolean = false; + @Input('loading') public loading = false; private currentUser: EUser | null = null; - public canLogIn: boolean = false; - public canAccessSettings: boolean = false; - public canUpload: boolean = false; - public canRegister: boolean = false; + public canLogIn = false; + public canAccessSettings = false; + public canUpload = false; + public canRegister = false; public get user() { return this.currentUser; diff --git a/frontend/src/app/components/header/header.module.ts b/frontend/src/app/components/header/header.module.ts index 67b09494..950c3d9a 100644 --- a/frontend/src/app/components/header/header.module.ts +++ b/frontend/src/app/components/header/header.module.ts @@ -7,8 +7,8 @@ import { MatProgressBarModule } from '@angular/material/progress-bar'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MatTooltipModule } from '@angular/material/tooltip'; import { RouterModule } from '@angular/router'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { HeaderComponent } from './header.component'; +import { ErrorManagerModule } from '../../util/error-manager/error-manager.module'; @NgModule({ imports: [ diff --git a/frontend/src/app/components/masonry/masonry-item.directive.ts b/frontend/src/app/components/masonry/masonry-item.directive.ts index c10e1d70..f8f5fbf7 100644 --- a/frontend/src/app/components/masonry/masonry-item.directive.ts +++ b/frontend/src/app/components/masonry/masonry-item.directive.ts @@ -1,12 +1,11 @@ import { Directive, ElementRef, Inject } from '@angular/core'; import { - boxExtractor, - ResizeObserverDirective, - ResizeObserverService, RESIZE_OPTION_BOX, + ResizeObserverService, + boxExtractor, } from '@ng-web-apis/resize-observer'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; -import { map, Observable } from 'rxjs'; +import { Observable, map } from 'rxjs'; @Directive({ selector: '[masonry-item]', diff --git a/frontend/src/app/components/masonry/masonry.component.ts b/frontend/src/app/components/masonry/masonry.component.ts index de18552d..abd42d3d 100644 --- a/frontend/src/app/components/masonry/masonry.component.ts +++ b/frontend/src/app/components/masonry/masonry.component.ts @@ -12,9 +12,9 @@ import { } from '@angular/core'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { combineLatest, Subscription } from 'rxjs'; -import { RemoveChildren } from 'src/app/util/remove-children'; -import { Throttle } from 'src/app/util/throttle'; import { MasonryItemDirective } from './masonry-item.directive'; +import { RemoveChildren } from '../../util/remove-children'; +import { Throttle } from '../../util/throttle'; @Component({ selector: 'masonry', @@ -30,7 +30,7 @@ export class MasonryComponent implements AfterViewInit, OnDestroy { this.changeDetector.markForCheck(); } public _column_count = 1; - @Input('update-speed') update_speed: number = 200; + @Input('update-speed') update_speed = 200; @ContentChildren(MasonryItemDirective) private content: QueryList; @@ -59,7 +59,7 @@ export class MasonryComponent implements AfterViewInit, OnDestroy { this.sizesSubscription = combineLatest(sizes) .pipe(Throttle(this.update_speed)) - .subscribe((output) => { + .subscribe(() => { this.resortItems(items); }); @@ -76,7 +76,7 @@ export class MasonryComponent implements AfterViewInit, OnDestroy { RemoveChildren(columnsArray[i]); } - const columnSizes = columnsArray.map((c) => 0); + const columnSizes = columnsArray.map(() => 0); for (let i = 0; i < itemsArray.length; i++) { const item = itemsArray[i]; @@ -84,7 +84,7 @@ export class MasonryComponent implements AfterViewInit, OnDestroy { let smallestColumn = 0; let smallestColumnSize = columnSizes[0]; for (let j = columnSizes.length - 1; j >= 0; j--) { - let better_j = (j + i) % columnSizes.length; + const better_j = (j + i) % columnSizes.length; if (columnSizes[better_j] <= smallestColumnSize) { smallestColumn = better_j; diff --git a/frontend/src/app/components/paginator/paginator.component.ts b/frontend/src/app/components/paginator/paginator.component.ts index 87cb18aa..4067ac99 100644 --- a/frontend/src/app/components/paginator/paginator.component.ts +++ b/frontend/src/app/components/paginator/paginator.component.ts @@ -1,5 +1,5 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { Required } from 'src/app/models/decorators/required.decorator'; +import { Required } from '../../models/decorators/required.decorator'; @Component({ selector: 'paginator', @@ -13,18 +13,18 @@ export class PaginatorComponent implements OnInit { this.calculateRanges(); } - page: number = 1; + page = 1; @Input('page') set pageInput(value: number) { this.page = value; this.calculateRanges(); } @Output('page') pageChange = new EventEmitter(); - @Input('show-first-last') showFirstLast: boolean = true; + @Input('show-first-last') showFirstLast = true; - @Input('shown-pages') shownPages: number = 7; - @Input('shown-first-pages') shownFirstPages: number = 1; - @Input('shown-last-pages') shownLastPages: number = 1; + @Input('shown-pages') shownPages = 7; + @Input('shown-first-pages') shownFirstPages = 1; + @Input('shown-last-pages') shownLastPages = 1; firstPagesRange: [number, number] | null = null; lastPagesRange: [number, number] | null = null; diff --git a/frontend/src/app/components/paginator/paginator.module.ts b/frontend/src/app/components/paginator/paginator.module.ts index 4dc68c0b..0e7584d5 100644 --- a/frontend/src/app/components/paginator/paginator.module.ts +++ b/frontend/src/app/components/paginator/paginator.module.ts @@ -2,8 +2,8 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; -import { PipesModule } from 'src/app/pipes/pipes.module'; import { PaginatorComponent } from './paginator.component'; +import { PipesModule } from '../../pipes/pipes.module'; @NgModule({ declarations: [PaginatorComponent], diff --git a/frontend/src/app/components/picsur-img/picsur-img.component.html b/frontend/src/app/components/picsur-img/picsur-img.component.html index 75846376..3e771f4e 100644 --- a/frontend/src/app/components/picsur-img/picsur-img.component.html +++ b/frontend/src/app/components/picsur-img/picsur-img.component.html @@ -14,7 +14,7 @@ broken_image diff --git a/frontend/src/app/components/picsur-img/picsur-img.component.ts b/frontend/src/app/components/picsur-img/picsur-img.component.ts index 2600fa98..4ea473ce 100644 --- a/frontend/src/app/components/picsur-img/picsur-img.component.ts +++ b/frontend/src/app/components/picsur-img/picsur-img.component.ts @@ -5,16 +5,15 @@ import { ElementRef, Input, OnChanges, - SimpleChanges, ViewChild, } from '@angular/core'; import { FileType, ImageFileType } from 'picsur-shared/dist/dto/mimes.dto'; -import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types'; +import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types/failable'; import { URLRegex } from 'picsur-shared/dist/util/common-regex'; import { ParseMime2FileType } from 'picsur-shared/dist/util/parse-mime'; -import { ApiService } from 'src/app/services/api/api.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { QoiWorkerService } from 'src/app/workers/qoi-worker.service'; +import { ApiService } from '../../services/api/api.service'; +import { Logger } from '../../services/logger/logger.service'; +import { QoiWorkerService } from '../../workers/qoi-worker.service'; enum PicsurImgState { Init = 'init', @@ -48,12 +47,12 @@ export class PicsurImgComponent implements OnChanges { private readonly changeDetector: ChangeDetectorRef, ) {} - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { if (this.isInView) this.reload(); } private reload() { - let url = this.imageURL ?? ''; + const url = this.imageURL ?? ''; if (!URLRegex.test(url)) { this.state = PicsurImgState.Loading; this.changeDetector.markForCheck(); @@ -68,7 +67,7 @@ export class PicsurImgComponent implements OnChanges { this.changeDetector.markForCheck(); } }) - .catch((e) => this.logger.error); + .catch(this.logger.error); } private async update(url: string): AsyncFailable { @@ -111,7 +110,7 @@ export class PicsurImgComponent implements OnChanges { return ParseMime2FileType(mime); } - onInview(e: any) { + onInview() { this.isInView = true; if (this.state === PicsurImgState.Init) { @@ -120,7 +119,7 @@ export class PicsurImgComponent implements OnChanges { } } - onOutview(e: any) { + onOutview() { this.isInView = false; } } diff --git a/frontend/src/app/components/pref-option/pref-option.component.ts b/frontend/src/app/components/pref-option/pref-option.component.ts index a53e56f0..f788e61b 100644 --- a/frontend/src/app/components/pref-option/pref-option.component.ts +++ b/frontend/src/app/components/pref-option/pref-option.component.ts @@ -5,13 +5,13 @@ import { DecodedPref, PrefValueType, } from 'picsur-shared/dist/dto/preferences.dto'; -import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types'; +import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types/failable'; import { filter } from 'rxjs'; -import { Required } from 'src/app/models/decorators/required.decorator'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; -import { Throttle } from 'src/app/util/throttle'; import { ZodTypeAny } from 'zod'; +import { Required } from '../../models/decorators/required.decorator'; +import { Logger } from '../../services/logger/logger.service'; +import { ErrorService } from '../../util/error-manager/error.service'; +import { Throttle } from '../../util/throttle'; @Component({ selector: 'pref-option', @@ -40,8 +40,8 @@ export class PrefOptionComponent implements OnInit { pref: PrefValueType, ) => AsyncFailable; - @Input() @Required name: string = ''; - @Input() helpText: string = ''; + @Input() @Required name = ''; + @Input() helpText = ''; @Input() validator?: ZodTypeAny = undefined; constructor(private readonly errorService: ErrorService) {} @@ -96,7 +96,7 @@ export class PrefOptionComponent implements OnInit { subscribeUpdate() { return this.formControl.valueChanges .pipe( - filter((value) => this.formControl.errors === null), + filter(() => this.formControl.errors === null), Throttle(300), ) .subscribe(this.updatePreference.bind(this)); diff --git a/frontend/src/app/components/pref-option/pref-option.module.ts b/frontend/src/app/components/pref-option/pref-option.module.ts index 7137851a..e4125fc6 100644 --- a/frontend/src/app/components/pref-option/pref-option.module.ts +++ b/frontend/src/app/components/pref-option/pref-option.module.ts @@ -7,8 +7,8 @@ import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatSelectModule } from '@angular/material/select'; import { MatTooltipModule } from '@angular/material/tooltip'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { PrefOptionComponent } from './pref-option.component'; +import { ErrorManagerModule } from '../../util/error-manager/error-manager.module'; @NgModule({ imports: [ diff --git a/frontend/src/app/components/values-picker/values-picker.component.ts b/frontend/src/app/components/values-picker/values-picker.component.ts index 6046df03..b1458fb5 100644 --- a/frontend/src/app/components/values-picker/values-picker.component.ts +++ b/frontend/src/app/components/values-picker/values-picker.component.ts @@ -6,7 +6,7 @@ import { MatChipInputEvent } from '@angular/material/chips'; import Fuse from 'fuse.js'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { BehaviorSubject } from 'rxjs'; -import { Required } from 'src/app/models/decorators/required.decorator'; +import { Required } from '../../models/decorators/required.decorator'; @Component({ selector: 'values-picker', @@ -18,7 +18,7 @@ export class ValuesPickerComponent implements OnInit, OnChanges { readonly separatorKeysCodes: number[] = [ENTER, COMMA]; // Ui niceties - @Input('name') @Required name: string = ''; + @Input('name') @Required name = ''; public get nameCap(): string { return this.name.charAt(0).toUpperCase() + this.name.slice(1); } @@ -107,14 +107,14 @@ export class ValuesPickerComponent implements OnInit, OnChanges { @AutoUnsubscribe() private subscribeInputValue() { - return this.inputControl.valueChanges.subscribe((value) => { + return this.inputControl.valueChanges.subscribe(() => { this.updateSelectable(); }); } @AutoUnsubscribe() private subscribeMyValue() { - return this.myControl.valueChanges.subscribe((value) => { + return this.myControl.valueChanges.subscribe(() => { this.updateSelectable(); }); } diff --git a/frontend/src/app/guards/permission.guard.ts b/frontend/src/app/guards/permission.guard.ts index a7fa1eee..ada7f649 100644 --- a/frontend/src/app/guards/permission.guard.ts +++ b/frontend/src/app/guards/permission.guard.ts @@ -4,7 +4,6 @@ import { CanActivate, CanActivateChild, Router, - RouterStateSnapshot, } from '@angular/router'; import { isPermissionsArray } from 'picsur-shared/dist/validators/permissions.validator'; import { PRouteData } from '../models/dto/picsur-routes.dto'; @@ -24,18 +23,15 @@ export class PermissionGuard implements CanActivate, CanActivateChild { private readonly router: Router, ) {} - async canActivateChild( - childRoute: ActivatedRouteSnapshot, - state: RouterStateSnapshot, - ) { - return await this.can(childRoute, state); + async canActivateChild(childRoute: ActivatedRouteSnapshot) { + return await this.can(childRoute); } - async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { - return await this.can(route, state); + async canActivate(route: ActivatedRouteSnapshot) { + return await this.can(route); } - private async can(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + private async can(route: ActivatedRouteSnapshot) { const requiredPermissions: string[] = this.nestedPermissions(route); const allPermissionsArray = await this.staticInfo.getAllPermissions(); diff --git a/frontend/src/app/models/dto/images-upload-request.dto.ts b/frontend/src/app/models/dto/images-upload-request.dto.exclude.ts similarity index 100% rename from frontend/src/app/models/dto/images-upload-request.dto.ts rename to frontend/src/app/models/dto/images-upload-request.dto.exclude.ts diff --git a/frontend/src/app/models/dto/server-info.dto.ts b/frontend/src/app/models/dto/server-info.dto.ts index 2a662255..78285fa6 100644 --- a/frontend/src/app/models/dto/server-info.dto.ts +++ b/frontend/src/app/models/dto/server-info.dto.ts @@ -1,9 +1,9 @@ import { TrackingState } from 'picsur-shared/dist/dto/tracking-state.enum'; export class ServerInfo { - production: boolean = false; - demo: boolean = false; - version: string = '0.0.0'; + production = false; + demo = false; + version = '0.0.0'; host_override?: string; tracking: { state: TrackingState; diff --git a/frontend/src/app/models/forms/login.control.ts b/frontend/src/app/models/forms/login.control.ts index 93105aa8..55ccc5e6 100644 --- a/frontend/src/app/models/forms/login.control.ts +++ b/frontend/src/app/models/forms/login.control.ts @@ -1,5 +1,5 @@ import { FormControl } from '@angular/forms'; -import { Fail, Failable, FT } from 'picsur-shared/dist/types'; +import { Fail, Failable, FT } from 'picsur-shared/dist/types/failable'; import { UserPassModel } from '../forms-dto/userpass.dto'; import { CreatePasswordError, diff --git a/frontend/src/app/models/forms/register.control.ts b/frontend/src/app/models/forms/register.control.ts index 7610b711..bb1b3d45 100644 --- a/frontend/src/app/models/forms/register.control.ts +++ b/frontend/src/app/models/forms/register.control.ts @@ -1,5 +1,5 @@ import { FormControl } from '@angular/forms'; -import { Fail, Failable, FT } from 'picsur-shared/dist/types'; +import { Fail, Failable, FT } from 'picsur-shared/dist/types/failable'; import { UserPassModel } from '../forms-dto/userpass.dto'; import { Compare } from '../validators/compare.validator'; import { diff --git a/frontend/src/app/models/forms/update-user.control.ts b/frontend/src/app/models/forms/update-user.control.ts index 3841d09c..56798f81 100644 --- a/frontend/src/app/models/forms/update-user.control.ts +++ b/frontend/src/app/models/forms/update-user.control.ts @@ -11,7 +11,7 @@ import { } from '../validators/user.validator'; export class UpdateUserControl { - private id: string = ''; + private id = ''; public username = new FormControl('', UsernameValidators); public password = new FormControl('', PasswordValidators); public roles = new FormControl([]); diff --git a/frontend/src/app/pipes/truncate.pipe.ts b/frontend/src/app/pipes/truncate.pipe.ts index 6fcce82a..84c8a977 100644 --- a/frontend/src/app/pipes/truncate.pipe.ts +++ b/frontend/src/app/pipes/truncate.pipe.ts @@ -4,9 +4,9 @@ import { Pipe, PipeTransform } from '@angular/core'; name: 'truncate', }) export class TruncatePipe implements PipeTransform { - transform(text: string, length: number = 32, suffix: string = '...'): string { + transform(text: string, length = 32, suffix = '...'): string { if (text.length > length) { - let truncated: string = text.substring(0, length).trim() + suffix; + const truncated: string = text.substring(0, length).trim() + suffix; return truncated; } diff --git a/frontend/src/app/routes/errors/errors.routing.module.ts b/frontend/src/app/routes/errors/errors.routing.module.ts index 603a52dd..b937bbad 100644 --- a/frontend/src/app/routes/errors/errors.routing.module.ts +++ b/frontend/src/app/routes/errors/errors.routing.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { E401Component } from './401.component'; import { E404Component } from './404.component'; import { ImageDeleteFailureComponent } from './delete-failure.component'; import { ImageDeleteSuccessComponent } from './delete-success.component'; +import { PRoutes } from '../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/images/images.component.ts b/frontend/src/app/routes/images/images.component.ts index 22338f25..3418e0a5 100644 --- a/frontend/src/app/routes/images/images.component.ts +++ b/frontend/src/app/routes/images/images.component.ts @@ -6,19 +6,19 @@ import { EImage } from 'picsur-shared/dist/entities/image.entity'; import { HasFailed } from 'picsur-shared/dist/types/failable'; import { BehaviorSubject, + Observable, filter, map, merge, - Observable, switchMap, timer, } from 'rxjs'; -import { ImageService } from 'src/app/services/api/image.service'; -import { UserService } from 'src/app/services/api/user.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { BootstrapService, BSScreenSize } from 'src/app/util/bootstrap.service'; -import { DialogService } from 'src/app/util/dialog-manager/dialog.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { ImageService } from '../../services/api/image.service'; +import { UserService } from '../../services/api/user.service'; +import { Logger } from '../../services/logger/logger.service'; +import { BSScreenSize, BootstrapService } from '../../util/bootstrap.service'; +import { DialogService } from '../../util/dialog-manager/dialog.service'; +import { ErrorService } from '../../util/error-manager/error.service'; @Component({ templateUrl: './images.component.html', @@ -39,8 +39,8 @@ export class ImagesComponent implements OnInit { ); } - page: number = 1; - pages: number = 1; + page = 1; + pages = 1; constructor( private readonly route: ActivatedRoute, @@ -110,7 +110,7 @@ export class ImagesComponent implements OnInit { merge( ...images .filter((i) => i.expires_at !== null) - .map((i) => timer(i.expires_at!).pipe(map(() => i))), + .map((i) => timer(i.expires_at ?? new Date(0)).pipe(map(() => i))), ), ), ) as Observable; diff --git a/frontend/src/app/routes/images/images.module.ts b/frontend/src/app/routes/images/images.module.ts index 6b78689c..982c6ce9 100644 --- a/frontend/src/app/routes/images/images.module.ts +++ b/frontend/src/app/routes/images/images.module.ts @@ -4,12 +4,12 @@ import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { MomentModule } from 'ngx-moment'; -import { MasonryModule } from 'src/app/components/masonry/masonry.module'; -import { PaginatorModule } from 'src/app/components/paginator/paginator.module'; -import { PicsurImgModule } from 'src/app/components/picsur-img/picsur-img.module'; -import { PipesModule } from 'src/app/pipes/pipes.module'; -import { DialogManagerModule } from 'src/app/util/dialog-manager/dialog-manager.module'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; +import { MasonryModule } from '../../components/masonry/masonry.module'; +import { PaginatorModule } from '../../components/paginator/paginator.module'; +import { PicsurImgModule } from '../../components/picsur-img/picsur-img.module'; +import { PipesModule } from '../../pipes/pipes.module'; +import { DialogManagerModule } from '../../util/dialog-manager/dialog-manager.module'; +import { ErrorManagerModule } from '../../util/error-manager/error-manager.module'; import { ImagesComponent } from './images.component'; import { ImagesRoutingModule } from './images.routing.module'; diff --git a/frontend/src/app/routes/images/images.routing.module.ts b/frontend/src/app/routes/images/images.routing.module.ts index c57b103c..f0537eda 100644 --- a/frontend/src/app/routes/images/images.routing.module.ts +++ b/frontend/src/app/routes/images/images.routing.module.ts @@ -1,9 +1,9 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { PermissionGuard } from 'src/app/guards/permission.guard'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { ImagesComponent } from './images.component'; +import { PermissionGuard } from '../../guards/permission.guard'; +import { PRoutes } from '../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/processing/processing.component.ts b/frontend/src/app/routes/processing/processing.component.ts index 114ec27d..2707b8f1 100644 --- a/frontend/src/app/routes/processing/processing.component.ts +++ b/frontend/src/app/routes/processing/processing.component.ts @@ -1,11 +1,11 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; -import { Fail, FT, HasFailed } from 'picsur-shared/dist/types'; -import { ProcessingViewMeta } from 'src/app/models/dto/processing-view-meta.dto'; -import { ApiService } from 'src/app/services/api/api.service'; -import { ImageService } from 'src/app/services/api/image.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { Fail, FT, HasFailed } from 'picsur-shared/dist/types/failable'; +import { ProcessingViewMeta } from '../../models/dto/processing-view-meta.dto'; +import { ApiService } from '../../services/api/api.service'; +import { ImageService } from '../../services/api/image.service'; +import { Logger } from '../../services/logger/logger.service'; +import { ErrorService } from '../../util/error-manager/error.service'; @Component({ templateUrl: './processing.component.html', diff --git a/frontend/src/app/routes/processing/processing.module.ts b/frontend/src/app/routes/processing/processing.module.ts index 3547b150..3d75acd6 100644 --- a/frontend/src/app/routes/processing/processing.module.ts +++ b/frontend/src/app/routes/processing/processing.module.ts @@ -1,9 +1,9 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { ProcessingComponent } from './processing.component'; import { ProcessingRoutingModule } from './processing.routing.module'; +import { ErrorManagerModule } from '../../util/error-manager/error-manager.module'; @NgModule({ declarations: [ProcessingComponent], diff --git a/frontend/src/app/routes/processing/processing.routing.module.ts b/frontend/src/app/routes/processing/processing.routing.module.ts index 772a45a8..1ced6fc9 100644 --- a/frontend/src/app/routes/processing/processing.routing.module.ts +++ b/frontend/src/app/routes/processing/processing.routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { ProcessingComponent } from './processing.component'; +import { PRoutes } from '../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/settings/apikeys/apikey-editor/apikey-editor.component.html b/frontend/src/app/routes/settings/apikeys/apikey-editor/apikey-editor.component.html index dba68106..9438de4f 100644 --- a/frontend/src/app/routes/settings/apikeys/apikey-editor/apikey-editor.component.html +++ b/frontend/src/app/routes/settings/apikeys/apikey-editor/apikey-editor.component.html @@ -1,5 +1,5 @@ Name - + {{ getErrorMessage() }} diff --git a/frontend/src/app/routes/settings/apikeys/apikey-editor/apikey-editor.component.ts b/frontend/src/app/routes/settings/apikeys/apikey-editor/apikey-editor.component.ts index 44bb1be2..3ded1ec9 100644 --- a/frontend/src/app/routes/settings/apikeys/apikey-editor/apikey-editor.component.ts +++ b/frontend/src/app/routes/settings/apikeys/apikey-editor/apikey-editor.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; import { FormControl, Validators } from '@angular/forms'; -import { Logger } from 'src/app/services/logger/logger.service'; +import { Logger } from '../../../../services/logger/logger.service'; @Component({ selector: 'app-settings-apikey-editor', @@ -22,7 +22,7 @@ export class SettingsApiKeyEditorComponent { Validators.maxLength(255), ]); - async update(event: Event) { + async update() { if (this.field.invalid) { return; } diff --git a/frontend/src/app/routes/settings/apikeys/settings-apikeys.component.ts b/frontend/src/app/routes/settings/apikeys/settings-apikeys.component.ts index 1459e4f7..f6ceb53b 100644 --- a/frontend/src/app/routes/settings/apikeys/settings-apikeys.component.ts +++ b/frontend/src/app/routes/settings/apikeys/settings-apikeys.component.ts @@ -2,16 +2,16 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { MatPaginator, PageEvent } from '@angular/material/paginator'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { EApiKey } from 'picsur-shared/dist/entities/apikey.entity'; -import { FT, Fail, HasFailed } from 'picsur-shared/dist/types'; +import { FT, Fail, HasFailed } from 'picsur-shared/dist/types/failable'; import { BehaviorSubject, Subject } from 'rxjs'; -import { ApiKeysService } from 'src/app/services/api/apikeys.service'; -import { UserService } from 'src/app/services/api/user.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { BootstrapService } from 'src/app/util/bootstrap.service'; -import { ClipboardService } from 'src/app/util/clipboard.service'; -import { DialogService } from 'src/app/util/dialog-manager/dialog.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; -import { Throttle } from 'src/app/util/throttle'; +import { ApiKeysService } from '../../../services/api/apikeys.service'; +import { UserService } from '../../../services/api/user.service'; +import { Logger } from '../../../services/logger/logger.service'; +import { BootstrapService } from '../../../util/bootstrap.service'; +import { ClipboardService } from '../../../util/clipboard.service'; +import { DialogService } from '../../../util/dialog-manager/dialog.service'; +import { ErrorService } from '../../../util/error-manager/error.service'; +import { Throttle } from '../../../util/throttle'; @Component({ templateUrl: './settings-apikeys.component.html', @@ -31,7 +31,7 @@ export class SettingsApiKeysComponent implements OnInit { public dataSubject = new BehaviorSubject([]); public updateSubject = new Subject(); - public totalApiKeys: number = 0; + public totalApiKeys = 0; @ViewChild(MatPaginator) paginator: MatPaginator; @@ -136,7 +136,7 @@ export class SettingsApiKeysComponent implements OnInit { return this.updateSubject .pipe(Throttle(500)) .subscribe(async (pageEvent: PageEvent) => { - let success = await this.fetchApiKeys( + const success = await this.fetchApiKeys( pageEvent.pageSize, pageEvent.pageIndex, ); diff --git a/frontend/src/app/routes/settings/apikeys/settings-apikeys.module.ts b/frontend/src/app/routes/settings/apikeys/settings-apikeys.module.ts index cfdb5044..b7cfcd66 100644 --- a/frontend/src/app/routes/settings/apikeys/settings-apikeys.module.ts +++ b/frontend/src/app/routes/settings/apikeys/settings-apikeys.module.ts @@ -7,9 +7,9 @@ import { MatInputModule } from '@angular/material/input'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatTableModule } from '@angular/material/table'; import { MomentModule } from 'ngx-moment'; -import { FabModule } from 'src/app/components/fab/fab.module'; -import { DialogManagerModule } from 'src/app/util/dialog-manager/dialog-manager.module'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; +import { FabModule } from '../../../components/fab/fab.module'; +import { DialogManagerModule } from '../../../util/dialog-manager/dialog-manager.module'; +import { ErrorManagerModule } from '../../../util/error-manager/error-manager.module'; import { SettingsApiKeyEditorComponent } from './apikey-editor/apikey-editor.component'; import { SettingsApiKeysComponent } from './settings-apikeys.component'; import { SettingsApiKeysRoutingModule } from './settings-apikeys.routing.module'; diff --git a/frontend/src/app/routes/settings/apikeys/settings-apikeys.routing.module.ts b/frontend/src/app/routes/settings/apikeys/settings-apikeys.routing.module.ts index 0ef7c6d0..cfbe44b0 100644 --- a/frontend/src/app/routes/settings/apikeys/settings-apikeys.routing.module.ts +++ b/frontend/src/app/routes/settings/apikeys/settings-apikeys.routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { SettingsApiKeysComponent } from './settings-apikeys.component'; +import { PRoutes } from '../../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/settings/general/settings-general.component.ts b/frontend/src/app/routes/settings/general/settings-general.component.ts index 3735b8c8..c1883acd 100644 --- a/frontend/src/app/routes/settings/general/settings-general.component.ts +++ b/frontend/src/app/routes/settings/general/settings-general.component.ts @@ -4,8 +4,8 @@ import { Observable } from 'rxjs'; import { UsrPreferenceFriendlyNames, UsrPreferenceHelpText, -} from 'src/app/i18n/usr-pref.i18n'; -import { UsrPrefService } from 'src/app/services/api/usr-pref.service'; +} from '../../../i18n/usr-pref.i18n'; +import { UsrPrefService } from '../../../services/api/usr-pref.service'; @Component({ templateUrl: './settings-general.component.html', diff --git a/frontend/src/app/routes/settings/general/settings-general.module.ts b/frontend/src/app/routes/settings/general/settings-general.module.ts index 68f0d3bf..8ba29510 100644 --- a/frontend/src/app/routes/settings/general/settings-general.module.ts +++ b/frontend/src/app/routes/settings/general/settings-general.module.ts @@ -1,8 +1,8 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { PrefOptionModule } from 'src/app/components/pref-option/pref-option.module'; import { SettingsGeneralComponent } from './settings-general.component'; import { SettingsGeneralRoutingModule } from './settings-general.routing.module'; +import { PrefOptionModule } from '../../../components/pref-option/pref-option.module'; @NgModule({ declarations: [SettingsGeneralComponent], diff --git a/frontend/src/app/routes/settings/general/settings-general.routing.module.ts b/frontend/src/app/routes/settings/general/settings-general.routing.module.ts index cd55221a..6e562265 100644 --- a/frontend/src/app/routes/settings/general/settings-general.routing.module.ts +++ b/frontend/src/app/routes/settings/general/settings-general.routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { SettingsGeneralComponent } from './settings-general.component'; +import { PRoutes } from '../../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/settings/roles/settings-roles-edit/settings-roles-edit.component.ts b/frontend/src/app/routes/settings/roles/settings-roles-edit/settings-roles-edit.component.ts index 0ca795ef..25f68ae6 100644 --- a/frontend/src/app/routes/settings/roles/settings-roles-edit/settings-roles-edit.component.ts +++ b/frontend/src/app/routes/settings/roles/settings-roles-edit/settings-roles-edit.component.ts @@ -1,13 +1,13 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { HasFailed } from 'picsur-shared/dist/types'; -import { UIFriendlyPermissions } from 'src/app/i18n/permissions.i18n'; -import { UpdateRoleControl } from 'src/app/models/forms/update-role.control'; -import { RolesService } from 'src/app/services/api/roles.service'; -import { StaticInfoService } from 'src/app/services/api/static-info.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; +import { UIFriendlyPermissions } from '../../../../i18n/permissions.i18n'; +import { UpdateRoleControl } from '../../../../models/forms/update-role.control'; +import { RolesService } from '../../../../services/api/roles.service'; +import { StaticInfoService } from '../../../../services/api/static-info.service'; +import { Logger } from '../../../../services/logger/logger.service'; +import { ErrorService } from '../../../../util/error-manager/error.service'; enum EditMode { edit = 'edit', diff --git a/frontend/src/app/routes/settings/roles/settings-roles.component.ts b/frontend/src/app/routes/settings/roles/settings-roles.component.ts index a14767d7..fcf38718 100644 --- a/frontend/src/app/routes/settings/roles/settings-roles.component.ts +++ b/frontend/src/app/routes/settings/roles/settings-roles.component.ts @@ -4,14 +4,14 @@ import { MatTableDataSource } from '@angular/material/table'; import { Router } from '@angular/router'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; import { ERole } from 'picsur-shared/dist/entities/role.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; -import { UIFriendlyPermissions } from 'src/app/i18n/permissions.i18n'; -import { RolesService } from 'src/app/services/api/roles.service'; -import { StaticInfoService } from 'src/app/services/api/static-info.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { BootstrapService } from 'src/app/util/bootstrap.service'; -import { DialogService } from 'src/app/util/dialog-manager/dialog.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; +import { UIFriendlyPermissions } from '../../../i18n/permissions.i18n'; +import { RolesService } from '../../../services/api/roles.service'; +import { StaticInfoService } from '../../../services/api/static-info.service'; +import { Logger } from '../../../services/logger/logger.service'; +import { BootstrapService } from '../../../util/bootstrap.service'; +import { DialogService } from '../../../util/dialog-manager/dialog.service'; +import { ErrorService } from '../../../util/error-manager/error.service'; @Component({ templateUrl: './settings-roles.component.html', diff --git a/frontend/src/app/routes/settings/roles/settings-roles.module.ts b/frontend/src/app/routes/settings/roles/settings-roles.module.ts index f74d9993..975f3a36 100644 --- a/frontend/src/app/routes/settings/roles/settings-roles.module.ts +++ b/frontend/src/app/routes/settings/roles/settings-roles.module.ts @@ -8,10 +8,10 @@ import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatTableModule } from '@angular/material/table'; -import { FabModule } from 'src/app/components/fab/fab.module'; -import { ValuesPickerModule } from 'src/app/components/values-picker/values-picker.module'; -import { DialogManagerModule } from 'src/app/util/dialog-manager/dialog-manager.module'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; +import { FabModule } from '../../../components/fab/fab.module'; +import { ValuesPickerModule } from '../../../components/values-picker/values-picker.module'; +import { DialogManagerModule } from '../../../util/dialog-manager/dialog-manager.module'; +import { ErrorManagerModule } from '../../../util/error-manager/error-manager.module'; import { SettingsRolesEditComponent } from './settings-roles-edit/settings-roles-edit.component'; import { SettingsRolesComponent } from './settings-roles.component'; import { SettingsRolesRoutingModule } from './settings-roles.routing.module'; diff --git a/frontend/src/app/routes/settings/roles/settings-roles.routing.module.ts b/frontend/src/app/routes/settings/roles/settings-roles.routing.module.ts index 75a0c43b..77aac006 100644 --- a/frontend/src/app/routes/settings/roles/settings-roles.routing.module.ts +++ b/frontend/src/app/routes/settings/roles/settings-roles.routing.module.ts @@ -1,8 +1,8 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { SettingsRolesEditComponent } from './settings-roles-edit/settings-roles-edit.component'; import { SettingsRolesComponent } from './settings-roles.component'; +import { PRoutes } from '../../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/settings/settings.routing.module.ts b/frontend/src/app/routes/settings/settings.routing.module.ts index 75a7a760..fb9bbdd6 100644 --- a/frontend/src/app/routes/settings/settings.routing.module.ts +++ b/frontend/src/app/routes/settings/settings.routing.module.ts @@ -1,10 +1,10 @@ import { ModuleWithProviders, NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { PermissionGuard } from 'src/app/guards/permission.guard'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; -import { SidebarResolverService } from 'src/app/services/sidebar-resolver/sidebar-resolver.service'; import { SettingsSidebarComponent } from './sidebar/settings-sidebar.component'; +import { PermissionGuard } from '../../guards/permission.guard'; +import { PRoutes } from '../../models/dto/picsur-routes.dto'; +import { SidebarResolverService } from '../../services/sidebar-resolver/sidebar-resolver.service'; const SettingsRoutes: PRoutes = [ { diff --git a/frontend/src/app/routes/settings/sharex/settings-sharex.component.ts b/frontend/src/app/routes/settings/sharex/settings-sharex.component.ts index 2e106e89..63415533 100644 --- a/frontend/src/app/routes/settings/sharex/settings-sharex.component.ts +++ b/frontend/src/app/routes/settings/sharex/settings-sharex.component.ts @@ -3,15 +3,15 @@ import { MatSelectChange } from '@angular/material/select'; import { FileType2Ext, ImageFileType } from 'picsur-shared/dist/dto/mimes.dto'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; import { EApiKey } from 'picsur-shared/dist/entities/apikey.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { BehaviorSubject } from 'rxjs'; import { scan } from 'rxjs/operators'; -import { ApiKeysService } from 'src/app/services/api/apikeys.service'; -import { InfoService } from 'src/app/services/api/info.service'; -import { PermissionService } from 'src/app/services/api/permission.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; -import { UtilService } from 'src/app/util/util.service'; +import { ApiKeysService } from '../../../services/api/apikeys.service'; +import { InfoService } from '../../../services/api/info.service'; +import { PermissionService } from '../../../services/api/permission.service'; +import { Logger } from '../../../services/logger/logger.service'; +import { ErrorService } from '../../../util/error-manager/error.service'; +import { UtilService } from '../../../util/util.service'; import { BuildShareX } from './sharex-builder'; @Component({ diff --git a/frontend/src/app/routes/settings/sharex/settings-sharex.module.ts b/frontend/src/app/routes/settings/sharex/settings-sharex.module.ts index 05aa25b3..dd883a5d 100644 --- a/frontend/src/app/routes/settings/sharex/settings-sharex.module.ts +++ b/frontend/src/app/routes/settings/sharex/settings-sharex.module.ts @@ -5,9 +5,9 @@ import { MatInputModule } from '@angular/material/input'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { MatSelectModule } from '@angular/material/select'; import { MatSelectInfiniteScrollModule } from 'ng-mat-select-infinite-scroll'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { SettingsShareXComponent } from './settings-sharex.component'; import { SettingsShareXRoutingModule } from './settings-sharex.routing.module'; +import { ErrorManagerModule } from '../../../util/error-manager/error-manager.module'; @NgModule({ declarations: [SettingsShareXComponent], diff --git a/frontend/src/app/routes/settings/sharex/settings-sharex.routing.module.ts b/frontend/src/app/routes/settings/sharex/settings-sharex.routing.module.ts index 242695f2..6f21cfe8 100644 --- a/frontend/src/app/routes/settings/sharex/settings-sharex.routing.module.ts +++ b/frontend/src/app/routes/settings/sharex/settings-sharex.routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { SettingsShareXComponent } from './settings-sharex.component'; +import { PRoutes } from '../../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/settings/sidebar/settings-sidebar.component.ts b/frontend/src/app/routes/settings/sidebar/settings-sidebar.component.ts index 1069d5b1..e09f874f 100644 --- a/frontend/src/app/routes/settings/sidebar/settings-sidebar.component.ts +++ b/frontend/src/app/routes/settings/sidebar/settings-sidebar.component.ts @@ -1,8 +1,8 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; -import { PermissionService } from 'src/app/services/api/permission.service'; +import { PRoutes } from '../../../models/dto/picsur-routes.dto'; +import { PermissionService } from '../../../services/api/permission.service'; @Component({ templateUrl: './settings-sidebar.component.html', diff --git a/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.component.ts b/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.component.ts index 4669c839..c105704b 100644 --- a/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.component.ts +++ b/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.component.ts @@ -5,11 +5,11 @@ import { SysPreferenceValidators, } from 'picsur-shared/dist/dto/sys-preferences.enum'; import { map, Observable } from 'rxjs'; -import { SysPreferenceUI } from 'src/app/i18n/sys-pref.i18n'; import { makeUnique } from 'picsur-shared/dist/util/unique'; -import { SysPrefService } from 'src/app/services/api/sys-pref.service'; import { z, ZodTypeAny } from 'zod'; +import { SysPreferenceUI } from '../../../i18n/sys-pref.i18n'; +import { SysPrefService } from '../../../services/api/sys-pref.service'; @Component({ templateUrl: './settings-sys-pref.component.html', diff --git a/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.module.ts b/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.module.ts index 0008e832..9ad90a49 100644 --- a/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.module.ts +++ b/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.module.ts @@ -1,8 +1,8 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { PrefOptionModule } from 'src/app/components/pref-option/pref-option.module'; import { SettingsSysprefComponent } from './settings-sys-pref.component'; import { SettingsSysprefRoutingModule } from './settings-sys-pref.routing.module'; +import { PrefOptionModule } from '../../../components/pref-option/pref-option.module'; @NgModule({ declarations: [SettingsSysprefComponent], diff --git a/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.routing.module.ts b/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.routing.module.ts index c69943bb..b2b38a48 100644 --- a/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.routing.module.ts +++ b/frontend/src/app/routes/settings/sys-pref/settings-sys-pref.routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { SettingsSysprefComponent } from './settings-sys-pref.component'; +import { PRoutes } from '../../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/settings/users/settings-users-edit/settings-users-edit.component.ts b/frontend/src/app/routes/settings/users/settings-users-edit/settings-users-edit.component.ts index cd885b0b..1eaa09b9 100644 --- a/frontend/src/app/routes/settings/users/settings-users-edit/settings-users-edit.component.ts +++ b/frontend/src/app/routes/settings/users/settings-users-edit/settings-users-edit.component.ts @@ -2,14 +2,14 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; import { ERole } from 'picsur-shared/dist/entities/role.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; -import { UIFriendlyPermissions } from 'src/app/i18n/permissions.i18n'; -import { UpdateUserControl } from 'src/app/models/forms/update-user.control'; -import { RolesService } from 'src/app/services/api/roles.service'; -import { StaticInfoService } from 'src/app/services/api/static-info.service'; -import { UserAdminService } from 'src/app/services/api/user-manage.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; +import { UIFriendlyPermissions } from '../../../../i18n/permissions.i18n'; +import { UpdateUserControl } from '../../../../models/forms/update-user.control'; +import { RolesService } from '../../../../services/api/roles.service'; +import { StaticInfoService } from '../../../../services/api/static-info.service'; +import { UserAdminService } from '../../../../services/api/user-manage.service'; +import { Logger } from '../../../../services/logger/logger.service'; +import { ErrorService } from '../../../../util/error-manager/error.service'; enum EditMode { edit = 'edit', diff --git a/frontend/src/app/routes/settings/users/settings-users.component.ts b/frontend/src/app/routes/settings/users/settings-users.component.ts index 91f13963..689a3c7b 100644 --- a/frontend/src/app/routes/settings/users/settings-users.component.ts +++ b/frontend/src/app/routes/settings/users/settings-users.component.ts @@ -3,15 +3,15 @@ import { MatPaginator, PageEvent } from '@angular/material/paginator'; import { Router } from '@angular/router'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { BehaviorSubject, Subject } from 'rxjs'; -import { StaticInfoService } from 'src/app/services/api/static-info.service'; -import { UserAdminService } from 'src/app/services/api/user-manage.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { BootstrapService } from 'src/app/util/bootstrap.service'; -import { DialogService } from 'src/app/util/dialog-manager/dialog.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; -import { Throttle } from 'src/app/util/throttle'; +import { StaticInfoService } from '../../../services/api/static-info.service'; +import { UserAdminService } from '../../../services/api/user-manage.service'; +import { Logger } from '../../../services/logger/logger.service'; +import { BootstrapService } from '../../../util/bootstrap.service'; +import { DialogService } from '../../../util/dialog-manager/dialog.service'; +import { ErrorService } from '../../../util/error-manager/error.service'; +import { Throttle } from '../../../util/throttle'; @Component({ templateUrl: './settings-users.component.html', @@ -29,7 +29,7 @@ export class SettingsUsersComponent implements OnInit { public dataSubject = new BehaviorSubject([]); public updateSubject = new Subject(); - public totalUsers: number = 0; + public totalUsers = 0; @ViewChild(MatPaginator) paginator: MatPaginator; @@ -100,7 +100,7 @@ export class SettingsUsersComponent implements OnInit { return this.updateSubject .pipe(Throttle(500)) .subscribe(async (pageEvent: PageEvent) => { - let success = await this.fetchUsers( + const success = await this.fetchUsers( pageEvent.pageSize, pageEvent.pageIndex, ); diff --git a/frontend/src/app/routes/settings/users/settings-users.module.ts b/frontend/src/app/routes/settings/users/settings-users.module.ts index 150e2bcf..8f01d5a9 100644 --- a/frontend/src/app/routes/settings/users/settings-users.module.ts +++ b/frontend/src/app/routes/settings/users/settings-users.module.ts @@ -8,13 +8,13 @@ import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatTableModule } from '@angular/material/table'; -import { FabModule } from 'src/app/components/fab/fab.module'; -import { ValuesPickerModule } from 'src/app/components/values-picker/values-picker.module'; -import { DialogManagerModule } from 'src/app/util/dialog-manager/dialog-manager.module'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { SettingsUsersEditComponent } from './settings-users-edit/settings-users-edit.component'; import { SettingsUsersComponent } from './settings-users.component'; import { SettingsUsersRoutingModule } from './settings-users.routing.module'; +import { FabModule } from '../../../components/fab/fab.module'; +import { ValuesPickerModule } from '../../../components/values-picker/values-picker.module'; +import { DialogManagerModule } from '../../../util/dialog-manager/dialog-manager.module'; +import { ErrorManagerModule } from '../../../util/error-manager/error-manager.module'; @NgModule({ declarations: [SettingsUsersComponent, SettingsUsersEditComponent], diff --git a/frontend/src/app/routes/settings/users/settings-users.routing.module.ts b/frontend/src/app/routes/settings/users/settings-users.routing.module.ts index eefb9727..ec7cbba3 100644 --- a/frontend/src/app/routes/settings/users/settings-users.routing.module.ts +++ b/frontend/src/app/routes/settings/users/settings-users.routing.module.ts @@ -1,8 +1,8 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { SettingsUsersEditComponent } from './settings-users-edit/settings-users-edit.component'; import { SettingsUsersComponent } from './settings-users.component'; +import { PRoutes } from '../../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/upload/upload.component.ts b/frontend/src/app/routes/upload/upload.component.ts index 4c299521..c9684ef7 100644 --- a/frontend/src/app/routes/upload/upload.component.ts +++ b/frontend/src/app/routes/upload/upload.component.ts @@ -3,12 +3,12 @@ import { Router } from '@angular/router'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { NgxDropzoneChangeEvent } from 'ngx-dropzone'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { Fail, FT } from 'picsur-shared/dist/types'; +import { Fail, FT } from 'picsur-shared/dist/types/failable'; import { debounceTime } from 'rxjs'; -import { PermissionService } from 'src/app/services/api/permission.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; import { ProcessingViewMeta } from '../../models/dto/processing-view-meta.dto'; +import { PermissionService } from '../../services/api/permission.service'; +import { Logger } from '../../services/logger/logger.service'; +import { ErrorService } from '../../util/error-manager/error.service'; @Component({ templateUrl: './upload.component.html', diff --git a/frontend/src/app/routes/upload/upload.module.ts b/frontend/src/app/routes/upload/upload.module.ts index 3550a752..bae264df 100644 --- a/frontend/src/app/routes/upload/upload.module.ts +++ b/frontend/src/app/routes/upload/upload.module.ts @@ -1,9 +1,9 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { NgxDropzoneModule } from 'ngx-dropzone'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { UploadComponent } from './upload.component'; import { UploadRoutingModule } from './upload.routing.module'; +import { ErrorManagerModule } from '../../util/error-manager/error-manager.module'; @NgModule({ declarations: [UploadComponent], diff --git a/frontend/src/app/routes/upload/upload.routing.module.ts b/frontend/src/app/routes/upload/upload.routing.module.ts index b5075a88..2583d0e4 100644 --- a/frontend/src/app/routes/upload/upload.routing.module.ts +++ b/frontend/src/app/routes/upload/upload.routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { UploadComponent } from './upload.component'; +import { PRoutes } from '../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/user/login/login.component.ts b/frontend/src/app/routes/user/login/login.component.ts index 8ceb3a69..70fdc2c7 100644 --- a/frontend/src/app/routes/user/login/login.component.ts +++ b/frontend/src/app/routes/user/login/login.component.ts @@ -2,13 +2,13 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { HasFailed } from 'picsur-shared/dist/types'; -import { UserPassModel } from 'src/app/models/forms-dto/userpass.dto'; -import { PermissionService } from 'src/app/services/api/permission.service'; -import { UserService } from 'src/app/services/api/user.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { LoginControl } from '../../../models/forms/login.control'; +import { PermissionService } from '../../../services/api/permission.service'; +import { UserPassModel } from '../../../models/forms-dto/userpass.dto'; +import { UserService } from '../../../services/api/user.service'; +import { Logger } from '../../../services/logger/logger.service'; +import { ErrorService } from '../../../util/error-manager/error.service'; @Component({ templateUrl: './login.component.html', diff --git a/frontend/src/app/routes/user/register/register.component.ts b/frontend/src/app/routes/user/register/register.component.ts index 79d23eff..adffd036 100644 --- a/frontend/src/app/routes/user/register/register.component.ts +++ b/frontend/src/app/routes/user/register/register.component.ts @@ -2,14 +2,14 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { debounceTime } from 'rxjs'; -import { UserPassModel } from 'src/app/models/forms-dto/userpass.dto'; -import { PermissionService } from 'src/app/services/api/permission.service'; -import { UserService } from 'src/app/services/api/user.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; import { RegisterControl } from '../../../models/forms/register.control'; +import { UserPassModel } from '../../../models/forms-dto/userpass.dto'; +import { PermissionService } from '../../../services/api/permission.service'; +import { UserService } from '../../../services/api/user.service'; +import { Logger } from '../../../services/logger/logger.service'; +import { ErrorService } from '../../../util/error-manager/error.service'; @Component({ templateUrl: './register.component.html', diff --git a/frontend/src/app/routes/user/user.module.ts b/frontend/src/app/routes/user/user.module.ts index 66e288e5..937cd730 100644 --- a/frontend/src/app/routes/user/user.module.ts +++ b/frontend/src/app/routes/user/user.module.ts @@ -4,10 +4,10 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { LoginComponent } from './login/login.component'; import { RegisterComponent } from './register/register.component'; import { UserRoutingModule } from './user.routing.module'; +import { ErrorManagerModule } from '../../util/error-manager/error-manager.module'; @NgModule({ declarations: [LoginComponent, RegisterComponent], diff --git a/frontend/src/app/routes/user/user.routing.module.ts b/frontend/src/app/routes/user/user.routing.module.ts index 81982da7..0a90a90a 100644 --- a/frontend/src/app/routes/user/user.routing.module.ts +++ b/frontend/src/app/routes/user/user.routing.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { PermissionGuard } from 'src/app/guards/permission.guard'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; import { LoginComponent } from './login/login.component'; import { RegisterComponent } from './register/register.component'; +import { PermissionGuard } from '../../guards/permission.guard'; +import { PRoutes } from '../../models/dto/picsur-routes.dto'; const routes: PRoutes = [ { diff --git a/frontend/src/app/routes/view/customize-dialog/customize-dialog.component.ts b/frontend/src/app/routes/view/customize-dialog/customize-dialog.component.ts index c7cd5587..e1698403 100644 --- a/frontend/src/app/routes/view/customize-dialog/customize-dialog.component.ts +++ b/frontend/src/app/routes/view/customize-dialog/customize-dialog.component.ts @@ -1,6 +1,6 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { ImageService } from 'src/app/services/api/image.service'; +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { ImageService } from '../../../services/api/image.service'; export interface CustomizeDialogData { imageID: string; @@ -16,7 +16,7 @@ export interface CustomizeDialogData { templateUrl: './customize-dialog.component.html', styleUrls: ['./customize-dialog.component.scss'], }) -export class CustomizeDialogComponent implements OnInit { +export class CustomizeDialogComponent { public sizeTooltip = 'Leave empty to keep original aspect ratio'; public rotationOptions = [0, 90, 180, 270]; @@ -48,8 +48,6 @@ export class CustomizeDialogComponent implements OnInit { this.imageID = data.imageID; } - ngOnInit(): void {} - close() { this.dialogRef.close(); } diff --git a/frontend/src/app/routes/view/edit-dialog/edit-dialog.component.ts b/frontend/src/app/routes/view/edit-dialog/edit-dialog.component.ts index 088db85a..3da40469 100644 --- a/frontend/src/app/routes/view/edit-dialog/edit-dialog.component.ts +++ b/frontend/src/app/routes/view/edit-dialog/edit-dialog.component.ts @@ -1,10 +1,10 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { EImage } from 'picsur-shared/dist/entities/image.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; -import { ImageService } from 'src/app/services/api/image.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; +import { ImageService } from '../../../services/api/image.service'; +import { Logger } from '../../../services/logger/logger.service'; +import { ErrorService } from '../../../util/error-manager/error.service'; export interface EditDialogData { image: EImage; @@ -15,7 +15,7 @@ export interface EditDialogData { templateUrl: './edit-dialog.component.html', styleUrls: ['./edit-dialog.component.scss'], }) -export class EditDialogComponent implements OnInit { +export class EditDialogComponent { private readonly logger = new Logger(EditDialogComponent.name); public readonly ExpireOptions: Array<[string, number]> = [ @@ -47,8 +47,6 @@ export class EditDialogComponent implements OnInit { this.image = data.image; } - async ngOnInit() {} - close() { this.dialogRef.close(); } diff --git a/frontend/src/app/routes/view/view-speeddial/view-speeddial.component.ts b/frontend/src/app/routes/view/view-speeddial/view-speeddial.component.ts index 54b1632a..7ef04833 100644 --- a/frontend/src/app/routes/view/view-speeddial/view-speeddial.component.ts +++ b/frontend/src/app/routes/view/view-speeddial/view-speeddial.component.ts @@ -6,15 +6,15 @@ import { ImageFileType } from 'picsur-shared/dist/dto/mimes.dto'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; import { EImage } from 'picsur-shared/dist/entities/image.entity'; import { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; -import { ImageService } from 'src/app/services/api/image.service'; -import { PermissionService } from 'src/app/services/api/permission.service'; -import { UserService } from 'src/app/services/api/user.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { DialogService } from 'src/app/util/dialog-manager/dialog.service'; -import { DownloadService } from 'src/app/util/download-manager/download.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; -import { UtilService } from 'src/app/util/util.service'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; +import { ImageService } from '../../../services/api/image.service'; +import { PermissionService } from '../../../services/api/permission.service'; +import { UserService } from '../../../services/api/user.service'; +import { Logger } from '../../../services/logger/logger.service'; +import { DialogService } from '../../../util/dialog-manager/dialog.service'; +import { DownloadService } from '../../../util/download-manager/download.service'; +import { ErrorService } from '../../../util/error-manager/error.service'; +import { UtilService } from '../../../util/util.service'; import { CustomizeDialogComponent, CustomizeDialogData, @@ -32,7 +32,7 @@ import { export class ViewSpeeddialComponent implements OnInit { private readonly logger = new Logger(ViewSpeeddialComponent.name); - public canManage: boolean = false; + public canManage = false; @Input() public metadata: ImageMetaResponse | null = null; @Output() public metadataChange = new EventEmitter(); diff --git a/frontend/src/app/routes/view/view.component.ts b/frontend/src/app/routes/view/view.component.ts index b7a4be60..f11c38a2 100644 --- a/frontend/src/app/routes/view/view.component.ts +++ b/frontend/src/app/routes/view/view.component.ts @@ -16,14 +16,14 @@ import { import { EImage } from 'picsur-shared/dist/entities/image.entity'; import { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { UUIDRegex } from 'picsur-shared/dist/util/common-regex'; import { ParseFileType } from 'picsur-shared/dist/util/parse-mime'; import { Subscription, timer } from 'rxjs'; -import { ImageService } from 'src/app/services/api/image.service'; -import { Logger } from 'src/app/services/logger/logger.service'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; -import { UtilService } from 'src/app/util/util.service'; +import { ImageService } from '../../services/api/image.service'; +import { Logger } from '../../services/logger/logger.service'; +import { ErrorService } from '../../util/error-manager/error.service'; +import { UtilService } from '../../util/util.service'; @Component({ templateUrl: './view.component.html', @@ -44,7 +44,7 @@ export class ViewComponent implements OnInit, OnDestroy { private readonly changeDetector: ChangeDetectorRef, ) {} - private id: string = ''; + private id = ''; public metadata: ImageMetaResponse | null = null; public set OnMetadata(metadata: ImageMetaResponse) { this.metadata = metadata; diff --git a/frontend/src/app/routes/view/view.module.ts b/frontend/src/app/routes/view/view.module.ts index 0fc80a5f..e63a46c2 100644 --- a/frontend/src/app/routes/view/view.module.ts +++ b/frontend/src/app/routes/view/view.module.ts @@ -10,17 +10,17 @@ import { MatInputModule } from '@angular/material/input'; import { MatSelectModule } from '@angular/material/select'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; import { MomentModule } from 'ngx-moment'; -import { CopyFieldModule } from 'src/app/components/copy-field/copy-field.module'; -import { FabModule } from 'src/app/components/fab/fab.module'; -import { PicsurImgModule } from 'src/app/components/picsur-img/picsur-img.module'; -import { PipesModule } from 'src/app/pipes/pipes.module'; -import { DownloadManagerModule } from 'src/app/util/download-manager/dialog-manager.module'; -import { ErrorManagerModule } from 'src/app/util/error-manager/error-manager.module'; import { CustomizeDialogComponent } from './customize-dialog/customize-dialog.component'; import { EditDialogComponent } from './edit-dialog/edit-dialog.component'; import { ViewSpeeddialComponent } from './view-speeddial/view-speeddial.component'; import { ViewComponent } from './view.component'; import { ViewRoutingModule } from './view.routing.module'; +import { CopyFieldModule } from '../../components/copy-field/copy-field.module'; +import { FabModule } from '../../components/fab/fab.module'; +import { PicsurImgModule } from '../../components/picsur-img/picsur-img.module'; +import { PipesModule } from '../../pipes/pipes.module'; +import { DownloadManagerModule } from '../../util/download-manager/dialog-manager.module'; +import { ErrorManagerModule } from '../../util/error-manager/error-manager.module'; @NgModule({ declarations: [ diff --git a/frontend/src/app/routes/view/view.routing.module.ts b/frontend/src/app/routes/view/view.routing.module.ts index bdaccabf..409defc2 100644 --- a/frontend/src/app/routes/view/view.routing.module.ts +++ b/frontend/src/app/routes/view/view.routing.module.ts @@ -1,8 +1,8 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { Permission } from 'picsur-shared/dist/dto/permissions.enum'; -import { PermissionGuard } from 'src/app/guards/permission.guard'; -import { PRoutes } from 'src/app/models/dto/picsur-routes.dto'; +import { PermissionGuard } from '../../guards/permission.guard'; +import { PRoutes } from '../../models/dto/picsur-routes.dto'; import { ViewComponent } from './view.component'; const routes: PRoutes = [ diff --git a/frontend/src/app/services/api/api.service.ts b/frontend/src/app/services/api/api.service.ts index d7f95412..7a75f1ae 100644 --- a/frontend/src/app/services/api/api.service.ts +++ b/frontend/src/app/services/api/api.service.ts @@ -9,18 +9,18 @@ import { ApiResponseSchema } from 'picsur-shared/dist/dto/api/api.dto'; import { FileType2Ext } from 'picsur-shared/dist/dto/mimes.dto'; import { AsyncFailable, + FT, Fail, Failure, - FT, HasFailed, HasSuccess, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; import { ZodDtoStatic } from 'picsur-shared/dist/util/create-zod-dto'; import { ParseMime2FileType } from 'picsur-shared/dist/util/parse-mime'; import { BehaviorSubject, Observable, Subject } from 'rxjs'; -import { ApiBuffer } from 'src/app/models/dto/api-buffer.dto'; -import { ApiError } from 'src/app/models/dto/api-error.dto'; import { z } from 'zod'; +import { ApiBuffer } from '../../models/dto/api-buffer.dto'; +import { ApiError } from '../../models/dto/api-error.dto'; import { MultiPartRequest } from '../../models/dto/multi-part-request.dto'; import { Logger } from '../logger/logger.service'; import { KeyStorageService } from '../storage/key-storage.service'; @@ -56,6 +56,7 @@ function CreateFailedRunningRequest(failure: Failure) { uploadProgress: subject.asObservable(), downloadProgress: subject.asObservable(), result: Promise.resolve(failure), + // eslint-disable-next-line @typescript-eslint/no-empty-function cancel: () => {}, } as RunningRequest; } @@ -139,7 +140,7 @@ export class ApiService { const resultSchema = ApiResponseSchema(type.zodSchema as z.AnyZodObject); type resultType = z.infer; - let result = this.fetchJsonAs(url, options); + const result = this.fetchJsonAs(url, options); return MapRunningRequest(result, async (r) => { const validateResult = resultSchema.safeParse(r); diff --git a/frontend/src/app/services/api/apikeys.service.ts b/frontend/src/app/services/api/apikeys.service.ts index 5796b6eb..99ff2820 100644 --- a/frontend/src/app/services/api/apikeys.service.ts +++ b/frontend/src/app/services/api/apikeys.service.ts @@ -11,7 +11,7 @@ import { ApiKeyUpdateResponse, } from 'picsur-shared/dist/dto/api/apikeys.dto'; import { EApiKey } from 'picsur-shared/dist/entities/apikey.entity'; -import { AsyncFailable } from 'picsur-shared/dist/types'; +import { AsyncFailable } from 'picsur-shared/dist/types/failable'; import { FindResult } from 'picsur-shared/dist/types/find-result'; import { ApiService } from './api.service'; diff --git a/frontend/src/app/services/api/image.service.ts b/frontend/src/app/services/api/image.service.ts index 4cb862c4..ae116814 100644 --- a/frontend/src/app/services/api/image.service.ts +++ b/frontend/src/app/services/api/image.service.ts @@ -15,15 +15,14 @@ import { import { ImageLinks } from 'picsur-shared/dist/dto/image-links.class'; import { FileType2Ext } from 'picsur-shared/dist/dto/mimes.dto'; import { EImage } from 'picsur-shared/dist/entities/image.entity'; -import { AsyncFailable } from 'picsur-shared/dist/types'; +import { AsyncFailable } from 'picsur-shared/dist/types/failable'; import { - Fail, FT, + Fail, HasFailed, HasSuccess, Open, } from 'picsur-shared/dist/types/failable'; -import { ImagesUploadRequest } from 'src/app/models/dto/images-upload-request.dto'; import { ImageUploadRequest } from '../../models/dto/image-upload-request.dto'; import { ApiService } from './api.service'; import { InfoService } from './info.service'; @@ -49,20 +48,20 @@ export class ImageService { return Open(result, 'id'); } - public async UploadImages(images: File[]): AsyncFailable { - console.log('Uploading images', images); + // public async UploadImages(images: File[]): AsyncFailable { + // console.log('Uploading images', images); - // Split into chunks of 20 - const groups = this.chunks(images, 20); + // // Split into chunks of 20 + // const groups = this.chunks(images, 20); - const result = await this.api.postForm( - ImageUploadResponse, - '/api/image/upload/bulk', - new ImagesUploadRequest(images), - ); + // const result = await this.api.postForm( + // ImageUploadResponse, + // '/api/image/upload/bulk', + // new ImagesUploadRequest(images), + // ); - return []; - } + // return []; + // } public async GetImageMeta(image: string): AsyncFailable { return await this.api.get(ImageMetaResponse, `/i/meta/${image}`).result; @@ -176,7 +175,7 @@ export class ImageService { if (!betterOptions.success) return baseURL; - let queryParams: string[] = []; + const queryParams: string[] = []; if (options.height !== undefined) queryParams.push(`height=${options.height}`); @@ -210,7 +209,7 @@ export class ImageService { } private chunks(arr: T[], size: number): T[][] { - let result = []; + const result = []; for (let i = 0; i < arr.length; i += size) { result.push(arr.slice(i, size + i)); } diff --git a/frontend/src/app/services/api/info.service.ts b/frontend/src/app/services/api/info.service.ts index bcb58cf9..5e7378aa 100644 --- a/frontend/src/app/services/api/info.service.ts +++ b/frontend/src/app/services/api/info.service.ts @@ -1,7 +1,12 @@ import { Inject, Injectable } from '@angular/core'; import { LOCATION } from '@ng-web-apis/common'; import { InfoResponse } from 'picsur-shared/dist/dto/api/info.dto'; -import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Fail, + FT, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { SemVerRegex } from 'picsur-shared/dist/util/common-regex'; import { BehaviorSubject, filter, Observable, take } from 'rxjs'; import pkg from '../../../../package.json'; diff --git a/frontend/src/app/services/api/permission.service.ts b/frontend/src/app/services/api/permission.service.ts index 9d6e192d..eb121984 100644 --- a/frontend/src/app/services/api/permission.service.ts +++ b/frontend/src/app/services/api/permission.service.ts @@ -1,9 +1,9 @@ import { Injectable } from '@angular/core'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { UserMePermissionsResponse } from 'picsur-shared/dist/dto/api/user.dto'; -import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types'; -import { BehaviorSubject, filter, map, Observable, take } from 'rxjs'; -import { Throttle } from 'src/app/util/throttle'; +import { AsyncFailable, HasFailed } from 'picsur-shared/dist/types/failable'; +import { BehaviorSubject, Observable, filter, map, take } from 'rxjs'; +import { Throttle } from '../../util/throttle'; import { Logger } from '../logger/logger.service'; import { ApiService } from './api.service'; import { StaticInfoService } from './static-info.service'; @@ -56,7 +56,7 @@ export class PermissionService { @AutoUnsubscribe() private subscribeUser() { - return this.userService.live.pipe(Throttle(300)).subscribe(async (user) => { + return this.userService.live.pipe(Throttle(300)).subscribe(async () => { const permissions = await this.updatePermissions(); if (HasFailed(permissions)) { this.logger.error(permissions.getReason()); diff --git a/frontend/src/app/services/api/roles.service.ts b/frontend/src/app/services/api/roles.service.ts index 9a091e0c..baa668a8 100644 --- a/frontend/src/app/services/api/roles.service.ts +++ b/frontend/src/app/services/api/roles.service.ts @@ -11,8 +11,8 @@ import { RoleUpdateResponse, } from 'picsur-shared/dist/dto/api/roles.dto'; import { ERole } from 'picsur-shared/dist/entities/role.entity'; -import { AsyncFailable, Open } from 'picsur-shared/dist/types'; -import { RoleModel } from 'src/app/models/forms-dto/role.dto'; +import { AsyncFailable, Open } from 'picsur-shared/dist/types/failable'; +import { RoleModel } from '../../models/forms-dto/role.dto'; import { ApiService } from './api.service'; @Injectable({ diff --git a/frontend/src/app/services/api/static-info.service.ts b/frontend/src/app/services/api/static-info.service.ts index 590bba27..94482717 100644 --- a/frontend/src/app/services/api/static-info.service.ts +++ b/frontend/src/app/services/api/static-info.service.ts @@ -3,7 +3,7 @@ import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { AllPermissionsResponse } from 'picsur-shared/dist/dto/api/info.dto'; import { SpecialRolesResponse } from 'picsur-shared/dist/dto/api/roles.dto'; import { GetSpecialUsersResponse } from 'picsur-shared/dist/dto/api/user-manage.dto'; -import { Open } from 'picsur-shared/dist/types'; +import { Open } from 'picsur-shared/dist/types/failable'; import { CacheService } from '../storage/cache.service'; import { ApiService } from './api.service'; import { InfoService } from './info.service'; diff --git a/frontend/src/app/services/api/sys-pref.service.ts b/frontend/src/app/services/api/sys-pref.service.ts index 1044d812..c2093453 100644 --- a/frontend/src/app/services/api/sys-pref.service.ts +++ b/frontend/src/app/services/api/sys-pref.service.ts @@ -13,14 +13,14 @@ import { } from 'picsur-shared/dist/dto/preferences.dto'; import { AsyncFailable, - Fail, FT, + Fail, HasFailed, Map, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; import { BehaviorSubject } from 'rxjs'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; -import { Throttle } from 'src/app/util/throttle'; +import { ErrorService } from '../../util/error-manager/error.service'; +import { Throttle } from '../../util/throttle'; import { Logger } from '../logger/logger.service'; import { ApiService } from './api.service'; import { PermissionService } from './permission.service'; diff --git a/frontend/src/app/services/api/user-manage.service.ts b/frontend/src/app/services/api/user-manage.service.ts index 13e7b2bb..9a063c19 100644 --- a/frontend/src/app/services/api/user-manage.service.ts +++ b/frontend/src/app/services/api/user-manage.service.ts @@ -12,7 +12,7 @@ import { UserUpdateResponse, } from 'picsur-shared/dist/dto/api/user-manage.dto'; import { EUser } from 'picsur-shared/dist/entities/user.entity'; -import { AsyncFailable } from 'picsur-shared/dist/types'; +import { AsyncFailable } from 'picsur-shared/dist/types/failable'; import { ApiService } from './api.service'; @Injectable({ diff --git a/frontend/src/app/services/api/user.service.ts b/frontend/src/app/services/api/user.service.ts index fe51b736..31a8eadc 100644 --- a/frontend/src/app/services/api/user.service.ts +++ b/frontend/src/app/services/api/user.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import jwt_decode from 'jwt-decode'; +import { decodeToken } from '@leteu/jwt-decoder'; import { UserCheckNameRequest, UserCheckNameResponse, @@ -17,7 +17,7 @@ import { FT, HasFailed, Open, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; import { BehaviorSubject } from 'rxjs'; import { Logger } from '../logger/logger.service'; import { KeyStorageService } from '../storage/key-storage.service'; @@ -131,7 +131,7 @@ export class UserService { private async extractUserID(token: string): AsyncFailable { let decoded: any; try { - decoded = jwt_decode(token); + decoded = decodeToken(token); } catch (e) { return Fail(FT.UsrValidation, 'Invalid token'); } diff --git a/frontend/src/app/services/api/usr-pref.service.ts b/frontend/src/app/services/api/usr-pref.service.ts index f527a522..d1ed608b 100644 --- a/frontend/src/app/services/api/usr-pref.service.ts +++ b/frontend/src/app/services/api/usr-pref.service.ts @@ -13,14 +13,14 @@ import { } from 'picsur-shared/dist/dto/preferences.dto'; import { AsyncFailable, - Fail, FT, + Fail, HasFailed, Map, -} from 'picsur-shared/dist/types'; +} from 'picsur-shared/dist/types/failable'; import { BehaviorSubject } from 'rxjs'; -import { ErrorService } from 'src/app/util/error-manager/error.service'; -import { Throttle } from 'src/app/util/throttle'; +import { ErrorService } from '../../util/error-manager/error.service'; +import { Throttle } from '../../util/throttle'; import { Logger } from '../logger/logger.service'; import { ApiService } from './api.service'; import { PermissionService } from './permission.service'; diff --git a/frontend/src/app/services/sidebar-resolver/sidebar-resolver.service.ts b/frontend/src/app/services/sidebar-resolver/sidebar-resolver.service.ts index 09c95069..2f0e6c11 100644 --- a/frontend/src/app/services/sidebar-resolver/sidebar-resolver.service.ts +++ b/frontend/src/app/services/sidebar-resolver/sidebar-resolver.service.ts @@ -1,7 +1,7 @@ import { ComponentPortal, Portal } from '@angular/cdk/portal'; import { Injectable, Injector } from '@angular/core'; import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; -import { PRouteData } from 'src/app/models/dto/picsur-routes.dto'; +import { PRouteData } from '../../models/dto/picsur-routes.dto'; // This service makes sure that any sidebar components are getting dependency injection // from their correct module. Instead of getting it from the module where it is being diff --git a/frontend/src/app/services/storage/cache.service.ts b/frontend/src/app/services/storage/cache.service.ts index 7803b345..01f544c8 100644 --- a/frontend/src/app/services/storage/cache.service.ts +++ b/frontend/src/app/services/storage/cache.service.ts @@ -1,6 +1,10 @@ import { Inject, Injectable } from '@angular/core'; import { SESSION_STORAGE } from '@ng-web-apis/common'; -import { AsyncFailable, Failable, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Failable, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { Logger } from '../logger/logger.service'; interface dataWrapper { diff --git a/frontend/src/app/services/storage/info-storage.service.ts b/frontend/src/app/services/storage/info-storage.service.ts index 7f678d62..281b835e 100644 --- a/frontend/src/app/services/storage/info-storage.service.ts +++ b/frontend/src/app/services/storage/info-storage.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { ServerInfo } from 'src/app/models/dto/server-info.dto'; +import { ServerInfo } from '../../models/dto/server-info.dto'; import { Logger } from '../logger/logger.service'; @Injectable({ diff --git a/frontend/src/app/util/api-error-manager/api-error.service.ts b/frontend/src/app/util/api-error-manager/api-error.service.ts index 6a68f9da..4d0443f6 100644 --- a/frontend/src/app/util/api-error-manager/api-error.service.ts +++ b/frontend/src/app/util/api-error-manager/api-error.service.ts @@ -18,6 +18,7 @@ export class ApiErrorService { this.subscribeErrors(); } + // eslint-disable-next-line @typescript-eslint/no-empty-function nothing(): void {} @AutoUnsubscribe() diff --git a/frontend/src/app/util/bootstrap.service.ts b/frontend/src/app/util/bootstrap.service.ts index ed2a326e..eed994b7 100644 --- a/frontend/src/app/util/bootstrap.service.ts +++ b/frontend/src/app/util/bootstrap.service.ts @@ -2,7 +2,7 @@ import { BreakpointObserver } from '@angular/cdk/layout'; import { Injectable } from '@angular/core'; import { AutoUnsubscribe } from 'ngx-auto-unsubscribe-decorator'; import { BehaviorSubject, combineLatest, map, Observable } from 'rxjs'; -import { Logger } from 'src/app/services/logger/logger.service'; +import { Logger } from '../services/logger/logger.service'; export enum BSScreenSize { xs = 0, diff --git a/frontend/src/app/util/compatibilitiy-manager/compatibility.service.ts b/frontend/src/app/util/compatibilitiy-manager/compatibility.service.ts index 4b95ea46..9cea86a2 100644 --- a/frontend/src/app/util/compatibilitiy-manager/compatibility.service.ts +++ b/frontend/src/app/util/compatibilitiy-manager/compatibility.service.ts @@ -1,8 +1,8 @@ import { Inject, Injectable } from '@angular/core'; import { HISTORY } from '@ng-web-apis/common'; -import { HasFailed } from 'picsur-shared/dist/types'; -import { InfoService } from 'src/app/services/api/info.service'; -import { Logger } from 'src/app/services/logger/logger.service'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; +import { InfoService } from '../../services/api/info.service'; +import { Logger } from '../../services/logger/logger.service'; import { DialogService } from '../dialog-manager/dialog.service'; import { ErrorService } from '../error-manager/error.service'; @@ -21,6 +21,7 @@ export class CompatibilityService { this.checkCompatibility().catch(this.logger.error); } + // eslint-disable-next-line @typescript-eslint/no-empty-function nothing() {} private async checkCompatibility() { diff --git a/frontend/src/app/util/dialog-manager/dialog.service.ts b/frontend/src/app/util/dialog-manager/dialog.service.ts index 5271742a..b5238664 100644 --- a/frontend/src/app/util/dialog-manager/dialog.service.ts +++ b/frontend/src/app/util/dialog-manager/dialog.service.ts @@ -1,7 +1,7 @@ import { ComponentType } from '@angular/cdk/portal'; import { Injectable } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; -import { Logger } from 'src/app/services/logger/logger.service'; +import { Logger } from '../../services/logger/logger.service'; import { ConfirmDialogComponent, ConfirmDialogData, @@ -22,7 +22,7 @@ export class DialogService { dismissable?: boolean; }, ): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { const ref = this.dialog.open(component, { data, panelClass: 'small-dialog-padding', diff --git a/frontend/src/app/util/download-manager/download.service.ts b/frontend/src/app/util/download-manager/download.service.ts index 0c614730..abefa3a6 100644 --- a/frontend/src/app/util/download-manager/download.service.ts +++ b/frontend/src/app/util/download-manager/download.service.ts @@ -1,9 +1,9 @@ import { Injectable } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; -import { Fail, FT, HasFailed } from 'picsur-shared/dist/types'; +import { Fail, FT, HasFailed } from 'picsur-shared/dist/types/failable'; import { Observable } from 'rxjs'; -import { ApiService } from 'src/app/services/api/api.service'; -import { Logger } from 'src/app/services/logger/logger.service'; +import { ApiService } from '../../services/api/api.service'; +import { Logger } from '../../services/logger/logger.service'; import { DownloadDialogComponent } from '../dialog-manager/download-dialog/download-dialog.component'; import { ErrorService } from '../error-manager/error.service'; import { UtilService } from '../util.service'; diff --git a/frontend/src/app/util/error-manager/error.service.ts b/frontend/src/app/util/error-manager/error.service.ts index 93e3e26b..e8e2ced3 100644 --- a/frontend/src/app/util/error-manager/error.service.ts +++ b/frontend/src/app/util/error-manager/error.service.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; -import { Failure } from 'picsur-shared/dist/types'; -import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto'; -import { Logger } from 'src/app/services/logger/logger.service'; +import { Failure } from 'picsur-shared/dist/types/failable'; +import { SnackBarType } from '../../models/dto/snack-bar-type.dto'; +import { Logger } from '../../services/logger/logger.service'; import { SnackBarService } from '../snackbar-manager/snackbar.service'; @Injectable({ diff --git a/frontend/src/app/util/snackbar-manager/snackbar.service.ts b/frontend/src/app/util/snackbar-manager/snackbar.service.ts index de07438c..fa1e425f 100644 --- a/frontend/src/app/util/snackbar-manager/snackbar.service.ts +++ b/frontend/src/app/util/snackbar-manager/snackbar.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { SnackBarType } from 'src/app/models/dto/snack-bar-type.dto'; -import { Logger } from 'src/app/services/logger/logger.service'; +import { SnackBarType } from '../../models/dto/snack-bar-type.dto'; +import { Logger } from '../../services/logger/logger.service'; import { BootstrapService, BSScreenSize } from '../bootstrap.service'; @Injectable({ @@ -20,7 +20,7 @@ export class SnackBarService { type: SnackBarType = SnackBarType.Default, duration: number | undefined | null = null, ) { - let ref = this.snackBar.open(message, '', { + this.snackBar.open(message, '', { panelClass: ['mat-toolbar', 'snackbar', type], verticalPosition: this.bootstrap.screenSizeSnapshot() > BSScreenSize.xs diff --git a/frontend/src/app/util/util.service.ts b/frontend/src/app/util/util.service.ts index 2bd6302d..b17db257 100644 --- a/frontend/src/app/util/util.service.ts +++ b/frontend/src/app/util/util.service.ts @@ -3,7 +3,7 @@ import { FileType2Ext, SupportedFileTypes, } from 'picsur-shared/dist/dto/mimes.dto'; -import { HasFailed } from 'picsur-shared/dist/types'; +import { HasFailed } from 'picsur-shared/dist/types/failable'; import { Logger } from '../services/logger/logger.service'; @Injectable({ @@ -15,7 +15,7 @@ export class UtilService { public downloadBuffer( buffer: ArrayBuffer | string, filename: string, - filetype: string = 'application/octet-stream', + filetype = 'application/octet-stream', ) { const a = document.createElement('a'); a.href = URL.createObjectURL(new Blob([buffer], { type: filetype })); @@ -25,7 +25,7 @@ export class UtilService { } public getBaseFormatOptions() { - let newOptions: { + const newOptions: { value: string; key: string; }[] = []; diff --git a/frontend/src/app/workers/qoi-worker.dto.ts b/frontend/src/app/workers/qoi-worker.dto.ts index ab439bc6..3a026995 100644 --- a/frontend/src/app/workers/qoi-worker.dto.ts +++ b/frontend/src/app/workers/qoi-worker.dto.ts @@ -1,4 +1,4 @@ -import { AsyncFailable, Failable } from 'picsur-shared/dist/types'; +import { AsyncFailable, Failable } from 'picsur-shared/dist/types/failable'; export interface QOIImage { data: ImageData; diff --git a/frontend/src/app/workers/qoi-worker.service.ts b/frontend/src/app/workers/qoi-worker.service.ts index 733510b8..8dc12b38 100644 --- a/frontend/src/app/workers/qoi-worker.service.ts +++ b/frontend/src/app/workers/qoi-worker.service.ts @@ -1,5 +1,9 @@ import { Injectable } from '@angular/core'; -import { AsyncFailable, Failure, HasFailed } from 'picsur-shared/dist/types'; +import { + AsyncFailable, + Failure, + HasFailed, +} from 'picsur-shared/dist/types/failable'; import { KeyStorageService } from '../services/storage/key-storage.service'; import { QOIImage, QOIJob, QOIWorkerOut } from './qoi-worker.dto'; @@ -22,19 +26,19 @@ export class QoiWorkerService { const authorization = 'Bearer ' + (this.keyService.get() ?? ''); if (this.worker && !this.job) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { const id = Date.now(); const listener = ({ data }: { data: QOIWorkerOut }) => { if (data.id !== id) return; - this.worker!.removeEventListener('message', listener); + this.worker?.removeEventListener('message', listener); let result = data.result; if (HasFailed(result)) result = Failure.deserialize(data.result); resolve(result); }; - this.worker!.addEventListener('message', listener); - this.worker!.postMessage({ id, url, authorization }); + this.worker?.addEventListener('message', listener); + this.worker?.postMessage({ id, url, authorization }); }); } else if (!this.worker && this.job) { const job = await this.job; diff --git a/frontend/src/app/workers/qoi.job.ts b/frontend/src/app/workers/qoi.job.ts index 7b07cd8a..99c2d394 100644 --- a/frontend/src/app/workers/qoi.job.ts +++ b/frontend/src/app/workers/qoi.job.ts @@ -1,4 +1,4 @@ -import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types'; +import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types/failable'; import { QOIdecodeJS } from '../util/qoi/qoi-decode'; import { QOIImage } from './qoi-worker.dto'; diff --git a/frontend/src/scss/fonts.scss b/frontend/src/scss/fonts.scss index bbf594c2..d967cf9b 100644 --- a/frontend/src/scss/fonts.scss +++ b/frontend/src/scss/fonts.scss @@ -26,7 +26,6 @@ // -moz-osx-font-smoothing: grayscale; // } - // .material-icons { // font-family: 'Material Icons'; // font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 48; diff --git a/frontend/tsconfig.base.json b/frontend/tsconfig.base.json index ef7a7c96..4f790656 100644 --- a/frontend/tsconfig.base.json +++ b/frontend/tsconfig.base.json @@ -4,8 +4,6 @@ "compileOnSave": false, "compilerOptions": { - "baseUrl": "./", - "target": "ES2022", "module": "ES2022", diff --git a/package.json b/package.json index e4308fdd..7e00fbe5 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "setversion": "./support/setversion.sh", "purge": "rm -rf ./node_modules", "purge-all": "./support/purge-all.sh", - "format": "prettier --write ." + "format": "prettier --write .", + "lint": "eslint --fix ." }, "resolutions": { "fastify": ">=4.8.1", @@ -24,17 +25,19 @@ "jsonwebtoken": ">=9.0.0", "typescript": "~4.9.5", "webpack": ">=5.76.0", - "ms": "3.0.0-canary.1", "fastify-static": "npm:@fastify/static@*", "fastify-formbody": "npm:@fastify/formbody@*", "minimist": "npm:minimist-lite@*" }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.59.9", + "@typescript-eslint/parser": "^5.59.9", + "eslint": "^8.42.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-require-extensions": "^0.1.3", "prettier": "^2.8.8", "prettier-plugin-sh": "^0.12.8" }, - "packageManager": "yarn@3.2.2", - "dependencies": { - "eslint": "^8.42.0" - } + "packageManager": "yarn@3.2.2" } diff --git a/shared/.eslintrc.cjs b/shared/.eslintrc.cjs new file mode 100644 index 00000000..cb4b8d70 --- /dev/null +++ b/shared/.eslintrc.cjs @@ -0,0 +1,8 @@ +module.exports = { + parserOptions: { + project: './tsconfig.json', + tsconfigRootDir: __dirname, + sourceType: 'module', + }, + root: false, +}; diff --git a/shared/package.json b/shared/package.json index 9624dbaa..fecdbb88 100644 --- a/shared/package.json +++ b/shared/package.json @@ -7,11 +7,17 @@ "author": "Caramel ", "type": "module", "main": "./dist/index.js", + "exports": { + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./dist/*": "./dist/*.js" + }, "dependencies": { + "ms": "3.0.0-canary.1", "zod": "^3.21.4" }, "devDependencies": { - "@types/node": "^20.2.5", + "@types/node": "^20.3.1", "tsc-watch": "^6.0.4", "typescript": "^5.1.3" }, diff --git a/shared/src/dto/api/api.dto.ts b/shared/src/dto/api/api.dto.ts index ae5716dc..88b09383 100644 --- a/shared/src/dto/api/api.dto.ts +++ b/shared/src/dto/api/api.dto.ts @@ -1,4 +1,4 @@ -import z from 'zod'; +import * as z from 'zod'; const ApiResponseBase = z.object({ statusCode: z.number().min(0).max(600).int(), diff --git a/shared/src/dto/image-links.class.ts b/shared/src/dto/image-links.class.ts index f0da6689..df5471a2 100644 --- a/shared/src/dto/image-links.class.ts +++ b/shared/src/dto/image-links.class.ts @@ -1,7 +1,7 @@ export class ImageLinks { - source: string = ''; - markdown: string = ''; - html: string = ''; - rst: string = ''; - bbcode: string = ''; + source = ''; + markdown = ''; + html = ''; + rst = ''; + bbcode = ''; } diff --git a/shared/src/dto/mimes.dto.ts b/shared/src/dto/mimes.dto.ts index 63175f07..2ab87272 100644 --- a/shared/src/dto/mimes.dto.ts +++ b/shared/src/dto/mimes.dto.ts @@ -1,4 +1,4 @@ -import { Fail, Failable, FT } from '../types'; +import { Fail, Failable, FT } from '../types/failable'; // Config export enum ImageFileType { @@ -57,7 +57,7 @@ const FileType2MimeMap: { export const Mime2FileType = (mime: string): Failable => { const entries = Object.entries(FileType2MimeMap).filter( - ([k, v]) => v === mime, + ([, v]) => v === mime, ); if (entries.length === 0) return Fail(FT.Internal, undefined, `Unsupported mime type: ${mime}`); @@ -88,7 +88,7 @@ const FileType2ExtMap: { }; export const Ext2FileType = (ext: string): Failable => { - const entries = Object.entries(FileType2ExtMap).filter(([k, v]) => v === ext); + const entries = Object.entries(FileType2ExtMap).filter(([, v]) => v === ext); if (entries.length === 0) return Fail(FT.Internal, undefined, `Unsupported ext: ${ext}`); return entries[0][0]; diff --git a/shared/src/entities/image.entity.ts b/shared/src/entities/image.entity.ts index 22cbc816..c1b556e6 100644 --- a/shared/src/entities/image.entity.ts +++ b/shared/src/entities/image.entity.ts @@ -1,9 +1,5 @@ import { z } from 'zod'; import { IsEntityID } from '../validators/entity-id.validator'; -import { IsPosInt } from '../validators/positive-int.validator'; - -const MONTH_IN_SECONDS = 60 * 60 * 24 * 30; -const FIVE_MIN_IN_SECONDS = 60 * 5; export const EImageSchema = z.object({ id: IsEntityID(), diff --git a/shared/src/types/index.ts b/shared/src/types/index.ts deleted file mode 100644 index 4afc322a..00000000 --- a/shared/src/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './failable'; -export * from './newable'; -export * from './tuple'; diff --git a/shared/src/util/decorator.ts b/shared/src/util/decorator.ts index a76004ae..e7d53cd5 100644 --- a/shared/src/util/decorator.ts +++ b/shared/src/util/decorator.ts @@ -14,7 +14,7 @@ export const CombinePDecorators = ( ...decorators: PropertyDecorator[] ): (() => PropertyDecorator) => { return () => { - return (target: Object, propertyKey: string | symbol): void => { + return (target: object, propertyKey: string | symbol): void => { decorators.forEach((decorator) => decorator(target, propertyKey)); }; }; diff --git a/shared/src/util/parse-mime.ts b/shared/src/util/parse-mime.ts index 21e93e68..4b0f1b12 100644 --- a/shared/src/util/parse-mime.ts +++ b/shared/src/util/parse-mime.ts @@ -6,7 +6,7 @@ import { SupportedFileTypeCategory, SupportedImageFileTypes, } from '../dto/mimes.dto'; -import { Fail, Failable, FT, HasFailed } from '../types'; +import { Fail, Failable, FT, HasFailed } from '../types/failable'; export function ParseFileType(filetype: string): Failable { if (SupportedImageFileTypes.includes(filetype)) diff --git a/shared/src/util/random.ts b/shared/src/util/random.ts index c6ffc211..5b759590 100644 --- a/shared/src/util/random.ts +++ b/shared/src/util/random.ts @@ -1,4 +1,4 @@ -import crypto from 'crypto'; +import { randomInt } from 'crypto'; const randomCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; @@ -7,7 +7,7 @@ export function generateRandomString(length: number): string { let out = ''; for (let i = 0; i < length; i++) { // Yes this is done synchronously, but it's not a big deal - out += randomCharacters[crypto.randomInt(0, randomCharacters.length - 1)]; + out += randomCharacters[randomInt(0, randomCharacters.length - 1)]; } return out; } diff --git a/shared/tsconfig.json b/shared/tsconfig.json index 8f4fc03c..e5969306 100644 --- a/shared/tsconfig.json +++ b/shared/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "target": "ES2022", "module": "ES2022", - "lib": ["ES2022"], + "lib": ["ES2022", "DOM"], "outDir": "./dist", "declaration": true, diff --git a/tsconfig.base.json b/tsconfig.base.json index 29335725..cbbd947f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,6 +1,7 @@ { "compilerOptions": { "moduleResolution": "node", + "esModuleInterop": true, "resolveJsonModule": true, "allowSyntheticDefaultImports": true, @@ -21,6 +22,6 @@ "skipLibCheck": true, "removeComments": true, "isolatedModules": true, - "incremental": true + "incremental": false } } diff --git a/yarn.lock b/yarn.lock index 0f44be22..c74ed794 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3453,6 +3453,15 @@ __metadata: languageName: node linkType: hard +"@leteu/jwt-decoder@npm:^1.0.4": + version: 1.0.4 + resolution: "@leteu/jwt-decoder@npm:1.0.4" + dependencies: + buffer: ^6.0.3 + checksum: f3b4cfeacbefaef0a68efaba505fd60e9c319c80cb41e6eebcfd554433a33572c159e76527f25b11e52bd31a292e769f93597e68eac069553930c9d9caafbdde + languageName: node + linkType: hard + "@lukeed/csprng@npm:^1.0.0": version: 1.0.1 resolution: "@lukeed/csprng@npm:1.0.1" @@ -5061,6 +5070,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20.3.1": + version: 20.3.1 + resolution: "@types/node@npm:20.3.1" + checksum: 63a393ab6d947be17320817b35d7277ef03728e231558166ed07ee30b09fd7c08861be4d746f10fdc63ca7912e8cd023939d4eab887ff6580ff704ff24ed810c + languageName: node + linkType: hard + "@types/parse-json@npm:^4.0.0": version: 4.0.0 resolution: "@types/parse-json@npm:4.0.0" @@ -9379,13 +9395,6 @@ __metadata: languageName: node linkType: hard -"jwt-decode@npm:^3.1.2": - version: 3.1.2 - resolution: "jwt-decode@npm:3.1.2" - checksum: 20a4b072d44ce3479f42d0d2c8d3dabeb353081ba4982e40b83a779f2459a70be26441be6c160bfc8c3c6eadf9f6380a036fbb06ac5406b5674e35d8c4205eeb - languageName: node - linkType: hard - "karma-source-map-support@npm:1.4.0": version: 1.4.0 resolution: "karma-source-map-support@npm:1.4.0" @@ -10082,6 +10091,27 @@ __metadata: languageName: node linkType: hard +"ms@npm:2.0.0": + version: 2.0.0 + resolution: "ms@npm:2.0.0" + checksum: 0e6a22b8b746d2e0b65a430519934fefd41b6db0682e3477c10f60c76e947c4c0ad06f63ffdf1d78d335f83edee8c0aa928aa66a36c7cd95b69b26f468d527f4 + languageName: node + linkType: hard + +"ms@npm:2.1.2": + version: 2.1.2 + resolution: "ms@npm:2.1.2" + checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f + languageName: node + linkType: hard + +"ms@npm:2.1.3, ms@npm:^2.0.0, ms@npm:^2.1.1": + version: 2.1.3 + resolution: "ms@npm:2.1.3" + checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d + languageName: node + linkType: hard + "ms@npm:3.0.0-canary.1": version: 3.0.0-canary.1 resolution: "ms@npm:3.0.0-canary.1" @@ -11139,18 +11169,12 @@ __metadata: "@types/passport-strategy": ^0.2.35 "@types/sharp": ^0.32.0 "@types/supertest": ^2.0.12 - "@typescript-eslint/eslint-plugin": ^5.59.9 - "@typescript-eslint/parser": ^5.59.9 bcrypt: ^5.1.0 bmp-img: ^1.2.1 cors: ^2.8.5 - eslint: ^8.42.0 - eslint-config-prettier: ^8.8.0 - eslint-plugin-prettier: ^4.2.1 - eslint-plugin-require-extensions: ^0.1.3 file-type: ^18.5.0 is-docker: ^3.0.0 - ms: ^2.1.3 + ms: 3.0.0-canary.1 node-fetch: ^3.3.1 p-timeout: ^6.1.1 passport: ^0.6.0 @@ -11201,6 +11225,7 @@ __metadata: "@babel/core": ^7.22.1 "@babel/preset-env": ^7.22.4 "@fontsource/roboto": ^5.0.2 + "@leteu/jwt-decoder": ^1.0.4 "@ng-web-apis/common": ^2.1.0 "@ng-web-apis/resize-observer": ^2.0.0 "@ngui/common": ^1.0.0 @@ -11216,7 +11241,6 @@ __metadata: browserslist: ^4.21.7 caniuse-lite: ^1.0.30001495 fuse.js: ^6.6.2 - jwt-decode: ^3.1.2 material-icons: ^1.13.8 moment: ^2.29.4 ng-mat-select-infinite-scroll: ^4.0.0 @@ -11238,7 +11262,8 @@ __metadata: version: 0.0.0-use.local resolution: "picsur-shared@workspace:shared" dependencies: - "@types/node": ^20.2.5 + "@types/node": ^20.3.1 + ms: 3.0.0-canary.1 tsc-watch: ^6.0.4 typescript: ^5.1.3 zod: ^3.21.4 @@ -12074,7 +12099,12 @@ __metadata: version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." dependencies: + "@typescript-eslint/eslint-plugin": ^5.59.9 + "@typescript-eslint/parser": ^5.59.9 eslint: ^8.42.0 + eslint-config-prettier: ^8.8.0 + eslint-plugin-prettier: ^4.2.1 + eslint-plugin-require-extensions: ^0.1.3 prettier: ^2.8.8 prettier-plugin-sh: ^0.12.8 languageName: unknown