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

CAMS-283: update model #913

Merged
merged 3 commits into from
Sep 17, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { CamsRole } from '../../../../../../common/src/cams/roles';
import { StorageGateway } from '../../types/storage';
import { UstpOfficeDetails } from '../../../../../../common/src/cams/courts';
import { USTP_OFFICE_DATA_MAP } from './ustp-office-data-map';

let roleMapping;
let officeMapping;
Expand Down Expand Up @@ -55,6 +57,10 @@ function getOfficeMapping(): Map<string, GroupDesignators> {
return officeMapping;
}

function getUstpOffices(): Map<string, UstpOfficeDetails> {
return USTP_OFFICE_DATA_MAP;
}

function getRoleMapping(): Map<string, CamsRole> {
if (!roleMapping) {
const roleArray = ROLE_MAPPING.split('\n');
Expand All @@ -74,6 +80,7 @@ function getRoleMapping(): Map<string, CamsRole> {
export const LocalStorageGateway: StorageGateway = {
get,
getOfficeMapping,
getUstpOffices,
getRoleMapping,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { UstpOfficeDetails } from '../../../../../../common/src/cams/courts';

//TODO: We should probably put this in Cosmos so we don't have to deal with this locally
export const USTP_OFFICE_DATA_MAP = new Map<string, UstpOfficeDetails>([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add the following in addition to NY and Seattle:

  'USTP_CAMS_Region_2_Office_Brooklyn,USTP CAMS Region 2 Office Brooklyn,BR\n' +
  'USTP_CAMS_Region_2_Office_Central_Islip,USTP CAMS Region 2 Office Central Islip,LI\n' +
  'USTP_CAMS_Region_2_Office_Albany,USTP CAMS Region 2 Office Albany,AL\n' +
  'USTP_CAMS_Region_2_Office_Utica,USTP CAMS Region 2 Office Utica,UT\n' +
  'USTP_CAMS_Region_2_Office_Buffalo,USTP CAMS Region 2 Office Buffalo,BU\n' +
  'USTP_CAMS_Region_2_Office_Rochester,USTP CAMS Region 2 Office Rochester,RO\n' +
  'USTP_CAMS_Region_2_Office_New_Haven,USTP CAMS Region 2 Office New Haven,NH\n' +

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least before we end work on CAMS-283.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a goal to our tracker.

[
'USTP_CAMS_Region_18_Office_Seattle',
{
officeCode: 'USTP_CAMS_Region_18_Office_Seattle',
idpGroupId: 'USTP CAMS Region 18 Office Seattle',
officeName: 'Seattle',
groups: [
{
groupDesignator: 'SE',
divisions: [
{
divisionCode: '812',
court: { courtId: '0981', courtName: 'Western District of Washington' },
courtOffice: {
courtOfficeCode: '2',
courtOfficeName: 'Seattle',
},
},
{
divisionCode: '813',
court: { courtId: '0981', courtName: 'Western District of Washington' },
courtOffice: {
courtOfficeCode: '3',
courtOfficeName: 'Tacoma',
},
},
],
},
{
groupDesignator: 'AK',
divisions: [
{
divisionCode: '710',
court: { courtId: '097-', courtName: 'District of Alaska' },
courtOffice: {
courtOfficeCode: '1',
courtOfficeName: 'Juneau',
},
},
{
divisionCode: '720',
court: { courtId: '097-', courtName: 'District of Alaska' },
courtOffice: {
courtOfficeCode: '2',
courtOfficeName: 'Nome',
},
},
{
divisionCode: '730',
court: { courtId: '097-', courtName: 'District of Alaska' },
courtOffice: {
courtOfficeCode: '3',
courtOfficeName: 'Anchorage',
},
},
{
divisionCode: '740',
court: { courtId: '097-', courtName: 'District of Alaska' },
courtOffice: {
courtOfficeCode: '4',
courtOfficeName: 'Fairbanks',
},
},
{
divisionCode: '750',
court: { courtId: '097-', courtName: 'District of Alaska' },
courtOffice: {
courtOfficeCode: '5',
courtOfficeName: 'Ketchikan',
},
},
],
},
],
regionId: '18',
regionName: 'Seattle',
},
],
[
'USTP_CAMS_Region_2_Office_Manhattan',
{
officeCode: 'USTP_CAMS_Region_2_Office_Manhattan',
idpGroupId: 'USTP CAMS Region 2 Office Manhattan',
officeName: 'Manhattan',
groups: [
{
groupDesignator: 'NY',
divisions: [
{
divisionCode: '081',
court: { courtId: '0208', courtName: 'Southern District of New York' },
courtOffice: {
courtOfficeCode: '1',
courtOfficeName: 'Manhattan',
},
},
{
divisionCode: '087',
court: { courtId: '0208', courtName: 'Southern District of New York' },
courtOffice: {
courtOfficeCode: '7',
courtOfficeName: 'White Plains',
},
},
],
},
],
regionId: '2',
regionName: 'New York',
},
],
]);
2 changes: 2 additions & 0 deletions backend/functions/lib/adapters/types/storage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { CamsRole } from '../../../../../common/src/cams/roles';
import { GroupDesignators } from '../gateways/storage/local-storage-gateway';
import { UstpOfficeDetails } from '../../../../../common/src/cams/courts';

export type StorageGateway = {
get(key: string): string | null;
getOfficeMapping(): Map<string, GroupDesignators>;
getUstpOffices(): Map<string, UstpOfficeDetails>;
getRoleMapping(): Map<string, CamsRole>;
};
39 changes: 38 additions & 1 deletion common/src/cams/courts.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
import { CamsUserReference } from './users';

//TODO: Start switching this over to use this
export type CourtOfficeDetails = OfficeDetails;
export interface OfficeDetails {
officeName: string;
officeCode: string;
courtId: string;
// TODO: court to office relationship is not one-to-one, may need to refactor
courtName: string;
courtDivisionCode: string;
courtDivisionName: string;
groupDesignator: string;
regionId: string;
regionName: string;
state?: string;
staff?: CamsUserReference[];
}

//TODO: Some of these probably do not belong here
export type UstpOfficeDetails = {
officeCode: string; // Active Directory Group name (for now)
officeName: string; // https://www.justice.gov/ust/us-trustee-regions-and-offices and dxtr.constants.ts
groups: UstpGroup[];
idpGroupId: string; // Okta
regionId: string; // DXTR AO_REGION
regionName: string; // DXTR AO_REGION
state?: string; // https://www.justice.gov/ust/us-trustee-regions-and-offices
staff?: CamsUserReference[];
};

export type UstpGroup = {
groupDesignator: string; // ACMS Group Office_Regions_and_Divisions.pdf
divisions: UstpDivision[];
};

export type UstpDivision = {
divisionCode: string; // ACMS Div Code Office_Regions_and_Divisions.pdf
court: Court;
courtOffice: CourtOffice; // DXTR AO_CS_DIV.OFFICE_CODE
};

export type Court = {
courtId: string; // DXTR AO_CS_DIV.COURT_ID
courtName?: string; // DXTR
};

export type CourtOffice = {
courtOfficeCode: string;
courtOfficeName: string;
};

export function filterCourtByDivision(divisionCode: string, officeList: OfficeDetails[]) {
const divisionOffice = officeList.find((office) => office.courtDivisionCode === divisionCode);
if (divisionOffice) {
Expand Down
12 changes: 8 additions & 4 deletions common/src/cams/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ describe('session', () => {
expect(CamsRole.SuperUser).toEqual('SuperUser');
});
});

describe('getCamsUserReference', () => {
const user = MockData.getCamsUser();
const expected = { id: user.id, name: user.name };
const actual = getCamsUserReference(user);
expect(actual).toEqual(expected);
test('should return a CamsUserReference with expected properties', () => {
const roles = [CamsRole.CaseAssignmentManager];
const user = MockData.getCamsUser({ roles });
const expected = { id: user.id, name: user.name, roles };
const actual = getCamsUserReference(user);
expect(actual).toEqual(expected);
});
});
});
4 changes: 2 additions & 2 deletions common/src/cams/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export type CamsSession = {
};

export function getCamsUserReference<T extends CamsUserReference>(user: T): CamsUserReference {
const { id, name } = user;
return { id, name };
const { id, name, roles } = user;
return { id, name, roles };
}
2 changes: 1 addition & 1 deletion common/src/cams/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { CamsRole } from './roles';
export type CamsUserReference = {
id: string;
name: string;
roles?: CamsRole[];
};

export type CamsUser = CamsUserReference & {
offices?: OfficeDetails[];
roles?: CamsRole[];
};

export type AttorneyUser = CamsUser & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
"parameters": {
"databaseContainers": {
"value": [
{
"name": "healthcheck",
"partitionKey1": "/id",
"partitionKeys": ["/id"]
},
{
"name": "assignments",
"partitionKey1": "/caseId",
Expand All @@ -19,16 +14,26 @@
"partitionKey1": "/caseId",
"partitionKeys": ["/caseId"]
},
{
"name": "orders",
"partitionKey1": "/caseId",
"partitionKeys": ["/caseId"]
},
{
"name": "consolidations",
"partitionKey1": "/consolidationId",
"partitionKeys": ["/consolidationId"]
},
{
"name": "healthcheck",
"partitionKey1": "/id",
"partitionKeys": ["/id"]
},
{
"name": "offices",
"partitionKey1": "/officeCode",
"partitionKeys": ["/officeCode"]
},
{
"name": "orders",
"partitionKey1": "/caseId",
"partitionKeys": ["/caseId"]
},
{
"name": "runtime-state",
"partitionKey1": "/documentType",
Expand Down
Loading