Skip to content

Commit

Permalink
Merge pull request #472 from Enterprise-CMCS/master
Browse files Browse the repository at this point in the history
Release to val
  • Loading branch information
mdial89f authored Apr 1, 2024
2 parents e4d0290 + af1f3f4 commit b3e76e9
Show file tree
Hide file tree
Showing 18 changed files with 2,671 additions and 2,318 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ build_run
.turbo
coverage
lambda_layer.zip
**/.auth/*.json
**/.auth/*.json
.dccache
15 changes: 15 additions & 0 deletions docs/docs/webforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,19 @@ These webforms are a replacement for the pdf form uploads previously used in mmd
## Things to note
Some of the fields listed in these webforms are FieldGroups and FieldArrays. This means that they are arrays of values that contain groups of like values (think an array of identicaly typed objects). The items within those arrays will have `Parent` values to indicate which parent they belong to.

## Key structuring of Webforms:
For our webforms, we are in communication with data connect on our we should pass our json data to their team. We have gone with this approach to help streamline our data, but also make it as easy as possible to hunt down questions if items are added or changed. Our “name” keys are made up of for different parts.

Our agreed upon key structures for the “name” property of form field sections are as follows:

The Four Parts to the name field are:
- form name '-' instead of dots
- section title separated by “-” shortened if possible
- input id/label as close and short as possible with only '-' as separators
- input type is usually the (rhf) value text/textarea/array/checkgroup/upload/radiogroup/select

> `[form-name]_[section-title]_[question-id]_[input]`
Example: **"abp1_pop-id_abp-pop-name_input"**

**It is imperative that this pattern be followed in all forms.**
15 changes: 11 additions & 4 deletions src/cli/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ export default class LabeledProcessRunner {
return `\x1b[38;5;${color}m ${prefix.padStart(maxLength)}|\x1b[0m`;
}

private sanitizeInput(input) {
// A basic pattern that allows letters, numbers, dashes, underscores, and periods
// Adjust the pattern to fit the expected input format
const sanitizedInput = input.replace(/[^a-zA-Z0-9-_\.]/g, "");
return sanitizedInput;
}

// run_command_and_output runs the given shell command and interleaves its output with all
// other commands run via this method.
//
Expand All @@ -64,15 +71,15 @@ export default class LabeledProcessRunner {
stdout?: boolean;
stderr?: boolean;
close?: boolean;
} = {}
} = {},
) {
silenced = {
...{ open: false, stdout: false, stderr: false, close: false },
...silenced,
};
const proc_opts = cwd ? { cwd } : {};

const command = cmd[0];
const command = this.sanitizeInput(cmd[0]);
const args = cmd.slice(1);

const proc = spawn(command, args, proc_opts);
Expand All @@ -89,10 +96,10 @@ export default class LabeledProcessRunner {
};

proc.stdout.on("data", (data) =>
handleOutput(data, prefix, silenced.stdout!)
handleOutput(data, prefix, silenced.stdout!),
);
proc.stderr.on("data", (data) =>
handleOutput(data, prefix, silenced.stderr!)
handleOutput(data, prefix, silenced.stderr!),
);

return new Promise<void>((resolve, reject) => {
Expand Down
8 changes: 2 additions & 6 deletions src/packages/shared-types/action-types/new-submission.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { z } from "zod";
import { attachmentSchema } from "../attachments";
import { notificationMetadataSchema } from "../notification-metadata";

// This is the event schema for ne submissions from our system
export const onemacSchema = z.object({
Expand All @@ -13,12 +14,7 @@ export const onemacSchema = z.object({
submitterEmail: z.string(),
attachments: z.array(attachmentSchema).nullish(),
raiWithdrawEnabled: z.boolean().default(false),
notificationMetadata: z
.object({
proposedEffectiveDate: z.number().nullish(),
submissionDate: z.number().nullish(),
})
.nullish(),
notificationMetadata: notificationMetadataSchema.nullish(),
// these are specific to TEs... should be broken into its own schema
statusDate: z.number().optional(),
submissionDate: z.number().optional(),
Expand Down
2 changes: 2 additions & 0 deletions src/packages/shared-types/action-types/respond-to-rai.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { z } from "zod";
import { attachmentSchema } from "../attachments";
import { notificationMetadataSchema } from "../notification-metadata";

export const raiResponseSchema = z.object({
id: z.string(),
Expand All @@ -11,5 +12,6 @@ export const raiResponseSchema = z.object({
additionalInformation: z.string().nullable().default(null),
submitterName: z.string(),
submitterEmail: z.string(),
notificationMetadata: notificationMetadataSchema.nullish(),
});
export type RaiResponse = z.infer<typeof raiResponseSchema>;
9 changes: 9 additions & 0 deletions src/packages/shared-types/notification-metadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { z } from "zod";

// This is addiitonal notification metadata needed for email
export const notificationMetadataSchema = z.object({
proposedEffectiveDate: z.number().nullish(),
submissionDate: z.number().nullish(),
});

export type NotificationMetadata = z.infer<typeof notificationMetadataSchema>;
8 changes: 7 additions & 1 deletion src/services/api/handlers/packageActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import { produceMessage } from "../libs/kafka";
import { response } from "../libs/handler";
import { SEATOOL_STATUS } from "shared-types/statusHelper";
import { formatSeatoolDate, seaToolFriendlyTimestamp } from "shared-utils";
import { formatSeatoolDate, seaToolFriendlyTimestamp, getNextBusinessDayTimestamp } from "shared-utils";
import { buildStatusMemoQuery } from "../libs/statusMemo";

const TOPIC_NAME = process.env.topicName as string;
Expand Down Expand Up @@ -171,6 +171,9 @@ export async function withdrawRai(body: RaiWithdraw, document: any) {
JSON.stringify({
...result.data,
actionType: Action.WITHDRAW_RAI,
notificationMetadata: {
submissionDate: getNextBusinessDayTimestamp()
},
}),
);

Expand Down Expand Up @@ -273,6 +276,9 @@ export async function respondToRai(body: RaiResponse, document: any) {
...result.data,
responseDate: today,
actionType: Action.RESPOND_TO_RAI,
notificationMetadata: {
submissionDate: getNextBusinessDayTimestamp()
},
}),
);

Expand Down
4 changes: 2 additions & 2 deletions src/services/api/handlers/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ export const submit = async (event: APIGatewayEvent) => {
// ${subTypeIdsInsert}

// data for emails
body.notificationMetadata = {
submissionDate,
eventBody.data.notificationMetadata = {
submissionDate: submissionDate,
proposedEffectiveDate: body.proposedEffectiveDate,
};

Expand Down
Loading

0 comments on commit b3e76e9

Please sign in to comment.