class-transformer#Exclude TypeScript Examples

The following examples show how to use class-transformer#Exclude. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.resourceId != null) {
            identifier[this.IDENTIFIER_KEY_RESOURCEID] = this.resourceId;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #2
Source File: interface.ts    From cloudformation-cli-typescript-plugin with Apache License 2.0 6 votes vote down vote up
@Exclude()
    public serialize(removeNull = true): Dict {
        const data: Dict = JSON.parse(JSON.stringify(classToPlain(this)));
        // To match Java serialization, which drops 'null' values, and the
        // contract tests currently expect this also.
        if (removeNull) {
            for (const key in data) {
                const value = data[key];
                if (value == null) {
                    delete data[key];
                }
            }
        }
        return data;
    }
Example #3
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.resourceId != null) {
            identifier[this.IDENTIFIER_KEY_RESOURCEID] = this.resourceId;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #4
Source File: interface.ts    From cloudformation-cli-typescript-plugin with Apache License 2.0 6 votes vote down vote up
@Exclude()
    public static getPartition(region: Optional<string>): Optional<string> {
        if (!region) {
            return null;
        }
        if (region.startsWith('cn')) {
            return 'aws-cn';
        }
        if (region.startsWith('us-gov')) {
            return 'aws-gov';
        }
        return 'aws';
    }
Example #5
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.arn != null) {
            identifier[this.IDENTIFIER_KEY_ARN] = this.arn;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #6
Source File: proxy.ts    From cloudformation-cli-typescript-plugin with Apache License 2.0 6 votes vote down vote up
/**
     * Convenience method for constructing FAILED response
     */
    @Exclude()
    public static failed<T extends ProgressEvent>(
        errorCode: HandlerErrorCode,
        message: string
    ): T {
        const event = ProgressEvent.builder<T>()
            .status(OperationStatus.Failed)
            .errorCode(errorCode)
            .message(message)
            .build();
        return event;
    }
Example #7
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.resourceId != null) {
            identifier[this.IDENTIFIER_KEY_RESOURCEID] = this.resourceId;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #8
Source File: category.dto.ts    From codeclannigeria-backend with MIT License 6 votes vote down vote up
@Exclude()
export class CategoryDto extends BaseDto {
  @MaxLength(columnSize.length32)
  @Expose()
  name: string;
  @MaxLength(columnSize.length128)
  @Expose()
  description: string;
}
Example #9
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.resourceId != null) {
            identifier[this.IDENTIFIER_KEY_RESOURCEID] = this.resourceId;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #10
Source File: task.dto.ts    From codeclannigeria-backend with MIT License 6 votes vote down vote up
@Exclude()
export class TaskDto extends BaseDto {
  @MaxLength(columnSize.length256)
  @IsNotEmpty()
  @Expose()
  title: string;
  // @MaxLength(columnSize.length1024)
  @Expose()
  @IsNotEmpty()
  description: string;
  @IsMongoId()
  @Expose()
  track: string;
  @IsMongoId()
  @Expose()
  stage: string;
  @IsMongoId()
  @Expose()
  // @IsOptional()
  course: string;
  @Expose()
  @IsDate()
  @MinDate(new Date(), { message: 'Date must be in future' })
  @IsOptional()
  @ApiProperty({ type: Date })
  @Type(() => Date)
  deadline?: Date;
}
Example #11
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.resourceId != null) {
            identifier[this.IDENTIFIER_KEY_RESOURCEID] = this.resourceId;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #12
Source File: userstage.dto.ts    From codeclannigeria-backend with MIT License 6 votes vote down vote up
@Exclude()
export class UserStageDto extends BaseDto {
  @MaxLength(columnSize.length32)
  @IsNotEmpty()
  @Expose()
  taskRemaining: number;
  @MaxLength(columnSize.length128)
  @Expose()
  isCompleted: boolean;
  @ApiProperty({ readOnly: true, type: StageDto })
  @Expose()
  @Type(() => StageDto)
  readonly stage: StageDto;
}
Example #13
Source File: GetUserAdapter.ts    From typescript-clean-architecture with MIT License 6 votes vote down vote up
@Exclude()
export class GetUserAdapter extends UseCaseValidatableAdapter implements GetUserPort {
  
  @Expose()
  @IsUUID()
  public userId: string;
  
  public static async new(payload: GetUserPort): Promise<GetUserAdapter> {
    const adapter: GetUserAdapter = plainToClass(GetUserAdapter, payload);
    await adapter.validate();
    
    return adapter;
  }
  
}
Example #14
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.arn != null) {
            identifier[this.IDENTIFIER_KEY_ARN] = this.arn;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #15
Source File: MediaUseCaseDto.ts    From typescript-clean-architecture with MIT License 6 votes vote down vote up
@Exclude()
export class MediaUseCaseDto {

  @Expose()
  public id: string;
  
  @Expose()
  public ownerId: string;
  
  @Expose()
  public name: string;
  
  @Expose()
  public type: MediaType;
  
  public url: string;
  
  public createdAt: number;
  
  public editedAt: Nullable<number>;
  
  public static newFromMedia(media: Media): MediaUseCaseDto {
    const dto: MediaUseCaseDto = plainToClass(MediaUseCaseDto, media);
    
    dto.url = media.getMetadata().relativePath;
    dto.createdAt = media.getCreatedAt().getTime();
    dto.editedAt = media.getEditedAt()?.getTime() || null;
    
    return dto;
  }
  
  public static newListFromMedias(medias: Media[]): MediaUseCaseDto[] {
    return medias.map(media => this.newFromMedia(media));
  }
  
}
Example #16
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.arn != null) {
            identifier[this.IDENTIFIER_KEY_ARN] = this.arn;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #17
Source File: calendar.dto.ts    From life-helper-backend with MIT License 6 votes vote down vote up
@Exclude()
export class CreateProjectResponseDto {
  @Expose()
  id: number

  @IsString()
  @IsNotEmpty()
  name: string
}
Example #18
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getIdentifier_Id(): Dict {
        const identifier: Dict = {};
        if ((this as any).id != null) {
            identifier[this.IDENTIFIER_KEY_ID] = (this as any).id;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #19
Source File: weather-city.dto.ts    From life-helper-backend with MIT License 6 votes vote down vote up
/**
 * 新增天气城市响应数据
 */
@Exclude()
export class AddResponseDto extends WeatherCity {
  /** 主键 ID */
  @Expose()
  id: number
}
Example #20
Source File: models.ts    From aws-resource-providers with MIT License 6 votes vote down vote up
@Exclude()
    public getPrimaryIdentifier(): Dict {
        const identifier: Dict = {};
        if (this.resourceId != null) {
            identifier[this.IDENTIFIER_KEY_RESOURCEID] = this.resourceId;
        }

        // only return the identifier if it can be used, i.e. if all components are present
        return Object.keys(identifier).length === 1 ? identifier : null;
    }
Example #21
Source File: course.entity.ts    From office-hours with GNU General Public License v3.0 5 votes vote down vote up
@ManyToOne((type) => SemesterModel, (semester) => semester.courses)
  @JoinColumn({ name: 'semesterId' })
  @Exclude()
  semester: SemesterModel;
Example #22
Source File: models.ts    From aws-resource-providers with MIT License 5 votes vote down vote up
@Exclude()
    protected readonly IDENTIFIER_KEY_RESOURCEID: string = '/properties/ResourceId';