From 4a95a78e56e4845617bde329d7aee658f3b1c36c Mon Sep 17 00:00:00 2001 From: hannah-macdonald1 Date: Fri, 13 Dec 2024 11:36:55 -0700 Subject: [PATCH] Changing names to constants --- src/common/constants/upstream-constants.ts | 12 ++++++ src/configuration/configuration.ts | 10 +++-- src/entities/attachments.entity.ts | 44 +++++++++++-------- src/entities/contacts.entity.ts | 44 +++++++++++-------- src/entities/in-person-visits.entity.ts | 44 +++++++++++-------- src/entities/support-network.entity.ts | 50 +++++++++++++--------- 6 files changed, 125 insertions(+), 79 deletions(-) diff --git a/src/common/constants/upstream-constants.ts b/src/common/constants/upstream-constants.ts index 555849f..0ab9eea 100644 --- a/src/common/constants/upstream-constants.ts +++ b/src/common/constants/upstream-constants.ts @@ -11,6 +11,12 @@ const childVisitEntityIdFieldName = 'Parent Id'; const startRowNumParamName = 'StartRowNum'; const recordCountNeededParamName = 'recordcountneeded'; const pageSizeParamName = 'PageSize'; +const createdByFieldName = 'Created By'; +const createdByIdFieldName = 'Created By Id'; +const createdDateFieldName = 'Created Date'; +const updatedByFieldName = 'Updated By'; +const updatedByIdFieldName = 'Updated By Id'; +const updatedDateFieldName = 'Updated Date'; const pageSizeMin = 1; const pageSizeMax = 100; const pageSizeDefault = 10; @@ -33,6 +39,12 @@ export { startRowNumParamName, recordCountNeededParamName, pageSizeParamName, + createdByFieldName, + createdByIdFieldName, + createdDateFieldName, + updatedByFieldName, + updatedByIdFieldName, + updatedDateFieldName, pageSizeMin, pageSizeMax, pageSizeDefault, diff --git a/src/configuration/configuration.ts b/src/configuration/configuration.ts index 4bef50b..033afd1 100644 --- a/src/configuration/configuration.ts +++ b/src/configuration/configuration.ts @@ -1,3 +1,5 @@ +import { updatedDateFieldName } from '../common/constants/upstream-constants'; + export default () => ({ recordCache: { cacheTtlMs: parseInt(process.env.RECORD_CACHE_MS) || 5 * 60 * 1000, // 5 minutes @@ -39,10 +41,10 @@ export default () => ({ contacts: process.env.CONTACTS_WORKSPACE ?? undefined, }, sinceFieldName: { - supportNetwork: 'Updated Date', - inPersonVisits: 'Updated Date', - attachments: 'Updated Date', - contacts: 'Updated Date', + supportNetwork: updatedDateFieldName, + inPersonVisits: updatedDateFieldName, + attachments: updatedDateFieldName, + contacts: updatedDateFieldName, }, skipAuthGuard: process.env.SKIP_AUTH_GUARD === 'true', endpointUrls: { diff --git a/src/entities/attachments.entity.ts b/src/entities/attachments.entity.ts index 6ff8f1c..c473182 100644 --- a/src/entities/attachments.entity.ts +++ b/src/entities/attachments.entity.ts @@ -1,5 +1,13 @@ import { ApiProperty, ApiSchema } from '@nestjs/swagger'; import { Exclude, Expose, Type } from 'class-transformer'; +import { + createdByFieldName, + createdByIdFieldName, + createdDateFieldName, + updatedByFieldName, + updatedByIdFieldName, + updatedDateFieldName, +} from '../common/constants/upstream-constants'; /* * Examples @@ -39,12 +47,12 @@ const AttachmentsSingleResponseCaseExample = { MemoNumber: '', 'SR Id': '', Id: 'Attachment-Id-Here', - 'Created By': 'Creator-Idir-Here', - 'Created By Id': 'Creator-Id-Here', - 'Created Date': '01/01/1970 00:00:00', - 'Updated By': 'Updater-Idir-Here', - 'Updated By Id': 'Updater-Id-Here', - 'Updated Date': '01/01/1970 00:00:00', + [createdByFieldName]: 'Creator-Idir-Here', + [createdByIdFieldName]: 'Creator-Id-Here', + [createdDateFieldName]: '01/01/1970 00:00:00', + [updatedByFieldName]: 'Updater-Idir-Here', + [updatedByIdFieldName]: 'Updater-Id-Here', + [updatedDateFieldName]: '01/01/1970 00:00:00', }; export const AttachmentDetailsCaseExample = { @@ -358,40 +366,40 @@ class AttachmentsEntity { Id: string; @ApiProperty({ - example: AttachmentsSingleResponseCaseExample['Created By'], + example: AttachmentsSingleResponseCaseExample[createdByFieldName], }) @Expose() - 'Created By': string; + [createdByFieldName]: string; @ApiProperty({ - example: AttachmentsSingleResponseCaseExample['Created By Id'], + example: AttachmentsSingleResponseCaseExample[createdByIdFieldName], }) @Expose() - 'Created By Id': string; + [createdByIdFieldName]: string; @ApiProperty({ - example: AttachmentsSingleResponseCaseExample['Created Date'], + example: AttachmentsSingleResponseCaseExample[createdDateFieldName], }) @Expose() - 'Created Date': string; + [createdDateFieldName]: string; @ApiProperty({ - example: AttachmentsSingleResponseCaseExample['Updated By'], + example: AttachmentsSingleResponseCaseExample[updatedByFieldName], }) @Expose() - 'Updated By': string; + [updatedByFieldName]: string; @ApiProperty({ - example: AttachmentsSingleResponseCaseExample['Updated By Id'], + example: AttachmentsSingleResponseCaseExample[updatedByIdFieldName], }) @Expose() - 'Updated By Id': string; + [updatedByIdFieldName]: string; @ApiProperty({ - example: AttachmentsSingleResponseCaseExample['Updated Date'], + example: AttachmentsSingleResponseCaseExample[updatedDateFieldName], }) @Expose() - 'Updated Date': string; + [updatedDateFieldName]: string; constructor(partial: Partial) { Object.assign(this, partial); diff --git a/src/entities/contacts.entity.ts b/src/entities/contacts.entity.ts index bf8b6ad..7a1bc42 100644 --- a/src/entities/contacts.entity.ts +++ b/src/entities/contacts.entity.ts @@ -1,5 +1,13 @@ import { ApiProperty, ApiSchema } from '@nestjs/swagger'; import { Exclude, Expose, Type } from 'class-transformer'; +import { + createdByFieldName, + createdByIdFieldName, + createdDateFieldName, + updatedByFieldName, + updatedByIdFieldName, + updatedDateFieldName, +} from '../common/constants/upstream-constants'; // TODO: Add more string examples once we can query the endpoint /* @@ -29,12 +37,12 @@ export const ContactsSingleResponseCaseExample = { 'Case Con Original Start Dt': '', 'Case Con Start Dt': '01/01/1970 00:00:00', 'Case Con End Dt': '', - 'Created By': 'Creator-Idir-Here', - 'Created By Id': 'Creator-Id-Here', - 'Created Date': '01/01/1970 00:00:00', - 'Updated By': 'Updater-Idir-Here', - 'Updated By Id': 'Updater-Id-Here', - 'Updated Date': '01/01/1970 00:00:00', + [createdByFieldName]: 'Creator-Idir-Here', + [createdByIdFieldName]: 'Creator-Id-Here', + [createdDateFieldName]: '01/01/1970 00:00:00', + [updatedByFieldName]: 'Updater-Idir-Here', + [updatedByIdFieldName]: 'Updater-Id-Here', + [updatedDateFieldName]: '01/01/1970 00:00:00', }; export const { ...ContactsSingleResponseIncidentExample } = @@ -232,40 +240,40 @@ class ContactsEntity { 'Case Con End Dt': string; @ApiProperty({ - example: ContactsSingleResponseCaseExample['Created By'], + example: ContactsSingleResponseCaseExample[createdByFieldName], }) @Expose() - 'Created By': string; + [createdByFieldName]: string; @ApiProperty({ - example: ContactsSingleResponseCaseExample['Created By Id'], + example: ContactsSingleResponseCaseExample[createdByIdFieldName], }) @Expose() - 'Created By Id': string; + [createdByIdFieldName]: string; @ApiProperty({ - example: ContactsSingleResponseCaseExample['Created Date'], + example: ContactsSingleResponseCaseExample[createdDateFieldName], }) @Expose() - 'Created Date': string; + [createdDateFieldName]: string; @ApiProperty({ - example: ContactsSingleResponseCaseExample['Updated By'], + example: ContactsSingleResponseCaseExample[updatedByFieldName], }) @Expose() - 'Updated By': string; + [updatedByFieldName]: string; @ApiProperty({ - example: ContactsSingleResponseCaseExample['Updated By Id'], + example: ContactsSingleResponseCaseExample[updatedByIdFieldName], }) @Expose() - 'Updated By Id': string; + [updatedByIdFieldName]: string; @ApiProperty({ - example: ContactsSingleResponseCaseExample['Updated Date'], + example: ContactsSingleResponseCaseExample[updatedDateFieldName], }) @Expose() - 'Updated Date': string; + [updatedDateFieldName]: string; constructor(object) { Object.assign(this, object); diff --git a/src/entities/in-person-visits.entity.ts b/src/entities/in-person-visits.entity.ts index 14f914f..6eeefaa 100644 --- a/src/entities/in-person-visits.entity.ts +++ b/src/entities/in-person-visits.entity.ts @@ -1,5 +1,13 @@ import { ApiProperty, ApiSchema } from '@nestjs/swagger'; import { Exclude, Expose, Type } from 'class-transformer'; +import { + createdByFieldName, + createdByIdFieldName, + createdDateFieldName, + updatedByFieldName, + updatedByIdFieldName, + updatedDateFieldName, +} from '../common/constants/upstream-constants'; /* * Examples @@ -13,12 +21,12 @@ const InPersonVisitsSingleResponseCaseExample = { 'Visit Details Value': 'comment', 'Parent Id': 'Entity-Id-here', 'Login Name': 'Idir-here', - 'Created By': 'Creator-Idir-Here', - 'Created By Id': 'Creator-Id-Here', - 'Created Date': '01/01/1970 00:00:00', - 'Updated By': 'Updater-Idir-Here', - 'Updated By Id': 'Updater-Id-Here', - 'Updated Date': '01/01/1970 00:00:00', + [createdByFieldName]: 'Creator-Idir-Here', + [createdByIdFieldName]: 'Creator-Id-Here', + [createdDateFieldName]: '01/01/1970 00:00:00', + [updatedByFieldName]: 'Updater-Idir-Here', + [updatedByIdFieldName]: 'Updater-Id-Here', + [updatedDateFieldName]: '01/01/1970 00:00:00', }; export const InPersonVisitsListResponseCaseExample = { @@ -94,40 +102,40 @@ class InPersonVisitsEntity { 'Login Name': string; @ApiProperty({ - example: InPersonVisitsSingleResponseCaseExample['Created By'], + example: InPersonVisitsSingleResponseCaseExample[createdByFieldName], }) @Expose() - 'Created By': string; + [createdByFieldName]: string; @ApiProperty({ - example: InPersonVisitsSingleResponseCaseExample['Created By Id'], + example: InPersonVisitsSingleResponseCaseExample[createdByIdFieldName], }) @Expose() - 'Created By Id': string; + [createdByIdFieldName]: string; @ApiProperty({ - example: InPersonVisitsSingleResponseCaseExample['Created Date'], + example: InPersonVisitsSingleResponseCaseExample[createdDateFieldName], }) @Expose() - 'Created Date': string; + [createdDateFieldName]: string; @ApiProperty({ - example: InPersonVisitsSingleResponseCaseExample['Updated By'], + example: InPersonVisitsSingleResponseCaseExample[updatedByFieldName], }) @Expose() - 'Updated By': string; + [updatedByFieldName]: string; @ApiProperty({ - example: InPersonVisitsSingleResponseCaseExample['Updated By Id'], + example: InPersonVisitsSingleResponseCaseExample[updatedByIdFieldName], }) @Expose() - 'Updated By Id': string; + [updatedByIdFieldName]: string; @ApiProperty({ - example: InPersonVisitsSingleResponseCaseExample['Updated Date'], + example: InPersonVisitsSingleResponseCaseExample[updatedDateFieldName], }) @Expose() - 'Updated Date': string; + [updatedDateFieldName]: string; } @Exclude() diff --git a/src/entities/support-network.entity.ts b/src/entities/support-network.entity.ts index f97b210..33f251c 100644 --- a/src/entities/support-network.entity.ts +++ b/src/entities/support-network.entity.ts @@ -1,6 +1,14 @@ import { ApiProperty, ApiSchema } from '@nestjs/swagger'; import { Exclude, Expose, Type } from 'class-transformer'; import { EntityType } from '../common/constants/enumerations'; +import { + createdByFieldName, + createdByIdFieldName, + createdDateFieldName, + updatedByFieldName, + updatedByIdFieldName, + updatedDateFieldName, +} from '../common/constants/upstream-constants'; /* * Examples @@ -20,12 +28,12 @@ const SupportNetworkSingleResponseCaseExample = { Address: 'Test Address', Active: 'Yes', 'ICM SNC Case Con Flag': 'N', - 'Created By': 'Creator-Idir-Here', - 'Created By Id': 'Creator-Id-Here', - 'Created Date': '01/01/1970 00:00:00', - 'Updated By': 'Updater-Idir-Here', - 'Updated By Id': 'Updater-Id-Here', - 'Updated Date': '01/01/1970 00:00:00', + [createdByFieldName]: 'Creator-Idir-Here', + [createdByIdFieldName]: 'Creator-Id-Here', + [createdDateFieldName]: '01/01/1970 00:00:00', + [updatedByFieldName]: 'Updater-Idir-Here', + [updatedByIdFieldName]: 'Updater-Id-Here', + [updatedDateFieldName]: '01/01/1970 00:00:00', }; const SupportNetworkSingleResponseSRExample = { @@ -42,7 +50,7 @@ export const SupportNetworkListResponseCaseExample = { items: [ { ...SupportNetworkSingleResponseCaseExample, - 'Updated Date': '12/25/2024 00:33:37', + [updatedDateFieldName]: '12/25/2024 00:33:37', }, SupportNetworkSingleResponseCaseExample, ], @@ -52,7 +60,7 @@ export const SupportNetworkListResponseSRExample = { items: [ { ...SupportNetworkSingleResponseSRExample, - 'Updated Date': '12/25/2024 00:33:37', + [updatedDateFieldName]: '12/25/2024 00:33:37', }, SupportNetworkSingleResponseSRExample, ], @@ -62,7 +70,7 @@ export const SupportNetworkListResponseIncidentExample = { items: [ { ...SupportNetworkSingleResponseIncidentExample, - 'Updated Date': '12/25/2024 00:33:37', + [updatedDateFieldName]: '12/25/2024 00:33:37', }, SupportNetworkSingleResponseIncidentExample, ], @@ -148,40 +156,40 @@ class SupportNetworkEntity { 'ICM SNC Case Con Flag': string; @ApiProperty({ - example: SupportNetworkSingleResponseCaseExample['Created By'], + example: SupportNetworkSingleResponseCaseExample[createdByFieldName], }) @Expose() - 'Created By': string; + [createdByFieldName]: string; @ApiProperty({ - example: SupportNetworkSingleResponseCaseExample['Created By Id'], + example: SupportNetworkSingleResponseCaseExample[createdByIdFieldName], }) @Expose() - 'Created By Id': string; + [createdByIdFieldName]: string; @ApiProperty({ - example: SupportNetworkSingleResponseCaseExample['Created Date'], + example: SupportNetworkSingleResponseCaseExample[createdDateFieldName], }) @Expose() - 'Created Date': string; + [createdDateFieldName]: string; @ApiProperty({ - example: SupportNetworkSingleResponseCaseExample['Updated By'], + example: SupportNetworkSingleResponseCaseExample[updatedByFieldName], }) @Expose() - 'Updated By': string; + [updatedByFieldName]: string; @ApiProperty({ - example: SupportNetworkSingleResponseCaseExample['Updated By Id'], + example: SupportNetworkSingleResponseCaseExample[updatedByIdFieldName], }) @Expose() - 'Updated By Id': string; + [updatedByIdFieldName]: string; @ApiProperty({ - example: SupportNetworkSingleResponseCaseExample['Updated Date'], + example: SupportNetworkSingleResponseCaseExample[updatedDateFieldName], }) @Expose() - 'Updated Date': string; + [updatedDateFieldName]: string; constructor(partial: Partial) { Object.assign(this, partial);