diff --git a/packages/types/src/infrastructure/httpServer/BaseController.ts b/packages/types/src/infrastructure/httpServer/BaseController.ts index 7d3a2d220..0717b33a2 100644 --- a/packages/types/src/infrastructure/httpServer/BaseController.ts +++ b/packages/types/src/infrastructure/httpServer/BaseController.ts @@ -6,20 +6,20 @@ import { Envelope } from "./common/Envelope"; import { Mimetype } from "./common/Mimetype"; export abstract class BaseController { - protected created(result: Result): Return.NewResource { - return new Return.NewResource("_", this.json(result)); + protected created(result: Result): Return.NewResource> { + return new Return.NewResource>("_", this.json(result)); } - protected ok(result: Result): Envelope { - return this.json(result); + protected ok(result: Result): Envelope { + return this.json(result); } protected noContent(result: Result): void { - this.guard(result); + this.guard(result); return; } - private json(result: Result): Envelope { + private json(result: Result): Envelope { this.guard(result); return Envelope.ok(result.value); } diff --git a/packages/types/src/infrastructure/httpServer/common/Envelope.ts b/packages/types/src/infrastructure/httpServer/common/Envelope.ts index 7f792201b..de01b2bd3 100644 --- a/packages/types/src/infrastructure/httpServer/common/Envelope.ts +++ b/packages/types/src/infrastructure/httpServer/common/Envelope.ts @@ -1,17 +1,17 @@ import { ConnectorMode } from "../../../ConnectorMode"; import { HttpError, HttpErrorJSON } from "./HttpError"; -export class Envelope { +export class Envelope { protected constructor( - public result?: any, + public result?: T, public error?: HttpErrorJSON ) {} - public static ok(result: any): Envelope { + public static ok(result: T): Envelope { return new Envelope(result, undefined); } - public static error(error: HttpError, connectorMode: ConnectorMode): Envelope { + public static error(error: HttpError, connectorMode: ConnectorMode): Envelope { switch (connectorMode) { case "debug": return new Envelope(undefined, error.toJSON("verbose")); diff --git a/src/modules/coreHttpApi/controllers/AccountController.ts b/src/modules/coreHttpApi/controllers/AccountController.ts index a774f5fb7..248598f3f 100644 --- a/src/modules/coreHttpApi/controllers/AccountController.ts +++ b/src/modules/coreHttpApi/controllers/AccountController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { TransportServices } from "@nmshd/runtime"; +import { GetIdentityInfoResponse, SyncInfo, TransportServices } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, GET, Path, POST, Security } from "@nmshd/typescript-rest"; @@ -13,7 +13,7 @@ export class AccountController extends BaseController { @GET @Path("/IdentityInfo") @Accept("application/json") - public async getIdentityInfo(): Promise { + public async getIdentityInfo(): Promise> { const result = await this.transportServices.account.getIdentityInfo(); return this.ok(result); } @@ -30,7 +30,7 @@ export class AccountController extends BaseController { @GET @Path("/SyncInfo") @Accept("application/json") - public async getSyncInfo(): Promise { + public async getSyncInfo(): Promise> { const result = await this.transportServices.account.getSyncInfo(); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/AnnouncementsController.ts b/src/modules/coreHttpApi/controllers/AnnouncementsController.ts index 2db0e6bce..16557520c 100644 --- a/src/modules/coreHttpApi/controllers/AnnouncementsController.ts +++ b/src/modules/coreHttpApi/controllers/AnnouncementsController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { TransportServices } from "@nmshd/runtime"; +import { AnnouncementDTO, TransportServices } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, GET, Path, QueryParam, Security } from "@nmshd/typescript-rest"; @@ -12,7 +12,7 @@ export class AnnouncementsController extends BaseController { @GET @Accept("application/json") - public async getAnnouncements(@QueryParam("language") language: string): Promise { + public async getAnnouncements(@QueryParam("language") language: string): Promise> { const result = await this.transportServices.announcements.getAnnouncements({ language: language as any }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/AttributesController.ts b/src/modules/coreHttpApi/controllers/AttributesController.ts index f6ea52116..5c2ecd552 100644 --- a/src/modules/coreHttpApi/controllers/AttributesController.ts +++ b/src/modules/coreHttpApi/controllers/AttributesController.ts @@ -1,7 +1,19 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { ConsumptionServices, RuntimeErrors } from "@nmshd/runtime"; +import { + AttributeTagCollectionDTO, + CanCreateOwnIdentityAttributeResponse, + ConsumptionServices, + DeleteAttributeAndNotifyResponse, + LocalAttributeDTO, + LocalAttributeForwardingDetailsDTO, + NotifyPeerAboutOwnIdentityAttributeSuccessionResponse, + RuntimeErrors, + SucceedOwnIdentityAttributeResponse, + SucceedRelationshipAttributeAndNotifyPeerResponse, + ValidateIQLQueryResponse +} from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; -import { Accept, Context, DELETE, GET, POST, PUT, Path, PathParam, QueryParam, Return, Security, ServiceContext } from "@nmshd/typescript-rest"; +import { Accept, Context, DELETE, GET, Path, PathParam, POST, PUT, QueryParam, Return, Security, ServiceContext } from "@nmshd/typescript-rest"; @Security("core:attributes") @Path("/api/core/v1/Attributes") @@ -13,14 +25,14 @@ export class AttributesController extends BaseController { @PUT @Path("CanCreate") @Accept("application/json") - public async canCreateOwnIdentityAttribute(request: any): Promise { + public async canCreateOwnIdentityAttribute(request: any): Promise> { const result = await this.consumptionServices.attributes.canCreateOwnIdentityAttribute(request); return this.ok(result); } @POST @Accept("application/json") - public async createOwnIdentityAttribute(request: any): Promise> { + public async createOwnIdentityAttribute(request: any): Promise>> { const result = await this.consumptionServices.attributes.createOwnIdentityAttribute(request); return this.created(result); } @@ -28,7 +40,10 @@ export class AttributesController extends BaseController { @POST @Path("/:predecessorId/Succeed") @Accept("application/json") - public async succeedAttribute(@PathParam("predecessorId") predecessorId: string, request: any): Promise> { + public async succeedAttribute( + @PathParam("predecessorId") predecessorId: string, + request: any + ): Promise>> { const result = await this.consumptionServices.attributes.getAttribute({ id: predecessorId }); if (result.isError) { throw RuntimeErrors.general.recordNotFoundWithMessage(`Predecessor attribute '${predecessorId}' not found.`); @@ -54,14 +69,17 @@ export class AttributesController extends BaseController { @POST @Path("/:id/NotifyPeer") @Accept("application/json") - public async notifyPeerAboutOwnIdentityAttributeSuccession(@PathParam("id") attributeId: string, request: any): Promise> { + public async notifyPeerAboutOwnIdentityAttributeSuccession( + @PathParam("id") attributeId: string, + request: any + ): Promise>> { const result = await this.consumptionServices.attributes.notifyPeerAboutOwnIdentityAttributeSuccession({ attributeId: attributeId, peer: request.peer }); return this.created(result); } @GET @Accept("application/json") - public async getAttributes(@Context context: ServiceContext): Promise { + public async getAttributes(@Context context: ServiceContext): Promise> { const result = await this.consumptionServices.attributes.getAttributes({ query: context.request.query }); return this.ok(result); } @@ -69,7 +87,10 @@ export class AttributesController extends BaseController { @GET @Path("/Own/Identity") @Accept("application/json") - public async getOwnIdentityAttributes(@Context context: ServiceContext, @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean): Promise { + public async getOwnIdentityAttributes( + @Context context: ServiceContext, + @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean + ): Promise> { const query: Record = this.extractQuery(context.request.query, ["onlyLatestVersions"]); const result = await this.consumptionServices.attributes.getOwnIdentityAttributes({ onlyLatestVersions, query }); return this.ok(result); @@ -83,7 +104,7 @@ export class AttributesController extends BaseController { @PathParam("peer") peer: string, @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean, @QueryParam("hideTechnical") hideTechnical?: boolean - ): Promise { + ): Promise> { const query: Record = this.extractQuery(context.request.query, ["onlyLatestVersions", "hideTechnical"]); const result = await this.consumptionServices.attributes.getOwnAttributesSharedWithPeer({ peer, onlyLatestVersions, hideTechnical, query }); return this.ok(result); @@ -97,7 +118,7 @@ export class AttributesController extends BaseController { @PathParam("peer") peer: string, @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean, @QueryParam("hideTechnical") hideTechnical?: boolean - ): Promise { + ): Promise> { const query: Record = this.extractQuery(context.request.query, ["onlyLatestVersions", "hideTechnical"]); const result = await this.consumptionServices.attributes.getPeerAttributes({ peer, onlyLatestVersions, hideTechnical, query }); return this.ok(result); @@ -106,7 +127,7 @@ export class AttributesController extends BaseController { @GET @Path("/:id/ForwardingDetails") @Accept("application/json") - public async getForwardingDetailsForAttribute(@Context context: ServiceContext, @PathParam("id") attributeId: string): Promise { + public async getForwardingDetailsForAttribute(@Context context: ServiceContext, @PathParam("id") attributeId: string): Promise> { const result = await this.consumptionServices.attributes.getForwardingDetailsForAttribute({ attributeId, query: context.request.query }); return this.ok(result); } @@ -114,7 +135,7 @@ export class AttributesController extends BaseController { @GET @Path("/:id/Versions") @Accept("application/json") - public async getVersionsOfAttribute(@PathParam("id") attributeId: string): Promise { + public async getVersionsOfAttribute(@PathParam("id") attributeId: string): Promise> { const result = await this.consumptionServices.attributes.getVersionsOfAttribute({ attributeId }); @@ -128,7 +149,7 @@ export class AttributesController extends BaseController { @PathParam("id") attributeId: string, @QueryParam("peer") peer: string, @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean - ): Promise { + ): Promise> { const result = await this.consumptionServices.attributes.getVersionsOfAttributeSharedWithPeer({ attributeId, onlyLatestVersions, peer }); return this.ok(result); } @@ -136,7 +157,7 @@ export class AttributesController extends BaseController { @GET @Path("/TagCollection") @Accept("application/json") - public async getAttributeTagCollection(): Promise { + public async getAttributeTagCollection(): Promise> { const result = await this.consumptionServices.attributes.getAttributeTagCollection(); return this.ok(result); } @@ -144,7 +165,7 @@ export class AttributesController extends BaseController { @POST @Path("/ExecuteIdentityAttributeQuery") @Accept("application/json") - public async executeIdentityAttributeQuery(request: any): Promise { + public async executeIdentityAttributeQuery(request: any): Promise> { const result = await this.consumptionServices.attributes.executeIdentityAttributeQuery(request); return this.ok(result); } @@ -152,7 +173,7 @@ export class AttributesController extends BaseController { @POST @Path("/ExecuteRelationshipAttributeQuery") @Accept("application/json") - public async executeRelationshipAttributeQuery(request: any): Promise { + public async executeRelationshipAttributeQuery(request: any): Promise> { const result = await this.consumptionServices.attributes.executeRelationshipAttributeQuery(request); return this.ok(result); } @@ -160,7 +181,7 @@ export class AttributesController extends BaseController { @POST @Path("/ExecuteThirdPartyRelationshipAttributeQuery") @Accept("application/json") - public async executeThirdPartyRelationshipAttributeQuery(request: any): Promise { + public async executeThirdPartyRelationshipAttributeQuery(request: any): Promise> { const result = await this.consumptionServices.attributes.executeThirdPartyRelationshipAttributeQuery(request); return this.ok(result); } @@ -168,7 +189,7 @@ export class AttributesController extends BaseController { @POST @Path("/ExecuteIQLQuery") @Accept("application/json") - public async executeIQLQuery(request: any): Promise { + public async executeIQLQuery(request: any): Promise> { const result = await this.consumptionServices.attributes.executeIQLQuery(request); return this.ok(result); } @@ -176,7 +197,7 @@ export class AttributesController extends BaseController { @POST @Path("/ValidateIQLQuery") @Accept("application/json") - public async validateIQLQuery(request: any): Promise { + public async validateIQLQuery(request: any): Promise> { const result = await this.consumptionServices.attributes.validateIQLQuery(request); return this.ok(result); } @@ -184,14 +205,14 @@ export class AttributesController extends BaseController { @GET @Path("/:id") @Accept("application/json") - public async getAttribute(@PathParam("id") id: string): Promise { + public async getAttribute(@PathParam("id") id: string): Promise> { const result = await this.consumptionServices.attributes.getAttribute({ id }); return this.ok(result); } @DELETE @Path(":id") - public async deleteAttributeAndNotify(@PathParam("id") attributeId: string): Promise { + public async deleteAttributeAndNotify(@PathParam("id") attributeId: string): Promise> { const result = await this.consumptionServices.attributes.deleteAttributeAndNotify({ attributeId }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/ChallengesController.ts b/src/modules/coreHttpApi/controllers/ChallengesController.ts index 2cef0c921..2d440f911 100644 --- a/src/modules/coreHttpApi/controllers/ChallengesController.ts +++ b/src/modules/coreHttpApi/controllers/ChallengesController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { TransportServices } from "@nmshd/runtime"; +import { ChallengeDTO, TransportServices, ValidateChallengeResponse } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, Path, POST, Return, Security } from "@nmshd/typescript-rest"; @@ -12,7 +12,7 @@ export class ChallengesController extends BaseController { @POST @Accept("application/json") - public async createChallenge(request: any): Promise> { + public async createChallenge(request: any): Promise>> { const result = await this.transportServices.challenges.createChallenge(request); return this.created(result); } @@ -20,7 +20,7 @@ export class ChallengesController extends BaseController { @POST @Path("/Validate") @Accept("application/json") - public async validateChallenge(request: any): Promise { + public async validateChallenge(request: any): Promise> { const result = await this.transportServices.challenges.validateChallenge(request); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/FilesController.ts b/src/modules/coreHttpApi/controllers/FilesController.ts index 2e41497ef..dbc1b31d3 100644 --- a/src/modules/coreHttpApi/controllers/FilesController.ts +++ b/src/modules/coreHttpApi/controllers/FilesController.ts @@ -1,6 +1,6 @@ import { BaseController, Envelope, Mimetype } from "@nmshd/connector-types"; import { Reference } from "@nmshd/core-types"; -import { OwnerRestriction, TransportServices } from "@nmshd/runtime"; +import { FileDTO, OwnerRestriction, TokenDTO, TransportServices } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, @@ -37,7 +37,7 @@ export class FilesController extends BaseController { @FileParam("file") file?: Express.Multer.File, @FormParam("description") description?: string, @FormParam("tags") tags?: string[] - ): Promise> { + ): Promise>> { const result = await this.transportServices.files.uploadOwnFile({ content: file?.buffer, expiresAt, @@ -53,7 +53,7 @@ export class FilesController extends BaseController { @POST @Path("/Peer") @Accept("application/json") - public async loadPeerFile(request: any): Promise> { + public async loadPeerFile(request: any): Promise>> { const result = await this.transportServices.files.getOrLoadFile(request); return this.created(result); } @@ -75,7 +75,7 @@ export class FilesController extends BaseController { @GET @Accept("application/json") - public async getFiles(@Context context: ServiceContext): Promise { + public async getFiles(@Context context: ServiceContext): Promise> { const result = await this.transportServices.files.getFiles({ query: context.request.query }); return this.ok(result); } @@ -83,7 +83,7 @@ export class FilesController extends BaseController { @GET @Path("/Own") @Accept("application/json") - public async getOwnFiles(@Context context: ServiceContext): Promise { + public async getOwnFiles(@Context context: ServiceContext): Promise> { const result = await this.transportServices.files.getFiles({ query: context.request.query, ownerRestriction: OwnerRestriction.Own }); return this.ok(result); } @@ -91,7 +91,7 @@ export class FilesController extends BaseController { @GET @Path("/Peer") @Accept("application/json") - public async getPeerFiles(@Context context: ServiceContext): Promise { + public async getPeerFiles(@Context context: ServiceContext): Promise> { const result = await this.transportServices.files.getFiles({ query: context.request.query, ownerRestriction: OwnerRestriction.Peer }); return this.ok(result); } @@ -99,7 +99,11 @@ export class FilesController extends BaseController { @GET @Path("/:idOrReference") @Accept("application/json", "image/png") - public async getFile(@PathParam("idOrReference") idOrReference: string, @ContextAccept accept: string, @ContextResponse response: express.Response): Promise { + public async getFile( + @PathParam("idOrReference") idOrReference: string, + @ContextAccept accept: string, + @ContextResponse response: express.Response + ): Promise | void> { const fileId = idOrReference.startsWith("FIL") ? idOrReference : Reference.from(idOrReference).id.toString(); const result = await this.transportServices.files.getFile({ id: fileId }); @@ -120,7 +124,7 @@ export class FilesController extends BaseController { @ContextAccept accept: string, @ContextResponse response: express.Response, request: any - ): Promise | void> { + ): Promise> | void> { const result = await this.transportServices.files.createTokenForFile({ fileId: id, expiresAt: request.expiresAt, @@ -146,7 +150,7 @@ export class FilesController extends BaseController { @PATCH @Path("/:id/RegenerateOwnershipToken") - public async regenerateOwnershipToken(@PathParam("id") id: string): Promise { + public async regenerateOwnershipToken(@PathParam("id") id: string): Promise> { const result = await this.transportServices.files.regenerateFileOwnershipToken({ id }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/IdentityMetadataController.ts b/src/modules/coreHttpApi/controllers/IdentityMetadataController.ts index 13bc553c6..7470e554e 100644 --- a/src/modules/coreHttpApi/controllers/IdentityMetadataController.ts +++ b/src/modules/coreHttpApi/controllers/IdentityMetadataController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { ConsumptionServices } from "@nmshd/runtime"; +import { ConsumptionServices, IdentityMetadataDTO } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, DELETE, GET, PUT, Path, QueryParam, Security } from "@nmshd/typescript-rest"; @@ -12,13 +12,13 @@ export class IdentityMetadataController extends BaseController { @PUT @Accept("application/json") - public async upsertIdentityMetadata(request: any): Promise { + public async upsertIdentityMetadata(request: any): Promise> { const result = await this.consumptionServices.identityMetadata.upsertIdentityMetadata(request); return this.ok(result); } @GET - public async getIdentityMetadata(@QueryParam("reference") reference: string, @QueryParam("key") key?: string): Promise { + public async getIdentityMetadata(@QueryParam("reference") reference: string, @QueryParam("key") key?: string): Promise> { const result = await this.consumptionServices.identityMetadata.getIdentityMetadata({ reference, key }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/IncomingRequestsController.ts b/src/modules/coreHttpApi/controllers/IncomingRequestsController.ts index 88d4fb9b2..ab0d839f4 100644 --- a/src/modules/coreHttpApi/controllers/IncomingRequestsController.ts +++ b/src/modules/coreHttpApi/controllers/IncomingRequestsController.ts @@ -1,6 +1,6 @@ import { ApplicationError } from "@js-soft/ts-utils"; import { BaseController, Envelope } from "@nmshd/connector-types"; -import { ConsumptionServices } from "@nmshd/runtime"; +import { ConsumptionServices, LocalRequestDTO, RequestValidationResultDTO } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, Context, GET, Path, PathParam, PUT, Security, ServiceContext } from "@nmshd/typescript-rest"; @@ -14,7 +14,7 @@ export class IncomingRequestsController extends BaseController { @PUT @Path("/:id/CanAccept") @Accept("application/json") - public async canAccept(@PathParam("id") requestId: string, request: any): Promise { + public async canAccept(@PathParam("id") requestId: string, request: any): Promise> { if (request?.decidedByAutomation === true) { throw new ApplicationError("error.connector.incomingRequests.decidedByAutomation", "Decided by automation is not allowed for this endpoint."); } @@ -26,7 +26,7 @@ export class IncomingRequestsController extends BaseController { @PUT @Path("/:id/Accept") @Accept("application/json") - public async accept(@PathParam("id") requestId: string, request: any): Promise { + public async accept(@PathParam("id") requestId: string, request: any): Promise> { if (request?.decidedByAutomation === true) { throw new ApplicationError("error.connector.incomingRequests.decidedByAutomation", "Decided by automation is not allowed for this endpoint."); } @@ -38,7 +38,7 @@ export class IncomingRequestsController extends BaseController { @PUT @Path("/:id/CanReject") @Accept("application/json") - public async canReject(@PathParam("id") requestId: string, request: any): Promise { + public async canReject(@PathParam("id") requestId: string, request: any): Promise> { if (request?.decidedByAutomation === true) { throw new ApplicationError("error.connector.incomingRequests.decidedByAutomation", "Decided by automation is not allowed for this endpoint."); } @@ -50,7 +50,7 @@ export class IncomingRequestsController extends BaseController { @PUT @Path("/:id/Reject") @Accept("application/json") - public async reject(@PathParam("id") requestId: string, request: any): Promise { + public async reject(@PathParam("id") requestId: string, request: any): Promise> { if (request?.decidedByAutomation === true) { throw new ApplicationError("error.connector.incomingRequests.decidedByAutomation", "Decided by automation is not allowed for this endpoint."); } @@ -62,14 +62,14 @@ export class IncomingRequestsController extends BaseController { @GET @Path("/:id") @Accept("application/json") - public async getRequest(@PathParam("id") id: string): Promise { + public async getRequest(@PathParam("id") id: string): Promise> { const result = await this.consumptionServices.incomingRequests.getRequest({ id }); return this.ok(result); } @GET @Accept("application/json") - public async getRequests(@Context context: ServiceContext): Promise { + public async getRequests(@Context context: ServiceContext): Promise> { const result = await this.consumptionServices.incomingRequests.getRequests({ query: context.request.query }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/MessagesController.ts b/src/modules/coreHttpApi/controllers/MessagesController.ts index 0cf726d71..bbda70f48 100644 --- a/src/modules/coreHttpApi/controllers/MessagesController.ts +++ b/src/modules/coreHttpApi/controllers/MessagesController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, Mimetype } from "@nmshd/connector-types"; -import { TransportServices } from "@nmshd/runtime"; +import { FileDTO, MessageDTO, MessageWithAttachmentsDTO, TransportServices } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, Context, ContextResponse, GET, Path, PathParam, POST, Return, Security, ServiceContext } from "@nmshd/typescript-rest"; import express from "express"; @@ -13,14 +13,14 @@ export class MessagesController extends BaseController { @POST @Accept("application/json") - public async sendMessage(request: any): Promise> { + public async sendMessage(request: any): Promise>> { const result = await this.transportServices.messages.sendMessage(request); return this.created(result); } @GET @Accept("application/json") - public async getMessages(@Context context: ServiceContext): Promise { + public async getMessages(@Context context: ServiceContext): Promise> { const result = await this.transportServices.messages.getMessages({ query: context.request.query }); @@ -31,7 +31,7 @@ export class MessagesController extends BaseController { @GET @Path("/:id") @Accept("application/json") - public async getMessage(@PathParam("id") id: string): Promise { + public async getMessage(@PathParam("id") id: string): Promise> { const result = await this.transportServices.messages.getMessage({ id }); return this.ok(result); } @@ -39,7 +39,7 @@ export class MessagesController extends BaseController { @GET @Path("/:id/Attachments/:attachmentId") @Accept("application/json") - public async getMessageAttachmentMetadata(@PathParam("id") id: string, @PathParam("attachmentId") attachmentId: string): Promise { + public async getMessageAttachmentMetadata(@PathParam("id") id: string, @PathParam("attachmentId") attachmentId: string): Promise> { const result = await this.transportServices.messages.getAttachmentMetadata({ id, attachmentId }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/OutgoingRequestsController.ts b/src/modules/coreHttpApi/controllers/OutgoingRequestsController.ts index 011a5d0dd..9f6907635 100644 --- a/src/modules/coreHttpApi/controllers/OutgoingRequestsController.ts +++ b/src/modules/coreHttpApi/controllers/OutgoingRequestsController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { ConsumptionServices } from "@nmshd/runtime"; +import { ConsumptionServices, LocalRequestDTO, RequestValidationResultDTO } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, Context, GET, Path, PathParam, POST, Return, Security, ServiceContext } from "@nmshd/typescript-rest"; @@ -13,14 +13,14 @@ export class OutgoingRequestsController extends BaseController { @POST @Path("/Validate") @Accept("application/json") - public async canCreate(request: any): Promise> { + public async canCreate(request: any): Promise>> { const result = await this.consumptionServices.outgoingRequests.canCreate(request); return this.created(result); } @POST @Accept("application/json") - public async create(request: any): Promise> { + public async create(request: any): Promise>> { const result = await this.consumptionServices.outgoingRequests.create(request); return this.created(result); } @@ -28,14 +28,14 @@ export class OutgoingRequestsController extends BaseController { @GET @Path("/:id") @Accept("application/json") - public async getRequest(@PathParam("id") id: string): Promise { + public async getRequest(@PathParam("id") id: string): Promise> { const result = await this.consumptionServices.outgoingRequests.getRequest({ id }); return this.ok(result); } @GET @Accept("application/json") - public async getRequests(@Context context: ServiceContext): Promise { + public async getRequests(@Context context: ServiceContext): Promise> { const result = await this.consumptionServices.outgoingRequests.getRequests({ query: context.request.query }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/RelationshipTemplatesController.ts b/src/modules/coreHttpApi/controllers/RelationshipTemplatesController.ts index c1cc3e6fc..97db0189f 100644 --- a/src/modules/coreHttpApi/controllers/RelationshipTemplatesController.ts +++ b/src/modules/coreHttpApi/controllers/RelationshipTemplatesController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { OwnerRestriction, TransportServices } from "@nmshd/runtime"; +import { OwnerRestriction, RelationshipTemplateDTO, TokenDTO, TransportServices } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, Context, ContextAccept, ContextResponse, DELETE, GET, POST, Path, PathParam, Return, Security, ServiceContext } from "@nmshd/typescript-rest"; import express from "express"; @@ -12,7 +12,7 @@ export class RelationshipTemplatesController extends BaseController { } @GET - public async getTemplates(@Context context: ServiceContext): Promise { + public async getTemplates(@Context context: ServiceContext): Promise> { const result = await this.transportServices.relationshipTemplates.getRelationshipTemplates({ query: context.request.query }); @@ -22,7 +22,7 @@ export class RelationshipTemplatesController extends BaseController { @GET @Path("/Own") @Accept("application/json") - public async getOwnTemplates(@Context context: ServiceContext): Promise { + public async getOwnTemplates(@Context context: ServiceContext): Promise> { const result = await this.transportServices.relationshipTemplates.getRelationshipTemplates({ query: context.request.query, ownerRestriction: OwnerRestriction.Own @@ -33,7 +33,7 @@ export class RelationshipTemplatesController extends BaseController { @GET @Path("/Peer") @Accept("application/json") - public async getPeerTemplates(@Context context: ServiceContext): Promise { + public async getPeerTemplates(@Context context: ServiceContext): Promise> { const result = await this.transportServices.relationshipTemplates.getRelationshipTemplates({ query: context.request.query, ownerRestriction: OwnerRestriction.Peer @@ -44,7 +44,11 @@ export class RelationshipTemplatesController extends BaseController { @GET @Path("/:id") @Accept("application/json", "image/png") - public async getRelationshipTemplate(@PathParam("id") id: string, @ContextAccept accept: string, @ContextResponse response: express.Response): Promise { + public async getRelationshipTemplate( + @PathParam("id") id: string, + @ContextAccept accept: string, + @ContextResponse response: express.Response + ): Promise | void> { const result = await this.transportServices.relationshipTemplates.getRelationshipTemplate({ id }); switch (accept) { @@ -58,7 +62,7 @@ export class RelationshipTemplatesController extends BaseController { @POST @Path("/Own") @Accept("application/json") - public async createOwnTemplate(request: any): Promise> { + public async createOwnTemplate(request: any): Promise>> { const result = await this.transportServices.relationshipTemplates.createOwnRelationshipTemplate(request); return this.created(result); } @@ -66,7 +70,7 @@ export class RelationshipTemplatesController extends BaseController { @POST @Path("/Peer") @Accept("application/json") - public async loadPeerTemplate(request: any): Promise> { + public async loadPeerTemplate(request: any): Promise>> { const result = await this.transportServices.relationshipTemplates.loadPeerRelationshipTemplate(request); return this.created(result); } @@ -86,7 +90,7 @@ export class RelationshipTemplatesController extends BaseController { @ContextAccept accept: string, @ContextResponse response: express.Response, request: any - ): Promise | void> { + ): Promise> | void> { const result = await this.transportServices.relationshipTemplates.createTokenForOwnRelationshipTemplate({ templateId: id, expiresAt: request.expiresAt, diff --git a/src/modules/coreHttpApi/controllers/RelationshipsController.ts b/src/modules/coreHttpApi/controllers/RelationshipsController.ts index 0ce0a06a2..d6759b4f4 100644 --- a/src/modules/coreHttpApi/controllers/RelationshipsController.ts +++ b/src/modules/coreHttpApi/controllers/RelationshipsController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { TransportServices } from "@nmshd/runtime"; +import { CanCreateRelationshipResponse, GetAttributesForRelationshipResponse, RelationshipDTO, TransportServices } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, Context, DELETE, GET, Path, PathParam, POST, PUT, Return, Security, ServiceContext } from "@nmshd/typescript-rest"; @@ -13,14 +13,14 @@ export class RelationshipsController extends BaseController { @PUT @Path("CanCreate") @Accept("application/json") - public async canCreateRelationship(request: any): Promise { + public async canCreateRelationship(request: any): Promise> { const result = await this.transportServices.relationships.canCreateRelationship(request); return this.ok(result); } @POST @Accept("application/json") - public async createRelationship(request: any): Promise> { + public async createRelationship(request: any): Promise>> { const result = await this.transportServices.relationships.createRelationship(request); return this.created(result); } @@ -28,7 +28,7 @@ export class RelationshipsController extends BaseController { @PUT @Path("/:id/Accept") @Accept("application/json") - public async acceptRelationship(@PathParam("id") id: string): Promise { + public async acceptRelationship(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.acceptRelationship({ relationshipId: id }); @@ -38,7 +38,7 @@ export class RelationshipsController extends BaseController { @PUT @Path("/:id/Reject") @Accept("application/json") - public async rejectRelationship(@PathParam("id") id: string): Promise { + public async rejectRelationship(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.rejectRelationship({ relationshipId: id }); @@ -48,7 +48,7 @@ export class RelationshipsController extends BaseController { @PUT @Path("/:id/Revoke") @Accept("application/json") - public async revokeRelationship(@PathParam("id") id: string): Promise { + public async revokeRelationship(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.revokeRelationship({ relationshipId: id }); @@ -57,7 +57,7 @@ export class RelationshipsController extends BaseController { @GET @Accept("application/json") - public async getRelationships(@Context context: ServiceContext): Promise { + public async getRelationships(@Context context: ServiceContext): Promise> { const result = await this.transportServices.relationships.getRelationships({ query: context.request.query }); @@ -67,7 +67,7 @@ export class RelationshipsController extends BaseController { @GET @Path("/:id") @Accept("application/json") - public async getRelationship(@PathParam("id") id: string): Promise { + public async getRelationship(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.getRelationship({ id }); return this.ok(result); } @@ -75,7 +75,7 @@ export class RelationshipsController extends BaseController { @GET @Path("/:id/Attributes") @Accept("application/json") - public async getAttributesForRelationship(@PathParam("id") id: string): Promise { + public async getAttributesForRelationship(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.getAttributesForRelationship({ id }); return this.ok(result); } @@ -83,7 +83,7 @@ export class RelationshipsController extends BaseController { @PUT @Path("/:id/Terminate") @Accept("application/json") - public async terminateRelationship(@PathParam("id") id: string): Promise { + public async terminateRelationship(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.terminateRelationship({ relationshipId: id }); return this.ok(result); } @@ -99,7 +99,7 @@ export class RelationshipsController extends BaseController { @PUT @Path("/:id/Reactivate") @Accept("application/json") - public async requestRelationshipReactivation(@PathParam("id") id: string): Promise { + public async requestRelationshipReactivation(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.requestRelationshipReactivation({ relationshipId: id }); return this.ok(result); } @@ -107,7 +107,7 @@ export class RelationshipsController extends BaseController { @PUT @Path("/:id/Reactivate/Accept") @Accept("application/json") - public async acceptRelationshipReactivation(@PathParam("id") id: string): Promise { + public async acceptRelationshipReactivation(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.acceptRelationshipReactivation({ relationshipId: id }); return this.ok(result); } @@ -115,7 +115,7 @@ export class RelationshipsController extends BaseController { @PUT @Path("/:id/Reactivate/Reject") @Accept("application/json") - public async rejectRelationshipReactivation(@PathParam("id") id: string): Promise { + public async rejectRelationshipReactivation(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.rejectRelationshipReactivation({ relationshipId: id }); return this.ok(result); } @@ -123,7 +123,7 @@ export class RelationshipsController extends BaseController { @PUT @Path("/:id/Reactivate/Revoke") @Accept("application/json") - public async revokeRelationshipReactivation(@PathParam("id") id: string): Promise { + public async revokeRelationshipReactivation(@PathParam("id") id: string): Promise> { const result = await this.transportServices.relationships.revokeRelationshipReactivation({ relationshipId: id }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/TokensController.ts b/src/modules/coreHttpApi/controllers/TokensController.ts index c76c49b29..38bca82ea 100644 --- a/src/modules/coreHttpApi/controllers/TokensController.ts +++ b/src/modules/coreHttpApi/controllers/TokensController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { OwnerRestriction, TransportServices } from "@nmshd/runtime"; +import { OwnerRestriction, TokenDTO, TransportServices } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, Context, ContextAccept, ContextResponse, DELETE, GET, Path, PathParam, POST, Return, Security, ServiceContext } from "@nmshd/typescript-rest"; import express from "express"; @@ -14,7 +14,7 @@ export class TokensController extends BaseController { @POST @Path("/Own") @Accept("application/json") - public async createOwnToken(request: any): Promise> { + public async createOwnToken(request: any): Promise>> { request.ephemeral ??= false; const result = await this.transportServices.tokens.createOwnToken(request); return this.created(result); @@ -23,7 +23,7 @@ export class TokensController extends BaseController { @POST @Path("/Peer") @Accept("application/json") - public async loadPeerToken(request: any): Promise> { + public async loadPeerToken(request: any): Promise>> { request.ephemeral ??= false; const result = await this.transportServices.tokens.loadPeerToken(request); return this.created(result); @@ -32,7 +32,7 @@ export class TokensController extends BaseController { @GET @Path("/Own") @Accept("application/json") - public async getOwnTokens(@Context context: ServiceContext): Promise { + public async getOwnTokens(@Context context: ServiceContext): Promise> { const result = await this.transportServices.tokens.getTokens({ query: context.request.query, ownerRestriction: OwnerRestriction.Own @@ -43,7 +43,7 @@ export class TokensController extends BaseController { @GET @Path("/Peer") @Accept("application/json") - public async getPeerTokens(@Context context: ServiceContext): Promise { + public async getPeerTokens(@Context context: ServiceContext): Promise> { const result = await this.transportServices.tokens.getTokens({ query: context.request.query, ownerRestriction: OwnerRestriction.Peer @@ -61,7 +61,7 @@ export class TokensController extends BaseController { @GET @Path("/:id") @Accept("application/json", "image/png") - public async getToken(@PathParam("id") id: string, @ContextAccept accept: string, @ContextResponse response: express.Response): Promise { + public async getToken(@PathParam("id") id: string, @ContextAccept accept: string, @ContextResponse response: express.Response): Promise | void> { const result = await this.transportServices.tokens.getToken({ id }); switch (accept) { diff --git a/src/modules/coreHttpApi/debug-controllers/IdentityDeletionProcessController.ts b/src/modules/coreHttpApi/debug-controllers/IdentityDeletionProcessController.ts index 4a09446f3..e99762ca4 100644 --- a/src/modules/coreHttpApi/debug-controllers/IdentityDeletionProcessController.ts +++ b/src/modules/coreHttpApi/debug-controllers/IdentityDeletionProcessController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope } from "@nmshd/connector-types"; -import { TransportServices } from "@nmshd/runtime"; +import { IdentityDeletionProcessDTO, TransportServices } from "@nmshd/runtime"; import { Inject } from "@nmshd/typescript-ioc"; import { Accept, DELETE, GET, Path, POST, QueryParam, Security } from "@nmshd/typescript-rest"; @@ -12,21 +12,21 @@ export class IdentityDeletionProcessController extends BaseController { @POST @Accept("application/json") - public async initiateIdentityDeletionProcess(@QueryParam("lengthOfGracePeriodInDays") lengthOfGracePeriodInDays?: number): Promise { + public async initiateIdentityDeletionProcess(@QueryParam("lengthOfGracePeriodInDays") lengthOfGracePeriodInDays?: number): Promise> { const result = await this.transportServices.identityDeletionProcesses.initiateIdentityDeletionProcess({ lengthOfGracePeriodInDays }); return this.ok(result); } @GET @Accept("application/json") - public async getActiveIdentityDeletionProcess(): Promise { + public async getActiveIdentityDeletionProcess(): Promise> { const result = await this.transportServices.identityDeletionProcesses.getActiveIdentityDeletionProcess(); return this.ok(result); } @DELETE @Accept("application/json") - public async cancelIdentityDeletionProcess(): Promise { + public async cancelIdentityDeletionProcess(): Promise> { const result = await this.transportServices.identityDeletionProcesses.cancelIdentityDeletionProcess(); return this.ok(result); }