Skip to content

Commit 616c7a1

Browse files
authored
feat: added Deployment data to ServerInfo (#797)
1 parent 554a63e commit 616c7a1

File tree

8 files changed

+97
-8
lines changed

8 files changed

+97
-8
lines changed

package-lock.json

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"ripemd160": "^2.0.2",
113113
"rxjs": "^6.6.3",
114114
"rxjs-compat": "^6.6.3",
115-
"symbol-openapi-typescript-fetch-client": "0.11.2",
115+
"symbol-openapi-typescript-fetch-client": "1.0.1-SNAPSHOT.202106160954",
116116
"tweetnacl": "^1.0.3",
117117
"utf8": "^2.1.2",
118118
"ws": "^7.3.1"

src/infrastructure/NodeHttp.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { NodeInfoDTO, NodeRoutesApi } from 'symbol-openapi-typescript-fetch-clie
1919
import { UInt64 } from '../model';
2020
import { StorageInfo } from '../model/blockchain';
2121
import { NodeHealth, NodeInfo, NodeTime, RoleType, ServerInfo } from '../model/node';
22+
import { Deployment } from '../model/node/Deployment';
2223
import { Http } from './Http';
2324
import { NodeRepository } from './NodeRepository';
2425

@@ -95,7 +96,18 @@ export class NodeHttp extends Http implements NodeRepository {
9596
public getServerInfo(): Observable<ServerInfo> {
9697
return this.call(
9798
this.nodeRoutesApi.getServerInfo(),
98-
(body) => new ServerInfo(body.serverInfo.restVersion, body.serverInfo.sdkVersion),
99+
(body) =>
100+
new ServerInfo(
101+
body.serverInfo.restVersion,
102+
body.serverInfo.sdkVersion,
103+
body.serverInfo?.deployment
104+
? new Deployment(
105+
body.serverInfo.deployment.deploymentTool,
106+
body.serverInfo.deployment.deploymentToolVersion,
107+
body.serverInfo.deployment.lastUpdatedDate,
108+
)
109+
: undefined,
110+
),
99111
);
100112
}
101113

src/model/node/Deployment.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2019 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* The deployment information that helps tracking how the node was created.
19+
*/
20+
export class Deployment {
21+
/**
22+
* @param deploymentTool The tool used to create, maintain and deploy the node. Examples: symbol-bootstrap, manual.
23+
* @param deploymentToolVersion The version of the tool used to create, maintain and deploy the node.
24+
* @param lastUpdatedDate When was the node upgraded.
25+
*/
26+
constructor(
27+
/**
28+
* deploymentTool The tool used to create, maintain and deploy the node. Examples: symbol-bootstrap, manual.
29+
*/
30+
public readonly deploymentTool: string,
31+
/**
32+
* deploymentToolVersion The version of the tool used to create, maintain and deploy the node.
33+
*/
34+
public readonly deploymentToolVersion: string,
35+
/**
36+
* lastUpdatedDate When was the node last upgraded.
37+
*/
38+
public readonly lastUpdatedDate: string,
39+
) {}
40+
}

src/model/node/ServerInfo.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,29 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { Deployment } from './Deployment';
18+
1719
/**
1820
* The server information.
1921
*/
2022
export class ServerInfo {
2123
/**
2224
* @param restVersion - The catapult-rest component version
2325
* @param sdkVersion - the catapult-sdk component version
26+
* @param deployment - the deployment information.
2427
*/
2528
constructor(
2629
/**
27-
* The catapult-rest component version
30+
* restVersion The catapult-rest component version
2831
*/
2932
public readonly restVersion: string,
3033
/**
31-
* the catapult-sdk component version
34+
* sdkVersion the catapult-sdk component version
3235
*/
3336
public readonly sdkVersion: string,
37+
/**
38+
* deployment The deployment information that helps tracking how the node was created.
39+
*/
40+
public readonly deployment: Deployment | undefined,
3441
) {}
3542
}

src/model/node/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// created from 'create-ts-index'
22

3+
export * from './Deployment';
34
export * from './NodeHealth';
45
export * from './NodeInfo';
56
export * from './NodeTime';

test/infrastructure/NodeHttp.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ describe('NodeHttp', () => {
7070
expect(serverInfo).to.be.not.null;
7171
expect(serverInfo.restVersion).to.be.equals(body.serverInfo.restVersion);
7272
expect(serverInfo.sdkVersion).to.be.equals(body.serverInfo.sdkVersion);
73+
expect(serverInfo.deployment).to.be.undefined;
74+
});
75+
76+
it('getServerInfo with deployment', async () => {
77+
const body: ServerInfoDTO = {
78+
serverInfo: {
79+
restVersion: 'Some Rest Version',
80+
sdkVersion: 'Some SDK Version',
81+
deployment: {
82+
deploymentTool: 'symbol-bootstrap',
83+
deploymentToolVersion: '1.0.6-alpha-202105280712',
84+
lastUpdatedDate: '2021-06-02',
85+
},
86+
},
87+
};
88+
89+
when(nodeRoutesApi.getServerInfo()).thenReturn(Promise.resolve(body));
90+
const serverInfo = await nodeRepository.getServerInfo().toPromise();
91+
expect(serverInfo).to.be.not.null;
92+
expect(serverInfo.restVersion).to.be.equals(body.serverInfo.restVersion);
93+
expect(serverInfo.deployment).to.be.deep.equals(body.serverInfo.deployment);
7394
});
7495

7596
it('getNodeInfo', async () => {

test/infrastructure/SerializeTransactionToJSON.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ describe('SerializeTransactionToJSON', () => {
324324
);
325325

326326
const aggregateTransaction = AggregateTransaction.createBonded(
327-
Deadline.create(epochAdjustment),
327+
deadline,
328328
[transferTransaction.toAggregate(account.publicAccount)],
329329
NetworkType.PRIVATE_TEST,
330330
[],

0 commit comments

Comments
 (0)