Skip to content

update dev scorecard IDs #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
- image: cimg/aws:2023.01
environment:
CODEARTIFACT_ENV: PROD
ECR_ENV: QA
ECR_ENV: DEV
SERVICE_NAME: "domain-challenge"
OUT_DIR: "buildscripts"
steps:
Expand Down Expand Up @@ -48,5 +48,4 @@ workflows:
filters:
branches:
only:
- fix/update-pre-release
- main
- feature/dev
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"printWidth": 100
}
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@
"@aws-sdk/util-utf8-node": "^3.259.0",
"@grpc/grpc-js": "^1.7.1",
"@opensearch-project/opensearch": "^2.2.0",
"@topcoder-framework/domain-acl": "^0.7.0",
"@topcoder-framework/lib-common": "^0.7.0",
"@topcoder-framework/domain-acl": "^0.10.2",
"@topcoder-framework/domain-challenge": "^0.10.2",
"@topcoder-framework/lib-common": "^0.10.2",
"@types/uuid": "^9.0.1",
"aws-sdk": "^2.1339.0",
"axios": "^1.2.2",
"dayjs": "^1.11.7",
"dotenv": "^16.0.3",
"elasticsearch": "^16.7.3",
"grpc-server-reflection": "^0.1.5",
"http-aws-es": "^6.0.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"source-map-support": "^0.5.21",
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.6.4",
"topcoder-interface": "github:topcoder-platform/plat-interface-definition#v0.0.29",
"uuidv4": "^6.2.13",
"topcoder-interface": "github:topcoder-platform/plat-interface-definition#v0.0.36",
"uuid": "^9.0.0",
"xss": "^1.0.14"
},
"volta": {
Expand All @@ -43,6 +48,7 @@
"yarn": "1.22.19"
},
"devDependencies": {
"@types/elasticsearch": "^5.0.40",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.17",
"ts-node-dev": "^2.0.0",
Expand Down
22 changes: 22 additions & 0 deletions src/common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,26 @@ export const ResourceInfoIds = {
export const ChallengeStatuses = {
New: "New",
Active: "Active",
Draft: "Draft",
};

export const PhaseTypeIds = {
Registration: 1,
Submission: 2,
Screening: 3,
Review: 4,
Appeals: 5,
AppealsResponse: 6,
Aggregation: 7,
AggregationReview: 8,
FinalFix: 9,
FinalReview: 10,
Approval: 11,
PostMortem: 12,
SpecificationSubmission: 13,
SpecificationReview: 14,
CheckpointSubmission: 15,
CheckpointScreening: 16,
CheckpointReview: 17,
IterativeReview: 18,
};
2 changes: 1 addition & 1 deletion src/common/ConversionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const V4_TRACKS = {
DESIGN: "DESIGN",
};

const V4_SUBTRACKS = {
export const V4_SUBTRACKS = {
MARATHON_MATCH: "MARATHON_MATCH",
DESIGN_FIRST_2_FINISH: "DESIGN_FIRST_2_FINISH",
APPLICATION_FRONT_END_DESIGN: "APPLICATION_FRONT_END_DESIGN",
Expand Down
51 changes: 22 additions & 29 deletions src/common/CoreOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import { noSqlClient } from "../dal/client/nosql";

// TODO: Import from @topcoder-framework/lib-common
import {
LookupCriteria,
ScanCriteria,
ScanResult,
} from "../models/common/common";
import { LookupCriteria, ScanCriteria, ScanResult } from "../models/common/common";

// TODO: Import from @topcoder-framework/lib-common
import { Value } from "../models/google/protobuf/struct";
Expand All @@ -25,7 +21,7 @@ import {
UpdateType,
Value as PartiQLValue,
} from "../dal/models/nosql/parti_ql";
import { StatusBuilder } from "@grpc/grpc-js";
import { Metadata, StatusBuilder } from "@grpc/grpc-js";
import { Status } from "@grpc/grpc-js/build/src/constants";

export type ValueType =
Expand All @@ -44,24 +40,20 @@ export type DynamoTableIndex = {
};
};

abstract class CoreOperations<
T extends { [key: string]: any },
I extends { [key: string]: any }
> {
abstract class CoreOperations<T extends { [key: string]: any }, I extends { [key: string]: any }> {
public constructor(
private entityName: string,
private entityAttributes: Attribute[],
private entityIndexList: DynamoTableIndex
) {}

private attributesKeyTypeMap: { [key: string]: DataType } =
this.entityAttributes.reduce(
(map, attribute) => ({
...map,
[attribute.name]: attribute.type,
}),
{}
);
private attributesKeyTypeMap: { [key: string]: DataType } = this.entityAttributes.reduce(
(map, attribute) => ({
...map,
[attribute.name]: attribute.type,
}),
{}
);

public async lookup(lookupCriteria: LookupCriteria): Promise<T> {
const selectQuery: SelectQuery = {
Expand Down Expand Up @@ -150,7 +142,7 @@ abstract class CoreOperations<
};
}

protected async create(entity: I & T): Promise<T> {
protected async create(entity: I & T, metadata?: Metadata): Promise<T> {
const queryRequest: QueryRequest = {
kind: {
$case: "query",
Expand All @@ -177,7 +169,8 @@ abstract class CoreOperations<

public async update(
scanCriteria: ScanCriteria[],
entity: unknown
entity: unknown,
metadata?: Metadata
): Promise<{ items: T[] }> {
if (typeof entity != "object" || entity == null) {
throw new Error("Expected key-value pairs to update");
Expand All @@ -193,12 +186,14 @@ abstract class CoreOperations<
update: {
table: this.entityName,
// TODO: Write a convenience method in @topcoder-framework/lib-common to support additional update operations like LIST_APPEND, SET_ADD, SET_REMOVE, etc
updates: Object.entries(entity).map(([key, value]) => ({
action: UpdateAction.UPDATE_ACTION_SET,
type: UpdateType.UPDATE_TYPE_VALUE,
attribute: key,
value: this.toValue(key, value),
})),
updates: Object.entries(entity)
.filter(([key, value]) => value !== undefined)
.map(([key, value]) => ({
action: UpdateAction.UPDATE_ACTION_SET,
type: UpdateType.UPDATE_TYPE_VALUE,
attribute: key,
value: this.toValue(key, value),
})),
filters,
returnValue: ReturnValue.RETURN_VALUE_ALL_NEW,
},
Expand Down Expand Up @@ -330,9 +325,7 @@ abstract class CoreOperations<
break;

default:
throw new Error(
"Lookups are only supported for string, number & boolean value"
);
throw new Error("Lookups are only supported for string, number & boolean value");
}

return value;
Expand Down
88 changes: 66 additions & 22 deletions src/dal/models/nosql/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,20 @@ export const Struct = {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag != 10) {
break;
}

const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32());
if (entry1.value !== undefined) {
message.fields[entry1.key] = entry1.value;
}
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) == 4 || tag == 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand Down Expand Up @@ -209,15 +214,24 @@ export const Struct_FieldsEntry = {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag != 10) {
break;
}

message.key = reader.string();
break;
continue;
case 2:
if (tag != 18) {
break;
}

message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) == 4 || tag == 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand Down Expand Up @@ -282,27 +296,52 @@ export const Value = {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag != 8) {
break;
}

message.kind = { $case: "nullValue", nullValue: nullValueFromJSON(reader.int32()) };
break;
continue;
case 2:
if (tag != 17) {
break;
}

message.kind = { $case: "numberValue", numberValue: reader.double() };
break;
continue;
case 3:
if (tag != 26) {
break;
}

message.kind = { $case: "stringValue", stringValue: reader.string() };
break;
continue;
case 4:
if (tag != 32) {
break;
}

message.kind = { $case: "boolValue", boolValue: reader.bool() };
break;
continue;
case 5:
if (tag != 42) {
break;
}

message.kind = { $case: "structValue", structValue: Struct.unwrap(Struct.decode(reader, reader.uint32())) };
break;
continue;
case 6:
if (tag != 50) {
break;
}

message.kind = { $case: "listValue", listValue: ListValue.unwrap(ListValue.decode(reader, reader.uint32())) };
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) == 4 || tag == 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand Down Expand Up @@ -435,12 +474,17 @@ export const ListValue = {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag != 10) {
break;
}

message.values.push(Value.unwrap(Value.decode(reader, reader.uint32())));
break;
default:
reader.skipType(tag & 7);
break;
continue;
}
if ((tag & 7) == 4 || tag == 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
Expand Down
Loading