Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove object loading by id and key #281

Merged
merged 13 commits into from
Sep 23, 2024
4 changes: 1 addition & 3 deletions packages/app-runtime/src/AppStringProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ export class AppStringProcessor {
return UserfriendlyResult.fail(error);
}

const tokenResult = await this.runtime.anonymousServices.tokens.loadPeerTokenByTruncatedReference({
reference: truncatedReference
});
const tokenResult = await this.runtime.anonymousServices.tokens.loadPeerToken({ reference: truncatedReference });
if (tokenResult.isError) {
return UserfriendlyResult.fail(UserfriendlyApplicationError.fromError(tokenResult.error));
}
Expand Down
1 change: 0 additions & 1 deletion packages/runtime/src/dataViews/transport/FileDVO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ export interface FileDVO extends DataViewObject {
mimetype: string;
isOwn: boolean;
title: string;
secretKey: string;
truncatedReference: string;
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import { ApplicationError, Result } from "@js-soft/ts-utils";
import { Inject } from "typescript-ioc";
import { TokenDTO } from "../../../types";
import {
LoadPeerTokenAnonymousByIdAndKeyRequest,
LoadPeerTokenAnonymousByIdAndKeyUseCase,
LoadPeerTokenAnonymousByTruncatedReferenceRequest,
LoadPeerTokenAnonymousByTruncatedReferenceUseCase
} from "../../../useCases";
import { LoadPeerTokenAnonymousRequest, LoadPeerTokenAnonymousUseCase } from "../../../useCases";

export class AnonymousTokensFacade {
public constructor(
@Inject private readonly loadPeerTokenByTruncatedReferenceUseCase: LoadPeerTokenAnonymousByTruncatedReferenceUseCase,
@Inject private readonly loadPeerTokenByIdAndKeyUseCase: LoadPeerTokenAnonymousByIdAndKeyUseCase
) {}
public constructor(@Inject private readonly loadPeerTokenUseCase: LoadPeerTokenAnonymousUseCase) {}

public async loadPeerTokenByTruncatedReference(request: LoadPeerTokenAnonymousByTruncatedReferenceRequest): Promise<Result<TokenDTO, ApplicationError>> {
return await this.loadPeerTokenByTruncatedReferenceUseCase.execute(request);
}

public async loadPeerTokenByIdAndKey(request: LoadPeerTokenAnonymousByIdAndKeyRequest): Promise<Result<TokenDTO, ApplicationError>> {
return await this.loadPeerTokenByIdAndKeyUseCase.execute(request);
public async loadPeerToken(request: LoadPeerTokenAnonymousRequest): Promise<Result<TokenDTO, ApplicationError>> {
return await this.loadPeerTokenUseCase.execute(request);
}
}
1 change: 0 additions & 1 deletion packages/runtime/src/types/transport/FileDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface FileDTO {
mimetype: string;
isOwn: boolean;
title: string;
secretKey: string;
description?: string;
truncatedReference: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ export interface RelationshipTemplateDTO {
content: RelationshipTemplateContentDerivation;
expiresAt?: string;
maxNumberOfAllocations?: number;
secretKey: string;
truncatedReference: string;
}
1 change: 0 additions & 1 deletion packages/runtime/src/types/transport/TokenDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export interface TokenDTO {
content: any;
createdAt: string;
expiresAt: string;
secretKey: string;
truncatedReference: string;
isEphemeral: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ import { TokenDTO } from "../../../types";
import { SchemaRepository, SchemaValidator, TokenReferenceString, UseCase } from "../../common";
import { TokenMapper } from "../../transport/tokens/TokenMapper";

export interface LoadPeerTokenAnonymousByTruncatedReferenceRequest {
export interface LoadPeerTokenAnonymousRequest {
reference: TokenReferenceString;
}

class Validator extends SchemaValidator<LoadPeerTokenAnonymousByTruncatedReferenceRequest> {
class Validator extends SchemaValidator<LoadPeerTokenAnonymousRequest> {
public constructor(@Inject schemaRepository: SchemaRepository) {
super(schemaRepository.getSchema("LoadPeerTokenAnonymousByTruncatedReferenceRequest"));
super(schemaRepository.getSchema("LoadPeerTokenAnonymousRequest"));
}
}

export class LoadPeerTokenAnonymousByTruncatedReferenceUseCase extends UseCase<LoadPeerTokenAnonymousByTruncatedReferenceRequest, TokenDTO> {
export class LoadPeerTokenAnonymousUseCase extends UseCase<LoadPeerTokenAnonymousRequest, TokenDTO> {
public constructor(
@Inject private readonly anonymousTokenController: AnonymousTokenController,
@Inject validator: Validator
) {
super(validator);
}

protected async executeInternal(request: LoadPeerTokenAnonymousByTruncatedReferenceRequest): Promise<Result<TokenDTO>> {
protected async executeInternal(request: LoadPeerTokenAnonymousRequest): Promise<Result<TokenDTO>> {
const createdToken = await this.anonymousTokenController.loadPeerTokenByTruncated(request.reference);
return Result.ok(TokenMapper.toTokenDTO(createdToken, true));
}
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions packages/runtime/src/useCases/anonymous/tokens/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from "./LoadPeerTokenAnonymousByIdAndKey";
export * from "./LoadPeerTokenAnonymousByTruncatedReference";
export * from "./LoadPeerTokenAnonymous";
Loading