Skip to content

Commit 05b8302

Browse files
authored
Merge pull request #913 from US-Trustee-Program/CAMS-283-update-model
CAMS-283: update model
2 parents 9872084 + a955b91 commit 05b8302

File tree

8 files changed

+189
-18
lines changed

8 files changed

+189
-18
lines changed

backend/functions/lib/adapters/gateways/storage/local-storage-gateway.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { CamsRole } from '../../../../../../common/src/cams/roles';
22
import { StorageGateway } from '../../types/storage';
3+
import { UstpOfficeDetails } from '../../../../../../common/src/cams/courts';
4+
import { USTP_OFFICE_DATA_MAP } from './ustp-office-data-map';
35

46
let roleMapping;
57
let officeMapping;
@@ -55,6 +57,10 @@ function getOfficeMapping(): Map<string, GroupDesignators> {
5557
return officeMapping;
5658
}
5759

60+
function getUstpOffices(): Map<string, UstpOfficeDetails> {
61+
return USTP_OFFICE_DATA_MAP;
62+
}
63+
5864
function getRoleMapping(): Map<string, CamsRole> {
5965
if (!roleMapping) {
6066
const roleArray = ROLE_MAPPING.split('\n');
@@ -74,6 +80,7 @@ function getRoleMapping(): Map<string, CamsRole> {
7480
export const LocalStorageGateway: StorageGateway = {
7581
get,
7682
getOfficeMapping,
83+
getUstpOffices,
7784
getRoleMapping,
7885
};
7986

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import { UstpOfficeDetails } from '../../../../../../common/src/cams/courts';
2+
3+
//TODO: We should probably put this in Cosmos so we don't have to deal with this locally
4+
export const USTP_OFFICE_DATA_MAP = new Map<string, UstpOfficeDetails>([
5+
[
6+
'USTP_CAMS_Region_18_Office_Seattle',
7+
{
8+
officeCode: 'USTP_CAMS_Region_18_Office_Seattle',
9+
idpGroupId: 'USTP CAMS Region 18 Office Seattle',
10+
officeName: 'Seattle',
11+
groups: [
12+
{
13+
groupDesignator: 'SE',
14+
divisions: [
15+
{
16+
divisionCode: '812',
17+
court: { courtId: '0981', courtName: 'Western District of Washington' },
18+
courtOffice: {
19+
courtOfficeCode: '2',
20+
courtOfficeName: 'Seattle',
21+
},
22+
},
23+
{
24+
divisionCode: '813',
25+
court: { courtId: '0981', courtName: 'Western District of Washington' },
26+
courtOffice: {
27+
courtOfficeCode: '3',
28+
courtOfficeName: 'Tacoma',
29+
},
30+
},
31+
],
32+
},
33+
{
34+
groupDesignator: 'AK',
35+
divisions: [
36+
{
37+
divisionCode: '710',
38+
court: { courtId: '097-', courtName: 'District of Alaska' },
39+
courtOffice: {
40+
courtOfficeCode: '1',
41+
courtOfficeName: 'Juneau',
42+
},
43+
},
44+
{
45+
divisionCode: '720',
46+
court: { courtId: '097-', courtName: 'District of Alaska' },
47+
courtOffice: {
48+
courtOfficeCode: '2',
49+
courtOfficeName: 'Nome',
50+
},
51+
},
52+
{
53+
divisionCode: '730',
54+
court: { courtId: '097-', courtName: 'District of Alaska' },
55+
courtOffice: {
56+
courtOfficeCode: '3',
57+
courtOfficeName: 'Anchorage',
58+
},
59+
},
60+
{
61+
divisionCode: '740',
62+
court: { courtId: '097-', courtName: 'District of Alaska' },
63+
courtOffice: {
64+
courtOfficeCode: '4',
65+
courtOfficeName: 'Fairbanks',
66+
},
67+
},
68+
{
69+
divisionCode: '750',
70+
court: { courtId: '097-', courtName: 'District of Alaska' },
71+
courtOffice: {
72+
courtOfficeCode: '5',
73+
courtOfficeName: 'Ketchikan',
74+
},
75+
},
76+
],
77+
},
78+
],
79+
regionId: '18',
80+
regionName: 'Seattle',
81+
},
82+
],
83+
[
84+
'USTP_CAMS_Region_2_Office_Manhattan',
85+
{
86+
officeCode: 'USTP_CAMS_Region_2_Office_Manhattan',
87+
idpGroupId: 'USTP CAMS Region 2 Office Manhattan',
88+
officeName: 'Manhattan',
89+
groups: [
90+
{
91+
groupDesignator: 'NY',
92+
divisions: [
93+
{
94+
divisionCode: '081',
95+
court: { courtId: '0208', courtName: 'Southern District of New York' },
96+
courtOffice: {
97+
courtOfficeCode: '1',
98+
courtOfficeName: 'Manhattan',
99+
},
100+
},
101+
{
102+
divisionCode: '087',
103+
court: { courtId: '0208', courtName: 'Southern District of New York' },
104+
courtOffice: {
105+
courtOfficeCode: '7',
106+
courtOfficeName: 'White Plains',
107+
},
108+
},
109+
],
110+
},
111+
],
112+
regionId: '2',
113+
regionName: 'New York',
114+
},
115+
],
116+
]);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { CamsRole } from '../../../../../common/src/cams/roles';
22
import { GroupDesignators } from '../gateways/storage/local-storage-gateway';
3+
import { UstpOfficeDetails } from '../../../../../common/src/cams/courts';
34

45
export type StorageGateway = {
56
get(key: string): string | null;
67
getOfficeMapping(): Map<string, GroupDesignators>;
8+
getUstpOffices(): Map<string, UstpOfficeDetails>;
79
getRoleMapping(): Map<string, CamsRole>;
810
};

common/src/cams/courts.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
1+
import { CamsUserReference } from './users';
2+
3+
//TODO: Start switching this over to use this
4+
export type CourtOfficeDetails = OfficeDetails;
15
export interface OfficeDetails {
26
officeName: string;
37
officeCode: string;
48
courtId: string;
5-
// TODO: court to office relationship is not one-to-one, may need to refactor
69
courtName: string;
710
courtDivisionCode: string;
811
courtDivisionName: string;
912
groupDesignator: string;
1013
regionId: string;
1114
regionName: string;
1215
state?: string;
16+
staff?: CamsUserReference[];
1317
}
1418

19+
//TODO: Some of these probably do not belong here
20+
export type UstpOfficeDetails = {
21+
officeCode: string; // Active Directory Group name (for now)
22+
officeName: string; // https://www.justice.gov/ust/us-trustee-regions-and-offices and dxtr.constants.ts
23+
groups: UstpGroup[];
24+
idpGroupId: string; // Okta
25+
regionId: string; // DXTR AO_REGION
26+
regionName: string; // DXTR AO_REGION
27+
state?: string; // https://www.justice.gov/ust/us-trustee-regions-and-offices
28+
staff?: CamsUserReference[];
29+
};
30+
31+
export type UstpGroup = {
32+
groupDesignator: string; // ACMS Group Office_Regions_and_Divisions.pdf
33+
divisions: UstpDivision[];
34+
};
35+
36+
export type UstpDivision = {
37+
divisionCode: string; // ACMS Div Code Office_Regions_and_Divisions.pdf
38+
court: Court;
39+
courtOffice: CourtOffice; // DXTR AO_CS_DIV.OFFICE_CODE
40+
};
41+
42+
export type Court = {
43+
courtId: string; // DXTR AO_CS_DIV.COURT_ID
44+
courtName?: string; // DXTR
45+
};
46+
47+
export type CourtOffice = {
48+
courtOfficeCode: string;
49+
courtOfficeName: string;
50+
};
51+
1552
export function filterCourtByDivision(divisionCode: string, officeList: OfficeDetails[]) {
1653
const divisionOffice = officeList.find((office) => office.courtDivisionCode === divisionCode);
1754
if (divisionOffice) {

common/src/cams/session.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ describe('session', () => {
1010
expect(CamsRole.SuperUser).toEqual('SuperUser');
1111
});
1212
});
13+
1314
describe('getCamsUserReference', () => {
14-
const user = MockData.getCamsUser();
15-
const expected = { id: user.id, name: user.name };
16-
const actual = getCamsUserReference(user);
17-
expect(actual).toEqual(expected);
15+
test('should return a CamsUserReference with expected properties', () => {
16+
const roles = [CamsRole.CaseAssignmentManager];
17+
const user = MockData.getCamsUser({ roles });
18+
const expected = { id: user.id, name: user.name, roles };
19+
const actual = getCamsUserReference(user);
20+
expect(actual).toEqual(expected);
21+
});
1822
});
1923
});

common/src/cams/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export type CamsSession = {
99
};
1010

1111
export function getCamsUserReference<T extends CamsUserReference>(user: T): CamsUserReference {
12-
const { id, name } = user;
13-
return { id, name };
12+
const { id, name, roles } = user;
13+
return { id, name, roles };
1414
}

common/src/cams/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { CamsRole } from './roles';
44
export type CamsUserReference = {
55
id: string;
66
name: string;
7+
roles?: CamsRole[];
78
};
89

910
export type CamsUser = CamsUserReference & {
1011
offices?: OfficeDetails[];
11-
roles?: CamsRole[];
1212
};
1313

1414
export type AttorneyUser = CamsUser & {

ops/cloud-deployment/params/ustp-cams-cosmos-containers.parameters.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"parameters": {
55
"databaseContainers": {
66
"value": [
7-
{
8-
"name": "healthcheck",
9-
"partitionKey1": "/id",
10-
"partitionKeys": ["/id"]
11-
},
127
{
138
"name": "assignments",
149
"partitionKey1": "/caseId",
@@ -19,16 +14,26 @@
1914
"partitionKey1": "/caseId",
2015
"partitionKeys": ["/caseId"]
2116
},
22-
{
23-
"name": "orders",
24-
"partitionKey1": "/caseId",
25-
"partitionKeys": ["/caseId"]
26-
},
2717
{
2818
"name": "consolidations",
2919
"partitionKey1": "/consolidationId",
3020
"partitionKeys": ["/consolidationId"]
3121
},
22+
{
23+
"name": "healthcheck",
24+
"partitionKey1": "/id",
25+
"partitionKeys": ["/id"]
26+
},
27+
{
28+
"name": "offices",
29+
"partitionKey1": "/officeCode",
30+
"partitionKeys": ["/officeCode"]
31+
},
32+
{
33+
"name": "orders",
34+
"partitionKey1": "/caseId",
35+
"partitionKeys": ["/caseId"]
36+
},
3237
{
3338
"name": "runtime-state",
3439
"partitionKey1": "/documentType",

0 commit comments

Comments
 (0)