Skip to content

Commit 06bfd88

Browse files
committed
fix(cockpit): compilation issues hyperledger-cacti#496
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 <[email protected]>
1 parent cd50124 commit 06bfd88

File tree

8 files changed

+19
-68
lines changed

8 files changed

+19
-68
lines changed

packages/cactus-api-client/src/main/typescript/default-consortium-provider.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ import {
33
LogLevelDesc,
44
LoggerProvider,
55
} from "@hyperledger/cactus-common";
6+
67
import { Checks, IAsyncProvider } from "@hyperledger/cactus-common";
78
import { ConsortiumDatabase } from "@hyperledger/cactus-core-api";
9+
810
import {
9-
DefaultApi,
11+
DefaultApi as ConsortiumManualApi,
1012
GetConsortiumJwsResponse,
1113
} from "@hyperledger/cactus-plugin-consortium-manual";
1214

1315
export interface IDefaultConsortiumProviderOptions {
1416
logLevel?: LogLevelDesc;
15-
apiClient: DefaultApi;
17+
apiClient: ConsortiumManualApi;
1618
}
1719

1820
export class DefaultConsortiumProvider

packages/cactus-api-client/src/main/typescript/generated/openapi/typescript-axios/.gitignore

-4
This file was deleted.

packages/cactus-api-client/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator-ignore

-26
This file was deleted.

packages/cactus-api-client/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES

-5
This file was deleted.

packages/cactus-api-client/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION

-1
This file was deleted.

packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AddressInfo } from "net";
33
import test, { Test } from "tape";
44

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

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

1919
const provider = new DefaultConsortiumProvider({
2020
logLevel,
21-
apiClient: new ConsortiumApi({
21+
apiClient: new ConsortiumManualApi({
2222
basePath: apiHost,
2323
baseOptions: {
2424
timeout: 100,
@@ -45,7 +45,7 @@ test("Reports failures with meaningful information", async (t: Test) => {
4545
test("Handles 4xx transparently", async (t2: Test) => {
4646
const provider = new DefaultConsortiumProvider({
4747
logLevel,
48-
apiClient: new ConsortiumApi({
48+
apiClient: new ConsortiumManualApi({
4949
basePath: "https://httpbin.org/status/400",
5050
}),
5151
});

packages/cactus-cockpit/src/app/app.component.ts

+1-16
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { SplashScreen } from "@ionic-native/splash-screen/ngx";
55
import { StatusBar } from "@ionic-native/status-bar/ngx";
66

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

1210
@Component({
@@ -48,18 +46,5 @@ export class AppComponent implements OnInit {
4846
});
4947
}
5048

51-
ngOnInit() {
52-
this.testApi();
53-
}
54-
55-
async testApi(): Promise<void> {
56-
const configuration = new Configuration({ basePath: this.cactusApiUrl });
57-
const apiClient = new ApiClient(configuration).extendWith(
58-
DefaultApiConsortium
59-
);
60-
const res = await apiClient.getNodeJws();
61-
const resHealthCheck = await apiClient.apiV1ApiServerHealthcheckGet();
62-
this.log.info(`ConsortiumNodeJwtGet`, res.data);
63-
this.log.info(`ApiServer HealthCheck Get:`, resHealthCheck.data);
64-
}
49+
ngOnInit() {}
6550
}

packages/cactus-cockpit/src/app/consortium-inspector/consortium-inspector.page.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import { Component, Inject } from "@angular/core";
2-
import { CACTUS_API_URL } from "src/constants";
2+
import * as JwtDecode from "jwt-decode";
3+
34
import {
45
Logger,
56
LoggerProvider,
67
ILoggerOptions,
78
} from "@hyperledger/cactus-common";
8-
import { Configuration, ApiClient } from "@hyperledger/cactus-api-client";
9+
10+
import { ApiClient } from "@hyperledger/cactus-api-client";
11+
912
import {
10-
DefaultApi as PluginConsortiumManualApi,
13+
Configuration,
14+
DefaultApi as ConsortiumManualApi,
1115
JWSGeneral,
1216
} from "@hyperledger/cactus-plugin-consortium-manual";
13-
import * as JwtDecode from "jwt-decode";
17+
18+
import { CACTUS_API_URL } from "src/constants";
1419

1520
@Component({
1621
selector: "app-folder",
@@ -44,13 +49,8 @@ export class ConsortiumInspectorPage {
4449

4550
async onBtnClickInspect(): Promise<void> {
4651
this.log.debug(`onBtnClickInspect() apiHost=${this.apiHost}`);
47-
const configuration = new Configuration({ basePath: this.cactusApiUrl });
48-
const apiClient = new ApiClient(configuration).extendWith(
49-
PluginConsortiumManualApi
50-
);
51-
52-
const resHealthCheck = await apiClient.apiV1ApiServerHealthcheckGet();
53-
this.log.debug(`ApiServer HealthCheck Get:`, resHealthCheck.data);
52+
const config = new Configuration({ basePath: this.cactusApiUrl });
53+
const apiClient = new ApiClient(config).extendWith(ConsortiumManualApi);
5454

5555
const res = await apiClient.getConsortiumJws();
5656
this.jws = res.data.jws;

0 commit comments

Comments
 (0)