161 lines
3.3 KiB
TypeScript
161 lines
3.3 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional, PartialType } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
import {
|
|
IsBoolean,
|
|
IsDateString,
|
|
IsEnum,
|
|
IsNumber,
|
|
IsObject,
|
|
IsOptional,
|
|
IsString,
|
|
MaxLength,
|
|
MinLength,
|
|
ValidateNested,
|
|
} from 'class-validator';
|
|
import { ItemType } from 'src/objects/storage/enums/item-type.enum';
|
|
import { TransactionType } from 'src/objects/storage/enums/transaction-type.enum';
|
|
|
|
export class StorageItemRequestDto {
|
|
@ApiProperty()
|
|
@IsString()
|
|
@MinLength(3)
|
|
@MaxLength(32)
|
|
displayName: string;
|
|
|
|
@ApiProperty({ type: String, enum: ItemType })
|
|
@IsEnum(ItemType)
|
|
type: ItemType;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsString()
|
|
@IsOptional()
|
|
barcode?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsString()
|
|
@IsOptional()
|
|
sku?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsBoolean()
|
|
@IsOptional()
|
|
consumable?: boolean;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsString()
|
|
@IsOptional()
|
|
image?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsNumber()
|
|
@IsOptional()
|
|
weight?: number;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsString()
|
|
@IsOptional()
|
|
url?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsString()
|
|
@IsOptional()
|
|
notes?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsBoolean()
|
|
@IsOptional()
|
|
public?: boolean;
|
|
}
|
|
|
|
export class StorageItemUpdateRequestDto extends PartialType(
|
|
StorageItemRequestDto,
|
|
) {}
|
|
|
|
export class StorageStoredItemRequestDto {
|
|
@ApiProperty()
|
|
@IsString()
|
|
@IsOptional()
|
|
notes?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsDateString()
|
|
@IsOptional()
|
|
expiresAt?: Date;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsDateString()
|
|
@IsOptional()
|
|
acquiredAt?: Date;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsDateString()
|
|
@IsOptional()
|
|
consumedAt?: Date;
|
|
}
|
|
|
|
export class StorageStoredItemUpdateRequestDto extends PartialType(
|
|
StorageStoredItemRequestDto,
|
|
) {}
|
|
|
|
export class StorageStoredItemTransactionRequestDto {
|
|
@ApiProperty({ type: String, enum: TransactionType })
|
|
@IsEnum(TransactionType)
|
|
type: TransactionType;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsNumber()
|
|
@IsOptional()
|
|
price?: number;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsString()
|
|
@MaxLength(3)
|
|
@MinLength(3)
|
|
@IsOptional()
|
|
currency?: string;
|
|
|
|
@ApiProperty()
|
|
@IsString()
|
|
@IsOptional()
|
|
notes?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsDateString()
|
|
@IsOptional()
|
|
actionAt?: Date;
|
|
}
|
|
|
|
export class StorageStoredItemTransactionUpdateRequestDto extends PartialType(
|
|
StorageStoredItemTransactionRequestDto,
|
|
) {}
|
|
|
|
export class StorageAddExistingItemRequestDto {
|
|
@ApiPropertyOptional({ type: StorageStoredItemRequestDto })
|
|
@Type(() => StorageStoredItemRequestDto)
|
|
@IsObject()
|
|
@IsOptional()
|
|
@ValidateNested()
|
|
additionalInfo: StorageStoredItemRequestDto;
|
|
|
|
@ApiProperty({ type: StorageStoredItemTransactionRequestDto })
|
|
@Type(() => StorageStoredItemTransactionRequestDto)
|
|
@IsObject()
|
|
@ValidateNested()
|
|
transactionInfo: StorageStoredItemTransactionRequestDto;
|
|
}
|
|
|
|
export class StorageAddItemRequestDto extends StorageItemRequestDto {
|
|
@ApiPropertyOptional({ type: StorageStoredItemRequestDto })
|
|
@Type(() => StorageStoredItemRequestDto)
|
|
@IsObject()
|
|
@IsOptional()
|
|
@ValidateNested()
|
|
additionalInfo: StorageStoredItemRequestDto;
|
|
|
|
@ApiProperty({ type: StorageStoredItemTransactionRequestDto })
|
|
@Type(() => StorageStoredItemTransactionRequestDto)
|
|
@IsObject()
|
|
@ValidateNested()
|
|
transactionInfo: StorageStoredItemTransactionRequestDto;
|
|
}
|