Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit 6be4675

Browse files
Merge pull request #54 from solace-iot-team/mtn-var
Mtn var
2 parents 8cad027 + 7f82bd3 commit 6be4675

File tree

9 files changed

+110
-67
lines changed

9 files changed

+110
-67
lines changed

ReleaseNotes.md

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
Solace Async API Management.
44

5+
## Version 0.4.4
6+
7+
* [API-M Admin & Developer Portal](https://github.com/solace-iot-team/async-apim/tree/main/apim-portal): 0.4.4
8+
* [API-M Server OpenAPI](https://github.com/solace-iot-team/async-apim/blob/main/apim-server/server/common/api.yml): 0.4.0
9+
* [API-M Server](https://github.com/solace-iot-team/async-apim/tree/main/apim-server): 0.4.1
10+
* [API-M Connector OpenAPI](https://github.com/solace-iot-team/platform-api): 0.15.2
11+
12+
**Enhancements:**
13+
- **App:Credentials**
14+
- display credentials Id if provided
15+
16+
**Fixes:**
17+
- **Download zip file for Async Api**
18+
- fixed bug 'invalid url' when downloading the zip file
19+
520
## Version 0.4.3
621

722
* [API-M Admin & Developer Portal](https://github.com/solace-iot-team/async-apim/tree/main/apim-portal): 0.4.3

apim-portal/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apim-portal/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "async-apim-portal",
3-
"version": "0.4.3",
3+
"version": "0.4.4",
44
"description": "Solace Async API Management Portal",
55
"repository": {
66
"type": "git",
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"@asyncapi/react-component": "1.0.0-next.33",
27-
"@solace-iot-team/apim-connector-openapi-browser": "^0.15.0",
27+
"@solace-iot-team/apim-connector-openapi-browser": "^0.15.2",
2828
"async-mutex": "^0.3.2",
2929
"base-64": "^1.0.0",
3030
"dompurify": "^2.3.8",

apim-portal/src/components/APDisplayDeveloperPortalApp/APDisplayDeveloperPortalApp_Credentials.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export const APDisplayDeveloperPortalAppCredentials: React.FC<IAPDisplayDevelope
3939
}
4040
}
4141

42+
const idBodyTemplate = (row: TAPAppCredentialsDisplay): string => {
43+
return row.apCredentialsId;
44+
}
45+
4246
// const devel_connectorExpiresInBodyTemplate = (row: TAPAppCredentialsDisplay): JSX.Element => {
4347
// return (<div>{APDisplayUtils.convertMilliseconds(row.devel_connector_app_expires_in)}</div>);
4448
// }
@@ -53,6 +57,7 @@ export const APDisplayDeveloperPortalAppCredentials: React.FC<IAPDisplayDevelope
5357
// }
5458

5559
const renderComponentContent = (): JSX.Element => {
60+
const credentialsIdField = APAppsDisplayService.nameOf_ApAppCredentialsDisplay('apCredentialsId');
5661
const consumerKeyField = APAppsDisplayService.nameOf_ApAppCredentialsDisplay_Secret('consumerKey');
5762
const consumerSecretField = APAppsDisplayService.nameOf_ApAppCredentialsDisplay_Secret('consumerSecret');
5863
const expiresAtField = APAppsDisplayService.nameOf_ApAppCredentialsDisplay('expiresAt');
@@ -68,6 +73,7 @@ export const APDisplayDeveloperPortalAppCredentials: React.FC<IAPDisplayDevelope
6873
resizableColumns={true}
6974
columnResizeMode="fit"
7075
>
76+
<Column header="Id" body={idBodyTemplate} field={credentialsIdField} />
7177
<Column header="Consumer Key" field={consumerKeyField} />
7278
<Column header="Consumer Secret" field={consumerSecretField} />
7379
<Column header="Issued At" body={issuedAtBodyTemplate} field={issuedAtField} style={{ textAlign: 'center'}}/>

apim-portal/src/displayServices/APAppsDisplayService/APAppsDisplayService.ts

+4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export enum EAPApp_OwnerType {
5555
export type TAPOrganizationAppSettings = {
5656
apAppCredentialsExpiryDuration_millis: number;
5757
}
58+
export const CAP_Credentials_Id_Empty = "-";
5859
export type TAPAppCredentialsDisplay = {
60+
apCredentialsId: string; /** id of credentials */
5961
apConsumerKeyExiresIn: number; /** duration in millseconds */
6062
expiresAt: number; /** millis since epoch */
6163
issuedAt: CommonTimestampInteger; /** millis since epoch */
@@ -195,6 +197,7 @@ export class APAppsDisplayService {
195197
apOrganizationAppSettings: TAPOrganizationAppSettings;
196198
}): TAPAppCredentialsDisplay {
197199
return {
200+
apCredentialsId: CAP_Credentials_Id_Empty,
198201
expiresAt: -1,
199202
issuedAt: -1,
200203
secret: {
@@ -319,6 +322,7 @@ export class APAppsDisplayService {
319322
apAppCredentialsDisplay.secret.consumerSecret = connectorCredentials.secret.consumerSecret;
320323
}
321324
if(connectorAppResponse_expiresIn) apAppCredentialsDisplay.apConsumerKeyExiresIn = connectorAppResponse_expiresIn;
325+
if(connectorCredentials.name) apAppCredentialsDisplay.apCredentialsId = connectorCredentials.name;
322326
// devel:
323327
apAppCredentialsDisplay.devel_calculated_expiresAt = apAppCredentialsDisplay.issuedAt + apAppCredentialsDisplay.apConsumerKeyExiresIn;
324328
return apAppCredentialsDisplay;

apim-portal/src/utils/APClientRaw.ts

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {
2-
APSConnectorClientConfig
3-
} from "../_generated/@solace-iot-team/apim-server-openapi-browser";
4-
import { Mutex, MutexInterface } from 'async-mutex';
5-
import { APClientConnectorOpenApi } from './APClientConnectorOpenApi';
1+
// import {
2+
// APSConnectorClientConfig
3+
// } from "../_generated/@solace-iot-team/apim-server-openapi-browser";
4+
// import { Mutex, MutexInterface } from 'async-mutex';
5+
// import { APClientConnectorOpenApi } from './APClientConnectorOpenApi';
66
import { APTimeoutError } from './APError';
77
import { APFetch, APFetchResult } from './APFetch';
88
import { APSClientOpenApi } from './APSClientOpenApi';
@@ -79,49 +79,49 @@ export class APClientServerRaw {
7979
}
8080
}
8181

82-
export class APClientConnectorRaw {
83-
private static componentName = 'APClientConnectorRaw';
84-
private static baseUrl: string;
85-
private static basePath: string;
86-
private static mutex = new Mutex();
87-
private static mutexReleaser: MutexInterface.Releaser;
82+
// class APClientConnectorRaw {
83+
// private static componentName = 'APClientConnectorRaw';
84+
// private static baseUrl: string;
85+
// private static basePath: string;
86+
// private static mutex = new Mutex();
87+
// private static mutexReleaser: MutexInterface.Releaser;
8888

89-
public static initialize = async (connectorClientConfig: APSConnectorClientConfig) => {
90-
// const funcName = 'initialize';
91-
// const logName= `${APClientConnectorRaw.componentName}.${funcName}()`;
92-
APClientConnectorRaw.mutexReleaser = await APClientConnectorRaw.mutex.acquire();
93-
APClientConnectorRaw.baseUrl = APClientConnectorOpenApi.constructBaseUrl(connectorClientConfig);
94-
// console.log(`${logName}: APClientConnectorRaw.baseUrl = ${APClientConnectorRaw.baseUrl}`);
95-
APClientConnectorRaw.basePath = APClientConnectorOpenApi.constructOpenApiBase(connectorClientConfig);
96-
// console.log(`${logName}: APClientConnectorRaw.basePath = ${APClientConnectorRaw.basePath}`);
97-
}
89+
// public static initialize = async (connectorClientConfig: APSConnectorClientConfig) => {
90+
// const funcName = 'initialize';
91+
// const logName= `${APClientConnectorRaw.componentName}.${funcName}()`;
92+
// APClientConnectorRaw.mutexReleaser = await APClientConnectorRaw.mutex.acquire();
93+
// APClientConnectorRaw.baseUrl = APClientConnectorOpenApi.constructBaseUrl(connectorClientConfig);
94+
// console.log(`${logName}: APClientConnectorRaw.baseUrl = ${APClientConnectorRaw.baseUrl}`);
95+
// APClientConnectorRaw.basePath = APClientConnectorOpenApi.constructOpenApiBase(connectorClientConfig);
96+
// console.log(`${logName}: APClientConnectorRaw.basePath = ${APClientConnectorRaw.basePath}`);
97+
// }
9898

99-
public static unInitialize = async (): Promise<void> => {
100-
APClientConnectorRaw.mutexReleaser();
101-
}
99+
// public static unInitialize = async (): Promise<void> => {
100+
// APClientConnectorRaw.mutexReleaser();
101+
// }
102102

103-
public static getBasePath = (): string => {
104-
return APClientConnectorRaw.basePath;
105-
}
106-
public static httpGET_BasePath = async (): Promise<any> => {
107-
const funcName = 'httpGET_BasePath';
108-
const logName= `${APClientConnectorRaw.componentName}.${funcName}()`;
109-
let response: Response;
110-
let responseBody: any;
111-
try {
112-
try {
113-
response = await APFetch.fetchWithTimeoutAndRandomBasicAuth(APClientConnectorRaw.basePath, FetchTimeout_ms);
114-
} catch (e: any) {
115-
if(e.name === 'AbortError') {
116-
throw new APTimeoutError(logName, "fetch timeout", { url: APClientConnectorRaw.basePath, timeout_ms: FetchTimeout_ms});
117-
} else throw e;
118-
}
119-
const result: APFetchResult = await APFetch.getFetchResult(response);
120-
responseBody = result.body;
121-
if(!response.ok) APClientRaw.handleError(logName, response, responseBody);
122-
return responseBody;
123-
} catch (e) {
124-
throw e;
125-
}
126-
}
127-
}
103+
// public static getBasePath = (): string => {
104+
// return APClientConnectorRaw.basePath;
105+
// }
106+
// public static httpGET_BasePath = async (): Promise<any> => {
107+
// const funcName = 'httpGET_BasePath';
108+
// const logName= `${APClientConnectorRaw.componentName}.${funcName}()`;
109+
// let response: Response;
110+
// let responseBody: any;
111+
// try {
112+
// try {
113+
// response = await APFetch.fetchWithTimeoutAndRandomBasicAuth(APClientConnectorRaw.basePath, FetchTimeout_ms);
114+
// } catch (e: any) {
115+
// if(e.name === 'AbortError') {
116+
// throw new APTimeoutError(logName, "fetch timeout", { url: APClientConnectorRaw.basePath, timeout_ms: FetchTimeout_ms});
117+
// } else throw e;
118+
// }
119+
// const result: APFetchResult = await APFetch.getFetchResult(response);
120+
// responseBody = result.body;
121+
// if(!response.ok) APClientRaw.handleError(logName, response, responseBody);
122+
// return responseBody;
123+
// } catch (e) {
124+
// throw e;
125+
// }
126+
// }
127+
// }

apim-portal/src/utils/APFetch.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
import base64 from 'base-64';
3-
import { ApiError } from '../_generated/@solace-iot-team/apim-server-openapi-browser';
3+
import {
4+
ApiError,
5+
OpenAPIConfig as APSOpenAPIConfig,
6+
} from '../_generated/@solace-iot-team/apim-server-openapi-browser';
47
import { APSClientOpenApi } from './APSClientOpenApi';
58

69
export enum EAPFetchResultBodyType {
@@ -92,12 +95,27 @@ export class APFetch {
9295
const logName = `${APFetch.name}.${funcName}()`;
9396

9497
const connectorOpenApiConfig: any = await APSClientOpenApi.getConnectorClientOpenApiConfig();
98+
console.log(`${logName}: connectorOpenApiConfig=${JSON.stringify(connectorOpenApiConfig, null, 2)}`);
9599
// console.warn(`${logName}: connectorOpenApiConfig = ${JSON.stringify(connectorOpenApiConfig)}`);
96100
// throw new Error(`${logName}: check the connectorOpenApiConfig`);
97101
// {"BASE":"http://localhost:3003/apim-server/v1/connectorProxy/v1","VERSION":"0.11.0","WITH_CREDENTIALS":true,"TOKEN":"xxx"
98102

103+
// "BASE": "/apim-server/v1/connectorProxy/v1",
104+
105+
const apsOpenAPIConfig: APSOpenAPIConfig = await APSClientOpenApi.getApsClientOpenApiConfig();
106+
console.log(`${logName}: apsOpenAPIConfig=${JSON.stringify(apsOpenAPIConfig, null, 2)}`);
107+
99108
const base = connectorOpenApiConfig.BASE + '/';
100-
const url: URL = new URL(connectorUrlPath, base);
109+
console.log(`${logName}: connectorUrlPath=${connectorUrlPath}, base=${base}`);
110+
111+
// distinguish between using browser bar host/port and specific host/port
112+
let url: URL;
113+
if(base.includes('http')) {
114+
url = new URL(connectorUrlPath, base);
115+
} else {
116+
url = new URL(base + connectorUrlPath);
117+
}
118+
101119
const headers = new Headers({
102120
"Authorization": `Bearer ${connectorOpenApiConfig.TOKEN}`,
103121
"Content-Type": 'application/json',

apim-server/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apim-server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"url": "https://github.com/solace-iot-team/async-apim/issues"
4343
},
4444
"dependencies": {
45-
"@solace-iot-team/apim-connector-openapi-node": "^0.15.0",
45+
"@solace-iot-team/apim-connector-openapi-node": "^0.15.2",
4646
"abort-controller": "^3.0.0",
4747
"async-mutex": "^0.3.2",
4848
"body-parser": "^1.19.0",

0 commit comments

Comments
 (0)