Skip to content

Commit

Permalink
Added support for shortening URL while creating connection
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna <[email protected]>
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
GHkrishna authored and KulkarniShashank committed Sep 11, 2024
1 parent ca108b1 commit a95fb4c
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 207 deletions.
230 changes: 120 additions & 110 deletions apps/api-gateway/src/utilities/dtos/store-object.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,59 @@ import { IsNotEmpty, IsOptional, IsString, IsUrl, ValidateNested } from 'class-v

// export type StoreObjectDto = InvitationDto;

class ServiceDto {
@ApiProperty({
example: 'service-id'
})
@IsString()
@IsNotEmpty({ message: 'please provide valid id' })
id: string;

@ApiProperty({
example: 'http://example.com'
})
@IsString()
@IsNotEmpty({ message: 'please provide valid serviceEndpoint' })
@IsUrl({}, { message: 'Invalid serviceEndpoint format' })
serviceEndpoint: string;
// class ServiceDto {
// @ApiProperty({
// example: 'service-id'
// })
// @IsString()
// @IsNotEmpty({ message: 'please provide valid id' })
// id: string;

// @ApiProperty({
// example: 'http://example.com'
// })
// @IsString()
// @IsNotEmpty({ message: 'please provide valid serviceEndpoint' })
// @IsUrl({}, { message: 'Invalid serviceEndpoint format' })
// serviceEndpoint: string;

// @ApiProperty({
// example: 'service-type'
// })
// @IsString()
// @IsNotEmpty({ message: 'please provide valid type' })
// type: string;

// @ApiProperty({
// example: ['key1', 'key2']
// })
// @IsString({ each: true })
// recipientKeys: string[];

// @ApiPropertyOptional({
// example: ['key1', 'key2']
// })
// @IsOptional()
// @IsString({ each: true })
// routingKeys: string[];

// @ApiPropertyOptional({
// example: ['true']
// })
// @IsOptional()
// @IsString({ each: true })
// accept: string[];
// }

export class LegacyInvitationDto {

@ApiProperty({
example: 'service-type'
example: 'your-type'
})
@IsString()
@IsNotEmpty({ message: 'please provide valid type' })
type: string;

@ApiProperty({
example: ['key1', 'key2']
})
@IsString({ each: true })
recipientKeys: string[];

@ApiPropertyOptional({
example: ['key1', 'key2']
})
@IsOptional()
@IsString({ each: true })
routingKeys: string[];

@ApiPropertyOptional({
example: ['true']
})
@IsOptional()
@IsString({ each: true })
accept: string[];
}
@IsNotEmpty({ message: 'please provide valid @type' })
'@type': string;

export class InvitationDto {
@ApiPropertyOptional({
example: 'your-id'
})
Expand All @@ -57,13 +65,6 @@ export class InvitationDto {
@IsNotEmpty({ message: 'please provide valid @id' })
'@id': string;

@ApiProperty({
example: 'your-type'
})
@IsString()
@IsNotEmpty({ message: 'please provide valid @type' })
'@type': string;

@ApiProperty({
example: 'your-label'
})
Expand All @@ -72,90 +73,99 @@ export class InvitationDto {
label: string;

@ApiPropertyOptional({
example: 'your-goal-code'
example: 'http://example.com/image.jpg'
})
@IsOptional()
@IsString()
@IsNotEmpty({ message: 'please provide valid goalCode' })
goalCode: string;

@ApiPropertyOptional({
example: 'your-goal'
})
@IsOptional()
@IsNotEmpty({ message: 'please provide valid imageUrl' })
@IsString()
@IsNotEmpty({ message: 'please provide valid goal' })
goal: string;
imageUrl?: string;

@ApiPropertyOptional({
example: ['accept1', 'accept2']
@ApiProperty({
example: ['key1', 'key2']
})
@IsOptional()
@IsString({ each: true })
accept: string[];
recipientKeys: string[];

@ApiPropertyOptional({
example: ['protocol1', 'protocol2']
@ApiProperty({
example: 'http://example.com'
})
@IsOptional()
@IsString({ each: true })
// eslint-disable-next-line camelcase
handshake_protocols: string[];

@ApiProperty(
// {
// 'example': [
// {
// id: 'service-id',
// serviceEndpoint: 'http://example.com',
// type: 'service-type',
// recipientKeys: ['key1', 'key2'],
// routingKeys: ['key1', 'key2'],
// accept: ['true']
// }
// ]
// }
)
@ValidateNested({ each: true })
@Type(() => ServiceDto)
services: ServiceDto[];
@IsString()
@IsNotEmpty({ message: 'please provide valid serviceEndpoint' })
@IsUrl({}, { message: 'Invalid serviceEndpoint format' })
serviceEndpoint: string;

@ApiPropertyOptional({
example: 'http://example.com/image.jpg'
example: ['key1', 'key2']
})
@IsString()
@IsOptional()
@IsNotEmpty({ message: 'please provide valid imageUrl' })
@IsString()
imageUrl?: string;
@IsString({ each: true })
routingKeys: string[];
}

// @ApiPropertyOptional({
// example: 'your-goal-code'
// })
// @IsOptional()
// @IsString()
// @IsNotEmpty({ message: 'please provide valid goalCode' })
// goalCode: string;

// @ApiPropertyOptional({
// example: 'your-goal'
// })
// @IsOptional()
// @IsString()
// @IsNotEmpty({ message: 'please provide valid goal' })
// goal: string;

// @ApiPropertyOptional({
// example: ['accept1', 'accept2']
// })
// @IsOptional()
// @IsString({ each: true })
// accept: string[];

// @ApiPropertyOptional({
// example: ['protocol1', 'protocol2']
// })
// @IsOptional()
// @IsString({ each: true })
// // eslint-disable-next-line camelcase
// handshake_protocols: string[];

// @ApiProperty(
// // {
// // 'example': [
// // {
// // id: 'service-id',
// // serviceEndpoint: 'http://example.com',
// // type: 'service-type',
// // recipientKeys: ['key1', 'key2'],
// // routingKeys: ['key1', 'key2'],
// // accept: ['true']
// // }
// // ]
// // }
// )
// @ValidateNested({ each: true })
// @Type(() => ServiceDto)
// services: ServiceDto[];
// }

export class StoreObjectDto {
@ApiProperty({
'example': {
'@id': 'your-id',
'@type': 'your-type',
'@id': 'your-id',
label: 'your-label',
goalCode: 'your-goal-code',
goal: 'your-goal',
accept: ['accept1', 'accept2'],
// eslint-disable-next-line camelcase
handshake_protocols: ['protocol1', 'protocol2'],
services: [
{
id: 'service-id',
serviceEndpoint: 'http://example.com',
type: 'service-type',
recipientKeys: ['key1', 'key2'],
routingKeys: ['key1', 'key2'],
accept: ['true']
}
// Add more service objects as needed
],
imageUrl: 'http://example.com/image.jpg'
imageUrl: 'http://example.com/image.jpg',
recipientKeys: ['key1', 'key2'],
serviceEndpoint: 'http://example.com',
routingKeys: ['key1', 'key2']
}
})
@ValidateNested()
@Type(() => InvitationDto)
data: InvitationDto;
@Type(() => LegacyInvitationDto)
data: LegacyInvitationDto;
}
Loading

0 comments on commit a95fb4c

Please sign in to comment.