Skip to content

Commit

Permalink
fix(cockpit): compilation issues hyperledger-cacti#496
Browse files Browse the repository at this point in the history
The full build with frontend components included are now working
once again.

1. The cockpit components no longer depend on the api-client package
shipping the standard typescript-axios client types such as DefaultApi,
Configuration and the likes. This is because we hollowed out the
client-api package to only contain the extensions to these generated
types mentioned above (provided via typescript-axios OpenAPI generator)

This is part of a larger ongoing effort where we decoupled the api-client
and the cmd-api-server packages where earlier there was some tangling
between the two in the form of the cmd-api-server exporting it's
openapi spec onto the api-client package which in hindsight didn't
make much sense to be honest. Mistakes were made, but now are being
fixed.

2. A related, but not strictly necessary, cleanup type of change is that
we also deleted the remnants of the generated code from the api-client
package, e.g. the whole ./generated/openapi/typescrit-axios/ folder is
now gone properly (it didn't have any actual Typescript code at this
point anyway due to the ongoing changes on other works streams
that were pointed out above as well.)

Fixes hyperledger-cacti#496

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Jan 15, 2021
1 parent cd50124 commit 06bfd88
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import {
LogLevelDesc,
LoggerProvider,
} from "@hyperledger/cactus-common";

import { Checks, IAsyncProvider } from "@hyperledger/cactus-common";
import { ConsortiumDatabase } from "@hyperledger/cactus-core-api";

import {
DefaultApi,
DefaultApi as ConsortiumManualApi,
GetConsortiumJwsResponse,
} from "@hyperledger/cactus-plugin-consortium-manual";

export interface IDefaultConsortiumProviderOptions {
logLevel?: LogLevelDesc;
apiClient: DefaultApi;
apiClient: ConsortiumManualApi;
}

export class DefaultConsortiumProvider
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AddressInfo } from "net";
import test, { Test } from "tape";

// import { ApiClient } from "../../../main/typescript/public-api";
import { DefaultApi as ConsortiumApi } from "@hyperledger/cactus-plugin-consortium-manual";
import { DefaultApi as ConsortiumManualApi } from "@hyperledger/cactus-plugin-consortium-manual";
import { LogLevelDesc, Servers } from "@hyperledger/cactus-common";
import { DefaultConsortiumProvider } from "../../../main/typescript";

Expand All @@ -18,7 +18,7 @@ test("Reports failures with meaningful information", async (t: Test) => {

const provider = new DefaultConsortiumProvider({
logLevel,
apiClient: new ConsortiumApi({
apiClient: new ConsortiumManualApi({
basePath: apiHost,
baseOptions: {
timeout: 100,
Expand All @@ -45,7 +45,7 @@ test("Reports failures with meaningful information", async (t: Test) => {
test("Handles 4xx transparently", async (t2: Test) => {
const provider = new DefaultConsortiumProvider({
logLevel,
apiClient: new ConsortiumApi({
apiClient: new ConsortiumManualApi({
basePath: "https://httpbin.org/status/400",
}),
});
Expand Down
17 changes: 1 addition & 16 deletions packages/cactus-cockpit/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { SplashScreen } from "@ionic-native/splash-screen/ngx";
import { StatusBar } from "@ionic-native/status-bar/ngx";

import { LoggerProvider, Logger } from "@hyperledger/cactus-common";
import { DefaultApi as DefaultApiConsortium } from "@hyperledger/cactus-plugin-consortium-manual";
import { ApiClient, Configuration } from "@hyperledger/cactus-api-client";
import { CACTUS_API_URL } from "src/constants";

@Component({
Expand Down Expand Up @@ -48,18 +46,5 @@ export class AppComponent implements OnInit {
});
}

ngOnInit() {
this.testApi();
}

async testApi(): Promise<void> {
const configuration = new Configuration({ basePath: this.cactusApiUrl });
const apiClient = new ApiClient(configuration).extendWith(
DefaultApiConsortium
);
const res = await apiClient.getNodeJws();
const resHealthCheck = await apiClient.apiV1ApiServerHealthcheckGet();
this.log.info(`ConsortiumNodeJwtGet`, res.data);
this.log.info(`ApiServer HealthCheck Get:`, resHealthCheck.data);
}
ngOnInit() {}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { Component, Inject } from "@angular/core";
import { CACTUS_API_URL } from "src/constants";
import * as JwtDecode from "jwt-decode";

import {
Logger,
LoggerProvider,
ILoggerOptions,
} from "@hyperledger/cactus-common";
import { Configuration, ApiClient } from "@hyperledger/cactus-api-client";

import { ApiClient } from "@hyperledger/cactus-api-client";

import {
DefaultApi as PluginConsortiumManualApi,
Configuration,
DefaultApi as ConsortiumManualApi,
JWSGeneral,
} from "@hyperledger/cactus-plugin-consortium-manual";
import * as JwtDecode from "jwt-decode";

import { CACTUS_API_URL } from "src/constants";

@Component({
selector: "app-folder",
Expand Down Expand Up @@ -44,13 +49,8 @@ export class ConsortiumInspectorPage {

async onBtnClickInspect(): Promise<void> {
this.log.debug(`onBtnClickInspect() apiHost=${this.apiHost}`);
const configuration = new Configuration({ basePath: this.cactusApiUrl });
const apiClient = new ApiClient(configuration).extendWith(
PluginConsortiumManualApi
);

const resHealthCheck = await apiClient.apiV1ApiServerHealthcheckGet();
this.log.debug(`ApiServer HealthCheck Get:`, resHealthCheck.data);
const config = new Configuration({ basePath: this.cactusApiUrl });
const apiClient = new ApiClient(config).extendWith(ConsortiumManualApi);

const res = await apiClient.getConsortiumJws();
this.jws = res.data.jws;
Expand Down

0 comments on commit 06bfd88

Please sign in to comment.