Skip to content

Commit 74456eb

Browse files
committed
refactor: use v0.0.14 proto definitions
Signed-off-by: Rakib Ansary <rakibansary@gmail.com>
1 parent 56eda4e commit 74456eb

File tree

6 files changed

+22
-116
lines changed

6 files changed

+22
-116
lines changed

src/domain/LegacyChallenge.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
Operator as RelationalOperator,
33
QueryBuilder,
44
} from "@topcoder-framework/client-relational";
5-
import { Operator } from "@topcoder-framework/lib-common";
5+
import { Operator, CheckExistsResult } from "@topcoder-framework/lib-common";
66
import _ from "lodash";
77
import moment from "moment";
88
import {
@@ -13,7 +13,6 @@ import {
1313
} from "../config/constants";
1414
import { queryRunner } from "../helper/QueryRunner";
1515
import {
16-
CheckExistsResponse,
1716
CloseChallengeInput,
1817
CreateChallengeInput,
1918
LegacyChallenge,
@@ -427,7 +426,7 @@ class LegacyChallengeDomain {
427426
return LegacyChallenge.fromPartial(rows[0] as LegacyChallenge);
428427
}
429428

430-
public async checkChallengeExists(legacyChallengeId: number): Promise<CheckExistsResponse> {
429+
public async checkChallengeExists(legacyChallengeId: number): Promise<CheckExistsResult> {
431430
const { projectId } = ProjectSchema.columns;
432431

433432
const query = new QueryBuilder(ProjectSchema)

src/models/domain-layer/legacy/challenge.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ export interface LegacyChallengeList {
2121
legacyChallenges: LegacyChallenge[];
2222
}
2323

24-
export interface CheckExistsResponse {
25-
exists: boolean;
26-
}
27-
2824
export interface CreateChallengeInput {
2925
name: string;
3026
projectStatusId: number;
@@ -296,57 +292,6 @@ export const LegacyChallengeList = {
296292
},
297293
};
298294

299-
function createBaseCheckExistsResponse(): CheckExistsResponse {
300-
return { exists: false };
301-
}
302-
303-
export const CheckExistsResponse = {
304-
encode(message: CheckExistsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
305-
if (message.exists === true) {
306-
writer.uint32(8).bool(message.exists);
307-
}
308-
return writer;
309-
},
310-
311-
decode(input: _m0.Reader | Uint8Array, length?: number): CheckExistsResponse {
312-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
313-
let end = length === undefined ? reader.len : reader.pos + length;
314-
const message = createBaseCheckExistsResponse();
315-
while (reader.pos < end) {
316-
const tag = reader.uint32();
317-
switch (tag >>> 3) {
318-
case 1:
319-
message.exists = reader.bool();
320-
break;
321-
default:
322-
reader.skipType(tag & 7);
323-
break;
324-
}
325-
}
326-
return message;
327-
},
328-
329-
fromJSON(object: any): CheckExistsResponse {
330-
return { exists: isSet(object.exists) ? Boolean(object.exists) : false };
331-
},
332-
333-
toJSON(message: CheckExistsResponse): unknown {
334-
const obj: any = {};
335-
message.exists !== undefined && (obj.exists = message.exists);
336-
return obj;
337-
},
338-
339-
create<I extends Exact<DeepPartial<CheckExistsResponse>, I>>(base?: I): CheckExistsResponse {
340-
return CheckExistsResponse.fromPartial(base ?? {});
341-
},
342-
343-
fromPartial<I extends Exact<DeepPartial<CheckExistsResponse>, I>>(object: I): CheckExistsResponse {
344-
const message = createBaseCheckExistsResponse();
345-
message.exists = object.exists ?? false;
346-
return message;
347-
},
348-
};
349-
350295
function createBaseCreateChallengeInput(): CreateChallengeInput {
351296
return {
352297
name: "",

src/models/domain-layer/legacy/services/challenge.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint-disable */
22
import { handleUnaryCall, UntypedServiceImplementation } from "@grpc/grpc-js";
3-
import { CreateResult, LookupCriteria } from "@topcoder-framework/lib-common";
3+
import { CheckExistsResult, CreateResult, LookupCriteria } from "@topcoder-framework/lib-common";
44
import {
5-
CheckExistsResponse,
65
CloseChallengeInput,
76
CreateChallengeInput,
87
LegacyChallenge,
@@ -19,8 +18,8 @@ export const LegacyChallengeService = {
1918
responseStream: false,
2019
requestSerialize: (value: LegacyChallengeId) => Buffer.from(LegacyChallengeId.encode(value).finish()),
2120
requestDeserialize: (value: Buffer) => LegacyChallengeId.decode(value),
22-
responseSerialize: (value: CheckExistsResponse) => Buffer.from(CheckExistsResponse.encode(value).finish()),
23-
responseDeserialize: (value: Buffer) => CheckExistsResponse.decode(value),
21+
responseSerialize: (value: CheckExistsResult) => Buffer.from(CheckExistsResult.encode(value).finish()),
22+
responseDeserialize: (value: Buffer) => CheckExistsResult.decode(value),
2423
},
2524
lookup: {
2625
path: "/topcoder.domain.service.legacy_challenge_service.LegacyChallenge/Lookup",
@@ -67,8 +66,8 @@ export const LegacyChallengeService = {
6766
responseSerialize: (value: LegacyChallenge) => Buffer.from(LegacyChallenge.encode(value).finish()),
6867
responseDeserialize: (value: Buffer) => LegacyChallenge.decode(value),
6968
},
70-
close: {
71-
path: "/topcoder.domain.service.legacy_challenge_service.LegacyChallenge/Close",
69+
closeChallenge: {
70+
path: "/topcoder.domain.service.legacy_challenge_service.LegacyChallenge/CloseChallenge",
7271
requestStream: false,
7372
responseStream: false,
7473
requestSerialize: (value: CloseChallengeInput) => Buffer.from(CloseChallengeInput.encode(value).finish()),
@@ -79,11 +78,11 @@ export const LegacyChallengeService = {
7978
} as const;
8079

8180
export interface LegacyChallengeServer extends UntypedServiceImplementation {
82-
checkExists: handleUnaryCall<LegacyChallengeId, CheckExistsResponse>;
81+
checkExists: handleUnaryCall<LegacyChallengeId, CheckExistsResult>;
8382
lookup: handleUnaryCall<LookupCriteria, LegacyChallengeList>;
8483
create: handleUnaryCall<CreateChallengeInput, CreateResult>;
8584
update: handleUnaryCall<UpdateChallengeInput, LegacyChallenge>;
8685
get: handleUnaryCall<LegacyChallengeId, LegacyChallenge>;
8786
activate: handleUnaryCall<LegacyChallengeId, LegacyChallenge>;
88-
close: handleUnaryCall<CloseChallengeInput, LegacyChallenge>;
87+
closeChallenge: handleUnaryCall<CloseChallengeInput, LegacyChallenge>;
8988
}

src/models/domain-layer/legacy/services/challenge_payment.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable */
22
import { handleUnaryCall, UntypedServiceImplementation } from "@grpc/grpc-js";
3-
import { CreateResult, Empty } from "@topcoder-framework/lib-common";
3+
import { CreateResult, Empty, UpdateResult } from "@topcoder-framework/lib-common";
44
import {
55
CreateLegacyChallengePaymentInput,
66
DeleteLegacyChallengePaymentInput,
@@ -39,8 +39,8 @@ export const LegacyChallengePaymentService = {
3939
requestSerialize: (value: UpdateLegacyChallengePaymentInput) =>
4040
Buffer.from(UpdateLegacyChallengePaymentInput.encode(value).finish()),
4141
requestDeserialize: (value: Buffer) => UpdateLegacyChallengePaymentInput.decode(value),
42-
responseSerialize: (value: Empty) => Buffer.from(Empty.encode(value).finish()),
43-
responseDeserialize: (value: Buffer) => Empty.decode(value),
42+
responseSerialize: (value: UpdateResult) => Buffer.from(UpdateResult.encode(value).finish()),
43+
responseDeserialize: (value: Buffer) => UpdateResult.decode(value),
4444
},
4545
delete: {
4646
path: "/topcoder.domain.service.legacy_challenge_payment.LegacyChallengePayment/Delete",
@@ -57,6 +57,6 @@ export const LegacyChallengePaymentService = {
5757
export interface LegacyChallengePaymentServer extends UntypedServiceImplementation {
5858
get: handleUnaryCall<GetLegacyChallengePaymentInput, LegacyChallengePaymentList>;
5959
create: handleUnaryCall<CreateLegacyChallengePaymentInput, CreateResult>;
60-
update: handleUnaryCall<UpdateLegacyChallengePaymentInput, Empty>;
60+
update: handleUnaryCall<UpdateLegacyChallengePaymentInput, UpdateResult>;
6161
delete: handleUnaryCall<DeleteLegacyChallengePaymentInput, Empty>;
6262
}

src/service/LegacyChallenge.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { handleUnaryCall, sendUnaryData, ServerUnaryCall, UntypedHandleCall } from "@grpc/grpc-js";
22

33
import {
4-
CheckExistsResponse,
54
CloseChallengeInput,
65
LegacyChallenge,
76
LegacyChallengeId,
@@ -14,7 +13,7 @@ import {
1413
LegacyChallengeService,
1514
} from "../models/domain-layer/legacy/services/challenge";
1615

17-
import { CreateResult, LookupCriteria } from "@topcoder-framework/lib-common";
16+
import { CheckExistsResult, CreateResult, LookupCriteria } from "@topcoder-framework/lib-common";
1817
import LegacyChallengeDomain from "../domain/LegacyChallenge";
1918

2019
class LegacyChallengeServerImpl implements LegacyChallengeServer {
@@ -29,9 +28,9 @@ class LegacyChallengeServerImpl implements LegacyChallengeServer {
2928
// .catch((err) => callback(err, null));
3029
};
3130

32-
checkExists: handleUnaryCall<LegacyChallengeId, CheckExistsResponse> = (
33-
call: ServerUnaryCall<LegacyChallengeId, CheckExistsResponse>,
34-
callback: sendUnaryData<CheckExistsResponse>
31+
checkExists: handleUnaryCall<LegacyChallengeId, CheckExistsResult> = (
32+
call: ServerUnaryCall<LegacyChallengeId, CheckExistsResult>,
33+
callback: sendUnaryData<CheckExistsResult>
3534
) => {
3635
LegacyChallengeDomain.checkChallengeExists(call.request.legacyChallengeId)
3736
.then((response) => callback(null, response))
@@ -70,7 +69,7 @@ class LegacyChallengeServerImpl implements LegacyChallengeServer {
7069
.catch((err) => callback(err, null));
7170
};
7271

73-
close: handleUnaryCall<CloseChallengeInput, LegacyChallenge> = (
72+
closeChallenge: handleUnaryCall<CloseChallengeInput, LegacyChallenge> = (
7473
call: ServerUnaryCall<CloseChallengeInput, LegacyChallenge>,
7574
callback: sendUnaryData<LegacyChallenge>
7675
) => {

src/service/LegacyChallengePayment.ts

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
LegacyChallengePaymentService,
66
} from "../models/domain-layer/legacy/services/challenge_payment";
77

8-
import { CreateResult, Empty } from "@topcoder-framework/lib-common";
8+
import { CreateResult, Empty, UpdateResult } from "@topcoder-framework/lib-common";
99
import LegacyPaymentDomain from "../domain/LegacyChallengePayment";
1010
import {
1111
CreateLegacyChallengePaymentInput,
@@ -36,9 +36,9 @@ class LegacyChallengePaymentServerImpl implements LegacyChallengePaymentServer {
3636
.catch((err) => callback(err, null));
3737
};
3838

39-
update: handleUnaryCall<UpdateLegacyChallengePaymentInput, Empty> = (
40-
call: ServerUnaryCall<UpdateLegacyChallengePaymentInput, Empty>,
41-
callback: sendUnaryData<Empty>
39+
update: handleUnaryCall<UpdateLegacyChallengePaymentInput, UpdateResult> = (
40+
call: ServerUnaryCall<UpdateLegacyChallengePaymentInput, UpdateResult>,
41+
callback: sendUnaryData<UpdateResult>
4242
) => {
4343
LegacyPaymentDomain.updateProjectPayment(call.request)
4444
.then((response) => callback(null))
@@ -53,42 +53,6 @@ class LegacyChallengePaymentServerImpl implements LegacyChallengePaymentServer {
5353
.then((response) => callback(null))
5454
.catch((err) => callback(err, null));
5555
};
56-
57-
// getProjectPrizes: handleUnaryCall<GetPrizesInput, PrizeList> = (
58-
// call: ServerUnaryCall<GetPrizesInput, PrizeList>,
59-
// callback: sendUnaryData<PrizeList>
60-
// ) => {
61-
// LegacyPaymentDomain.getProjectPrizes(call.request)
62-
// .then((response) => callback(null, response))
63-
// .catch((err) => callback(err, null));
64-
// };
65-
66-
// createProjectPrize: handleUnaryCall<CreatePrizeInput, CreateResult> = (
67-
// call: ServerUnaryCall<CreatePrizeInput, CreateResult>,
68-
// callback: sendUnaryData<CreateResult>
69-
// ) => {
70-
// LegacyPaymentDomain.createProjectPrize(call.request)
71-
// .then((response) => callback(null, response))
72-
// .catch((err) => callback(err, null));
73-
// };
74-
75-
// updateProjectPrize: handleUnaryCall<UpdatePrizeInput, Empty> = (
76-
// call: ServerUnaryCall<UpdatePrizeInput, Empty>,
77-
// callback: sendUnaryData<Empty>
78-
// ) => {
79-
// LegacyPaymentDomain.updateProjectPrize(call.request)
80-
// .then((response) => callback(null))
81-
// .catch((err) => callback(err, null));
82-
// };
83-
84-
// deleteProjectPrize: handleUnaryCall<DeletePrizeInput, Empty> = (
85-
// call: ServerUnaryCall<DeletePrizeInput, Empty>,
86-
// callback: sendUnaryData<Empty>
87-
// ) => {
88-
// LegacyPaymentDomain.deleteProjectPrize(call.request)
89-
// .then((response) => callback(null))
90-
// .catch((err) => callback(err, null));
91-
// };
9256
}
9357

9458
export {

0 commit comments

Comments
 (0)