src/registrar/schema-metadata.controller.ts
schema-metadata
Controller for managing TS11 schema metadata at the configured registrar / catalog provider. Operations are scoped to the calling tenant; auth is delegated to the registrar via the tenant's registrar credentials.
The signing endpoint that produces a JWS lives on the issuer side
(POST /issuer/credentials/schema-metadata/sign) because it depends on
the tenant's key chain.
not yet finalized.
Methods |
| deprecateVersion | |||||||||||||||
deprecateVersion(token: TokenPayload, id: string, version: string, body: DeprecateSchemaMetadataDto)
|
|||||||||||||||
Decorators :
@Patch(':id/versions/:version/deprecation')
|
|||||||||||||||
|
Parameters :
Returns :
Promise<SchemaMetadataResponseDto>
|
| export | ||||||||||||
export(token: TokenPayload, id: string, version: string)
|
||||||||||||
Decorators :
@Get(':id/versions/:version/export')
|
||||||||||||
|
Parameters :
Returns :
Promise<unknown>
|
| findAll | ||||||||||||
findAll(token: TokenPayload, attestationId?: string, version?: string)
|
||||||||||||
Decorators :
@Get()
|
||||||||||||
|
Parameters :
Returns :
Promise<SchemaMetadataResponseDto[]>
|
| findOne | |||||||||
findOne(token: TokenPayload, id: string)
|
|||||||||
Decorators :
@Get(':id')
|
|||||||||
|
Parameters :
Returns :
Promise<SchemaMetadataResponseDto>
|
| getJwt | ||||||||||||
getJwt(token: TokenPayload, id: string, version: string)
|
||||||||||||
Decorators :
@Get(':id/versions/:version/jwt')
|
||||||||||||
|
Parameters :
Returns :
Promise<string>
|
| getLatest | |||||||||
getLatest(token: TokenPayload, id: string)
|
|||||||||
Decorators :
@Get(':id/latest')
|
|||||||||
|
Parameters :
Returns :
Promise<SchemaMetadataResponseDto>
|
| getSchema | |||||||||||||||
getSchema(token: TokenPayload, id: string, version: string, format: string)
|
|||||||||||||||
Decorators :
@Get(':id/versions/:version/schemas/:format')
|
|||||||||||||||
|
Parameters :
Returns :
Promise<unknown>
|
| getVersions | |||||||||
getVersions(token: TokenPayload, id: string)
|
|||||||||
Decorators :
@Get(':id/versions')
|
|||||||||
|
Parameters :
Returns :
Promise<SchemaMetadataResponseDto[]>
|
| getVocabularies | ||||||
getVocabularies(token: TokenPayload)
|
||||||
Decorators :
@Get('vocabularies')
|
||||||
|
Parameters :
Returns :
Promise<SchemaMetadataVocabulariesDto>
|
| remove | ||||||||||||
remove(token: TokenPayload, id: string, version: string)
|
||||||||||||
Decorators :
@Delete(':id/versions/:version')
|
||||||||||||
|
Parameters :
Returns :
Promise<void>
|
| update | |||||||||||||||
update(token: TokenPayload, id: string, version: string, body: UpdateSchemaMetadataDto)
|
|||||||||||||||
Decorators :
@Patch(':id/versions/:version')
|
|||||||||||||||
|
Parameters :
Returns :
Promise<SchemaMetadataResponseDto>
|
import {
Body,
Controller,
Delete,
Get,
Param,
Patch,
Query,
} from "@nestjs/common";
import { ApiBody, ApiOperation, ApiResponse, 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 {
DeprecateSchemaMetadataDto,
SchemaMetadataResponseDto,
SchemaMetadataVocabulariesDto,
UpdateSchemaMetadataDto,
} from "./dto/schema-metadata.dto";
import { SchemaMetadataService } from "./schema-metadata.service";
/**
* Controller for managing TS11 schema metadata at the configured registrar /
* catalog provider. Operations are scoped to the calling tenant; auth is
* delegated to the registrar via the tenant's registrar credentials.
*
* The signing endpoint that produces a JWS lives on the issuer side
* (`POST /issuer/credentials/schema-metadata/sign`) because it depends on
* the tenant's key chain.
*
* @experimental The TS11 specification (EUDI Catalogue of Attestations) is
* not yet finalized.
*/
@ApiTags("Schema Metadata")
@Secured([Role.Registrar])
@Controller("schema-metadata")
export class SchemaMetadataController {
constructor(
private readonly schemaMetadataService: SchemaMetadataService,
) {}
@Get("vocabularies")
@ApiOperation({ summary: "Get predefined schema metadata vocabularies" })
@ApiResponse({ status: 200, type: SchemaMetadataVocabulariesDto })
getVocabularies(
@Token() token: TokenPayload,
): Promise<SchemaMetadataVocabulariesDto> {
return this.schemaMetadataService.getVocabularies(token.entity!.id);
}
@Get()
@ApiOperation({ summary: "List schema metadata" })
@ApiResponse({ status: 200, type: [SchemaMetadataResponseDto] })
findAll(
@Token() token: TokenPayload,
@Query("attestationId") attestationId?: string,
@Query("version") version?: string,
): Promise<SchemaMetadataResponseDto[]> {
return this.schemaMetadataService.findAll(token.entity!.id, {
attestationId,
version,
});
}
@Get(":id")
@ApiOperation({ summary: "Get schema metadata by ID" })
@ApiResponse({ status: 200, type: SchemaMetadataResponseDto })
findOne(
@Token() token: TokenPayload,
@Param("id") id: string,
): Promise<SchemaMetadataResponseDto> {
return this.schemaMetadataService.findOne(token.entity!.id, id);
}
@Patch(":id/versions/:version")
@ApiOperation({ summary: "Update schema metadata attributes" })
@ApiBody({ type: UpdateSchemaMetadataDto })
@ApiResponse({ status: 200, type: SchemaMetadataResponseDto })
update(
@Token() token: TokenPayload,
@Param("id") id: string,
@Param("version") version: string,
@Body() body: UpdateSchemaMetadataDto,
): Promise<SchemaMetadataResponseDto> {
return this.schemaMetadataService.updateMetadata(
token.entity!.id,
id,
version,
body,
);
}
@Delete(":id/versions/:version")
@ApiOperation({ summary: "Delete schema metadata" })
@ApiResponse({ status: 200, description: "Deleted" })
remove(
@Token() token: TokenPayload,
@Param("id") id: string,
@Param("version") version: string,
): Promise<void> {
return this.schemaMetadataService.remove(token.entity!.id, id, version);
}
@Get(":id/latest")
@ApiOperation({ summary: "Get latest version of schema metadata by ID" })
@ApiResponse({ status: 200, type: SchemaMetadataResponseDto })
getLatest(
@Token() token: TokenPayload,
@Param("id") id: string,
): Promise<SchemaMetadataResponseDto> {
return this.schemaMetadataService.getLatest(token.entity!.id, id);
}
@Get(":id/versions")
@ApiOperation({ summary: "List all versions of a schema metadata entry" })
@ApiResponse({ status: 200, type: [SchemaMetadataResponseDto] })
getVersions(
@Token() token: TokenPayload,
@Param("id") id: string,
): Promise<SchemaMetadataResponseDto[]> {
return this.schemaMetadataService.getVersions(token.entity!.id, id);
}
@Get(":id/versions/:version/jwt")
@ApiOperation({ summary: "Get signed schema metadata JWT" })
@ApiResponse({
status: 200,
description: "Compact-serialization JWS string",
schema: { type: "string" },
})
getJwt(
@Token() token: TokenPayload,
@Param("id") id: string,
@Param("version") version: string,
): Promise<string> {
return this.schemaMetadataService.getSignedJwt(
token.entity!.id,
id,
version,
);
}
@Get(":id/versions/:version/export")
@ApiOperation({ summary: "Export schema metadata in catalog format" })
@ApiResponse({
status: 200,
description: "Registrar-defined catalog document",
schema: { type: "object", additionalProperties: true },
})
export(
@Token() token: TokenPayload,
@Param("id") id: string,
@Param("version") version: string,
): Promise<unknown> {
return this.schemaMetadataService.exportCatalogFormat(
token.entity!.id,
id,
version,
);
}
@Get(":id/versions/:version/schemas/:format")
@ApiOperation({ summary: "Get schema content for a specific format" })
@ApiResponse({
status: 200,
description: "JSON Schema document for the requested format",
schema: { type: "object", additionalProperties: true },
})
getSchema(
@Token() token: TokenPayload,
@Param("id") id: string,
@Param("version") version: string,
@Param("format") format: string,
): Promise<unknown> {
return this.schemaMetadataService.getSchemaByFormat(
token.entity!.id,
id,
version,
format,
);
}
@Patch(":id/versions/:version/deprecation")
@ApiOperation({ summary: "Deprecate a schema metadata version" })
@ApiBody({ type: DeprecateSchemaMetadataDto })
@ApiResponse({ status: 200, type: SchemaMetadataResponseDto })
deprecateVersion(
@Token() token: TokenPayload,
@Param("id") id: string,
@Param("version") version: string,
@Body() body: DeprecateSchemaMetadataDto,
): Promise<SchemaMetadataResponseDto> {
return this.schemaMetadataService.deprecateVersion(
token.entity!.id,
id,
version,
body,
);
}
}