File

src/issuer/trust-list/trustlist.controller.ts

Prefix

trust-list

Description

Controller for managing trust lists.

Index

Methods

Methods

createTrustList
createTrustList(body: TrustListCreateDto, token: TokenPayload)
Decorators :
@Post()

Creates a new trust list for the tenant

Parameters :
Name Type Optional
body TrustListCreateDto No
token TokenPayload No
Returns : any
deleteTrustList
deleteTrustList(id: string, token: TokenPayload)
Decorators :
@Delete(':id')

Deletes a trust list

Parameters :
Name Type Optional
id string No
token TokenPayload No
Returns : any
exportTrustList
exportTrustList(token: TokenPayload, id: string)
Decorators :
@Get(':id/export')

Exports the trust list in LoTE format

Parameters :
Name Type Optional
token TokenPayload No
id string No
Returns : any
getAllTrustLists
getAllTrustLists(token: TokenPayload)
Decorators :
@Get()

Returns all trust lists for the tenant

Parameters :
Name Type Optional
token TokenPayload No
Returns : any
getTrustList
getTrustList(token: TokenPayload, id: string)
Decorators :
@Get(':id')

Returns the trust list by id for the tenant

Parameters :
Name Type Optional
token TokenPayload No
id string No
Returns : any
getTrustListVersion
getTrustListVersion(token: TokenPayload, id: string, versionId: string)
Decorators :
@Get(':id/versions/:versionId')

Returns a specific version of a trust list

Parameters :
Name Type Optional
token TokenPayload No
id string No
versionId string No
Returns : any
getTrustListVersions
getTrustListVersions(token: TokenPayload, id: string)
Decorators :
@Get(':id/versions')

Returns the version history for a trust list

Parameters :
Name Type Optional
token TokenPayload No
id string No
Returns : any
updateTrustList
updateTrustList(id: string, body: TrustListCreateDto, token: TokenPayload)
Decorators :
@Put(':id')

Updates a trust list with new entities Creates a new version for audit and regenerates the JWT

Parameters :
Name Type Optional
id string No
body TrustListCreateDto No
token TokenPayload No
Returns : any
import {
    Body,
    ConflictException,
    Controller,
    Delete,
    Get,
    Param,
    Post,
    Put,
} from "@nestjs/common";
import { ApiTags } from "@nestjs/swagger";
import { Role } from "../../auth/roles/role.enum";
import { Secured } from "../../auth/secure.decorator";
import { Token, TokenPayload } from "../../auth/token.decorator";
import { TrustListCreateDto } from "./dto/trust-list-create.dto";
import { TrustListService } from "./trustlist.service";

/**
 * Controller for managing trust lists.
 */
@Secured([Role.Issuances, Role.Presentations])
@ApiTags("Issuer")
@Controller("trust-list")
export class TrustListController {
    constructor(private readonly trustListService: TrustListService) {}

    /**
     * Creates a new trust list for the tenant
     * @param body
     * @returns
     */
    @Post()
    createTrustList(
        @Body() body: TrustListCreateDto,
        @Token() token: TokenPayload,
    ) {
        return this.trustListService
            .create(body, token.entity!)
            .catch((err) => {
                throw new ConflictException(err.message);
            });
    }

    /**
     * Returns all trust lists for the tenant
     * @param token
     * @returns
     */
    @Get()
    getAllTrustLists(@Token() token: TokenPayload) {
        return this.trustListService.findAll(token.entity!);
    }

    /**
     * Returns the trust list by id for the tenant
     * @param tenantId
     * @param id
     * @returns
     */
    @Get(":id")
    getTrustList(@Token() token: TokenPayload, @Param("id") id: string) {
        return this.trustListService.findOne(token.entity!.id, id).catch(() => {
            throw new ConflictException("Trust list not found");
        });
    }

    /**
     * Exports the trust list in LoTE format
     * @param token
     * @param id
     * @returns
     */
    @Get(":id/export")
    exportTrustList(@Token() token: TokenPayload, @Param("id") id: string) {
        return this.trustListService
            .exportTrustList(token.entity!.id, id)
            .catch(() => {
                throw new ConflictException("Trust list not found");
            });
    }

    /**
     * Returns the version history for a trust list
     * @param token
     * @param id
     * @returns
     */
    @Get(":id/versions")
    getTrustListVersions(
        @Token() token: TokenPayload,
        @Param("id") id: string,
    ) {
        return this.trustListService
            .getVersionHistory(token.entity!.id, id)
            .catch(() => {
                throw new ConflictException("Trust list not found");
            });
    }

    /**
     * Returns a specific version of a trust list
     * @param token
     * @param id
     * @param versionId
     * @returns
     */
    @Get(":id/versions/:versionId")
    getTrustListVersion(
        @Token() token: TokenPayload,
        @Param("id") id: string,
        @Param("versionId") versionId: string,
    ) {
        return this.trustListService
            .getVersion(token.entity!.id, id, versionId)
            .catch(() => {
                throw new ConflictException("Trust list version not found");
            });
    }

    /**
     * Updates a trust list with new entities
     * Creates a new version for audit and regenerates the JWT
     * @param id
     * @param body
     * @param token
     * @returns
     */
    @Put(":id")
    updateTrustList(
        @Param("id") id: string,
        @Body() body: TrustListCreateDto,
        @Token() token: TokenPayload,
    ) {
        return this.trustListService
            .update(token.entity!.id, id, body)
            .catch((err) => {
                throw new ConflictException(err.message);
            });
    }

    /**
     * Deletes a trust list
     * @param id
     * @param token
     * @returns
     */
    @Delete(":id")
    deleteTrustList(@Param("id") id: string, @Token() token: TokenPayload) {
        return this.trustListService.remove(token.entity!.id, id);
    }
}

results matching ""

    No results matching ""