From dd712db1edacdc4238233df64b508fc6a59b2a41 Mon Sep 17 00:00:00 2001 From: Sebastian Mahr Date: Tue, 28 Oct 2025 08:54:27 +0100 Subject: [PATCH 1/2] Add type-parameter to Envelope and BaseController --- .../src/infrastructure/httpServer/BaseController.ts | 12 ++++++------ .../src/infrastructure/httpServer/common/Envelope.ts | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/types/src/infrastructure/httpServer/BaseController.ts b/packages/types/src/infrastructure/httpServer/BaseController.ts index fba808ea8..c060cb6d2 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..290002269 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")); From a28c2e0f236a665028c9162047051a3adbb98266 Mon Sep 17 00:00:00 2001 From: Sebastian Mahr Date: Tue, 28 Oct 2025 09:12:38 +0100 Subject: [PATCH 2/2] add type parameter to controller methods return type --- .../controllers/AccountController.ts | 6 +- .../controllers/AnnouncementsController.ts | 4 +- .../controllers/AttributesController.ts | 66 ++++++++++++------- .../controllers/ChallengesController.ts | 6 +- .../controllers/FilesController.ts | 18 ++--- .../controllers/IdentityMetadataController.ts | 6 +- .../controllers/IncomingRequestsController.ts | 14 ++-- .../controllers/MessagesController.ts | 10 +-- .../controllers/OutgoingRequestsController.ts | 10 +-- .../RelationshipTemplatesController.ts | 16 ++--- .../controllers/RelationshipsController.ts | 28 ++++---- .../controllers/TokensController.ts | 12 ++-- .../IdentityDeletionProcessController.ts | 8 +-- 13 files changed, 112 insertions(+), 92 deletions(-) diff --git a/src/modules/coreHttpApi/controllers/AccountController.ts b/src/modules/coreHttpApi/controllers/AccountController.ts index 6ec8cffe5..55356d956 100644 --- a/src/modules/coreHttpApi/controllers/AccountController.ts +++ b/src/modules/coreHttpApi/controllers/AccountController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole } 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 e65d1ef04..2aaadce57 100644 --- a/src/modules/coreHttpApi/controllers/AnnouncementsController.ts +++ b/src/modules/coreHttpApi/controllers/AnnouncementsController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole } 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 1dfc2b28b..57b5b87c9 100644 --- a/src/modules/coreHttpApi/controllers/AttributesController.ts +++ b/src/modules/coreHttpApi/controllers/AttributesController.ts @@ -1,7 +1,19 @@ import { BaseController, Envelope, HttpServerRole } from "@nmshd/connector-types"; -import { ConsumptionServices, RuntimeErrors } from "@nmshd/runtime"; +import { IValidateResult } from "@nmshd/iql"; +import { + AttributeTagCollectionDTO, + CanCreateRepositoryAttributeResponse, + ConsumptionServices, + DeleteOwnSharedAttributeAndNotifyPeerResponse, + DeletePeerSharedAttributeAndNotifyOwnerResponse, + DeleteThirdPartyRelationshipAttributeAndNotifyPeerResponse, + LocalAttributeDTO, + NotifyPeerAboutRepositoryAttributeSuccessionResponse, + RuntimeErrors, + SucceedRepositoryAttributeResponse +} 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([HttpServerRole.ADMIN, "core:*", "core:attributes"]) @Path("/api/v2/Attributes") @@ -13,14 +25,14 @@ export class AttributesController extends BaseController { @PUT @Path("CanCreate") @Accept("application/json") - public async canCreateRepositoryAttribute(request: any): Promise { + public async canCreateRepositoryAttribute(request: any): Promise> { const result = await this.consumptionServices.attributes.canCreateRepositoryAttribute(request); return this.ok(result); } @POST @Accept("application/json") - public async createRepositoryAttribute(request: any): Promise> { + public async createRepositoryAttribute(request: any): Promise>> { const result = await this.consumptionServices.attributes.createRepositoryAttribute(request); return this.created(result); } @@ -28,7 +40,7 @@ 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 +66,17 @@ export class AttributesController extends BaseController { @POST @Path("/:id/NotifyPeer") @Accept("application/json") - public async notifyPeerAboutRepositoryAttributeSuccession(@PathParam("id") attributeId: string, request: any): Promise> { + public async notifyPeerAboutRepositoryAttributeSuccession( + @PathParam("id") attributeId: string, + request: any + ): Promise>> { const result = await this.consumptionServices.attributes.notifyPeerAboutRepositoryAttributeSuccession({ 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 +84,10 @@ export class AttributesController extends BaseController { @GET @Path("/Own/Repository") @Accept("application/json") - public async getOwnRepositoryAttributes(@Context context: ServiceContext, @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean): Promise { + public async getOwnRepositoryAttributes( + @Context context: ServiceContext, + @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean + ): Promise> { const query: Record = this.extractQuery(context.request.query, ["onlyLatestVersions"]); const result = await this.consumptionServices.attributes.getRepositoryAttributes({ onlyLatestVersions, query }); return this.ok(result); @@ -84,7 +102,7 @@ export class AttributesController extends BaseController { @QueryParam("hideTechnical") hideTechnical?: boolean, @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean, @QueryParam("onlyValid") onlyValid?: boolean - ): Promise { + ): Promise> { const query: Record = this.extractQuery(context.request.query, ["peer", "hideTechnical", "onlyLatestVersions", "onlyValid"]); const result = await this.consumptionServices.attributes.getOwnSharedAttributes({ peer, hideTechnical, query, onlyLatestVersions, onlyValid }); return this.ok(result); @@ -99,7 +117,7 @@ export class AttributesController extends BaseController { @QueryParam("hideTechnical") hideTechnical?: boolean, @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean, @QueryParam("onlyValid") onlyValid?: boolean - ): Promise { + ): Promise> { const query: Record = this.extractQuery(context.request.query, ["peer", "hideTechnical", "onlyLatestVersions", "onlyValid"]); const result = await this.consumptionServices.attributes.getPeerSharedAttributes({ peer, hideTechnical, query, onlyLatestVersions, onlyValid }); @@ -109,7 +127,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 }); @@ -123,7 +141,7 @@ export class AttributesController extends BaseController { @PathParam("id") attributeId: string, @QueryParam("peers") peers?: string | string[], @QueryParam("onlyLatestVersions") onlyLatestVersions?: boolean - ): Promise { + ): Promise> { if (typeof peers === "string") { peers = [peers]; } @@ -135,7 +153,7 @@ export class AttributesController extends BaseController { @GET @Path("/Valid") @Accept("application/json") - public async getValidAttributes(@Context context: ServiceContext): Promise { + public async getValidAttributes(@Context context: ServiceContext): Promise> { const result = await this.consumptionServices.attributes.getAttributes({ query: context.request.query, onlyValid: true }); return this.ok(result); } @@ -143,7 +161,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); } @@ -151,7 +169,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); } @@ -159,7 +177,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); } @@ -167,7 +185,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); } @@ -175,7 +193,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); } @@ -183,7 +201,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); } @@ -191,28 +209,30 @@ 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("/Own/Shared/:id") - public async deleteOwnSharedAttributeAndNotifyPeer(@PathParam("id") attributeId: string): Promise { + public async deleteOwnSharedAttributeAndNotifyPeer(@PathParam("id") attributeId: string): Promise> { const result = await this.consumptionServices.attributes.deleteOwnSharedAttributeAndNotifyPeer({ attributeId }); return this.ok(result); } @DELETE @Path("/Peer/Shared/:id") - public async deletePeerSharedAttributeAndNotifyOwner(@PathParam("id") attributeId: string): Promise { + public async deletePeerSharedAttributeAndNotifyOwner(@PathParam("id") attributeId: string): Promise> { const result = await this.consumptionServices.attributes.deletePeerSharedAttributeAndNotifyOwner({ attributeId }); return this.ok(result); } @DELETE @Path("/ThirdParty/:id") - public async deleteThirdPartyRelationshipAttributeAndNotifyPeer(@PathParam("id") attributeId: string): Promise { + public async deleteThirdPartyRelationshipAttributeAndNotifyPeer( + @PathParam("id") attributeId: string + ): Promise> { const result = await this.consumptionServices.attributes.deleteThirdPartyRelationshipAttributeAndNotifyPeer({ attributeId }); return this.ok(result); } diff --git a/src/modules/coreHttpApi/controllers/ChallengesController.ts b/src/modules/coreHttpApi/controllers/ChallengesController.ts index 731226422..f1d76af32 100644 --- a/src/modules/coreHttpApi/controllers/ChallengesController.ts +++ b/src/modules/coreHttpApi/controllers/ChallengesController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole } 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 579125839..47787e330 100644 --- a/src/modules/coreHttpApi/controllers/FilesController.ts +++ b/src/modules/coreHttpApi/controllers/FilesController.ts @@ -1,6 +1,6 @@ import { BaseController, Envelope, HttpServerRole, Mimetype, QRCode } 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, @@ -38,7 +38,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, @@ -54,7 +54,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); } @@ -76,7 +76,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); } @@ -84,7 +84,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); } @@ -92,7 +92,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); } @@ -105,7 +105,7 @@ export class FilesController extends BaseController { @ContextAccept accept: string, @ContextResponse response: express.Response, @QueryParam("newQRCodeFormat") newQRCodeFormat?: boolean - ): Promise { + ): Promise | void> { const fileId = idOrReference.startsWith("FIL") ? idOrReference : Reference.from(idOrReference).id.toString(); const result = await this.transportServices.files.getFile({ id: fileId }); @@ -126,7 +126,7 @@ export class FilesController extends BaseController { @ContextAccept accept: string, @ContextResponse response: express.Response, request: any - ): Promise | void> { + ): Promise>> { const newQRCodeFormat = request["newQRCodeFormat"] === true; delete request["newQRCodeFormat"]; @@ -155,7 +155,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 fbc561032..d2595bf39 100644 --- a/src/modules/coreHttpApi/controllers/IdentityMetadataController.ts +++ b/src/modules/coreHttpApi/controllers/IdentityMetadataController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole } 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 6f040cbc0..8c7fd066e 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, HttpServerRole } 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 70c24a4ac..267ef9625 100644 --- a/src/modules/coreHttpApi/controllers/MessagesController.ts +++ b/src/modules/coreHttpApi/controllers/MessagesController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole, 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 423ae8a8c..e5cf9f62a 100644 --- a/src/modules/coreHttpApi/controllers/OutgoingRequestsController.ts +++ b/src/modules/coreHttpApi/controllers/OutgoingRequestsController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole } 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 76413a037..529c31439 100644 --- a/src/modules/coreHttpApi/controllers/RelationshipTemplatesController.ts +++ b/src/modules/coreHttpApi/controllers/RelationshipTemplatesController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole, QRCode } 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, GET, POST, Path, PathParam, QueryParam, 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 @@ -49,7 +49,7 @@ export class RelationshipTemplatesController extends BaseController { @ContextAccept accept: string, @ContextResponse response: express.Response, @QueryParam("newQRCodeFormat") newQRCodeFormat?: boolean - ): Promise { + ): Promise | void> { const result = await this.transportServices.relationshipTemplates.getRelationshipTemplate({ id }); switch (accept) { @@ -63,7 +63,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); } @@ -71,7 +71,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); } @@ -84,7 +84,7 @@ export class RelationshipTemplatesController extends BaseController { @ContextAccept accept: string, @ContextResponse response: express.Response, request: any - ): Promise | void> { + ): Promise> | void> { const newQRCodeFormat = request["newQRCodeFormat"] === true; delete request["newQRCodeFormat"]; diff --git a/src/modules/coreHttpApi/controllers/RelationshipsController.ts b/src/modules/coreHttpApi/controllers/RelationshipsController.ts index 9b8bc6709..ea8b38438 100644 --- a/src/modules/coreHttpApi/controllers/RelationshipsController.ts +++ b/src/modules/coreHttpApi/controllers/RelationshipsController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole } 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 ab36c78a0..d918f75f4 100644 --- a/src/modules/coreHttpApi/controllers/TokensController.ts +++ b/src/modules/coreHttpApi/controllers/TokensController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole, QRCode } 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, GET, Path, PathParam, POST, QueryParam, 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 @@ -59,7 +59,7 @@ export class TokensController extends BaseController { @ContextAccept accept: string, @ContextResponse response: express.Response, @QueryParam("newQRCodeFormat") newQRCodeFormat?: boolean - ): Promise { + ): 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 0e77d17e3..afd932c0b 100644 --- a/src/modules/coreHttpApi/debug-controllers/IdentityDeletionProcessController.ts +++ b/src/modules/coreHttpApi/debug-controllers/IdentityDeletionProcessController.ts @@ -1,5 +1,5 @@ import { BaseController, Envelope, HttpServerRole } 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); }