Skip to content

Commit

Permalink
Changing names to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
hannah-macdonald1 committed Dec 13, 2024
1 parent 2db80b1 commit 4a95a78
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 79 deletions.
12 changes: 12 additions & 0 deletions src/common/constants/upstream-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +39,12 @@ export {
startRowNumParamName,
recordCountNeededParamName,
pageSizeParamName,
createdByFieldName,
createdByIdFieldName,
createdDateFieldName,
updatedByFieldName,
updatedByIdFieldName,
updatedDateFieldName,
pageSizeMin,
pageSizeMax,
pageSizeDefault,
Expand Down
10 changes: 6 additions & 4 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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: {
Expand Down
44 changes: 26 additions & 18 deletions src/entities/attachments.entity.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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<AttachmentsEntity>) {
Object.assign(this, partial);
Expand Down
44 changes: 26 additions & 18 deletions src/entities/contacts.entity.ts
Original file line number Diff line number Diff line change
@@ -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
/*
Expand Down Expand Up @@ -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 } =
Expand Down Expand Up @@ -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);
Expand Down
44 changes: 26 additions & 18 deletions src/entities/in-person-visits.entity.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = {
Expand Down Expand Up @@ -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()
Expand Down
Loading

0 comments on commit 4a95a78

Please sign in to comment.