Skip to content

Commit

Permalink
Merge pull request #581 from bandada-infra/feat/group-types
Browse files Browse the repository at this point in the history
Add type to group entity
  • Loading branch information
vplasencia authored Oct 27, 2024
2 parents 0d3482c + 8ded485 commit 8f4285d
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 12 deletions.
8 changes: 8 additions & 0 deletions apps/api/src/app/credentials/credentials.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe("CredentialsService", () => {
{
name: "Group1",
description: "This is a description",
type: "off-chain",
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand All @@ -104,6 +105,7 @@ describe("CredentialsService", () => {
{
name: "Group2",
description: "This is a description",
type: "off-chain",
treeDepth: 16,
fingerprintDuration: 3600
},
Expand Down Expand Up @@ -186,6 +188,7 @@ describe("CredentialsService", () => {
{
name: "Group2",
description: "This is a description",
type: "off-chain",
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -232,6 +235,7 @@ describe("CredentialsService", () => {
{
name: "Group2",
description: "This is a description",
type: "off-chain",
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -337,6 +341,7 @@ describe("CredentialsService", () => {
{
name: "Group2",
description: "This is a description",
type: "off-chain",
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -387,6 +392,7 @@ describe("CredentialsService", () => {
{
name: "Group3",
description: "This is a description",
type: "off-chain",
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -439,6 +445,7 @@ describe("CredentialsService", () => {
{
name: "Group4",
description: "This is a description",
type: "off-chain",
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down Expand Up @@ -492,6 +499,7 @@ describe("CredentialsService", () => {
{
name: "Group5",
description: "This is a description",
type: "off-chain",
treeDepth: 16,
fingerprintDuration: 3600,
credentials: JSON.stringify({
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/app/groups/docSchemas/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export class Group {
@ApiProperty()
description: string
@ApiProperty()
type: string
@ApiProperty()
admin: string
@ApiProperty()
treeDepth: number
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/app/groups/docSchemas/groupResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export class GroupResponse {
@ApiProperty()
description: string
@ApiProperty()
type: string
@ApiProperty()
adminId: string
@ApiProperty()
treeDepth: number
Expand Down
10 changes: 9 additions & 1 deletion apps/api/src/app/groups/dto/create-group.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
MinLength,
NotContains,
IsNumberString,
IsJSON
IsJSON,
IsEnum
} from "class-validator"
import { ApiProperty } from "@nestjs/swagger"
import { GroupType } from "../types"

export class CreateGroupDto {
@IsString()
Expand All @@ -30,6 +32,12 @@ export class CreateGroupDto {
@ApiProperty()
readonly description: string

@IsEnum(["on-chain", "off-chain"])
@ApiProperty({
enum: ["on-chain", "off-chain"]
})
readonly type: GroupType

@IsNumber()
@Min(16, { message: "The tree depth must be between 16 and 32." })
@Max(32, { message: "The tree depth must be between 16 and 32." })
Expand Down
8 changes: 8 additions & 0 deletions apps/api/src/app/groups/entities/group.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { OAuthAccount } from "../../credentials/entities/credentials-account.entity"
import { Member } from "./member.entity"
import { Invite } from "../../invites/entities/invite.entity"
import { GroupType } from "../types"

@Entity("groups")
export class Group {
Expand All @@ -25,6 +26,13 @@ export class Group {
@Column()
description: string

@Column({
type: "simple-enum",
enum: ["on-chain", "off-chain"],
nullable: true
})
type: GroupType

@Column({ name: "admin_id" })
adminId: string

Expand Down
Loading

0 comments on commit 8f4285d

Please sign in to comment.