@companix/xeo-server 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/.eslintrc +0 -54
- package/jest.cases.config.cjs +0 -14
- package/lib/common/decorators.ts +0 -17
- package/lib/common/index.ts +0 -3
- package/lib/common/tokens.ts +0 -17
- package/lib/common/utils.ts +0 -29
- package/lib/constants.ts +0 -4
- package/lib/driver.module.ts +0 -37
- package/lib/drivers/collection.driver.ts +0 -157
- package/lib/drivers/table.driver.ts +0 -109
- package/lib/factories/definitions.factory.ts +0 -129
- package/lib/index.ts +0 -3
- package/lib/mongoose-options.interface.ts +0 -19
- package/lib/mongoose.module.ts +0 -95
- package/lib/storages/data-source.ts +0 -37
- package/tests/app/bootstrap.ts +0 -16
- package/tests/app/db.ts +0 -22
- package/tests/app/filters.ts +0 -25
- package/tests/app/helpers/is-one-of.ts +0 -58
- package/tests/app/main.ts +0 -3
- package/tests/app/module/app.controller.ts +0 -67
- package/tests/app/module/app.dto.ts +0 -394
- package/tests/app/module/app.module.ts +0 -12
- package/tests/app/module/app.service.ts +0 -76
- package/tests/app/root.module.ts +0 -12
- package/tests/globals.d.ts +0 -6
- package/tests/integrations/cases.test.ts +0 -154
- package/tests/integrations/custom.test.ts +0 -69
- package/tests/unit/definitions.test.ts +0 -31
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -17
- package/tsconfig.test-app.json +0 -10
package/lib/mongoose.module.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as mongoose from 'mongoose'
|
|
2
|
-
import { DynamicModule, Global, Inject, Module, OnApplicationShutdown } from '@nestjs/common'
|
|
3
|
-
import { ModuleRef } from '@nestjs/core'
|
|
4
|
-
import { ConnectOptions, Connection } from 'mongoose'
|
|
5
|
-
import { defer, lastValueFrom } from 'rxjs'
|
|
6
|
-
import { catchError } from 'rxjs/operators'
|
|
7
|
-
import { MONGOOSE_CONNECTION_NAME } from './constants'
|
|
8
|
-
import { getConnectionToken, handleRetry } from './common'
|
|
9
|
-
import { MongooseModuleOptions } from './mongoose-options.interface'
|
|
10
|
-
|
|
11
|
-
@Global()
|
|
12
|
-
@Module({})
|
|
13
|
-
export class MongooseCoreModule implements OnApplicationShutdown {
|
|
14
|
-
constructor(
|
|
15
|
-
@Inject(MONGOOSE_CONNECTION_NAME) private readonly connectionName: string,
|
|
16
|
-
private readonly moduleRef: ModuleRef
|
|
17
|
-
) {}
|
|
18
|
-
|
|
19
|
-
static forRoot(uri: string, options: MongooseModuleOptions = {}): DynamicModule {
|
|
20
|
-
const {
|
|
21
|
-
retryAttempts,
|
|
22
|
-
retryDelay,
|
|
23
|
-
connectionName,
|
|
24
|
-
connectionFactory,
|
|
25
|
-
connectionErrorFactory,
|
|
26
|
-
lazyConnection,
|
|
27
|
-
onConnectionCreate,
|
|
28
|
-
verboseRetryLog,
|
|
29
|
-
...mongooseOptions
|
|
30
|
-
} = options
|
|
31
|
-
|
|
32
|
-
const mongooseConnectionFactory = connectionFactory || ((connection) => connection)
|
|
33
|
-
|
|
34
|
-
const mongooseConnectionError = connectionErrorFactory || ((error) => error)
|
|
35
|
-
|
|
36
|
-
const mongooseConnectionName = getConnectionToken(connectionName)
|
|
37
|
-
|
|
38
|
-
const mongooseConnectionNameProvider = {
|
|
39
|
-
provide: MONGOOSE_CONNECTION_NAME,
|
|
40
|
-
useValue: mongooseConnectionName
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const connectionProvider = {
|
|
44
|
-
provide: mongooseConnectionName,
|
|
45
|
-
useFactory: async (): Promise<any> =>
|
|
46
|
-
await lastValueFrom(
|
|
47
|
-
defer(async () =>
|
|
48
|
-
mongooseConnectionFactory(
|
|
49
|
-
await this.createMongooseConnection(uri, mongooseOptions, {
|
|
50
|
-
lazyConnection,
|
|
51
|
-
onConnectionCreate
|
|
52
|
-
}),
|
|
53
|
-
mongooseConnectionName
|
|
54
|
-
)
|
|
55
|
-
).pipe(
|
|
56
|
-
handleRetry(retryAttempts, retryDelay, verboseRetryLog),
|
|
57
|
-
catchError((error) => {
|
|
58
|
-
throw mongooseConnectionError(error)
|
|
59
|
-
})
|
|
60
|
-
)
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
module: MongooseCoreModule,
|
|
65
|
-
providers: [connectionProvider, mongooseConnectionNameProvider],
|
|
66
|
-
exports: [connectionProvider]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private static async createMongooseConnection(
|
|
71
|
-
uri: string,
|
|
72
|
-
mongooseOptions: ConnectOptions,
|
|
73
|
-
factoryOptions: {
|
|
74
|
-
lazyConnection?: boolean
|
|
75
|
-
onConnectionCreate?: MongooseModuleOptions['onConnectionCreate']
|
|
76
|
-
}
|
|
77
|
-
): Promise<Connection> {
|
|
78
|
-
const connection = mongoose.createConnection(uri, mongooseOptions)
|
|
79
|
-
|
|
80
|
-
if (factoryOptions?.lazyConnection) {
|
|
81
|
-
return connection
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
factoryOptions?.onConnectionCreate?.(connection)
|
|
85
|
-
|
|
86
|
-
return connection.asPromise()
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async onApplicationShutdown() {
|
|
90
|
-
const connection = this.moduleRef.get<any>(this.connectionName)
|
|
91
|
-
if (connection) {
|
|
92
|
-
await connection.close()
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { CollectionScheme, DataScheme, DataSource } from '@companix/xeo-scheme'
|
|
2
|
-
import { Connection } from 'mongoose'
|
|
3
|
-
import { createMongoDriver } from '../drivers/collection.driver'
|
|
4
|
-
import { DATA_SOURCE_TOKEN } from '../constants'
|
|
5
|
-
|
|
6
|
-
class DataSourceStorageService {
|
|
7
|
-
private dataSource: DataSource<CollectionScheme> | null = null
|
|
8
|
-
private dataScheme: DataScheme<CollectionScheme> | null = null
|
|
9
|
-
|
|
10
|
-
getProviderToken(dataScheme: DataScheme<CollectionScheme>) {
|
|
11
|
-
if (this.dataScheme === null) {
|
|
12
|
-
this.dataScheme = dataScheme
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (this.dataScheme !== dataScheme) {
|
|
16
|
-
throw new Error(`[MongoDriver] driver cannot work with several dataSchemes`)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return DATA_SOURCE_TOKEN
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getSource(dataScheme: DataScheme<CollectionScheme>, connection: Connection) {
|
|
23
|
-
if (this.dataScheme !== dataScheme) {
|
|
24
|
-
throw new Error(`[MongoDriver] driver cannot work with several dataSchemes`)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (!this.dataSource) {
|
|
28
|
-
this.dataSource = new DataSource(dataScheme, {
|
|
29
|
-
createDriver: createMongoDriver(connection)
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return this.dataSource
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const DataSourceStorage = new DataSourceStorageService()
|
package/tests/app/bootstrap.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NestFactory } from '@nestjs/core'
|
|
2
|
-
import { RootModule } from './root.module'
|
|
3
|
-
import { ValidationPipe } from '@nestjs/common'
|
|
4
|
-
import { AllExceptionsFilter } from './filters'
|
|
5
|
-
|
|
6
|
-
export const bootstrap = async (port = 3111) => {
|
|
7
|
-
const app = await NestFactory.create(RootModule)
|
|
8
|
-
|
|
9
|
-
app.useGlobalFilters(new AllExceptionsFilter())
|
|
10
|
-
app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true }))
|
|
11
|
-
|
|
12
|
-
await app.listen(port)
|
|
13
|
-
console.log(`Application is running on: http://localhost:${port}/app`)
|
|
14
|
-
|
|
15
|
-
return app
|
|
16
|
-
}
|
package/tests/app/db.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { MongooseModuleOptions } from '../../lib/mongoose-options.interface'
|
|
2
|
-
|
|
3
|
-
const DB_NAME = 'xeo-test'
|
|
4
|
-
const DB_PORT = 27017
|
|
5
|
-
const DB_AUTH = 'admin'
|
|
6
|
-
const DB_PASS = 'example'
|
|
7
|
-
const DB_HOST = '127.0.0.1'
|
|
8
|
-
const DB_CERT = ''
|
|
9
|
-
const DB_USER = 'root'
|
|
10
|
-
|
|
11
|
-
export const getMongoConnectionURL = (): string => {
|
|
12
|
-
return `mongodb://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/`
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const getMongoConnectionOptions = (): MongooseModuleOptions => {
|
|
16
|
-
return {
|
|
17
|
-
tls: DB_CERT ? true : false,
|
|
18
|
-
tlsCAFile: DB_CERT,
|
|
19
|
-
dbName: DB_NAME,
|
|
20
|
-
authSource: DB_AUTH
|
|
21
|
-
}
|
|
22
|
-
}
|
package/tests/app/filters.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { CoreError } from '@companix/xeo-scheme'
|
|
2
|
-
import { ExceptionFilter, Catch, ArgumentsHost, HttpException, HttpStatus } from '@nestjs/common'
|
|
3
|
-
|
|
4
|
-
@Catch()
|
|
5
|
-
export class AllExceptionsFilter implements ExceptionFilter {
|
|
6
|
-
catch(exception: any, host: ArgumentsHost) {
|
|
7
|
-
const ctx = host.switchToHttp()
|
|
8
|
-
const response = ctx.getResponse()
|
|
9
|
-
|
|
10
|
-
// core conflicts
|
|
11
|
-
if (exception instanceof CoreError) {
|
|
12
|
-
console.log('core exception:', exception)
|
|
13
|
-
response.status(HttpStatus.BAD_REQUEST).json(exception)
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// internal server errors
|
|
18
|
-
if (exception instanceof HttpException) {
|
|
19
|
-
response.status(exception.getStatus()).json(exception.getResponse())
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
response.status(HttpStatus.INTERNAL_SERVER_ERROR).json(exception?.response)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { plainToInstance } from 'class-transformer'
|
|
2
|
-
import {
|
|
3
|
-
ValidatorConstraint,
|
|
4
|
-
ValidatorConstraintInterface,
|
|
5
|
-
ValidationArguments,
|
|
6
|
-
validate,
|
|
7
|
-
ValidationOptions,
|
|
8
|
-
registerDecorator
|
|
9
|
-
} from 'class-validator'
|
|
10
|
-
|
|
11
|
-
@ValidatorConstraint({ async: true })
|
|
12
|
-
export class IsOneOfDtoConstraint implements ValidatorConstraintInterface {
|
|
13
|
-
async validate(value: any, args: ValidationArguments) {
|
|
14
|
-
const [dtos, discriptor] = args.constraints as [any[], string]
|
|
15
|
-
|
|
16
|
-
if (!value) {
|
|
17
|
-
return false
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const dto = dtos.find((some) => {
|
|
21
|
-
const classDescriptor = new some()[discriptor]
|
|
22
|
-
|
|
23
|
-
if (classDescriptor) {
|
|
24
|
-
return classDescriptor === value[discriptor]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
console.warn('WARN: Set descriptor value to:', some)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
if (dto) {
|
|
31
|
-
const errors = await validate(plainToInstance(dto, value))
|
|
32
|
-
|
|
33
|
-
if (errors.length === 0) {
|
|
34
|
-
return true
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.error('ERRORs: ', dto, errors)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
defaultMessage(args: ValidationArguments) {
|
|
44
|
-
return 'Data does not match'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function IsOneOf(dtos: [Function[], string], validationOptions?: ValidationOptions) {
|
|
49
|
-
return function (object: Object, propertyName: string) {
|
|
50
|
-
registerDecorator({
|
|
51
|
-
target: object.constructor,
|
|
52
|
-
propertyName: propertyName,
|
|
53
|
-
options: validationOptions,
|
|
54
|
-
constraints: dtos,
|
|
55
|
-
validator: IsOneOfDtoConstraint
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
}
|
package/tests/app/main.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Body, Controller, Get, Post } from '@nestjs/common'
|
|
2
|
-
import {
|
|
3
|
-
CreateBankCardDto,
|
|
4
|
-
CreateBankDetailDto,
|
|
5
|
-
CreateDictionaryDto,
|
|
6
|
-
CreateOptionDto,
|
|
7
|
-
CreateRoleDto,
|
|
8
|
-
CreateScanDto,
|
|
9
|
-
CreateWorkerDto,
|
|
10
|
-
UpdateOptionDto
|
|
11
|
-
} from './app.dto'
|
|
12
|
-
import { AppService } from './app.service'
|
|
13
|
-
|
|
14
|
-
@Controller('app')
|
|
15
|
-
export class AppController {
|
|
16
|
-
constructor(private readonly appService: AppService) {}
|
|
17
|
-
|
|
18
|
-
@Post('addWorker')
|
|
19
|
-
async addWorker(@Body() dto: CreateWorkerDto) {
|
|
20
|
-
return this.appService.addWorker(dto)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Post('addScan')
|
|
24
|
-
async addScan(@Body() dto: CreateScanDto) {
|
|
25
|
-
return this.appService.addScan(dto)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Post('addBankCard')
|
|
29
|
-
async addBankCard(@Body() dto: CreateBankCardDto) {
|
|
30
|
-
return this.appService.addBankCard(dto)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@Post('addBankDetail')
|
|
34
|
-
async addBankDetail(@Body() dto: CreateBankDetailDto) {
|
|
35
|
-
return this.appService.addBankDetail(dto)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@Post('addRole')
|
|
39
|
-
async addRole(@Body() dto: CreateRoleDto) {
|
|
40
|
-
return this.appService.addRole(dto)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@Post('addDictionary')
|
|
44
|
-
async addDictionary(@Body() dto: CreateDictionaryDto) {
|
|
45
|
-
return this.appService.addDictionary(dto)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@Post('addOption')
|
|
49
|
-
async addOption(@Body() dto: CreateOptionDto) {
|
|
50
|
-
return this.appService.addOption(dto)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@Post('updateOption')
|
|
54
|
-
async updateOption(@Body() dto: UpdateOptionDto) {
|
|
55
|
-
return this.appService.updateOption(dto)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@Get()
|
|
59
|
-
async getState() {
|
|
60
|
-
return this.appService.getState()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@Get('tables')
|
|
64
|
-
async getTables() {
|
|
65
|
-
return this.appService.getTables()
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
import { Type } from 'class-transformer'
|
|
2
|
-
import {
|
|
3
|
-
IsArray,
|
|
4
|
-
IsBoolean,
|
|
5
|
-
IsEmail,
|
|
6
|
-
IsIn,
|
|
7
|
-
IsNotEmptyObject,
|
|
8
|
-
IsNumber,
|
|
9
|
-
IsObject,
|
|
10
|
-
IsString,
|
|
11
|
-
ValidateIf,
|
|
12
|
-
ValidateNested
|
|
13
|
-
} from 'class-validator'
|
|
14
|
-
import type { DateFormat, FileFormat } from '@companix/utils-js'
|
|
15
|
-
import { WorkerEntities, DictionaryEntities, RoleEntities, AppKey, AppKeys } from '@companix/xeo-devkit'
|
|
16
|
-
|
|
17
|
-
export class DateFormatDto implements DateFormat {
|
|
18
|
-
@IsNumber()
|
|
19
|
-
year: number
|
|
20
|
-
|
|
21
|
-
@IsNumber()
|
|
22
|
-
month: number
|
|
23
|
-
|
|
24
|
-
@IsNumber()
|
|
25
|
-
day: number
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class FilmDto implements WorkerEntities.Film {
|
|
29
|
-
@IsString()
|
|
30
|
-
anime: string
|
|
31
|
-
|
|
32
|
-
@IsBoolean()
|
|
33
|
-
isTheater: boolean
|
|
34
|
-
|
|
35
|
-
@IsArray()
|
|
36
|
-
@IsString({ each: true })
|
|
37
|
-
actors: string[]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class ContactsDto implements WorkerEntities.Contacts {
|
|
41
|
-
@IsString()
|
|
42
|
-
phone_base: string
|
|
43
|
-
|
|
44
|
-
@IsBoolean()
|
|
45
|
-
phone_base_verified: boolean
|
|
46
|
-
|
|
47
|
-
@IsString()
|
|
48
|
-
phone_extra: string
|
|
49
|
-
|
|
50
|
-
@IsBoolean()
|
|
51
|
-
phone_extra_verified: boolean
|
|
52
|
-
|
|
53
|
-
@IsString()
|
|
54
|
-
whatsapp_phone: string
|
|
55
|
-
|
|
56
|
-
@IsBoolean()
|
|
57
|
-
whatsapp_verified: boolean
|
|
58
|
-
|
|
59
|
-
@IsString()
|
|
60
|
-
viber_phone: string
|
|
61
|
-
|
|
62
|
-
@IsBoolean()
|
|
63
|
-
viber_verified: boolean
|
|
64
|
-
|
|
65
|
-
@IsString()
|
|
66
|
-
telegram_nickname: string
|
|
67
|
-
|
|
68
|
-
@IsString()
|
|
69
|
-
telegram_phone: string
|
|
70
|
-
|
|
71
|
-
@IsBoolean()
|
|
72
|
-
telegram_phone_verified: boolean
|
|
73
|
-
|
|
74
|
-
@ValidateNested()
|
|
75
|
-
@Type(() => FilmDto)
|
|
76
|
-
film: FilmDto
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export class AboutDto implements WorkerEntities.About {
|
|
80
|
-
@ValidateIf((_, value) => value !== null)
|
|
81
|
-
@IsNumber()
|
|
82
|
-
height: number | null
|
|
83
|
-
|
|
84
|
-
@IsString()
|
|
85
|
-
shoe_size: string
|
|
86
|
-
|
|
87
|
-
@IsString()
|
|
88
|
-
clothing_size: string
|
|
89
|
-
|
|
90
|
-
@IsArray()
|
|
91
|
-
@IsString({ each: true })
|
|
92
|
-
regions: string[]
|
|
93
|
-
|
|
94
|
-
@IsArray()
|
|
95
|
-
@IsString({ each: true })
|
|
96
|
-
kind_of_work: string[]
|
|
97
|
-
|
|
98
|
-
@IsArray()
|
|
99
|
-
@IsString({ each: true })
|
|
100
|
-
employments: string[]
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export class DocumentsDto implements WorkerEntities.Documents {
|
|
104
|
-
@ValidateIf((_, value) => value !== null)
|
|
105
|
-
@IsIn(AppKeys.Citizenship)
|
|
106
|
-
citizenship: AppKey.Citizenship | null
|
|
107
|
-
|
|
108
|
-
@IsString()
|
|
109
|
-
passport_number: string
|
|
110
|
-
|
|
111
|
-
@IsString()
|
|
112
|
-
passport_serial: string
|
|
113
|
-
|
|
114
|
-
@IsString()
|
|
115
|
-
passport_issued_by: string
|
|
116
|
-
|
|
117
|
-
@ValidateIf((_, value) => value !== null)
|
|
118
|
-
@ValidateNested()
|
|
119
|
-
@Type(() => DateFormatDto)
|
|
120
|
-
passport_issued_date: DateFormat | null
|
|
121
|
-
|
|
122
|
-
@IsString()
|
|
123
|
-
place_of_birth: string
|
|
124
|
-
|
|
125
|
-
@IsString()
|
|
126
|
-
registration_place: string
|
|
127
|
-
|
|
128
|
-
@IsString()
|
|
129
|
-
inn: string
|
|
130
|
-
|
|
131
|
-
@IsString()
|
|
132
|
-
snils: string
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export class WorkerBaseDto implements WorkerEntities.BaseWorker {
|
|
136
|
-
@IsNumber()
|
|
137
|
-
workerId: number
|
|
138
|
-
|
|
139
|
-
@IsIn(['office', 'revisor'])
|
|
140
|
-
type: 'office' | 'revisor'
|
|
141
|
-
|
|
142
|
-
@ValidateIf((_, value) => value !== null)
|
|
143
|
-
@IsNumber()
|
|
144
|
-
tgid: number | null
|
|
145
|
-
|
|
146
|
-
@IsNumber()
|
|
147
|
-
createdAt: number
|
|
148
|
-
|
|
149
|
-
@IsObject()
|
|
150
|
-
avatar: FileFormat
|
|
151
|
-
|
|
152
|
-
@IsString()
|
|
153
|
-
name: string
|
|
154
|
-
|
|
155
|
-
@IsString()
|
|
156
|
-
surname: string
|
|
157
|
-
|
|
158
|
-
@IsString()
|
|
159
|
-
patronymic: string
|
|
160
|
-
|
|
161
|
-
@IsEmail()
|
|
162
|
-
email: string
|
|
163
|
-
|
|
164
|
-
@IsIn(AppKeys.Sex)
|
|
165
|
-
sex: AppKey.Sex
|
|
166
|
-
|
|
167
|
-
@IsIn(AppKeys.WorkerStatus)
|
|
168
|
-
status: AppKey.WorkerStatus
|
|
169
|
-
|
|
170
|
-
@ValidateNested()
|
|
171
|
-
@Type(() => DateFormatDto)
|
|
172
|
-
date_birth: DateFormat
|
|
173
|
-
|
|
174
|
-
@ValidateNested()
|
|
175
|
-
@Type(() => DateFormatDto)
|
|
176
|
-
date_employ: DateFormat
|
|
177
|
-
|
|
178
|
-
@ValidateNested()
|
|
179
|
-
@Type(() => ContactsDto)
|
|
180
|
-
contacts: ContactsDto
|
|
181
|
-
|
|
182
|
-
@ValidateNested()
|
|
183
|
-
@Type(() => DocumentsDto)
|
|
184
|
-
documents: DocumentsDto
|
|
185
|
-
|
|
186
|
-
@ValidateNested()
|
|
187
|
-
@Type(() => AboutDto)
|
|
188
|
-
about: AboutDto
|
|
189
|
-
|
|
190
|
-
@IsArray()
|
|
191
|
-
@IsString({ each: true })
|
|
192
|
-
scans: string[]
|
|
193
|
-
|
|
194
|
-
@IsArray()
|
|
195
|
-
@IsString({ each: true })
|
|
196
|
-
bank_cards: string[]
|
|
197
|
-
|
|
198
|
-
@IsArray()
|
|
199
|
-
@IsString({ each: true })
|
|
200
|
-
bank_details: string[]
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export class OfficeProfileDto extends WorkerBaseDto implements WorkerEntities.OfficeProfile {
|
|
204
|
-
@IsIn(['office'])
|
|
205
|
-
type: 'office' = 'office'
|
|
206
|
-
|
|
207
|
-
@IsString()
|
|
208
|
-
password: string
|
|
209
|
-
|
|
210
|
-
@IsArray()
|
|
211
|
-
@IsString({ each: true })
|
|
212
|
-
roles: RoleEntities.Role['value'][]
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export class RevisorProfileDto extends WorkerBaseDto implements WorkerEntities.RevisorProfile {
|
|
216
|
-
@IsIn(['revisor'])
|
|
217
|
-
type: 'revisor' = 'revisor'
|
|
218
|
-
|
|
219
|
-
@IsString()
|
|
220
|
-
password: string
|
|
221
|
-
|
|
222
|
-
@IsIn(AppKeys.RevisorRoles)
|
|
223
|
-
revisor_role: AppKey.RevisorRoles
|
|
224
|
-
|
|
225
|
-
@IsIn(AppKeys.JobType)
|
|
226
|
-
job_type: AppKey.JobType
|
|
227
|
-
|
|
228
|
-
seats: string[]
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export class CreateWorkerDto {
|
|
232
|
-
@IsNotEmptyObject()
|
|
233
|
-
@ValidateNested()
|
|
234
|
-
@Type(() => WorkerBaseDto, {
|
|
235
|
-
discriminator: {
|
|
236
|
-
property: 'type',
|
|
237
|
-
subTypes: [
|
|
238
|
-
{ name: 'office', value: OfficeProfileDto },
|
|
239
|
-
{ name: 'revisor', value: RevisorProfileDto }
|
|
240
|
-
]
|
|
241
|
-
},
|
|
242
|
-
keepDiscriminatorProperty: true
|
|
243
|
-
})
|
|
244
|
-
worker: OfficeProfileDto | RevisorProfileDto
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export class ScanDto implements WorkerEntities.Scan {
|
|
248
|
-
@IsString()
|
|
249
|
-
scanId: string
|
|
250
|
-
|
|
251
|
-
@IsString()
|
|
252
|
-
name: string
|
|
253
|
-
|
|
254
|
-
@IsObject()
|
|
255
|
-
file: FileFormat
|
|
256
|
-
|
|
257
|
-
@IsNumber()
|
|
258
|
-
createdAt: number
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export class CreateScanDto {
|
|
262
|
-
@IsNotEmptyObject()
|
|
263
|
-
@ValidateNested()
|
|
264
|
-
@Type(() => ScanDto)
|
|
265
|
-
scan: ScanDto
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export class BankCardDto implements WorkerEntities.BankCard {
|
|
269
|
-
@IsString()
|
|
270
|
-
cardId: string
|
|
271
|
-
|
|
272
|
-
@IsString()
|
|
273
|
-
bank_name: string
|
|
274
|
-
|
|
275
|
-
@IsString()
|
|
276
|
-
bank_card_number: string
|
|
277
|
-
|
|
278
|
-
@IsString()
|
|
279
|
-
comment: string
|
|
280
|
-
|
|
281
|
-
@IsBoolean()
|
|
282
|
-
is_default_card: boolean
|
|
283
|
-
|
|
284
|
-
@IsObject()
|
|
285
|
-
image: FileFormat
|
|
286
|
-
|
|
287
|
-
@IsNumber()
|
|
288
|
-
createdAt: number
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export class CreateBankCardDto {
|
|
292
|
-
@IsNotEmptyObject()
|
|
293
|
-
@ValidateNested()
|
|
294
|
-
@Type(() => BankCardDto)
|
|
295
|
-
bankCard: BankCardDto
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
export class BankDetailDto implements WorkerEntities.BankDetail {
|
|
299
|
-
@IsString()
|
|
300
|
-
detailId: string
|
|
301
|
-
|
|
302
|
-
@IsString()
|
|
303
|
-
recipient_name: string
|
|
304
|
-
|
|
305
|
-
@IsString()
|
|
306
|
-
bank_name: string
|
|
307
|
-
|
|
308
|
-
@IsString()
|
|
309
|
-
recipient_count: string
|
|
310
|
-
|
|
311
|
-
@IsString()
|
|
312
|
-
kor: string
|
|
313
|
-
|
|
314
|
-
@IsString()
|
|
315
|
-
bik: string
|
|
316
|
-
|
|
317
|
-
@IsString()
|
|
318
|
-
kpp: string
|
|
319
|
-
|
|
320
|
-
@IsString()
|
|
321
|
-
inn: string
|
|
322
|
-
|
|
323
|
-
@IsNumber()
|
|
324
|
-
createdAt: number
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
export class CreateBankDetailDto {
|
|
328
|
-
@IsNotEmptyObject()
|
|
329
|
-
@ValidateNested()
|
|
330
|
-
@Type(() => BankDetailDto)
|
|
331
|
-
bankDetail: BankDetailDto
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
export class RoleDto implements RoleEntities.Role {
|
|
335
|
-
@IsString()
|
|
336
|
-
value: string
|
|
337
|
-
|
|
338
|
-
@IsString()
|
|
339
|
-
title: string
|
|
340
|
-
|
|
341
|
-
@IsNumber()
|
|
342
|
-
createdAt: number
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export class CreateRoleDto {
|
|
346
|
-
@IsNotEmptyObject()
|
|
347
|
-
@ValidateNested()
|
|
348
|
-
@Type(() => RoleDto)
|
|
349
|
-
role: RoleDto
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export class DictionaryDto implements DictionaryEntities.Dictionary {
|
|
353
|
-
@IsIn(AppKeys.Dictionaries)
|
|
354
|
-
dictionary: AppKey.Dictionaries
|
|
355
|
-
|
|
356
|
-
@IsString()
|
|
357
|
-
name: string
|
|
358
|
-
|
|
359
|
-
@IsArray()
|
|
360
|
-
@IsString({ each: true })
|
|
361
|
-
options: DictionaryEntities.Option['value'][]
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export class CreateDictionaryDto {
|
|
365
|
-
@IsNotEmptyObject()
|
|
366
|
-
@ValidateNested()
|
|
367
|
-
@Type(() => DictionaryDto)
|
|
368
|
-
dictionary: DictionaryDto
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export class OptionDto implements DictionaryEntities.Option {
|
|
372
|
-
@IsIn(AppKeys.Dictionaries)
|
|
373
|
-
dictionary: AppKey.Dictionaries
|
|
374
|
-
|
|
375
|
-
@IsString()
|
|
376
|
-
value: string
|
|
377
|
-
|
|
378
|
-
@IsString()
|
|
379
|
-
title: string
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export class CreateOptionDto {
|
|
383
|
-
@IsNotEmptyObject()
|
|
384
|
-
@ValidateNested()
|
|
385
|
-
@Type(() => OptionDto)
|
|
386
|
-
option: OptionDto
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
export class UpdateOptionDto {
|
|
390
|
-
@IsNotEmptyObject()
|
|
391
|
-
@ValidateNested()
|
|
392
|
-
@Type(() => OptionDto)
|
|
393
|
-
option: OptionDto
|
|
394
|
-
}
|