Skip to content

Commit

Permalink
Move entities
Browse files Browse the repository at this point in the history
  • Loading branch information
CaramelFur committed Dec 26, 2022
1 parent 72b6b2a commit 844d11b
Show file tree
Hide file tree
Showing 30 changed files with 60 additions and 65 deletions.
2 changes: 1 addition & 1 deletion backend/src/collections/apikey-db/apikey-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FindResult } from 'picsur-shared/dist/types/find-result';
import { generateRandomString } from 'picsur-shared/dist/util/random';
import { Repository } from 'typeorm';
import { EApiKeyBackend } from '../../database/entities/apikey.entity';
import { EUserBackend } from '../../database/entities/user.entity';
import { EUserBackend } from '../../database/entities/users/user.entity';

@Injectable()
export class ApiKeyDbService {
Expand Down
6 changes: 3 additions & 3 deletions backend/src/collections/image-db/image-db.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { EImageDerivativeBackend } from '../../database/entities/image-derivative.entity';
import { EImageFileBackend } from '../../database/entities/image-file.entity';
import { EImageBackend } from '../../database/entities/image.entity';
import { EImageDerivativeBackend } from '../../database/entities/images/image-derivative.entity';
import { EImageFileBackend } from '../../database/entities/images/image-file.entity';
import { EImageBackend } from '../../database/entities/images/image.entity';
import { ImageDBService } from './image-db.service';
import { ImageFileDBService } from './image-file-db.service';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/collections/image-db/image-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types';
import { FindResult } from 'picsur-shared/dist/types/find-result';
import { generateRandomString } from 'picsur-shared/dist/util/random';
import { In, LessThan, Repository } from 'typeorm';
import { EImageBackend } from '../../database/entities/image.entity';
import { EImageBackend } from '../../database/entities/images/image.entity';

@Injectable()
export class ImageDBService {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/collections/image-db/image-file-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { InjectRepository } from '@nestjs/typeorm';
import { ImageEntryVariant } from 'picsur-shared/dist/dto/image-entry-variant.enum';
import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types';
import { LessThan, Repository } from 'typeorm';
import { EImageDerivativeBackend } from '../../database/entities/image-derivative.entity';
import { EImageFileBackend } from '../../database/entities/image-file.entity';
import { EImageDerivativeBackend } from '../../database/entities/images/image-derivative.entity';
import { EImageFileBackend } from '../../database/entities/images/image-file.entity';

const A_DAY_IN_SECONDS = 24 * 60 * 60;

Expand Down
4 changes: 2 additions & 2 deletions backend/src/collections/preference-db/preference-db.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { EarlyConfigModule } from '../../config/early/early-config.module';
import { ESysPreferenceBackend } from '../../database/entities/sys-preference.entity';
import { EUsrPreferenceBackend } from '../../database/entities/usr-preference.entity';
import { ESysPreferenceBackend } from '../../database/entities/system/sys-preference.entity';
import { EUsrPreferenceBackend } from '../../database/entities/system/usr-preference.entity';
import { PreferenceCommonService } from './preference-common.service';
import { PreferenceDefaultsService } from './preference-defaults.service';
import { SysPreferenceDbService } from './sys-preference-db.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ import { InjectRepository } from '@nestjs/typeorm';
import {
DecodedSysPref,
PrefValueType,
PrefValueTypeStrings,
PrefValueTypeStrings
} from 'picsur-shared/dist/dto/preferences.dto';
import {
SysPreference,
SysPreferenceList,
SysPreferenceValidators,
SysPreferenceValueTypes,
SysPreferenceValueTypes
} from 'picsur-shared/dist/dto/sys-preferences.enum';
import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types';
import { Repository } from 'typeorm';
import {
ESysPreferenceBackend,
ESysPreferenceSchema,
} from '../../database/entities/sys-preference.entity';
import { ESysPreferenceBackend, ESysPreferenceSchema } from '../../database/entities/system/sys-preference.entity';
import { MutexFallBack } from '../../util/mutex-fallback';
import { PreferenceCommonService } from './preference-common.service';
import { PreferenceDefaultsService } from './preference-defaults.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { InjectRepository } from '@nestjs/typeorm';
import {
DecodedUsrPref,
PrefValueType,
PrefValueTypeStrings,
PrefValueTypeStrings
} from 'picsur-shared/dist/dto/preferences.dto';
import {
UsrPreference,
UsrPreferenceList,
UsrPreferenceValidators,
UsrPreferenceValueTypes,
UsrPreferenceValueTypes
} from 'picsur-shared/dist/dto/usr-preferences.enum';
import { AsyncFailable, Fail, FT, HasFailed } from 'picsur-shared/dist/types';
import { Repository } from 'typeorm';
import {
EUsrPreferenceBackend,
EUsrPreferenceSchema,
} from '../../database/entities/usr-preference.entity';
EUsrPreferenceSchema
} from '../../database/entities/system/usr-preference.entity';
import { MutexFallBack } from '../../util/mutex-fallback';
import { PreferenceCommonService } from './preference-common.service';
import { PreferenceDefaultsService } from './preference-defaults.service';
Expand Down
4 changes: 2 additions & 2 deletions backend/src/collections/role-db/role-db.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { HasFailed } from 'picsur-shared/dist/types';
import { EarlyConfigModule } from '../../config/early/early-config.module';
import { HostConfigService } from '../../config/early/host.config.service';
import { ERoleBackend } from '../../database/entities/role.entity';
import { ERoleBackend } from '../../database/entities/users/role.entity';
import {
ImmutableRolesList,
SystemRoleDefaults,
SystemRolesList,
SystemRolesList
} from '../../models/constants/roles.const';
import { RoleDbService } from './role-db.service';

Expand Down
6 changes: 3 additions & 3 deletions backend/src/collections/role-db/role-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
Fail,
FT,
HasFailed,
HasSuccess,
HasSuccess
} from 'picsur-shared/dist/types';
import { makeUnique } from 'picsur-shared/dist/util/unique';
import { In, Repository } from 'typeorm';
import { ERoleBackend } from '../../database/entities/role.entity';
import { ERoleBackend } from '../../database/entities/users/role.entity';
import { Permissions } from '../../models/constants/permissions.const';
import {
ImmutableRolesList,
UndeletableRolesList,
UndeletableRolesList
} from '../../models/constants/roles.const';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ESystemStateBackend } from '../../database/entities/system-state.entity';
import { ESystemStateBackend } from '../../database/entities/system/system-state.entity';
import { SystemStateDbService } from './system-state-db.service';

@Module({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { AsyncFailable, Fail, FT } from 'picsur-shared/dist/types';
import { Repository } from 'typeorm';
import { ESystemStateBackend } from '../../database/entities/system-state.entity';
import { ESystemStateBackend } from '../../database/entities/system/system-state.entity';

@Injectable()
export class SystemStateDbService {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/collections/user-db/user-db.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HasFailed } from 'picsur-shared/dist/types';
import { generateRandomString } from 'picsur-shared/dist/util/random';
import { AuthConfigService } from '../../config/early/auth.config.service';
import { EarlyConfigModule } from '../../config/early/early-config.module';
import { EUserBackend } from '../../database/entities/user.entity';
import { EUserBackend } from '../../database/entities/users/user.entity';
import { PreferenceDbModule } from '../preference-db/preference-db.module';
import { RoleDbModule } from '../role-db/role-db.module';
import { UserDbService } from './user-db.service';
Expand Down
8 changes: 4 additions & 4 deletions backend/src/collections/user-db/user-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import {
Fail,
FT,
HasFailed,
HasSuccess,
HasSuccess
} from 'picsur-shared/dist/types';
import { FindResult } from 'picsur-shared/dist/types/find-result';
import { makeUnique } from 'picsur-shared/dist/util/unique';
import { Repository } from 'typeorm';
import { EUserBackend } from '../../database/entities/user.entity';
import { EUserBackend } from '../../database/entities/users/user.entity';
import { Permissions } from '../../models/constants/permissions.const';
import {
DefaultRolesList,
SoulBoundRolesList,
SoulBoundRolesList
} from '../../models/constants/roles.const';
import {
ImmutableUsersList,
LockedLoginUsersList,
UndeletableUsersList,
UndeletableUsersList
} from '../../models/constants/special-users.const';
import { GetCols } from '../../util/collection';
import { SysPreferenceDbService } from '../preference-db/sys-preference-db.service';
Expand Down
4 changes: 2 additions & 2 deletions backend/src/database/entities/apikey.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
Entity,
Index,
ManyToOne,
PrimaryGeneratedColumn,
PrimaryGeneratedColumn
} from 'typeorm';
import { z } from 'zod';
import { EUserBackend } from './user.entity';
import { EUserBackend } from './users/user.entity';

const OverriddenEApiKeySchema = EApiKeySchema.omit({ user: true }).merge(
z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
Unique,
Unique
} from 'typeorm';
import { EImageBackend } from './image.entity';

Expand Down
16 changes: 8 additions & 8 deletions backend/src/database/entities/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { EApiKeyBackend } from './apikey.entity';
import { EImageDerivativeBackend } from './image-derivative.entity';
import { EImageFileBackend } from './image-file.entity';
import { EImageBackend } from './image.entity';
import { ERoleBackend } from './role.entity';
import { ESysPreferenceBackend } from './sys-preference.entity';
import { ESystemStateBackend } from './system-state.entity';
import { EUserBackend } from './user.entity';
import { EUsrPreferenceBackend } from './usr-preference.entity';
import { EImageDerivativeBackend } from './images/image-derivative.entity';
import { EImageFileBackend } from './images/image-file.entity';
import { EImageBackend } from './images/image.entity';
import { ESysPreferenceBackend } from './system/sys-preference.entity';
import { ESystemStateBackend } from './system/system-state.entity';
import { EUsrPreferenceBackend } from './system/usr-preference.entity';
import { ERoleBackend } from './users/role.entity';
import { EUserBackend } from './users/user.entity';

export const EntityList = [
EImageBackend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
Unique,
Unique
} from 'typeorm';
import z from 'zod';
import { EUserBackend } from './user.entity';
import { EUserBackend } from '../users/user.entity';

export const EUsrPreferenceSchema = z.object({
id: IsEntityID().optional(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ERole } from 'picsur-shared/dist/entities/role.entity';
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import type { Permissions } from '../../models/constants/permissions.const';
import type { Permissions } from '../../../models/constants/permissions.const';

@Entity()
export class ERoleBackend implements ERole {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
Entity,
Index,
OneToMany,
PrimaryGeneratedColumn,
PrimaryGeneratedColumn
} from 'typeorm';
import { z } from 'zod';
import { EApiKeyBackend } from './apikey.entity';
import { EUsrPreferenceBackend } from './usr-preference.entity';
import { EApiKeyBackend } from '../apikey.entity';
import { EUsrPreferenceBackend } from '../system/usr-preference.entity';

// Different data for public and private
const OverriddenEUserSchema = EUserSchema.omit({ hashedPassword: true }).merge(
Expand Down
2 changes: 1 addition & 1 deletion backend/src/managers/auth/guest.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { HasFailed } from 'picsur-shared/dist/types';
import { UserDbService } from '../../collections/user-db/user-db.service';
import { EUserBackend } from '../../database/entities/user.entity';
import { EUserBackend } from '../../database/entities/users/user.entity';

@Injectable()
export class GuestService {
Expand Down
12 changes: 5 additions & 7 deletions backend/src/managers/image/image.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import { ImageRequestParams } from 'picsur-shared/dist/dto/api/image.dto';
import { ImageEntryVariant } from 'picsur-shared/dist/dto/image-entry-variant.enum';
import {
AnimFileType,
FileType,
FileType2Mime,
ImageFileType,
Mime2FileType,
FileType, ImageFileType,
Mime2FileType
} 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';
Expand All @@ -20,9 +18,9 @@ import { ImageDBService } from '../../collections/image-db/image-db.service';
import { ImageFileDBService } from '../../collections/image-db/image-file-db.service';
import { SysPreferenceDbService } from '../../collections/preference-db/sys-preference-db.service';
import { UsrPreferenceDbService } from '../../collections/preference-db/usr-preference-db.service';
import { EImageDerivativeBackend } from '../../database/entities/image-derivative.entity';
import { EImageFileBackend } from '../../database/entities/image-file.entity';
import { EImageBackend } from '../../database/entities/image.entity';
import { EImageDerivativeBackend } from '../../database/entities/images/image-derivative.entity';
import { EImageFileBackend } from '../../database/entities/images/image-file.entity';
import { EImageBackend } from '../../database/entities/images/image.entity';
import { MutexFallBack } from '../../util/mutex-fallback';
import { ImageConverterService } from './image-converter.service';
import { ImageProcessorService } from './image-processor.service';
Expand Down
2 changes: 1 addition & 1 deletion backend/src/models/transformers/user.transformer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EUser } from 'picsur-shared/dist/entities/user.entity';
import { EUserBackend } from '../../database/entities/user.entity';
import { EUserBackend } from '../../database/entities/users/user.entity';

export function EUserBackend2EUser(eUser: EUserBackend): EUser {
if (eUser.hashed_password === undefined) return eUser as EUser;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/routes/images/images.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
merge,
Observable,
switchMap,
timer,
timer
} from 'rxjs';
import { ImageService } from 'src/app/services/api/image.service';
import { UserService } from 'src/app/services/api/user.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { ErrorService } from 'src/app/util/error-manager/error.service';
import { UtilService } from 'src/app/util/util.service';
import {
CustomizeDialogComponent,
CustomizeDialogData,
CustomizeDialogData
} from '../customize-dialog/customize-dialog.component';
import {
EditDialogComponent,
EditDialogData,
EditDialogData
} from '../edit-dialog/edit-dialog.component';

@Component({
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/routes/view/view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {
ChangeDetectorRef,
Component,
OnDestroy,
OnInit,
OnInit
} from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ImageMetaResponse } from 'picsur-shared/dist/dto/api/image.dto';
import { ImageLinks } from 'picsur-shared/dist/dto/image-links.class';
import {
AnimFileType,
ImageFileType,
SupportedFileTypeCategory,
SupportedFileTypeCategory
} from 'picsur-shared/dist/dto/mimes.dto';
import { EImage } from 'picsur-shared/dist/entities/image.entity';
import { EUser } from 'picsur-shared/dist/entities/user.entity';
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/services/api/image.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
ImageListResponse,
ImageUpdateRequest,
ImageUpdateResponse,
ImageUploadResponse,
ImageUploadResponse
} from 'picsur-shared/dist/dto/api/image-manage.dto';
import {
ImageMetaResponse,
ImageRequestParams,
ImageRequestParams
} from 'picsur-shared/dist/dto/api/image.dto';
import { ImageLinks } from 'picsur-shared/dist/dto/image-links.class';
import { FileType2Ext } from 'picsur-shared/dist/dto/mimes.dto';
Expand All @@ -21,7 +21,7 @@ import {
FT,
HasFailed,
HasSuccess,
Open,
Open
} from 'picsur-shared/dist/types/failable';
import { ImageUploadRequest } from '../../models/dto/image-upload-request.dto';
import { ApiService } from './api.service';
Expand Down

0 comments on commit 844d11b

Please sign in to comment.