Skip to content

Commit

Permalink
chore: rename backbone attrubte tag
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbi08 committed Dec 3, 2024
1 parent 76bcb12 commit c30dd02
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "@nmshd/content";
import { CoreAddress, CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types";
import * as iql from "@nmshd/iql";
import { SynchronizedCollection, TagClient, TransportCoreErrors } from "@nmshd/transport";
import { AttributeTagClient, SynchronizedCollection, TransportCoreErrors } from "@nmshd/transport";
import _ from "lodash";
import { nameof } from "ts-simple-nameof";
import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController";
Expand Down Expand Up @@ -46,7 +46,7 @@ import { IdentityAttributeQueryTranslator, RelationshipAttributeQueryTranslator,

export class AttributesController extends ConsumptionBaseController {
private attributes: SynchronizedCollection;
private tagsClient: TagClient;
private tagsClient: AttributeTagClient;

public constructor(
parent: ConsumptionController,
Expand All @@ -61,7 +61,7 @@ export class AttributesController extends ConsumptionBaseController {
await super.init();

this.attributes = await this.parent.accountController.getSynchronizedCollection("Attributes");
this.tagsClient = new TagClient(this.parent.transport.config, this.parent.accountController.authenticator, this.parent.transport.correlator);
this.tagsClient = new AttributeTagClient(this.parent.transport.config, this.parent.accountController.authenticator, this.parent.transport.correlator);

return this;
}
Expand Down Expand Up @@ -1295,7 +1295,7 @@ export class AttributesController extends ConsumptionBaseController {
}

public async getAttributeTagCollection(): Promise<AttributeTagCollection> {
const backboneTagList = (await this.tagsClient.getTags()).value;
const backboneTagList = (await this.tagsClient.getBackboneAttributeTagCollection()).value;
return AttributeTagCollection.fromAny(backboneTagList);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ClientResult, TagClient } from "@nmshd/transport";
import { ClientResult, DefinedTagClient } from "@nmshd/transport";
import { reset, spy, when } from "ts-mockito";
import { RuntimeServiceProvider, TestRuntimeServices } from "../lib";

const serviceProvider = new RuntimeServiceProvider();
let runtimeService: TestRuntimeServices;

let mockedRestClient: TagClient;
let mockedRestClient: DefinedTagClient;

beforeAll(async () => {
runtimeService = (await serviceProvider.launch(1))[0];
const client = runtimeService.consumption.attributes["getAttributeTagCollectionUseCase"]["attributesController"]["tagsClient"] as TagClient;
const client = runtimeService.consumption.attributes["getAttributeTagCollectionUseCase"]["attributesController"]["tagsClient"] as DefinedTagClient;
mockedRestClient = spy(client);
}, 30000);

Expand Down Expand Up @@ -57,7 +57,7 @@ describe("get attributeTagCollection", function () {
/* eslint-enable @typescript-eslint/naming-convention */

test("should receive the legal tags from the Backbone", async function () {
when(mockedRestClient.getTags()).thenResolve(ClientResult.ok(mockTags));
when(mockedRestClient.getBackboneDefinedTags()).thenResolve(ClientResult.ok(mockTags));
const tags = await runtimeService.consumption.attributes.getAttributeTagCollection();

expect(tags.value).toStrictEqual(mockTags);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export interface BackboneDefinedTags {
export interface BackboneAttributeTagCollection {
supportedLanguages: string[];
tagsForAttributeValueTypes: Record<string, Record<string, BackboneTag>>;
tagsForAttributeValueTypes: Record<string, Record<string, BackboneAttributeTag>>;
}

interface BackboneTag {
interface BackboneAttributeTag {
displayNames: Record<string, string>;
children?: Record<string, BackboneTag>;
children?: Record<string, BackboneAttributeTag>;
}
8 changes: 4 additions & 4 deletions packages/transport/src/modules/tags/backbone/TagClient.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ClientResult } from "../../../core/backbone/ClientResult";
import { RESTClientAuthenticate } from "../../../core/backbone/RESTClientAuthenticate";
import { BackboneDefinedTags } from "./BackboneGetTag";
import { BackboneAttributeTagCollection } from "./BackboneGetTag";

export class TagClient extends RESTClientAuthenticate {
public async getTags(): Promise<ClientResult<BackboneDefinedTags>> {
return await this.get<BackboneDefinedTags>("/api/v1/Tags");
export class AttributeTagClient extends RESTClientAuthenticate {
public async getBackboneAttributeTagCollection(): Promise<ClientResult<BackboneAttributeTagCollection>> {
return await this.get<BackboneAttributeTagCollection>("/api/v1/Tags");
}
}

0 comments on commit c30dd02

Please sign in to comment.