-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathmapper.ts
More file actions
159 lines (154 loc) · 6.83 KB
/
mapper.ts
File metadata and controls
159 lines (154 loc) · 6.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import { DocketEntry } from '@shared/business/entities/DocketEntry';
import { calculateDate } from '@shared/business/utilities/DateHandler';
import { DatabaseSchema } from '@web-api/database-schema';
import { NewDocketEntryKysely } from '@web-api/persistence/postgres/docketEntries/schema';
import { DatabaseToAppCodeMapper } from '@web-api/persistence/postgres/utils/databaseToAppCodeMapper';
// eslint-disable-next-line complexity
export function toKyselyNewDocketEntry(
docketEntry: RawDocketEntry,
): NewDocketEntryKysely {
return {
action: docketEntry.action ?? null,
additionalInfo: docketEntry.additionalInfo ?? null,
additionalInfo2: docketEntry.additionalInfo2 ?? null,
addToCoversheet: docketEntry.addToCoversheet ?? null,
archived: docketEntry.archived ?? null,
attachments: docketEntry.attachments ?? null,
caseType: docketEntry.caseType ?? null,
certificateOfService: docketEntry.certificateOfService ?? null,
certificateOfServiceDate: docketEntry.certificateOfServiceDate
? calculateDate({ dateString: docketEntry.certificateOfServiceDate })
: null,
createdAt: calculateDate({ dateString: docketEntry.createdAt }),
date: docketEntry.date
? calculateDate({ dateString: docketEntry.date })
: null,
docketEntryId: docketEntry.docketEntryId,
docketNumber: docketEntry.docketNumber,
docketNumbers: docketEntry.docketNumbers ?? null,
documentContentsId: docketEntry.documentContentsId ?? null,
documentIdBeforeSignature: docketEntry.documentIdBeforeSignature ?? null,
documentStorageId:
docketEntry.documentStorageId ?? docketEntry.docketEntryId, // 8477TODO: temp, remove after migration
documentTitle: docketEntry.documentTitle,
documentType: docketEntry.documentType ?? null,
draftOrderState: docketEntry.draftOrderState
? JSON.stringify(docketEntry.draftOrderState)
: null,
editState: docketEntry.editState ?? null,
eventCode: docketEntry.eventCode,
filedBy: docketEntry.filedBy ?? null,
filedByRole: docketEntry.filedByRole ?? null,
filers: JSON.stringify(docketEntry.filers),
filingDate: calculateDate({ dateString: docketEntry.filingDate }),
freeText: docketEntry.freeText ?? null,
hasOtherFilingParty: docketEntry.hasOtherFilingParty ?? null,
hasSupportingDocuments: docketEntry.hasSupportingDocuments ?? null,
index: docketEntry.index ?? null,
isAutoGenerated: docketEntry.isAutoGenerated ?? null,
isDraft: docketEntry.isDraft ?? null,
isFileAttached: docketEntry.isFileAttached ?? null,
isLegacy: docketEntry.isLegacy ?? null,
isLegacySealed: docketEntry.isLegacySealed ?? null,
isLegacyServed: docketEntry.isLegacyServed ?? false,
isOnDocketRecord: docketEntry.isOnDocketRecord,
isPaper: docketEntry.isPaper ?? null,
isPendingService: docketEntry.isPendingService ?? null,
isSealed: docketEntry.isSealed === undefined ? false : docketEntry.isSealed,
isStricken: docketEntry.isStricken ?? null,
judge: docketEntry.judge ?? null,
lodged: docketEntry.lodged ?? null,
mailingDate: docketEntry.mailingDate ?? null,
noticeIssuedDate: docketEntry.noticeIssuedDate
? calculateDate({ dateString: docketEntry.noticeIssuedDate })
: null,
numberOfPages: docketEntry.numberOfPages ?? null,
objections: docketEntry.objections ?? null,
ordinalValue: docketEntry.ordinalValue ?? null,
otherFilingParty: docketEntry.otherFilingParty ?? null,
otherIteration: docketEntry.otherIteration ?? null,
partyIrsPractitioner: docketEntry.partyIrsPractitioner ?? null,
pending: docketEntry.pending ?? null,
previousDocument: JSON.stringify(docketEntry.previousDocument) ?? null,
privatePractitioners:
JSON.stringify(docketEntry.privatePractitioners) ?? null,
processingStatus: docketEntry.processingStatus,
receivedAt: calculateDate({ dateString: docketEntry.receivedAt }),
redactionAcknowledgement: docketEntry.redactionAcknowledgement ?? null,
relationship: docketEntry.relationship ?? null,
scenario: docketEntry.scenario ?? null,
sealedTo: docketEntry.sealedTo,
secondaryDocument: JSON.stringify(docketEntry.secondaryDocument) ?? null,
servedAt: docketEntry.servedAt
? calculateDate({ dateString: docketEntry.servedAt })
: null,
servedParties: JSON.stringify(docketEntry.servedParties) ?? null,
servedPartiesCode: docketEntry.servedPartiesCode ?? null,
serviceDate: docketEntry.serviceDate
? calculateDate({ dateString: docketEntry.serviceDate })
: null,
serviceStamp: docketEntry.serviceStamp ?? null,
signedAt: docketEntry.signedAt ?? null,
signedByUserId: docketEntry.signedByUserId ?? null,
signedJudgeName: docketEntry.signedJudgeName ?? null,
stampData: JSON.stringify(docketEntry.stampData) ?? null,
strickenAt: docketEntry.strickenAt
? calculateDate({ dateString: docketEntry.strickenAt })
: null,
strickenBy: docketEntry.strickenBy ?? null,
strickenByUserId: docketEntry.strickenByUserId ?? null,
supportingDocument: docketEntry.supportingDocument ?? null,
taxYear: docketEntry.taxYear ?? null,
trialLocation: docketEntry.trialLocation ?? null,
userId: docketEntry.userId ?? null,
};
}
export function fromKyselyDocketEntry<T extends object>(record: T) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const dwDocketEntrySchema = DatabaseSchema.dwDocketEntry.table;
const transformMap = {
certificateOfServiceDate: (
value: typeof dwDocketEntrySchema.certificateOfServiceDate,
_: Partial<DocketEntry>,
) => value?.toISOString(),
createdAt: (
value: typeof dwDocketEntrySchema.createdAt,
_: Partial<DocketEntry>,
) => value.toISOString(),
date: (value: typeof dwDocketEntrySchema.date, _: Partial<DocketEntry>) =>
value?.toISOString(),
filingDate: (
value: typeof dwDocketEntrySchema.filingDate,
_: Partial<DocketEntry>,
) => value.toISOString(),
noticeIssuedDate: (
value: typeof dwDocketEntrySchema.noticeIssuedDate,
_: Partial<DocketEntry>,
) => value?.toISOString(),
receivedAt: (
value: typeof dwDocketEntrySchema.receivedAt,
_: Partial<DocketEntry>,
) => value.toISOString(),
servedAt: (
value: typeof dwDocketEntrySchema.servedAt,
_: Partial<DocketEntry>,
) => value?.toISOString(),
serviceDate: (
value: typeof dwDocketEntrySchema.serviceDate,
_: Partial<DocketEntry>,
) => value?.toISOString(),
stampData: (
value: typeof dwDocketEntrySchema.stampData,
_: Partial<DocketEntry>,
) => value ?? {},
strickenAt: (
value: typeof dwDocketEntrySchema.strickenAt,
_: Partial<DocketEntry>,
) => value?.toISOString(),
} as const;
const keyRenameMap = {} as const;
return new DatabaseToAppCodeMapper({
keyRenameMap,
transformMap,
}).transform(record);
}