Skip to content
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

Release to val #470

Merged
merged 2 commits into from
Mar 26, 2024
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand All @@ -137,7 +137,7 @@ jobs:
- name: Setup
uses: ./.github/actions/setup
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand All @@ -164,7 +164,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down Expand Up @@ -196,7 +196,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/running-stage-notifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security-group-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: ./.github/actions/setup # We need this largely for the PROJECT variable setting

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security-hub-jira-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workspace-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
Expand Down
4 changes: 3 additions & 1 deletion src/packages/shared-types/action-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export * from "./respond-to-rai";
export * from "./withdraw-rai";
export * from "./withdraw-package";
export * from "./new-submission";
export * from "./legacy-submission";
export * from "./legacy-event";
export * from "./legacy-package-view";
export * from "./legacy-admin-change";
export * from "./seatool";
export * from "./remove-appk-child";
11 changes: 11 additions & 0 deletions src/packages/shared-types/action-types/legacy-admin-change.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { z } from "zod";

// A schema for legacy admin changes
export const legacyAdminChangeSchema = z.object({
changeTimestamp: z.number(),
changeType: z.string().nullish(),
changeMade: z.string(),
changeReason: z.string().optional().default(""),
});

export type LegacyAdminChange = z.infer<typeof legacyAdminChangeSchema>;
14 changes: 14 additions & 0 deletions src/packages/shared-types/action-types/legacy-event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { z } from "zod";
import { legacySharedSchema } from "./legacy-shared";
import { legacyAttachmentSchema } from "../attachments";

// Event schema for legacy records
export const legacyEventSchema = legacySharedSchema.merge(
z.object({
eventTimestamp: z.number().nullish(),
GSI1pk: z.string(),
componentId: z.string(),
attachments: z.array(legacyAttachmentSchema).nullish(),
}),
);
export type LegacyEvent = z.infer<typeof legacyEventSchema>;
16 changes: 16 additions & 0 deletions src/packages/shared-types/action-types/legacy-package-view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { z } from "zod";
import { legacySharedSchema } from "./legacy-shared";
import { legacyAdminChangeSchema } from "./legacy-admin-change";

// Event schema for legacy package actions
export const legacyPackageViewSchema = legacySharedSchema.merge(
z.object({
submissionTimestamp: z.number().nullish(),
componentType: z.string().nullish(),
raiWithdrawEnabled: z.boolean().default(false),
parentId: z.string().nullish(),
temporaryExtensionType: z.string().nullish(),
adminChanges: z.array(legacyAdminChangeSchema).nullish(),
}),
);
export type LegacyPackageAction = z.infer<typeof legacyPackageViewSchema>;
9 changes: 9 additions & 0 deletions src/packages/shared-types/action-types/legacy-shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { z } from "zod";

// A base event schema used by all legacy events.
export const legacySharedSchema = z.object({
state: z.string().nullable().optional(),
additionalInformation: z.string().nullable().default(null),
submitterName: z.string(),
submitterEmail: z.string(),
});
12 changes: 0 additions & 12 deletions src/packages/shared-types/action-types/legacy-submission.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/packages/shared-types/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export enum Action {
WITHDRAW_PACKAGE = "withdraw-package",
REMOVE_APPK_CHILD = "remove-appk-child",
TEMP_EXTENSION = "temporary-extension",
LEGACY_ADMIN_CHANGE = "legacy-admin-change",
LEGACY_WITHDRAW_RAI_REQUEST = "legacy-withdraw-rai-request"
}

export type ActionRule = {
Expand Down
13 changes: 12 additions & 1 deletion src/packages/shared-types/opensearch/_.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ export type AggResult = Record<
}
>;

export type Index = "main" | "insights" | "changelog" | "types" | "subtypes";
export type ExportHeaderOptions<TData> = {
transform: (data: TData) => string;
name: string;
};

export type Index =
| "main"
| "insights"
| "changelog"
| "types"
| "subtypes"
| "legacyinsights";
9 changes: 8 additions & 1 deletion src/packages/shared-types/opensearch/changelog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
Filterable as FIL,
QueryState,
AggQuery,
ExportHeaderOptions,
} from "./../_";
import { z } from "zod";
import {
OneMac,
RaiIssue,
Expand All @@ -13,6 +15,7 @@ import {
WithdrawPackage,
ToggleWithdrawRaiEnabled,
} from "../../action-types";
import { legacyAdminChange, legacyEvent } from "./transforms";

export type Document = OneMac &
WithdrawPackage &
Expand All @@ -24,7 +27,8 @@ export type Document = OneMac &
timestamp: string;
packageId: string;
appkChildId: string;
};
} & z.infer<legacyEvent.Schema> &
z.infer<legacyAdminChange.Schema>;

export type Response = Res<Document>;
export type ItemResult = Hit<Document> & {
Expand All @@ -35,3 +39,6 @@ export type Field = keyof Document | `${keyof Document}.keyword`;
export type Filterable = FIL<Field>;
export type State = QueryState<Field>;
export type Aggs = AggQuery<Field>;
export type ExportHeader = ExportHeaderOptions<Document>;

export * from "./transforms";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * as legacyEvent from "./legacy-event";
export * as legacyAdminChange from "./legacy-admin-change";
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { legacyAdminChangeSchema, Action } from "../../..";

export const transform = (id: string) => {
return legacyAdminChangeSchema.transform((data) => {
const transformedData = {
// Timestamp is what makes admin changes unique; we add it to the id here, instead of the offset
id: `${id}-legacy-admin-change-${data.changeTimestamp}`,
packageId: id,
timestamp: data.changeTimestamp,
actionType: Action.LEGACY_ADMIN_CHANGE,
changeType: data.changeType,
changeMade: data.changeMade,
changeReason: data.changeReason,
};
return transformedData;
});
};

export type Schema = ReturnType<typeof transform>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { legacyEventSchema, handleLegacyAttachment, Action } from "../../..";

export const transform = (id: string) => {
return legacyEventSchema.transform((data) => {
// Resolve the action type based on the GSI1pk
const eventType = data.GSI1pk.split("OneMAC#submit")[1];

let actionType;

switch (eventType) {
case "chipspa":
case "medicaidspa":
case "waiveramendment":
case "waiverappk":
case "waiverextension":
case "waiverextensionb":
case "waiverextensionc":
case "waivernew":
case "waiverrenewal":
actionType = "new-submission";
break;
case "chipsparai":
case "medicaidsparai":
case "waiveramendmentrai":
case "waiverappkrai":
case "waiverrai":
actionType = Action.RESPOND_TO_RAI;
break;
case "chipspawithdraw":
case "medicaidspawithdraw":
case "waiveramendmentwithdraw":
case "waiverappkwithdraw":
case "waivernewwithdraw":
case "waiverrenewalwithdraw":
actionType = Action.WITHDRAW_PACKAGE;
break;
case "rairesponsewithdraw":
actionType = Action.LEGACY_WITHDRAW_RAI_REQUEST;
break;
default:
console.log(
`Unhandled event type for ${id}: ${eventType}. Doing nothing and continuing.`,
);
actionType = undefined;
break;
}

// Return if the actionType is unhandled
if (actionType === undefined) return undefined;

// If we're still here, go ahead and transform the data
const transformedData = {
// Append only changelog, so we add the offset to make the document id unique
// Legacy emits can emit multiple events for the same business event, so we key off the timestamp, not the offset, to prevent duplciates
id: `${data.componentId}-legacy-${data.eventTimestamp}`,
packageId: id,
timestamp: data.eventTimestamp,
actionType,
attachments: data.attachments?.map(handleLegacyAttachment) ?? null,
additionalInformation: data.additionalInformation,
submitterEmail: data.submitterEmail,
submitterName: data.submitterName,
};
return transformedData;
});
};

export type Schema = ReturnType<typeof transform>;
4 changes: 2 additions & 2 deletions src/packages/shared-types/opensearch/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { z } from "zod";
import { ItemResult as Changelog } from "./../changelog";
import {
newSubmission,
legacySubmission,
legacyPackageView,
withdrawPackage,
withdrawRai,
toggleWithdrawEnabled,
Expand All @@ -18,7 +18,7 @@ import {
} from "./transforms";

export type Document = z.infer<newSubmission.Schema> &
z.infer<legacySubmission.Schema> &
z.infer<legacyPackageView.Schema> &
z.infer<withdrawRai.Schema> &
z.infer<withdrawPackage.Schema> &
z.infer<toggleWithdrawEnabled.Schema> &
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * as legacySubmission from "./legacy-submission";
export * as legacyPackageView from "./legacy-package-view";
export * as newSubmission from "./new-submission";
export * as toggleWithdrawEnabled from "./toggle-withdraw-enabled";
export * as withdrawPackage from "./withdraw-package";
Expand Down
Loading
Loading