Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor:org create API #761

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 64 additions & 42 deletions apps/api-gateway/src/organization/dtos/create-organization-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,68 @@ import { IsNotSQLInjection, trim } from '@credebl/common/cast.helper';

@ApiExtraModels()
export class CreateOrganizationDto {
@ApiProperty()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'Organization name is required.' })
@MinLength(2, { message: 'Organization name must be at least 2 characters.' })
@MaxLength(50, { message: 'Organization name must be at most 50 characters.' })
@IsString({ message: 'Organization name must be in string format.' })
@IsNotSQLInjection({ message: 'Organization name is required.' })
name: string;

@ApiProperty()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'Organization name is required.' })
@MinLength(2, { message: 'Organization name must be at least 2 characters.' })
@MaxLength(50, { message: 'Organization name must be at most 50 characters.' })
@IsString({ message: 'Organization name must be in string format.' })
@IsNotSQLInjection({ message: 'Organization name is required.' })
name: string;

@ApiPropertyOptional()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'Description is required.' })
@MinLength(2, { message: 'Description must be at least 2 characters.' })
@MaxLength(255, { message: 'Description must be at most 255 characters.' })
@IsString({ message: 'Description must be in string format.' })
description: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
website?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'notificationWebhook is required.' })
@IsString({ message: 'notificationWebhook must be in string format.' })
@IsUrl({
// eslint-disable-next-line camelcase
require_protocol: true, // require URL protocol (e.g., http:// or https://)
// eslint-disable-next-line camelcase
require_tld: true // require top-level domain (e.g., .com, .net)

})
notificationWebhook?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'logo must be in string format.' })
logo?: string = '';
}
@ApiPropertyOptional()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'Description is required.' })
@MinLength(2, { message: 'Description must be at least 2 characters.' })
@MaxLength(255, { message: 'Description must be at most 255 characters.' })
@IsString({ message: 'Description must be in string format.' })
description: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
website?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'notificationWebhook is required.' })
@IsString({ message: 'notificationWebhook must be in string format.' })
@IsUrl({
// eslint-disable-next-line camelcase
require_protocol: true, // require URL protocol (e.g., http:// or https://)
// eslint-disable-next-line camelcase
require_tld: true // require top-level domain (e.g., .com, .net)
})
notificationWebhook?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'logo must be in string format.' })
logo?: string = '';

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'registrationNumber must be in string format.' })
registrationNumber?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'country must be in string format.' })
country?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'state must be in string format.' })
state?: string;

@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'city must be in string format.' })
city?: string;
}
4 changes: 4 additions & 0 deletions apps/organization/dtos/create-organization.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export class CreateOrganizationDto {
updatedBy?:string;
lastChangedBy?:string;
notificationWebhook?: string;
registrationNumber?:string;
country?:string;
city?:string;
state?:string;
}

export class CreateUserRoleOrgDto {
Expand Down
4 changes: 4 additions & 0 deletions apps/organization/repositories/organization.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export class OrganizationRepository {
website: createOrgDto.website,
orgSlug: createOrgDto.orgSlug,
publicProfile: false,
registrationNumber:createOrgDto.registrationNumber,
country:createOrgDto.country,
city:createOrgDto.city,
state:createOrgDto.state,
createdBy: createOrgDto.createdBy,
lastChangedBy: createOrgDto.lastChangedBy
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "organisation" ADD COLUMN "city" VARCHAR(100),
ADD COLUMN "country" VARCHAR(100),
ADD COLUMN "registrationNumber" VARCHAR(100),
ADD COLUMN "state" VARCHAR(100);
4 changes: 4 additions & 0 deletions libs/prisma-service/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ model organisation {
idpId String? @db.VarChar(500)
clientId String? @db.VarChar(500)
clientSecret String? @db.VarChar(500)
registrationNumber String? @db.VarChar(100)
country String? @db.VarChar(100)
city String? @db.VarChar(100)
state String? @db.VarChar(100)
connections connections[]
credentials credentials[]
org_agents org_agents[]
Expand Down