Skip to content

Commit

Permalink
Merge pull request #500 from Enterprise-CMCS/master
Browse files Browse the repository at this point in the history
Release to val
  • Loading branch information
mdial89f authored Apr 11, 2024
2 parents c6e0d32 + 270ce6c commit ef9c545
Show file tree
Hide file tree
Showing 33 changed files with 1,550 additions and 520 deletions.
2 changes: 1 addition & 1 deletion docs/_deploy-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"react-dom": "18.2.0",
"react-icons": "^4.8.0",
"react-json-to-csv": "^1.2.0",
"recharts": "^2.12.0"
"recharts": "^2.12.3"
},
"devDependencies": {
"@types/node": "18.11.0",
Expand Down
8 changes: 4 additions & 4 deletions docs/_deploy-metrics/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3715,10 +3715,10 @@ recharts-scale@^0.4.4:
dependencies:
decimal.js-light "^2.4.1"

recharts@^2.12.0:
version "2.12.2"
resolved "https://registry.yarnpkg.com/recharts/-/recharts-2.12.2.tgz#e2ee5ecad884ff3cb2192e615add75e20c3a276a"
integrity sha512-9bpxjXSF5g81YsKkTSlaX7mM4b6oYI1mIYck6YkUcWuL3tomADccI51/6thY4LmvhYuRTwpfrOvE80Zc3oBRfQ==
recharts@^2.12.3:
version "2.12.4"
resolved "https://registry.yarnpkg.com/recharts/-/recharts-2.12.4.tgz#e560a57cd44ab554c99a0d93bdd58d059b309a2e"
integrity sha512-dM4skmk4fDKEDjL9MNunxv6zcTxePGVEzRnLDXALRpfJ85JoQ0P0APJ/CoJlmnQI0gPjBlOkjzrwrfQrRST3KA==
dependencies:
clsx "^2.0.0"
eventemitter3 "^4.0.1"
Expand Down
2 changes: 2 additions & 0 deletions src/packages/shared-types/action-types/new-submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const onemacSchema = z.object({
seaActionType: z.string().optional(), // Used by waivers and chip spas
origin: z.string(),
appkParentId: z.string().nullable().default(null),
appkTitle: z.string().nullish(), // appk only, candidate to move to its own schema
appkParent: z.boolean().optional(),
originalWaiverNumber: z.string().nullable().default(null),
additionalInformation: z.string().nullable().default(null),
submitterName: z.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export const transform = (id: string) => {
id,
attachments: data.attachments,
appkParentId: data.appkParentId,
appkTitle: data.appkTitle, // this probably maps to subject, but for now we're just going to put it in main directly
appkParent: data.appkParent,
raiWithdrawEnabled: data.raiWithdrawEnabled,
additionalInformation: data.additionalInformation,
submitterEmail: data.submitterEmail,
Expand Down
4 changes: 3 additions & 1 deletion src/packages/shared-utils/package-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const PackageCheck = ({
authority,
actionType,
appkParentId,
appkParent,
initialIntakeNeeded,
}: opensearch.main.Document) => {
const planChecks = {
Expand All @@ -38,7 +39,8 @@ export const PackageCheck = ({
Authority["1915b"],
Authority["1915c"],
]),
isAppk: checkAuthority(authority, [Authority["1915c"]]) && !appkParentId,
isAppk: appkParent,
isAppkChild: appkParentId,
/** Keep excess methods to a minimum with `is` **/
authorityIs: (validAuthorities: Authority[]) =>
checkAuthority(authority, validAuthorities),
Expand Down
18 changes: 14 additions & 4 deletions src/services/api/handlers/appkNewSubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,33 @@ export const submit = async (event: APIGatewayEvent) => {
if (!validateRegex) {
throw console.error(
"MAKO Validation Error. The following APP-K Id format is incorrect: ",
ID
ID,
);
}

const notificationMetadata = {
submissionDate: getNextBusinessDayTimestamp(),
proposedEffectiveDate: body.proposedEffectiveDate,
};

const validateZod = onemacSchema.safeParse({
...body,
...(!!Number(WINDEX) && {
appkParentId: `${body.state}-${body.parentWaiver}`,
}),
...(!Number(WINDEX) && {
appkTitle: body.title,
appkParent: true,
}),
notificationMetadata,
});

if (!validateZod.success) {
throw console.error(
"MAKO Validation Error. The following record failed to parse: ",
JSON.stringify(validateZod),
"Because of the following Reason(s): ",
validateZod.error.message
validateZod.error.message,
);
}

Expand All @@ -79,7 +89,7 @@ export const submit = async (event: APIGatewayEvent) => {
if (existsInOpensearch) {
throw console.error(
"MAKO Validation Error. The following APP-K Id already exists ",
`${body.state}-${ID}`
`${body.state}-${ID}`,
);
}

Expand Down Expand Up @@ -147,7 +157,7 @@ export const submit = async (event: APIGatewayEvent) => {
await produceMessage(
process.env.topicName as string,
SCHEMA.id,
JSON.stringify(SCHEMA.data)
JSON.stringify(SCHEMA.data),
);
}

Expand Down
52 changes: 49 additions & 3 deletions src/services/api/handlers/getPackageActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
lookupUserAttributes,
} from "../libs/auth/user";
import { response } from "../libs/handler";
import { getAppkChildren } from "../libs/package";
import { Action } from "shared-types";

type GetPackageActionsBody = {
id: string;
Expand All @@ -24,7 +26,7 @@ export const getPackageActions = async (event: APIGatewayEvent) => {
const result = await getPackage(body.id);
const passedStateAuth = await isAuthorizedToGetPackageActions(
event,
result._source.state
result._source.state,
);
if (!passedStateAuth)
return response({
Expand All @@ -39,13 +41,57 @@ export const getPackageActions = async (event: APIGatewayEvent) => {
const authDetails = getAuthDetails(event);
const userAttr = await lookupUserAttributes(
authDetails.userId,
authDetails.poolId
authDetails.poolId,
);

if (!result._source.appkParent) {
return response({
statusCode: 200,
body: {
actions: getAvailableActions(userAttr, result._source),
},
});
}

// Actions available on an appk need to consider child waivers, so they're handled differently
const appkChildren = await getAppkChildren(result._source.id);
const allAppkMembers = [result, ...appkChildren.hits.hits];

const allActions = [result, ...appkChildren.hits.hits].map((child) =>
getAvailableActions(userAttr, child._source as any),
);

// only want common actions; omit actions not in every appk package
let commonActions = allActions.reduce((acc, currentActions, index) => {
if (index === 0) return currentActions;
return acc.filter((action) => currentActions.includes(action));
}, []);
// Remove RAI actions unless the RAI requested date is identical across all appk members
// Scenario: If the parent and the children all have respond to rai as an available action
// But one of those children's latest rai has a different requested date (raitable in seetool)
// There's drift, and there will be a failure when going to write the response
// Further, we can't reliably know what RAI is correct.
const allRaiRequestedDates = allAppkMembers.map(
(member) => member._source.raiRequestedDate,
);
const isRaiRequestedDateIdentical = allRaiRequestedDates.every(
(date, _, arr) => date === arr[0],
);
if (!isRaiRequestedDateIdentical) {
const actionsToRemove = [
Action.RESPOND_TO_RAI,
Action.WITHDRAW_RAI,
Action.ISSUE_RAI,
];
commonActions = commonActions.filter(
(action) => !actionsToRemove.includes(action),
);
}

return response({
statusCode: 200,
body: {
actions: getAvailableActions(userAttr, result._source),
actions: commonActions,
},
});
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/api/handlers/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getItemData = async (event: APIGatewayEvent) => {
const packageResult = await getPackage(body.id);

let appkChildren: any[] = [];
if (packageResult._source.authority === Authority["1915c"]) {
if (packageResult._source.appkParent) {
const children = await getAppkChildren(body.id);
appkChildren = children.hits.hits;
}
Expand Down
Loading

0 comments on commit ef9c545

Please sign in to comment.