Skip to content

Commit c2ecba5

Browse files
committed
fix(cmd-api-server): build occasionally broken - protoc-gen-ts #1563
Upgrading protoc-gen-ts from 0.4.0 to 0.6.0 instantly fixed the issue while I had it in a reproduced state (e.g. my build was broken on main) This is not necessarily evidence that the fix is legit, but it's most likely a step in the right direction and there's also the possibility that this is the actual fix. It would take too much time to properly debug if it really is the fix, so I'll just give it the benefit of the doubt for now and assume that it is. Also had to upgrade the @types/google-protobuf package to a newer version because it didn't have the deserializeBinary() method defined on the custom made Map type that ships with the PB compiler and this was causing the generated Typescript code to not compile. Fixes #1563 Signed-off-by: Peter Somogyvari <[email protected]>
1 parent 6130bea commit c2ecba5

File tree

20 files changed

+983
-13
lines changed

20 files changed

+983
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"npm-run-all": "4.1.5",
124124
"npm-watch": "0.11.0",
125125
"prettier": "2.1.2",
126-
"protoc-gen-ts": "0.4.0",
126+
"protoc-gen-ts": "0.6.0",
127127
"run-time-error": "1.4.0",
128128
"secp256k1": "4.0.2",
129129
"shebang-loader": "0.0.1",

packages/cactus-cmd-api-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"@types/express": "4.17.13",
114114
"@types/express-http-proxy": "1.6.2",
115115
"@types/express-jwt": "6.0.2",
116-
"@types/google-protobuf": "3.15.3",
116+
"@types/google-protobuf": "3.15.5",
117117
"@types/jsonwebtoken": "8.5.4",
118118
"@types/multer": "1.4.7",
119119
"@types/node-forge": "0.10.2",

packages/cactus-cmd-api-server/src/main/typescript/generated/proto/protoc-gen-ts/google/protobuf/empty.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export namespace google.protobuf {
1313
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], []);
1414
if (!Array.isArray(data) && typeof data == "object") { }
1515
}
16+
static fromObject(data: {}) {
17+
const message = new Empty({});
18+
return message;
19+
}
1620
toObject() {
1721
const data: {} = {};
1822
return data;

packages/cactus-cmd-api-server/src/main/typescript/generated/proto/protoc-gen-ts/models/health_check_response_pb.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ export namespace org.hyperledger.cactus.cmd_api_server {
4646
set memoryUsage(value: dependency_1.org.hyperledger.cactus.cmd_api_server.MemoryUsagePB) {
4747
pb_1.Message.setWrapperField(this, 335792418, value);
4848
}
49+
static fromObject(data: {
50+
success?: boolean;
51+
createdAt?: string;
52+
memoryUsage?: ReturnType<typeof dependency_1.org.hyperledger.cactus.cmd_api_server.MemoryUsagePB.prototype.toObject>;
53+
}) {
54+
const message = new HealthCheckResponsePB({});
55+
if (data.success != null) {
56+
message.success = data.success;
57+
}
58+
if (data.createdAt != null) {
59+
message.createdAt = data.createdAt;
60+
}
61+
if (data.memoryUsage != null) {
62+
message.memoryUsage = dependency_1.org.hyperledger.cactus.cmd_api_server.MemoryUsagePB.fromObject(data.memoryUsage);
63+
}
64+
return message;
65+
}
4966
toObject() {
5067
const data: {
5168
success?: boolean;

packages/cactus-cmd-api-server/src/main/typescript/generated/proto/protoc-gen-ts/models/memory_usage_pb.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,31 @@ export namespace org.hyperledger.cactus.cmd_api_server {
6565
set arrayBuffers(value: number) {
6666
pb_1.Message.setField(this, 116952168, value);
6767
}
68+
static fromObject(data: {
69+
rss?: number;
70+
heapTotal?: number;
71+
heapUsed?: number;
72+
external?: number;
73+
arrayBuffers?: number;
74+
}) {
75+
const message = new MemoryUsagePB({});
76+
if (data.rss != null) {
77+
message.rss = data.rss;
78+
}
79+
if (data.heapTotal != null) {
80+
message.heapTotal = data.heapTotal;
81+
}
82+
if (data.heapUsed != null) {
83+
message.heapUsed = data.heapUsed;
84+
}
85+
if (data.external != null) {
86+
message.external = data.external;
87+
}
88+
if (data.arrayBuffers != null) {
89+
message.arrayBuffers = data.arrayBuffers;
90+
}
91+
return message;
92+
}
6893
toObject() {
6994
const data: {
7095
rss?: number;

packages/cactus-cmd-api-server/src/main/typescript/generated/proto/protoc-gen-ts/services/default_service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ export namespace org.hyperledger.cactus.cmd_api_server {
2828
set data(value: string) {
2929
pb_1.Message.setField(this, 1, value);
3030
}
31+
static fromObject(data: {
32+
data?: string;
33+
}) {
34+
const message = new GetPrometheusMetricsV1Response({});
35+
if (data.data != null) {
36+
message.data = data.data;
37+
}
38+
return message;
39+
}
3140
toObject() {
3241
const data: {
3342
data?: string;

packages/cactus-core-api/src/main/typescript/generated/proto/protoc-gen-ts/weaver/common/protos/common/access_control.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ export namespace common.access_control {
3535
set rules(value: Rule[]) {
3636
pb_1.Message.setRepeatedWrapperField(this, 2, value);
3737
}
38+
static fromObject(data: {
39+
securityDomain?: string;
40+
rules?: ReturnType<typeof Rule.prototype.toObject>[];
41+
}) {
42+
const message = new AccessControlPolicy({});
43+
if (data.securityDomain != null) {
44+
message.securityDomain = data.securityDomain;
45+
}
46+
if (data.rules != null) {
47+
message.rules = data.rules.map(item => Rule.fromObject(item));
48+
}
49+
return message;
50+
}
3851
toObject() {
3952
const data: {
4053
securityDomain?: string;
@@ -131,6 +144,27 @@ export namespace common.access_control {
131144
set read(value: boolean) {
132145
pb_1.Message.setField(this, 4, value);
133146
}
147+
static fromObject(data: {
148+
principal?: string;
149+
principalType?: string;
150+
resource?: string;
151+
read?: boolean;
152+
}) {
153+
const message = new Rule({});
154+
if (data.principal != null) {
155+
message.principal = data.principal;
156+
}
157+
if (data.principalType != null) {
158+
message.principalType = data.principalType;
159+
}
160+
if (data.resource != null) {
161+
message.resource = data.resource;
162+
}
163+
if (data.read != null) {
164+
message.read = data.read;
165+
}
166+
return message;
167+
}
134168
toObject() {
135169
const data: {
136170
principal?: string;

packages/cactus-core-api/src/main/typescript/generated/proto/protoc-gen-ts/weaver/common/protos/common/ack.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ export namespace common.ack {
4545
set message(value: string) {
4646
pb_1.Message.setField(this, 4, value);
4747
}
48+
static fromObject(data: {
49+
status?: Ack.STATUS;
50+
request_id?: string;
51+
message?: string;
52+
}) {
53+
const message = new Ack({});
54+
if (data.status != null) {
55+
message.status = data.status;
56+
}
57+
if (data.request_id != null) {
58+
message.request_id = data.request_id;
59+
}
60+
if (data.message != null) {
61+
message.message = data.message;
62+
}
63+
return message;
64+
}
4865
toObject() {
4966
const data: {
5067
status?: Ack.STATUS;

packages/cactus-core-api/src/main/typescript/generated/proto/protoc-gen-ts/weaver/common/protos/common/asset_locks.ts

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ export namespace common.asset_locks {
3838
set lockInfo(value: Uint8Array) {
3939
pb_1.Message.setField(this, 2, value);
4040
}
41+
static fromObject(data: {
42+
lockMechanism?: LockMechanism;
43+
lockInfo?: Uint8Array;
44+
}) {
45+
const message = new AssetLock({});
46+
if (data.lockMechanism != null) {
47+
message.lockMechanism = data.lockMechanism;
48+
}
49+
if (data.lockInfo != null) {
50+
message.lockInfo = data.lockInfo;
51+
}
52+
return message;
53+
}
4154
toObject() {
4255
const data: {
4356
lockMechanism?: LockMechanism;
@@ -114,6 +127,19 @@ export namespace common.asset_locks {
114127
set claimInfo(value: Uint8Array) {
115128
pb_1.Message.setField(this, 2, value);
116129
}
130+
static fromObject(data: {
131+
lockMechanism?: LockMechanism;
132+
claimInfo?: Uint8Array;
133+
}) {
134+
const message = new AssetClaim({});
135+
if (data.lockMechanism != null) {
136+
message.lockMechanism = data.lockMechanism;
137+
}
138+
if (data.claimInfo != null) {
139+
message.claimInfo = data.claimInfo;
140+
}
141+
return message;
142+
}
117143
toObject() {
118144
const data: {
119145
lockMechanism?: LockMechanism;
@@ -200,6 +226,23 @@ export namespace common.asset_locks {
200226
set timeSpec(value: AssetLockHTLC.TimeSpec) {
201227
pb_1.Message.setField(this, 3, value);
202228
}
229+
static fromObject(data: {
230+
hashBase64?: Uint8Array;
231+
expiryTimeSecs?: number;
232+
timeSpec?: AssetLockHTLC.TimeSpec;
233+
}) {
234+
const message = new AssetLockHTLC({});
235+
if (data.hashBase64 != null) {
236+
message.hashBase64 = data.hashBase64;
237+
}
238+
if (data.expiryTimeSecs != null) {
239+
message.expiryTimeSecs = data.expiryTimeSecs;
240+
}
241+
if (data.timeSpec != null) {
242+
message.timeSpec = data.timeSpec;
243+
}
244+
return message;
245+
}
203246
toObject() {
204247
const data: {
205248
hashBase64?: Uint8Array;
@@ -281,6 +324,15 @@ export namespace common.asset_locks {
281324
set hashPreimageBase64(value: Uint8Array) {
282325
pb_1.Message.setField(this, 1, value);
283326
}
327+
static fromObject(data: {
328+
hashPreimageBase64?: Uint8Array;
329+
}) {
330+
const message = new AssetClaimHTLC({});
331+
if (data.hashPreimageBase64 != null) {
332+
message.hashPreimageBase64 = data.hashPreimageBase64;
333+
}
334+
return message;
335+
}
284336
toObject() {
285337
const data: {
286338
hashPreimageBase64?: Uint8Array;
@@ -368,6 +420,27 @@ export namespace common.asset_locks {
368420
set recipient(value: string) {
369421
pb_1.Message.setField(this, 4, value);
370422
}
423+
static fromObject(data: {
424+
type?: string;
425+
id?: string;
426+
locker?: string;
427+
recipient?: string;
428+
}) {
429+
const message = new AssetExchangeAgreement({});
430+
if (data.type != null) {
431+
message.type = data.type;
432+
}
433+
if (data.id != null) {
434+
message.id = data.id;
435+
}
436+
if (data.locker != null) {
437+
message.locker = data.locker;
438+
}
439+
if (data.recipient != null) {
440+
message.recipient = data.recipient;
441+
}
442+
return message;
443+
}
371444
toObject() {
372445
const data: {
373446
type?: string;
@@ -482,6 +555,27 @@ export namespace common.asset_locks {
482555
set recipient(value: string) {
483556
pb_1.Message.setField(this, 4, value);
484557
}
558+
static fromObject(data: {
559+
type?: string;
560+
numUnits?: number;
561+
locker?: string;
562+
recipient?: string;
563+
}) {
564+
const message = new FungibleAssetExchangeAgreement({});
565+
if (data.type != null) {
566+
message.type = data.type;
567+
}
568+
if (data.numUnits != null) {
569+
message.numUnits = data.numUnits;
570+
}
571+
if (data.locker != null) {
572+
message.locker = data.locker;
573+
}
574+
if (data.recipient != null) {
575+
message.recipient = data.recipient;
576+
}
577+
return message;
578+
}
485579
toObject() {
486580
const data: {
487581
type?: string;
@@ -596,6 +690,27 @@ export namespace common.asset_locks {
596690
set claim(value: AssetClaimHTLC) {
597691
pb_1.Message.setWrapperField(this, 4, value);
598692
}
693+
static fromObject(data: {
694+
contractId?: string;
695+
agreement?: ReturnType<typeof AssetExchangeAgreement.prototype.toObject>;
696+
lock?: ReturnType<typeof AssetLockHTLC.prototype.toObject>;
697+
claim?: ReturnType<typeof AssetClaimHTLC.prototype.toObject>;
698+
}) {
699+
const message = new AssetContractHTLC({});
700+
if (data.contractId != null) {
701+
message.contractId = data.contractId;
702+
}
703+
if (data.agreement != null) {
704+
message.agreement = AssetExchangeAgreement.fromObject(data.agreement);
705+
}
706+
if (data.lock != null) {
707+
message.lock = AssetLockHTLC.fromObject(data.lock);
708+
}
709+
if (data.claim != null) {
710+
message.claim = AssetClaimHTLC.fromObject(data.claim);
711+
}
712+
return message;
713+
}
599714
toObject() {
600715
const data: {
601716
contractId?: string;
@@ -710,6 +825,27 @@ export namespace common.asset_locks {
710825
set claim(value: AssetClaimHTLC) {
711826
pb_1.Message.setWrapperField(this, 4, value);
712827
}
828+
static fromObject(data: {
829+
contractId?: string;
830+
agreement?: ReturnType<typeof FungibleAssetExchangeAgreement.prototype.toObject>;
831+
lock?: ReturnType<typeof AssetLockHTLC.prototype.toObject>;
832+
claim?: ReturnType<typeof AssetClaimHTLC.prototype.toObject>;
833+
}) {
834+
const message = new FungibleAssetContractHTLC({});
835+
if (data.contractId != null) {
836+
message.contractId = data.contractId;
837+
}
838+
if (data.agreement != null) {
839+
message.agreement = FungibleAssetExchangeAgreement.fromObject(data.agreement);
840+
}
841+
if (data.lock != null) {
842+
message.lock = AssetLockHTLC.fromObject(data.lock);
843+
}
844+
if (data.claim != null) {
845+
message.claim = AssetClaimHTLC.fromObject(data.claim);
846+
}
847+
return message;
848+
}
713849
toObject() {
714850
const data: {
715851
contractId?: string;

0 commit comments

Comments
 (0)