Created
April 5, 2025 00:53
-
-
Save jelical/603605253a4bcf3e507a517776d764b6 to your computer and use it in GitHub Desktop.
For geminy
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/.eslintrc.js b/.eslintrc.js | |
| index 370fa4b35..3e0a7d470 100644 | |
| --- a/.eslintrc.js | |
| +++ b/.eslintrc.js | |
| @@ -19,25 +19,6 @@ module.exports = { | |
| // "filename-rules/not-match": ["error", {"includePath": true, | |
| // "pattern": /^(.*)?\/?src\/.*\/index\.ts/ | |
| // }], | |
| - 'dot-location': ["warn", "property"], | |
| - 'no-restricted-syntax': [ | |
| - 'error', | |
| - { | |
| - selector: 'NewExpression[callee.property.name="ObjectId"]', | |
| - message: | |
| - 'Do not use `ObjectId` constructor directly. Use `objectStringId` instead.', | |
| - }, | |
| - { | |
| - selector: 'CallExpression[callee.property.name="ObjectId"] CallExpression[callee.object.name="Types"]', | |
| - message: | |
| - 'Do not call `Types.ObjectId` constructor directly. Use `objectStringId` instead.', | |
| - }, | |
| - { | |
| - selector: 'CallExpression[callee.name="isMongoId"]', | |
| - message: | |
| - 'Do not call class-validator`s `isMongoId` - it is broken. Use `isObjectId` from @vinny/helpers instead.', | |
| - } | |
| - ], | |
| 'no-unused-vars': 'off', | |
| '@typescript-eslint/consistent-type-imports': 'off', | |
| 'import/no-cycle': ['error'], | |
| diff --git a/apps/activity-logs-ms/src/activity-logs/dal/activity-logs.dal.ts b/apps/activity-logs-ms/src/activity-logs/dal/activity-logs.dal.ts | |
| index 6f7a9d1c9..ce9264807 100644 | |
| --- a/apps/activity-logs-ms/src/activity-logs/dal/activity-logs.dal.ts | |
| +++ b/apps/activity-logs-ms/src/activity-logs/dal/activity-logs.dal.ts | |
| @@ -1,8 +1,8 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { ActivityLog, ActivityLogDocument } from './schemas/activity-log.schema'; | |
| -import { objectId, schemaToDto } from '@vinny/helpers'; | |
| +import { schemaToDto } from '@vinny/helpers'; | |
| import { | |
| ACTIVITY_LOG_DEFAULT_LIMIT, | |
| ActivityLogDto, | |
| @@ -30,14 +30,14 @@ export class ActivityLogsDALService { | |
| } | |
| async findOne(type: ActivityLogType, relatedDataId: string): Promise<ActivityLogDto> { | |
| - const query = { type, 'additionalData.relatedDataId': objectId(relatedDataId) }; | |
| + const query = { type, 'additionalData.relatedDataId': Types.ObjectId(relatedDataId) }; | |
| const result = await this.activityLogModel.findOne(query); | |
| return schemaToDto(ActivityLogDto, result?.toObject()); | |
| } | |
| async findByRelatedDataIds(relatedDataIds: string[]): Promise<ActivityLogDto[]> { | |
| const query = { | |
| - 'additionalData.relatedDataId': { $in: relatedDataIds.map((id) => objectId(id)) }, | |
| + 'additionalData.relatedDataId': { $in: relatedDataIds.map((id) => Types.ObjectId(id)) }, | |
| }; | |
| const result = await this.activityLogModel.find(query); | |
| return result.map((doc) => schemaToDto(ActivityLogDto, doc.toObject())); | |
| @@ -55,12 +55,12 @@ export class ActivityLogsDALService { | |
| aggregatedTypes = [], | |
| } = activityLogRequest; | |
| const query = { | |
| - ...(caseId && { 'additionalData.caseId': objectId(caseId) }), | |
| + ...(caseId && { 'additionalData.caseId': Types.ObjectId(caseId) }), | |
| ...(type && { type }), | |
| ...(types && { type: { $in: types } }), | |
| ...(initiators && { | |
| 'additionalData.initiator': { | |
| - $in: initiators.map((initiator) => objectId(initiator)), | |
| + $in: initiators.map((initiator) => Types.ObjectId(initiator)), | |
| }, | |
| }), | |
| ...(subTypes && { $or: [{ subType: { $in: subTypes } }, { subType: { $exists: false } }] }), | |
| diff --git a/apps/activity-logs-ms/src/activity-logs/dal/schemas/activity-log.schema.ts b/apps/activity-logs-ms/src/activity-logs/dal/schemas/activity-log.schema.ts | |
| index d194dc4cb..a34c28827 100644 | |
| --- a/apps/activity-logs-ms/src/activity-logs/dal/schemas/activity-log.schema.ts | |
| +++ b/apps/activity-logs-ms/src/activity-logs/dal/schemas/activity-log.schema.ts | |
| @@ -1,17 +1,33 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { ActivityLogSubType, ActivityLogType } from '@vinny/activity-logs-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| import { SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ toObject: { getters: true }, _id: false, id: false }) | |
| export class AdditionalData { | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + required: true, | |
| + index: true, | |
| + get: objectIdToStringGetter, | |
| + set: (value: string) => Types.ObjectId(value), | |
| + }) | |
| caseId: string; | |
| - @Prop(objectIdPropHandler({ index: true })) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + index: true, | |
| + get: objectIdToStringGetter, | |
| + set: (value: string) => Types.ObjectId(value), | |
| + }) | |
| relatedDataId?: string; | |
| - @Prop(objectIdPropHandler({ index: true })) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + index: true, | |
| + get: objectIdToStringGetter, | |
| + set: (value: string) => Types.ObjectId(value), | |
| + }) | |
| initiator?: string; | |
| } | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/administration/tests/practice-areas.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/administration/tests/practice-areas.resolver.spec.ts | |
| index 71952be2a..60c6e5b78 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/administration/tests/practice-areas.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/administration/tests/practice-areas.resolver.spec.ts | |
| @@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { ServicesClientModule } from '@vinny/services-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaResolver } from '../practice-areas.resolver'; | |
| import { PracticeAreaService } from '../practice-areas.service'; | |
| @@ -20,7 +20,7 @@ describe('practice area resolver', () => { | |
| nock.disableNetConnect(); | |
| const mockPracticeArea = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| key: 'MOCK', | |
| displayName: 'mock display name', | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/administration/tests/practice-areas.service.spec.ts b/apps/attorneys-graphql-gateway-ms/src/administration/tests/practice-areas.service.spec.ts | |
| index 3b63079e5..f145bdad2 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/administration/tests/practice-areas.service.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/administration/tests/practice-areas.service.spec.ts | |
| @@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { ServicesClientModule } from '@vinny/services-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaResolver } from '../practice-areas.resolver'; | |
| import { PracticeAreaService } from '../practice-areas.service'; | |
| @@ -20,7 +20,7 @@ describe('practice area service', () => { | |
| nock.disableNetConnect(); | |
| const mockPracticeArea = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| key: 'MOCK', | |
| displayName: 'mock display name', | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorney-calendar/test/attorney-calendar.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorney-calendar/test/attorney-calendar.spec.ts | |
| index 9da6016e9..7905bcf48 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorney-calendar/test/attorney-calendar.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorney-calendar/test/attorney-calendar.spec.ts | |
| @@ -1,5 +1,3 @@ | |
| -// noinspection DuplicatedCode | |
| - | |
| import '@vinny/test-utils'; | |
| import nock from 'nock'; | |
| import { TestingModule, Test } from '@nestjs/testing'; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews-breakdown.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews-breakdown.resolver.spec.ts | |
| index 815a5fad5..38ff76efd 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews-breakdown.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews-breakdown.resolver.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import nock from 'nock'; | |
| import { TestingModule } from '@nestjs/testing'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| attorneyReviewsBreakdownDtoMock, | |
| createAttorneyReviewTestingModule, | |
| @@ -34,7 +34,7 @@ describe('attorney-review-breakdown', () => { | |
| }); | |
| describe('getAttorneyReviewsBreakdown', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| it('should return attorney reviews breakdown', async () => { | |
| const getAttorneyReviewsBreakdown = statsMsNock | |
| .get(`/attorneys-review/${user.id}/breakdown`) | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews.resolver.spec.ts | |
| index 3d89e4ec6..67b4dc85a 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews.resolver.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import nock from 'nock'; | |
| import { TestingModule } from '@nestjs/testing'; | |
| import { AttorneyReviewsResolver } from '../attorney-reviews.resolver'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| attorneyReviewsFilterMock, | |
| attorneyReviewsSortMock, | |
| @@ -36,7 +36,7 @@ describe('attorney-review', () => { | |
| }); | |
| describe('getAttorneyReviews', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| it('should return attorney reviews', async () => { | |
| const attorneyReviewsDtoResponse = getAttorneyReviewsDtoResponse(user.id); | |
| const expectedAttorneyReviewsResponse = attorneyReviewsDtoResponse.map( | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews.service.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews.service.spec.ts | |
| index e536cf241..72251f531 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews.service.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/attorney-reviews.service.spec.ts | |
| @@ -9,7 +9,7 @@ import { | |
| getAttorneyReviewsDtoResponse, | |
| getMockAttorney, | |
| } from './mocks'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { AttorneyReviewsApiService } from '../attorney-reviews.service'; | |
| import { AttorneyReviewsModule } from '../attorney-reviews.module'; | |
| @@ -50,7 +50,7 @@ describe('attorney-review', () => { | |
| }); | |
| describe('getAttorneyReviews', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| it('should return attorney reviews', async () => { | |
| const attorneyReviewsDtoResponse = getAttorneyReviewsDtoResponse(user.id); | |
| const expectedAttorneyReviewsResponse = attorneyReviewsDtoResponse.map( | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/mocks.ts b/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/mocks.ts | |
| index 50aaf0709..3c0210889 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/mocks.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorney-reviews/tests/mocks.ts | |
| @@ -1,7 +1,7 @@ | |
| import faker from '@faker-js/faker'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { User } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { AttorneyReviewsFilter } from '../models/attorney-review.model'; | |
| import { SingleFieldSort, SortOrder } from '@vinny/pagination'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| @@ -15,8 +15,8 @@ const ENV_VARS: Record<string, string> = { | |
| export const getMockAttorney = ({ id }: Partial<User>): User => { | |
| return { | |
| - id: id ?? objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: id ?? Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber('+1##########'), | |
| name: { | |
| @@ -45,9 +45,9 @@ export const attorneyReviewsSortMock: SingleFieldSort = { | |
| export const getAttorneyReviewsDtoResponse = (attorneyId: string) => { | |
| return [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| attorneyId, | |
| - customerId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| score: faker.datatype.number(), | |
| reviewDate: faker.datatype.datetime().toString(), | |
| isHide: faker.datatype.boolean(), | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/attorney-stats.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/attorney-stats.resolver.spec.ts | |
| index 43d1139e1..1637b56ad 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/attorney-stats.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/attorney-stats.resolver.spec.ts | |
| @@ -8,7 +8,7 @@ import { AttorneyStatsApiService } from '../attroney-stats.service'; | |
| import { StatsClientModule } from '@vinny/stats-client'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| import { attorneyStatsResponse, getMockAttorney } from './mocks'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { LssWinRateRank } from '../models/attorney-stats.model'; | |
| const ENV_VARS: Record<string, string> = { | |
| @@ -57,7 +57,7 @@ describe('attorney-stats', () => { | |
| }); | |
| describe('getAttorneyStats', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| it('should return attorney stats', async () => { | |
| const getUserById = usersMsNock.get(`/users/${user.id}`).reply(200, user); | |
| const getAttorneyStatsByMarbleId = statsMsNock | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/attorney-stats.service.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/attorney-stats.service.spec.ts | |
| index 2bf1ae1d7..3d676dc86 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/attorney-stats.service.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/attorney-stats.service.spec.ts | |
| @@ -8,7 +8,7 @@ import { AttorneyStatsApiService } from '../attroney-stats.service'; | |
| import { StatsClientModule } from '@vinny/stats-client'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| import { attorneyStatsResponse, getMockAttorney } from './mocks'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { Logger } from '@nestjs/common'; | |
| import { getLogger } from '@vinny/test-utils'; | |
| import { LssWinRateRank } from '../models/attorney-stats.model'; | |
| @@ -61,7 +61,7 @@ describe('attorney-stats', () => { | |
| }); | |
| describe('getAttorneyStats', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| it('should return attorney stats', async () => { | |
| const getUserById = usersMsNock.get(`/users/${user.id}`).reply(200, user); | |
| const getAttorneyStatsByMarbleId = statsMsNock | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/mocks.ts b/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/mocks.ts | |
| index 689675e63..ff20d912d 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/mocks.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorney-stats/tests/mocks.ts | |
| @@ -1,11 +1,11 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { Months } from '@vinny/stats-types'; | |
| import { AttorneyType, EmailType, Language, LinkType, PhoneType, User } from '@vinny/users-types'; | |
| export const attorneyStatsResponse = { | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| activeClients: faker.datatype.number(), | |
| allTimeClients: faker.datatype.number(), | |
| currentMonthPayouts: faker.datatype.number(), | |
| @@ -22,8 +22,8 @@ export const attorneyStatsResponse = { | |
| export const getMockAttorney = ({ id }: Partial<User>): User => { | |
| return { | |
| - id: id ?? objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: id ?? Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber('+1##########'), | |
| name: { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/attorney-service.service.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/attorney-service.service.ts | |
| index 417924630..22ecfdb96 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/attorney-service.service.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/attorney-service.service.ts | |
| @@ -9,7 +9,7 @@ import { PatchMilestoneProgressDto, ServiceDto, ServiceStatus } from '@vinny/ser | |
| import { ATTORNEYS_GQL_PENDING_SERVICES_ENABLED } from './utils/consts'; | |
| import { CaseValidationService } from '../shared/validation/case-validation.service'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ServiceCatalogClientService } from '@vinny/catalog-client'; | |
| import { ServiceType } from '../services/service-types/models/service-type.model'; | |
| @@ -98,7 +98,7 @@ export class AttorneyServiceService { | |
| }; | |
| } catch (e) { | |
| return { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: undefined, | |
| email, | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/admin-attorney-practice-area.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/admin-attorney-practice-area.resolver.spec.ts | |
| index a8196a9d4..10e4870a8 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/admin-attorney-practice-area.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/admin-attorney-practice-area.resolver.spec.ts | |
| @@ -6,6 +6,7 @@ import { DocumentsClientModule } from '@vinny/documents-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { AttorneysModule } from '../attorneys.module'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| @@ -16,7 +17,6 @@ import { mapPracticeAreaLocationsInputToLocations } from '../graph-to-dto.mapper | |
| import { mapPracticeAreaToGraphAttorneyPracticeArea } from '../dto-to-graph.mapper'; | |
| import { MONGO_OBJECT_ID_REGEX } from '@vinny/test-utils'; | |
| import { AdminAttorneyPracticeAreaResolver } from '../admin-attorney-practice-area.resolver'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| USERS_MS_URL: 'https://us.ers', | |
| @@ -29,7 +29,7 @@ const servicesMsNock = nock(ENV_VARS.SERVICES_MS_URL); | |
| describe('AdminAttorneyPracticeAreaResolver', () => { | |
| let practiceAreaService: AttorneyPracticeAreaService; | |
| let resolver: AdminAttorneyPracticeAreaResolver; | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| beforeEach(async () => { | |
| const module: TestingModule = await Test.createTestingModule({ | |
| @@ -66,7 +66,7 @@ describe('AdminAttorneyPracticeAreaResolver', () => { | |
| describe('createAttorneyPracticeArea', () => { | |
| it('should create practice area', async () => { | |
| - const practiceAreaId = objectStringId(); | |
| + const practiceAreaId = Types.ObjectId().toString(); | |
| const payload = { | |
| practiceAreaId, | |
| performsLSS: faker.datatype.boolean(), | |
| @@ -139,7 +139,7 @@ describe('AdminAttorneyPracticeAreaResolver', () => { | |
| mapPracticeAreaToGraphAttorneyPracticeArea(createPracticeAreaResult); | |
| const attorneyPracticeArea = await resolver.createAttorneyPracticeArea( | |
| - { id: objectStringId() }, | |
| + { id: Types.ObjectId().toString() }, | |
| attorneyId, | |
| payload, | |
| ); | |
| @@ -152,7 +152,7 @@ describe('AdminAttorneyPracticeAreaResolver', () => { | |
| describe('updateAttorneyPracticeArea', () => { | |
| it('should update practice area', async () => { | |
| - const practiceAreaId = objectStringId(); | |
| + const practiceAreaId = Types.ObjectId().toString(); | |
| const payload = { | |
| performsLSS: faker.datatype.boolean(), | |
| handlesCases: faker.datatype.boolean(), | |
| @@ -224,7 +224,7 @@ describe('AdminAttorneyPracticeAreaResolver', () => { | |
| mapPracticeAreaToGraphAttorneyPracticeArea(updatePracticeAreaResult); | |
| const attorneyPracticeArea = await resolver.updateAttorneyPracticeArea( | |
| - { id: objectStringId() }, | |
| + { id: Types.ObjectId().toString() }, | |
| practiceAreaId, | |
| attorneyId, | |
| payload, | |
| @@ -238,7 +238,7 @@ describe('AdminAttorneyPracticeAreaResolver', () => { | |
| describe('deleteAttorneyPracticeArea', () => { | |
| it('should delete practice area', async () => { | |
| - const practiceAreaId = objectStringId(); | |
| + const practiceAreaId = Types.ObjectId().toString(); | |
| const usersMsReq = usersMsNock | |
| .delete(`/attorneys/${attorneyId}/practice-areas/${practiceAreaId}`) | |
| @@ -246,7 +246,7 @@ describe('AdminAttorneyPracticeAreaResolver', () => { | |
| .reply(200); | |
| const attorneyPracticeArea = await resolver.deleteAttorneyPracticeArea( | |
| - { id: objectStringId() }, | |
| + { id: Types.ObjectId().toString() }, | |
| practiceAreaId, | |
| attorneyId, | |
| ); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-case-tasks.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-case-tasks.resolver.spec.ts | |
| index d7901e0e6..e819a80db 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-case-tasks.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-case-tasks.resolver.spec.ts | |
| @@ -14,7 +14,7 @@ import { ServicesLoaderService } from '../../shared/services/services.loader'; | |
| import { ServicesClientService } from '@vinny/services-client'; | |
| import { ServiceTypesLoaderService } from '../../shared/services/service-types.loader'; | |
| import { ServiceCatalogClientService } from '@vinny/catalog-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { Assignee, CaseTask, CaseTaskService } from '../../tasks/model/tasks.model'; | |
| import { faker } from '@faker-js/faker'; | |
| import { LegalTeamMemberRole, ServiceDto, ServiceStatus } from '@vinny/services-types'; | |
| @@ -80,21 +80,21 @@ describe('AttorneyCaseTasksResolver', () => { | |
| describe('getServiceByTask', () => { | |
| const mockCaseTask = { | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| } as CaseTask; | |
| it('should get service for task', async () => { | |
| const mockService: ServiceDto = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| name: faker.name.firstName(), | |
| - serviceTypeId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [], | |
| status: ServiceStatus.OPEN, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| id: mockCaseTask.serviceId, | |
| location: { | |
| - state: objectStringId(), | |
| + state: Types.ObjectId().toString(), | |
| }, | |
| }; | |
| @@ -116,15 +116,15 @@ describe('AttorneyCaseTasksResolver', () => { | |
| legalDescription: 'test', | |
| }, | |
| firm: 'Marble', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| isAddendumProduct: faker.datatype.boolean(), | |
| category: 'test category', | |
| isRequiresAdditionalExpenseForClient: faker.datatype.boolean(), | |
| }, | |
| - serviceCode: objectStringId(), | |
| + serviceCode: Types.ObjectId().toString(), | |
| metadata: { | |
| status: 'ACTIVE', | |
| - createdById: objectStringId(), | |
| + createdById: Types.ObjectId().toString(), | |
| }, | |
| stateInfo: {}, | |
| requiredServiceTypes: { | |
| @@ -155,32 +155,32 @@ describe('AttorneyCaseTasksResolver', () => { | |
| describe('getAssigneeByTask', () => { | |
| const mockCaseTask = { | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| } as CaseTask; | |
| it('should get assignee for task', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const mockService: ServiceDto = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| name: faker.name.firstName(), | |
| - serviceTypeId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| { | |
| userId: attorneyId, | |
| role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.PARALEGAL, | |
| }, | |
| ], | |
| status: ServiceStatus.OPEN, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| id: mockCaseTask.serviceId, | |
| location: { | |
| - state: objectStringId(), | |
| + state: Types.ObjectId().toString(), | |
| }, | |
| }; | |
| @@ -192,7 +192,7 @@ describe('AttorneyCaseTasksResolver', () => { | |
| id: attorneyId, | |
| email: faker.internet.email(), | |
| roles: [Role.ATTORNEY], | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| servicesMsNock.get(`/services/list?ids[]=${mockService.id}`).reply(200, [mockService]); | |
| @@ -213,32 +213,32 @@ describe('AttorneyCaseTasksResolver', () => { | |
| describe('getClientNameByTask', () => { | |
| const mockCaseTask = { | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| } as CaseTask; | |
| it('should get client name for task', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const mockService: ServiceDto = { | |
| userId, | |
| name: faker.name.firstName(), | |
| - serviceTypeId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.PARALEGAL, | |
| }, | |
| ], | |
| status: ServiceStatus.OPEN, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| id: mockCaseTask.serviceId, | |
| location: { | |
| - state: objectStringId(), | |
| + state: Types.ObjectId().toString(), | |
| }, | |
| }; | |
| @@ -250,7 +250,7 @@ describe('AttorneyCaseTasksResolver', () => { | |
| id: userId, | |
| email: faker.internet.email(), | |
| roles: [Role.ATTORNEY], | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| servicesMsNock.get(`/services/list?ids[]=${mockService.id}`).reply(200, [mockService]); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-practice-area.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-practice-area.resolver.spec.ts | |
| index e27d4c741..be190f01a 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-practice-area.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-practice-area.resolver.spec.ts | |
| @@ -6,7 +6,7 @@ import { DocumentsClientModule } from '@vinny/documents-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { AttorneysModule } from '../attorneys.module'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| @@ -29,7 +29,7 @@ const servicesMsNock = nock(ENV_VARS.SERVICES_MS_URL); | |
| describe('AttorneyPracticeAreaResolver', () => { | |
| let practiceAreaService: AttorneyPracticeAreaService; | |
| let resolver: AttorneyPracticeAreaResolver; | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| beforeEach(async () => { | |
| const module: TestingModule = await Test.createTestingModule({ | |
| @@ -66,7 +66,7 @@ describe('AttorneyPracticeAreaResolver', () => { | |
| describe('updateAttorneyPracticeArea', () => { | |
| it('should update practice area', async () => { | |
| - const practiceAreaId = objectStringId(); | |
| + const practiceAreaId = Types.ObjectId().toString(); | |
| const payload = { | |
| servicePreferences: [ | |
| { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-practice-area.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-practice-area.schema.spec.ts | |
| index 2b0716177..ef50ebd47 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-practice-area.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorney-practice-area.schema.spec.ts | |
| @@ -1,13 +1,13 @@ | |
| import { ServiceAttitude } from '@vinny/users-types'; | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| import { | |
| AttorneyPracticeAreaCreateInput, | |
| AttorneyPracticeAreaUpdateInput, | |
| } from '../models/attorney-practice-area.model'; | |
| import { fullAttorneyPracticeAreaObject } from './utils'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| describe('AttorneyPracticeArea schema', () => { | |
| let tester: EasyGraphQLTester; | |
| @@ -19,9 +19,7 @@ describe('AttorneyPracticeArea schema', () => { | |
| it('Should pass when the schema is valid', () => { | |
| const query = ` | |
| { | |
| - getAttorneyPracticeArea(attorneyId: "${objectId( | |
| - objectStringId(), | |
| - )}", practiceAreaId: "${objectId(objectStringId())}") { | |
| + getAttorneyPracticeArea(attorneyId: "${Types.ObjectId()}", practiceAreaId: "${Types.ObjectId()}") { | |
| ${fullAttorneyPracticeAreaObject} | |
| } | |
| } | |
| @@ -34,7 +32,7 @@ describe('AttorneyPracticeArea schema', () => { | |
| describe('createAttorneyPracticeArea', () => { | |
| it('Should pass when the schema is valid', () => { | |
| const payload: AttorneyPracticeAreaCreateInput = { | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| performsLSS: true, | |
| handlesCases: false, | |
| servicePreferences: [ | |
| @@ -65,7 +63,7 @@ describe('AttorneyPracticeArea schema', () => { | |
| `; | |
| tester.test(true, mutation, { | |
| - attorneyId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| payload, | |
| }); | |
| }); | |
| @@ -98,12 +96,12 @@ describe('AttorneyPracticeArea schema', () => { | |
| const mutation = ` | |
| mutation Mutation( | |
| $practiceAreaId: String!, | |
| - $attorneyId: String!, | |
| + $attorneyId: String!, | |
| $payload: AttorneyPracticeAreaUpdateInput! | |
| ) { | |
| updateAttorneyPracticeArea( | |
| practiceAreaId: $practiceAreaId, | |
| - attorneyId: $attorneyId, | |
| + attorneyId: $attorneyId, | |
| updateAttorneyPracticeAreaInput: $payload | |
| ) { | |
| ${fullAttorneyPracticeAreaObject} | |
| @@ -112,8 +110,8 @@ describe('AttorneyPracticeArea schema', () => { | |
| `; | |
| tester.test(true, mutation, { | |
| - attorneyId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| payload, | |
| }); | |
| }); | |
| @@ -124,18 +122,18 @@ describe('AttorneyPracticeArea schema', () => { | |
| const mutation = ` | |
| mutation Mutation( | |
| $practiceAreaId: String!, | |
| - $attorneyId: String!, | |
| + $attorneyId: String!, | |
| ) { | |
| deleteAttorneyPracticeArea( | |
| practiceAreaId: $practiceAreaId, | |
| - attorneyId: $attorneyId, | |
| + attorneyId: $attorneyId, | |
| ) | |
| } | |
| `; | |
| tester.test(true, mutation, { | |
| - attorneyId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| }); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-case.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-case.resolver.spec.ts | |
| index 2675264e4..7de7c6ba1 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-case.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-case.resolver.spec.ts | |
| @@ -29,7 +29,7 @@ import { | |
| } from '@vinny/services-types'; | |
| import { MockConfigService, mockSplitService } from '@vinny/test-utils'; | |
| import { UsersClientModule, UsersClientService } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { mockLssEvent } from '../../lss/test/lss.utils'; | |
| @@ -353,7 +353,7 @@ describe('attorney case resolver', () => { | |
| }); | |
| describe('getEvents', () => { | |
| - const mockCase = { id: objectStringId() }; | |
| + const mockCase = { id: Types.ObjectId().toString() }; | |
| it("should return service's events", async () => { | |
| const caseServicesRequest = servicesMsMock | |
| @@ -391,9 +391,9 @@ describe('attorney case resolver', () => { | |
| }); | |
| describe('getCustomerUser', () => { | |
| - const mockCase1 = { id: objectStringId(), userId: mockCustomer1.id }; | |
| - const mockCase2 = { id: objectStringId(), userId: mockCustomer2.id }; | |
| - const mockCase3 = { id: objectStringId(), userId: mockAttorney1.id }; | |
| + const mockCase1 = { id: Types.ObjectId().toString(), userId: mockCustomer1.id }; | |
| + const mockCase2 = { id: Types.ObjectId().toString(), userId: mockCustomer2.id }; | |
| + const mockCase3 = { id: Types.ObjectId().toString(), userId: mockAttorney1.id }; | |
| it('should return user', async () => { | |
| const context = { | |
| @@ -434,7 +434,7 @@ describe('attorney case resolver', () => { | |
| }); | |
| describe('getUpcomingEvents', () => { | |
| - const mockCase = { id: objectStringId() }; | |
| + const mockCase = { id: Types.ObjectId().toString() }; | |
| it.skip('should return only upcoming sorted events', async () => { | |
| const caseServicesRequest = servicesMsMock | |
| @@ -570,7 +570,7 @@ describe('attorney case resolver', () => { | |
| }); | |
| it('should throw when attorney is not on case', async () => { | |
| - const randomAttorneyId = objectStringId(); | |
| + const randomAttorneyId = Types.ObjectId().toString(); | |
| const getServicesByCaseId = servicesMsMock | |
| .get(`/services/list/metadata`) | |
| .query({ caseId: mockCase.id }) | |
| @@ -673,7 +673,7 @@ describe('attorney case resolver', () => { | |
| .reply(200, [mockAttorneyTeam]); | |
| const introCalls = { | |
| [attorneyId]: { unresponsiveClient: true }, | |
| - [objectStringId()]: { strategyReviewCallCompleteDate: new Date() }, | |
| + [Types.ObjectId().toString()]: { strategyReviewCallCompleteDate: new Date() }, | |
| }; | |
| const mockCaseOne = generateMockAttorneyCase({}); | |
| const mockCaseTwo = generateMockAttorneyCase({}); | |
| @@ -971,7 +971,7 @@ describe('attorney case resolver', () => { | |
| { | |
| ...firstMockCase.case, | |
| introCalls: { | |
| - [objectStringId()]: { | |
| + [Types.ObjectId().toString()]: { | |
| strategyReviewCallCompleteDate: new Date(), | |
| }, | |
| }, | |
| @@ -1295,10 +1295,10 @@ describe('attorney case resolver', () => { | |
| }); | |
| it('should filter and return only cases that have an ongoing service closure', async () => { | |
| - const documentId = objectStringId(); | |
| + const documentId = Types.ObjectId().toString(); | |
| const milestonesProgressList = [ | |
| { | |
| - milestoneId: objectStringId(), | |
| + milestoneId: Types.ObjectId().toString(), | |
| percentCompleted: 100, | |
| documentIds: [documentId], | |
| documents: [{ id: documentId, name: 'doc.pdf' }], | |
| @@ -1927,7 +1927,7 @@ describe('attorney case resolver', () => { | |
| describe('getLawmaticsContactLink', () => { | |
| it('should return a link to the contact in lawmatics', async () => { | |
| - const mockCase = { id: objectStringId() }; | |
| + const mockCase = { id: Types.ObjectId().toString() }; | |
| const mockCaseConfig = { lawmaticsId: '1337420' }; | |
| const getCaseConfigurationRequest = lawmaticsMsMock | |
| .get(`/configurations/cases/${mockCase.id}`) | |
| @@ -1942,7 +1942,7 @@ describe('attorney case resolver', () => { | |
| }); | |
| it('should return an empty string when the case configuration is not found', async () => { | |
| - const mockCase = { id: objectStringId() }; | |
| + const mockCase = { id: Types.ObjectId().toString() }; | |
| const getCaseConfigurationRequest = lawmaticsMsMock | |
| .get(`/configurations/cases/${mockCase.id}`) | |
| .reply(404); | |
| @@ -1977,8 +1977,8 @@ describe('attorney case resolver', () => { | |
| describe('submitNewClientCall', () => { | |
| it('should set NCC completed on the case', async () => { | |
| - const attorneyId1 = objectStringId(); | |
| - const attorneyId2 = objectStringId(); | |
| + const attorneyId1 = Types.ObjectId().toString(); | |
| + const attorneyId2 = Types.ObjectId().toString(); | |
| const date1 = new Date('2023-07-09T14:37:13.238Z'); | |
| const date2 = new Date('2024-07-10T14:37:13.238Z'); | |
| const introCalls = { | |
| @@ -2007,8 +2007,8 @@ describe('attorney case resolver', () => { | |
| describe('markClientAsUnresponsiveForNcc', () => { | |
| it('should set the client as unresponsive for NCC and send braze event', async () => { | |
| - const attorneyId1 = objectStringId(); | |
| - const attorneyId2 = objectStringId(); | |
| + const attorneyId1 = Types.ObjectId().toString(); | |
| + const attorneyId2 = Types.ObjectId().toString(); | |
| const date1 = new Date('2023-07-09T14:37:13.238Z'); | |
| const introCalls = { | |
| [attorneyId1]: { unresponsiveClient: true }, | |
| @@ -2155,12 +2155,12 @@ describe('attorney case resolver', () => { | |
| describe('getRecommendedServices', () => { | |
| const mockRecommendedServices = [ | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| details: 'Service details 1', | |
| isOptional: true, | |
| }, | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| details: 'Service details 2', | |
| isOptional: false, | |
| }, | |
| @@ -2168,9 +2168,9 @@ describe('attorney case resolver', () => { | |
| it('should return recommended services for the case user', async () => { | |
| const mockCase = { | |
| - id: objectStringId(), | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| strategyReviewCallComplete: false, | |
| }; | |
| @@ -2204,9 +2204,9 @@ describe('attorney case resolver', () => { | |
| it('should return empty array when no recommended services exist', async () => { | |
| const mockCase = { | |
| - id: objectStringId(), | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| strategyReviewCallComplete: false, | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts-mocks.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts-mocks.ts | |
| index 816a00ba2..c8a1e6337 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts-mocks.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts-mocks.ts | |
| @@ -1,6 +1,6 @@ | |
| import faker from '@faker-js/faker'; | |
| import { FuturePayoutsListDto, PayoutInfo, PayoutStatus, PayoutType } from '@vinny/payouts-types'; | |
| -import { objectStringId, objectId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { PayoutsList } from '../payouts/models/attorney-payouts'; | |
| import { Months } from '@vinny/stats-types'; | |
| @@ -140,7 +140,7 @@ export function getMockFilterResponse() { | |
| } | |
| export const MockAttorneyStats = { | |
| - marbleId: objectId(objectStringId()), | |
| + marbleId: Types.ObjectId(), | |
| activeClients: faker.datatype.number(), | |
| allTimeClients: faker.datatype.number(), | |
| currentMonthPayouts: faker.datatype.number(), | |
| @@ -291,7 +291,7 @@ const futureEarnings = [ | |
| futureSum: faker.datatype.number(), | |
| clientFirstName: faker.name.firstName(), | |
| clientLastName: faker.name.lastName(), | |
| - flareCustomerId: objectStringId(), | |
| + flareCustomerId: Types.ObjectId().toString(), | |
| bundleId: faker.datatype.uuid(), | |
| paidAmount: 0, | |
| price: faker.datatype.number(), | |
| @@ -300,7 +300,7 @@ const futureEarnings = [ | |
| futureSum: faker.datatype.number(), | |
| clientFirstName: faker.name.firstName(), | |
| clientLastName: faker.name.lastName(), | |
| - flareCustomerId: objectStringId(), | |
| + flareCustomerId: Types.ObjectId().toString(), | |
| bundleId: faker.datatype.uuid(), | |
| paidAmount: 100, | |
| price: faker.datatype.number(), | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts.resolver.spec.ts | |
| index 7ab0d4463..bb75573ee 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts.resolver.spec.ts | |
| @@ -10,7 +10,7 @@ import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { AttorneysModule } from '../attorneys.module'; | |
| import nock from 'nock'; | |
| import { getMockAttorney } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| futurePayoutsListMock, | |
| getMockFilterResponse, | |
| @@ -83,7 +83,7 @@ describe('attorney resolver - payouts', () => { | |
| }); | |
| describe('listPayouts', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| it('should payout list by user id', async () => { | |
| const getPayouts = payoutSystemNock | |
| .get(`/api/payoutmanager/instructions`) | |
| @@ -210,7 +210,7 @@ describe('attorney resolver - payouts', () => { | |
| }); | |
| describe('getAttorneyPayoutDashboard', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| it('should get payouts dashboard data', async () => { | |
| const getStatsById = statsMsNock | |
| .get(`/attorneys-stats/${user.marbleId}`) | |
| @@ -359,7 +359,7 @@ describe('attorney resolver - payouts', () => { | |
| describe('listFuturePayouts', () => { | |
| let getAttorneyPayee: any; | |
| - const attorney = getMockAttorney({ id: objectStringId() }); | |
| + const attorney = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const expectedFuturePayouts = getMockFuturePayoutsResponse(); | |
| beforeEach(() => { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts.schema.spec.ts | |
| index ebd948567..dd7914eb4 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-payouts.schema.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| describe('Attorney payouts schema', () => { | |
| let tester: EasyGraphQLTester; | |
| @@ -39,7 +39,7 @@ describe('Attorney payouts schema', () => { | |
| describe('getBundleDetailsById', () => { | |
| it('should pass when the schema is valid', () => { | |
| - const query = `{ getBundleDetailsById(id: "${objectId(objectStringId())}") { | |
| + const query = `{ getBundleDetailsById(id: "${Types.ObjectId()}") { | |
| services{ | |
| name | |
| status | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-service.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-service.resolver.spec.ts | |
| index 494e5c5cf..106d6607a 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-service.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-service.resolver.spec.ts | |
| @@ -5,7 +5,7 @@ import { DocumentsClientModule } from '@vinny/documents-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { AttorneysModule } from '../attorneys.module'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| @@ -81,7 +81,7 @@ describe('attorney service resolver', () => { | |
| }); | |
| describe('getEvents', () => { | |
| - const mockService = { id: objectStringId() }; | |
| + const mockService = { id: Types.ObjectId().toString() }; | |
| it("should return service's events", async () => { | |
| const caseServicesRequest = servicesMsMock | |
| @@ -97,9 +97,9 @@ describe('attorney service resolver', () => { | |
| }); | |
| }); | |
| describe('getServiceClosure', () => { | |
| - const mockService1 = { id: objectStringId() }; | |
| - const mockService2 = { id: objectStringId() }; | |
| - const mockService3 = { id: objectStringId() }; | |
| + const mockService1 = { id: Types.ObjectId().toString() }; | |
| + const mockService2 = { id: Types.ObjectId().toString() }; | |
| + const mockService3 = { id: Types.ObjectId().toString() }; | |
| const getMockServiceClosure = (serviceId: string) => ({ | |
| serviceId, | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-service.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-service.schema.spec.ts | |
| index 020e3b520..a10fdf5c8 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-service.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys-service.schema.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('attorney service schema', () => { | |
| let tester: EasyGraphQLTester; | |
| @@ -31,11 +31,11 @@ describe('attorney service schema', () => { | |
| `; | |
| const variables = { | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| milestone: { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 75, | |
| - documentIds: [objectStringId()], | |
| + documentIds: [Types.ObjectId().toString()], | |
| }, | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys.resolver.spec.ts | |
| index b4b3ffba7..6070e1d94 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys.resolver.spec.ts | |
| @@ -6,7 +6,7 @@ import { DocumentsClientModule } from '@vinny/documents-client'; | |
| import { EntityType, FileClassification } from '@vinny/documents-types'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { | |
| Attorney, | |
| @@ -136,7 +136,7 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('getCurrentAttorney', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const bookeePersonId = 'someBookeePersonId'; | |
| @@ -167,8 +167,8 @@ describe('attorneys resolver', () => { | |
| it('should get authenticated attorney by id with partial fields', async () => { | |
| const user = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| bookItId: faker.datatype.uuid(), | |
| email: faker.internet.email(), | |
| emailAlias: faker.internet.email(undefined, undefined, 'mock-marble.co'), | |
| @@ -216,7 +216,7 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('listAttorneys', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| it('should get list with 1 attorney', async () => { | |
| const filter: AttorneysListFilter = { | |
| @@ -262,7 +262,7 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('updateAttorney', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const bookeePersonId = 'someBookeePersonId'; | |
| @@ -393,7 +393,7 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('bookItAvailabilityStatus', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const bookeePersonId = 'someBookeePersonId'; | |
| @@ -429,7 +429,7 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('holidays', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const bookeePersonId = 'someBookeePersonId'; | |
| @@ -540,7 +540,7 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('updateAttorneyById', () => { | |
| - const attorneyUser = getMockAttorney({ id: objectStringId() }); | |
| + const attorneyUser = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| let updateBookeeProviderConfiguration: nock.Scope, | |
| updateBookeeProviderConfigNoHours: nock.Scope, | |
| @@ -594,7 +594,7 @@ describe('attorneys resolver', () => { | |
| const expectedAttorney = mapUserToGraphAttorney(updateRes); | |
| const attorney = await resolver.updateAttorneyById( | |
| - { id: objectStringId() }, | |
| + { id: Types.ObjectId().toString() }, | |
| attorneyUser.id, | |
| updateAttorneyInput, | |
| ); | |
| @@ -645,7 +645,7 @@ describe('attorneys resolver', () => { | |
| const expectedAttorney = mapUserToGraphAttorney(updateRes); | |
| const attorney = await resolver.updateAttorneyById( | |
| - { id: objectStringId() }, | |
| + { id: Types.ObjectId().toString() }, | |
| attorneyUser.id, | |
| updateAttorneyInput, | |
| ); | |
| @@ -766,7 +766,7 @@ describe('attorneys resolver', () => { | |
| const expectedAttorney = mapUserToGraphAttorney(updateRes); | |
| const attorney = await resolver.updateAttorneyById( | |
| - { id: objectStringId() }, | |
| + { id: Types.ObjectId().toString() }, | |
| attorneyUser.id, | |
| updateAttorneyInput, | |
| ); | |
| @@ -779,11 +779,11 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('profileImageUrl', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const expectedAttorney = mapUserToGraphAttorney(user); | |
| const filesResponse = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| relatedEntityId: user.id, | |
| relatedEntityType: EntityType.USER, | |
| classification: FileClassification.PROFILE_IMAGE, | |
| @@ -816,11 +816,11 @@ describe('attorneys resolver', () => { | |
| describe('requestUploadProfileImageUrl', () => { | |
| it('should get a proper response', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const fileName = 'Test File Name'; | |
| const docsMsResponse = { | |
| - fileId: objectStringId(), | |
| + fileId: Types.ObjectId().toString(), | |
| uploadUrl: `https://files-bucket.s3.us-east-2.amazonaws.com/users/${attorneyId}/drek`, | |
| }; | |
| @@ -842,7 +842,7 @@ describe('attorneys resolver', () => { | |
| describe('deleteProfileImage', () => { | |
| it('should delete profile image successfully', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const deleteProfileImageMock = documentsMsMock | |
| .delete(`/files`) | |
| .query({ | |
| @@ -858,7 +858,7 @@ describe('attorneys resolver', () => { | |
| }); | |
| it('should handle error when deleting profile image', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const deleteProfileImageMock = documentsMsMock | |
| .delete(`/files`) | |
| .query({ | |
| @@ -873,15 +873,15 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('attorneyCases', () => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const attorney = mapUserToGraphAttorney(user); | |
| const lastContactDate = new Date('2023-01-01'); | |
| const caseOne = { | |
| - id: objectStringId(), | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| strategyReviewCallComplete: true, | |
| opposingParty: 'No U', | |
| additionalFields: {}, | |
| @@ -902,9 +902,9 @@ describe('attorneys resolver', () => { | |
| }); | |
| const caseTwo = { | |
| - id: objectStringId(), | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| createdAt: new Date().toISOString(), | |
| }; | |
| @@ -937,7 +937,7 @@ describe('attorneys resolver', () => { | |
| `( | |
| 'should return $expectedValue when the attorneys stats is $attorneyStats', | |
| async ({ attorneyStats, expectedValue }) => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const attorney = mapUserToGraphAttorney(user); | |
| const getStatsRequest = statsMsNock | |
| .get(`/attorneys-stats/${user.marbleId}`) | |
| @@ -968,7 +968,7 @@ describe('attorneys resolver', () => { | |
| attorneySubStatus, | |
| expectedAttorneyQualityStatus, | |
| }) => { | |
| - const user = getMockAttorney({ id: objectStringId() }); | |
| + const user = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const attorney = mapUserToGraphAttorney(user); | |
| attorney.status = attorneyStatus; | |
| attorney.subStatus = attorneySubStatus; | |
| @@ -995,7 +995,7 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('createBookItOneOnOneMeeting', () => { | |
| - const attorneyUser = getMockAttorney({ id: objectStringId() }); | |
| + const attorneyUser = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| let getBookeePerson: nock.Scope; | |
| let createBookeeRequest: nock.Scope; | |
| @@ -1145,8 +1145,8 @@ describe('attorneys resolver', () => { | |
| }); | |
| describe('getBookItMeetings', () => { | |
| - const attorneyUser = getMockAttorney({ id: objectStringId() }); | |
| - const clientUser = getMockAttorney({ id: objectStringId() }); | |
| + const attorneyUser = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| + const clientUser = getMockAttorney({ id: Types.ObjectId().toString() }); | |
| const clientEmail = faker.internet.email(); | |
| let getBookeeAttorney: nock.Scope; | |
| let getBookeeClient: nock.Scope; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys.schema.spec.ts | |
| index 43e08afd5..d87349f86 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/attorneys.schema.spec.ts | |
| @@ -2,9 +2,9 @@ import faker from '@faker-js/faker'; | |
| import { AttorneyType, Language } from '@vinny/users-types'; | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| import { fullAttorneyCaseObject } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('attorney schema', () => { | |
| let tester: EasyGraphQLTester; | |
| @@ -256,7 +256,7 @@ describe('attorney schema', () => { | |
| }`; | |
| tester.test(true, mutation, { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| strategyReviewCallCompleteDate: new Date(), | |
| }); | |
| }); | |
| @@ -271,7 +271,7 @@ describe('attorney schema', () => { | |
| } | |
| }`; | |
| - tester.test(true, mutation, { caseId: objectStringId() }); | |
| + tester.test(true, mutation, { caseId: Types.ObjectId().toString() }); | |
| }); | |
| }); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/case-event.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/case-event.resolver.spec.ts | |
| index c59a961a0..1bd843e22 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/case-event.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/case-event.resolver.spec.ts | |
| @@ -7,7 +7,7 @@ import { DocumentsClientModule } from '@vinny/documents-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { MockConfigService } from '@vinny/test-utils'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { AttorneyServiceService } from '../attorney-service.service'; | |
| @@ -75,7 +75,7 @@ describe('case event resolver', () => { | |
| describe('getEventAttendees', () => { | |
| it("should return service's events' attendees", async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const name = { | |
| first: faker.name.firstName(), | |
| middle: faker.name.middleName(), | |
| @@ -135,7 +135,7 @@ describe('case event resolver', () => { | |
| }); | |
| it("should return service's events' attendees on mixed results", async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const name = { | |
| first: faker.name.firstName(), | |
| middle: faker.name.middleName(), | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/legal-team.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/legal-team.resolver.spec.ts | |
| index ac2729137..3a57d1644 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/legal-team.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/legal-team.resolver.spec.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ConfigModule, ConfigService } from '@nestjs/config'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| @@ -49,12 +49,12 @@ describe('legal team resolver', () => { | |
| describe('getUser', () => { | |
| const mockMember = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.CASE_MANAGER, | |
| }; | |
| const user = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'mocky', | |
| last: 'mockson', | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/payouts-preview.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/payouts-preview.resolver.spec.ts | |
| index 607a2a035..012b8553c 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/payouts-preview.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/payouts-preview.resolver.spec.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { PayoutPreviewResolver } from '../payouts/payouts-preview.resolver'; | |
| import nock from 'nock'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| @@ -38,7 +38,7 @@ describe('PayoutPreviewResolver', () => { | |
| describe('getLawmaticsContactLink', () => { | |
| it('should return a link to the contact in lawmatics', async () => { | |
| - const mockCase = { id: objectStringId() }; | |
| + const mockCase = { id: Types.ObjectId().toString() }; | |
| const mockCaseConfig = { lawmaticsId: '1337420' }; | |
| const getCaseByUserIdRequest = servicesMsMock | |
| .get(`/cases/users/${mockPayoutPreview.customerId}/ids`) | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/register-invitation.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/register-invitation.resolver.spec.ts | |
| index 050c8f856..38026b26f 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/register-invitation.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/register-invitation.resolver.spec.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ConfigModule, ConfigService } from '@nestjs/config'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| @@ -49,7 +49,7 @@ describe('register invitation resolver', () => { | |
| describe('getOpenInvites', () => { | |
| it('should return open invites', async () => { | |
| - const inviterId = objectStringId(); | |
| + const inviterId = Types.ObjectId().toString(); | |
| const openInvites = [ | |
| { email: faker.internet.email(), isUsed: false }, | |
| { | |
| @@ -67,7 +67,7 @@ describe('register invitation resolver', () => { | |
| expect(result).toEqual(openInvites); | |
| }); | |
| it('should not return used invites', async () => { | |
| - const inviterId = objectStringId(); | |
| + const inviterId = Types.ObjectId().toString(); | |
| const openInvites = [{ email: faker.internet.email(), isUsed: true }]; | |
| const getOpenInvites = usersMsMock | |
| .get(`/register-invitations`) | |
| @@ -78,7 +78,7 @@ describe('register invitation resolver', () => { | |
| expect(result).toEqual([]); | |
| }); | |
| it('should not return expired invites', async () => { | |
| - const inviterId = objectStringId(); | |
| + const inviterId = Types.ObjectId().toString(); | |
| const openInvites = [ | |
| { | |
| email: faker.internet.email(), | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/related-customers.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/related-customers.resolver.spec.ts | |
| index cf0403c68..4bf7b283d 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/related-customers.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/related-customers.resolver.spec.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ConfigModule, ConfigService } from '@nestjs/config'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| @@ -45,33 +45,33 @@ describe('Related customers resolver', () => { | |
| }); | |
| describe('getRelatedCustomers', () => { | |
| - const mockUserId = objectStringId(); | |
| + const mockUserId = Types.ObjectId().toString(); | |
| const searchTerm = faker.name.firstName(); | |
| const relatedCustomer: Customer = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: searchTerm, | |
| last: searchTerm, | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.CUSTOMER], | |
| }; | |
| const unrelatedCustomer: Customer = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: searchTerm, | |
| last: searchTerm, | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.CUSTOMER], | |
| }; | |
| const clientsBySearchTerm: Customer[] = [relatedCustomer, unrelatedCustomer]; | |
| const customerIds = clientsBySearchTerm.map((customer) => customer.id); | |
| const team: TeamDto[] = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| members: [ | |
| { | |
| userId: mockUserId, | |
| @@ -82,10 +82,10 @@ describe('Related customers resolver', () => { | |
| }, | |
| ]; | |
| const relatedService: ServiceMetadataDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId: relatedCustomer.id, | |
| - caseId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| { | |
| userId: mockUserId, | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/team-member.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/team-member.resolver.spec.ts | |
| index eb2283149..d78b1d659 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/team-member.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/team-member.resolver.spec.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ConfigModule, ConfigService } from '@nestjs/config'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| @@ -51,12 +51,12 @@ describe('team member resolver', () => { | |
| describe('getUser', () => { | |
| const mockMember = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.PARALEGAL_LEAD, | |
| }; | |
| const user = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'ragner', | |
| last: 'lutbrok', | |
| @@ -76,9 +76,9 @@ describe('team member resolver', () => { | |
| describe('addExternalStaffToTeam', () => { | |
| it('should add external staff to the attorney team if user already exists', async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const externalStaff = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| email: faker.internet.email(), | |
| roles: [Role.EXTERNAL_STAFF], | |
| }; | |
| @@ -93,7 +93,7 @@ describe('team member resolver', () => { | |
| }); | |
| it('should send registration invitation when no external staff user is found', async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const externalStaffEmail = faker.internet.email(); | |
| const getUser = usersMsMock | |
| @@ -116,10 +116,10 @@ describe('team member resolver', () => { | |
| }); | |
| it('should throw error if user is not Role.EXTERNAL_STAFF', async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const externalStaffEmail = faker.internet.email(); | |
| const user = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| email: externalStaffEmail, | |
| }; | |
| @@ -135,9 +135,9 @@ describe('team member resolver', () => { | |
| describe('setTeamMemberStatus', () => { | |
| it('should set team member status', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const teamId = objectStringId(); | |
| - const memberId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const teamId = Types.ObjectId().toString(); | |
| + const memberId = Types.ObjectId().toString(); | |
| const teams = [{ id: teamId, members: [{ userId: attorneyId, role: MemberRole.ATTORNEY }] }]; | |
| const findTeam = usersMsMock | |
| .get(`/teams`) | |
| @@ -166,21 +166,21 @@ describe('team member resolver', () => { | |
| { | |
| members: [ | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.PARALEGAL_LEAD, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.CASE_PARALEGAL, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.PARALEGAL_LEAD, | |
| }, | |
| ], | |
| }, | |
| ]; | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| let findTeam: nock.Scope; | |
| beforeEach(() => { | |
| findTeam = usersMsMock | |
| @@ -215,7 +215,7 @@ describe('team member resolver', () => { | |
| { | |
| members: [ | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.EXTERNAL_STAFF, | |
| status: MemberStatus.ACTIVE, | |
| }, | |
| @@ -224,22 +224,22 @@ describe('team member resolver', () => { | |
| { | |
| members: [ | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.CASE_PARALEGAL, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.EXTERNAL_STAFF, | |
| status: MemberStatus.DISABLED, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.EXTERNAL_STAFF, | |
| }, | |
| ], | |
| }, | |
| ]; | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| let findTeam: nock.Scope; | |
| beforeEach(() => { | |
| findTeam = usersMsMock | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/utils.ts b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/utils.ts | |
| index 21d5b0cc9..8724e0877 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/attorneys/tests/utils.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { faker } from '@faker-js/faker'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { | |
| @@ -31,19 +31,19 @@ import { AttorneyStatsEntity, Months } from '@vinny/stats-types'; | |
| import { MockServiceTypeResponse } from '../../catalog/service-types/test/utils'; | |
| import { ServiceDraftsStatus } from '@vinny/data-requests-types'; | |
| -export const userId = objectStringId(); | |
| -export const caseId = objectStringId(); | |
| -export const payoutId = objectStringId(); | |
| -export const attorneyId = objectStringId(); | |
| -export const secondAttorneyId = objectStringId(); | |
| -export const teamId = objectStringId(); | |
| -export const paralegalId = objectStringId(); | |
| -export const managingAttorneyId = objectStringId(); | |
| -export const secondParalegalId = objectStringId(); | |
| -export const serviceId = objectStringId(); | |
| -export const serviceTypeId = objectStringId(); | |
| -export const eventId = objectStringId(); | |
| -export const practiceAreaId = objectStringId(); | |
| +export const userId = Types.ObjectId().toString(); | |
| +export const caseId = Types.ObjectId().toString(); | |
| +export const payoutId = Types.ObjectId().toString(); | |
| +export const attorneyId = Types.ObjectId().toString(); | |
| +export const secondAttorneyId = Types.ObjectId().toString(); | |
| +export const teamId = Types.ObjectId().toString(); | |
| +export const paralegalId = Types.ObjectId().toString(); | |
| +export const managingAttorneyId = Types.ObjectId().toString(); | |
| +export const secondParalegalId = Types.ObjectId().toString(); | |
| +export const serviceId = Types.ObjectId().toString(); | |
| +export const serviceTypeId = Types.ObjectId().toString(); | |
| +export const eventId = Types.ObjectId().toString(); | |
| +export const practiceAreaId = Types.ObjectId().toString(); | |
| const startDateOne = faker.date.soon(); | |
| const endDateOne = new Date(startDateOne); | |
| @@ -58,7 +58,7 @@ const mockPartialName: PartialName = { | |
| export const getMockAttorney = ({ id, email }: Partial<User>): User => { | |
| return { | |
| id: id ?? attorneyId, | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| bookItId: faker.datatype.uuid(), | |
| email: email ?? faker.internet.email(), | |
| emailAlias: faker.internet.email(undefined, undefined, 'mock-marble.co'), | |
| @@ -312,7 +312,7 @@ export const mockAttorneyQualityStats: AttorneyQualityStats = { | |
| }; | |
| export const mockAttorneyStats: AttorneyStatsEntity = { | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| activeClients: 5, | |
| allTimeClients: 10, | |
| currentMonthPayouts: 20, | |
| @@ -706,8 +706,8 @@ export function getDisplayCaseStatus( | |
| } | |
| export const mockCustomer1: User = { | |
| - id: objectStringId(), | |
| - bookItId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + bookItId: Types.ObjectId().toString(), | |
| address: { | |
| street: faker.address.streetName(), | |
| city: faker.address.city(), | |
| @@ -732,11 +732,11 @@ export const mockCustomer1: User = { | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const mockCustomer2: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| address: { | |
| street: faker.address.streetName(), | |
| state: faker.address.state(), | |
| @@ -749,11 +749,11 @@ export const mockCustomer2: User = { | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const mockAttorney1: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| address: { | |
| street: faker.address.streetName(), | |
| state: faker.address.state(), | |
| @@ -767,7 +767,7 @@ export const mockAttorney1: User = { | |
| }, | |
| email: faker.internet.email(), | |
| emailAlias: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const mockServiceType = { | |
| @@ -792,8 +792,8 @@ export const generateServiceDraftMock = ({ | |
| serviceId?: string; | |
| status?: ServiceDraftsStatus; | |
| }) => ({ | |
| - userId: userId ?? objectStringId(), | |
| - caseId: caseId ?? objectStringId(), | |
| - serviceId: serviceId ?? objectStringId(), | |
| + userId: userId ?? Types.ObjectId().toString(), | |
| + caseId: caseId ?? Types.ObjectId().toString(), | |
| + serviceId: serviceId ?? Types.ObjectId().toString(), | |
| status: status ?? ServiceDraftsStatus.PENDING_ATTORNEY, | |
| }); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/case-note.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/case-note.schema.spec.ts | |
| index e7548e24b..201e25690 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/case-note.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/case-note.schema.spec.ts | |
| @@ -2,7 +2,7 @@ import 'reflect-metadata'; | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| import * as path from 'path'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| const CASE_NOTE_FULL_FIELDS = ` | |
| createdAt | |
| @@ -27,7 +27,7 @@ describe('CaseNote schema', () => { | |
| }`; | |
| tester.test(true, query, { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| }); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/case-notes.service.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/case-notes.service.spec.ts | |
| index e061ff379..2a476b5f4 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/case-notes.service.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/case-notes.service.spec.ts | |
| @@ -7,7 +7,7 @@ import { CaseNotesModule } from '../case-notes.module'; | |
| import { CaseNotesService } from '../case-notes.service'; | |
| import { mapCaseUpdateToCaseNote, mapTasksToCaseNote } from '../mappers/dto-to-graph'; | |
| import { mockAttorneyId, mockOlderTask, mockRecentCaseUpdate, mockServiceId } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| const ENV_VARS: Record<string, string> = { | |
| SERVICES_MS_URL: 'https://servic.es', | |
| @@ -46,7 +46,7 @@ describe('CaseNotesService', () => { | |
| }); | |
| describe('getCaseNotes', () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| it('should return case notes in recent date order', async () => { | |
| const expectedCaseNotesResponse = [ | |
| { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/utils.ts b/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/utils.ts | |
| index 18e38a0e6..58a259013 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-notes/tests/utils.ts | |
| @@ -1,16 +1,16 @@ | |
| import { CaseUpdateSources, TaskDto } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { CaseUpdate } from '../../attorneys/models/attorney-case-update.model'; | |
| const recentDate = new Date('2023-09-20T00:00:00'); | |
| const olderDate = new Date('2018-09-20T00:00:00'); | |
| -export const mockServiceId = objectStringId(); | |
| -export const mockAttorneyId = objectStringId(); | |
| +export const mockServiceId = Types.ObjectId().toString(); | |
| +export const mockAttorneyId = Types.ObjectId().toString(); | |
| export const mockRecentCaseUpdate: CaseUpdate = { | |
| - id: objectStringId(), | |
| - caseId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| content: 'content', | |
| title: 'title', | |
| source: CaseUpdateSources.LP, | |
| @@ -18,7 +18,7 @@ export const mockRecentCaseUpdate: CaseUpdate = { | |
| }; | |
| export const mockOlderTask: TaskDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdByUserId: mockAttorneyId, | |
| serviceId: mockServiceId, | |
| taskName: 'taskName', | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers-data.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers-data.resolver.spec.ts | |
| index f40cabfd2..9909f17f9 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers-data.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers-data.resolver.spec.ts | |
| @@ -8,7 +8,7 @@ import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { SplitService, getSplitService } from '@marbletech/split'; | |
| import { PracticeAreaDto, ServiceDto, ServiceStatus } from '@vinny/services-types'; | |
| import { User as UserDto } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeArea } from '../../administration/models/practice-areas.model'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| @@ -101,7 +101,7 @@ describe('AttorneyCaseOffersDataResolver', () => { | |
| fips: '12345', | |
| customerId: faker.database.mongodbObjectId(), | |
| type: CaseOfferType.INITIAL_DISPATCH, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| practiceAreaId: faker.database.mongodbObjectId(), | |
| serviceTypes: [ | |
| { | |
| @@ -113,7 +113,7 @@ describe('AttorneyCaseOffersDataResolver', () => { | |
| const noLocationCaseOfferData = { | |
| type: CaseOfferType.INITIAL_DISPATCH, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| customerId: faker.database.mongodbObjectId(), | |
| practiceAreaId: faker.database.mongodbObjectId(), | |
| serviceTypes: [], | |
| @@ -237,13 +237,13 @@ describe('AttorneyCaseOffersDataResolver', () => { | |
| describe('resolve servicesHistory field', () => { | |
| const servicesList: ServiceDto[] = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'Service name', | |
| description: 'Service description', | |
| practiceAreaId: caseOfferData.practiceAreaId, | |
| caseId: caseOfferData.caseId, | |
| userId: caseOfferData.customerId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.COMPLETED, | |
| legalTeam: [], | |
| location: { | |
| @@ -252,13 +252,13 @@ describe('AttorneyCaseOffersDataResolver', () => { | |
| }, | |
| }, | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'Service name1', | |
| description: 'Service description1', | |
| practiceAreaId: caseOfferData.practiceAreaId, | |
| caseId: caseOfferData.caseId, | |
| userId: caseOfferData.customerId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| legalTeam: [], | |
| location: { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers.resolver.spec.ts | |
| index 20e92e321..1c0fd19f9 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers.resolver.spec.ts | |
| @@ -18,7 +18,7 @@ import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { Attorney } from '@vinny/users-types'; | |
| import _ from 'lodash'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { AttorneysModule } from '../../attorneys/attorneys.module'; | |
| @@ -88,13 +88,13 @@ describe('AttorneyCaseOfferResolver resolver', () => { | |
| }); | |
| const attorney: Attorney = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'John', | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| @@ -219,7 +219,7 @@ describe('AttorneyCaseOfferResolver resolver', () => { | |
| }); | |
| it('Should throw not found error when case offer is missing', async () => { | |
| - const caseOfferId = objectStringId(); | |
| + const caseOfferId = Types.ObjectId().toString(); | |
| const getCaseOffer = dispatchMsNock.get(`/case-offers/${caseOfferId}`).reply(404, { | |
| message: 'NOT_FOUND', | |
| status: HttpStatus.NOT_FOUND, | |
| @@ -232,7 +232,7 @@ describe('AttorneyCaseOfferResolver resolver', () => { | |
| }); | |
| it('Should throw not found error when attorney is not part of dispatchedAttorneys list', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const caseOffer = createCaseOfferDto({ | |
| dispatchedAttorneys: [ | |
| { | |
| @@ -358,7 +358,7 @@ describe('AttorneyCaseOfferResolver resolver', () => { | |
| describe('fail', () => { | |
| it('Should throw not found error when attorney is not part of dispatchedAttorneys list', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const caseOffer = createCaseOfferDto({ | |
| dispatchedAttorneys: [ | |
| { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers.schema.spec.ts | |
| index dea9466d5..9a81e6aa7 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/attorney.case-offers.schema.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| describe('AttorneyCaseOffer schema', () => { | |
| let tester: EasyGraphQLTester; | |
| @@ -93,7 +93,7 @@ describe('AttorneyCaseOffer schema', () => { | |
| it('Should pass when the schema is valid', () => { | |
| const query = `{ | |
| getCurrentAttorney { | |
| - caseOffer(id: "${objectId(objectStringId())}") { | |
| + caseOffer(id: "${Types.ObjectId()}") { | |
| id | |
| createdAt | |
| isUrgent | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/case-offers-data.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/case-offers-data.resolver.spec.ts | |
| index 73c47fc65..35d07c2cb 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/case-offers-data.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/case-offers-data.resolver.spec.ts | |
| @@ -9,7 +9,7 @@ import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { SplitService, getSplitService } from '@marbletech/split'; | |
| import { PracticeAreaDto, ServiceDto, ServiceStatus } from '@vinny/services-types'; | |
| import { User as UserDto } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeArea } from '../../administration/models/practice-areas.model'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| @@ -87,14 +87,14 @@ describe('CaseOffersDataResolver', () => { | |
| customerId: faker.database.mongodbObjectId(), | |
| practiceAreaId: faker.database.mongodbObjectId(), | |
| type: CaseOfferType.INITIAL_DISPATCH, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| serviceTypes: [ | |
| { | |
| id: faker.database.mongodbObjectId(), | |
| }, | |
| ], | |
| attorneyBaseFee: 100, | |
| - lssAttorneyId: objectStringId(), | |
| + lssAttorneyId: Types.ObjectId().toString(), | |
| }; | |
| describe('resolve county field', () => { | |
| @@ -238,13 +238,13 @@ describe('CaseOffersDataResolver', () => { | |
| describe('resolve servicesHistory field', () => { | |
| const servicesList: ServiceDto[] = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'Service name', | |
| description: 'Service description', | |
| practiceAreaId: caseOfferData.practiceAreaId, | |
| caseId: caseOfferData.caseId, | |
| userId: caseOfferData.customerId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.COMPLETED, | |
| legalTeam: [], | |
| location: { | |
| @@ -253,13 +253,13 @@ describe('CaseOffersDataResolver', () => { | |
| }, | |
| }, | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'Service name1', | |
| description: 'Service description1', | |
| practiceAreaId: caseOfferData.practiceAreaId, | |
| caseId: caseOfferData.caseId, | |
| userId: caseOfferData.customerId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| legalTeam: [], | |
| location: { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/case-offers.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/case-offers.resolver.spec.ts | |
| index edb922e54..3236109cc 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/case-offers.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/case-offers.resolver.spec.ts | |
| @@ -19,7 +19,7 @@ import { IDEMPOTENCY_KEY_HEADER } from '@vinny/idempotency'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { Attorney, User } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { LocationsModule } from '../../locations/locations.module'; | |
| @@ -48,14 +48,14 @@ const caseOffer: CaseOffer = { | |
| data: { | |
| ...createCaseOfferData({}), | |
| type: CaseOfferType.INITIAL_DISPATCH, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| }, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| isUrgent: false, | |
| - assignedAttorneyId: objectStringId(), | |
| - agentUserId: objectStringId(), | |
| - assigningAgentUserId: objectStringId(), | |
| + assignedAttorneyId: Types.ObjectId().toString(), | |
| + agentUserId: Types.ObjectId().toString(), | |
| + assigningAgentUserId: Types.ObjectId().toString(), | |
| isManuallyAssignable: true, | |
| dispatchMethod: DispatchMethod.DEFAULT_DISPATCH, | |
| }; | |
| @@ -114,7 +114,7 @@ describe('CaseOfferResolver', () => { | |
| describe('getCaseOffers', () => { | |
| it('Should get all case offers when filter is empty', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const caseOffersDtos = [CaseOfferType.INITIAL_DISPATCH, CaseOfferType.REPEAT_DISPATCH].map( | |
| (type) => | |
| createCaseOfferDto({ | |
| @@ -146,7 +146,7 @@ describe('CaseOfferResolver', () => { | |
| }); | |
| it('Should get case offers by status filter', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const closedAtFrom = new Date('2023-01-01'); | |
| const closedAtTo = new Date('2023-02-01'); | |
| const caseOffersDtos = [1, 2].map(() => | |
| @@ -208,7 +208,7 @@ describe('CaseOfferResolver', () => { | |
| `( | |
| 'Should get case offer by id of type $type and of dispatch method $dispatchMethod', | |
| async ({ type, dispatchMethod }) => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const caseOfferDto = createCaseOfferDto({ | |
| type, | |
| dispatchMethod: dispatchMethod, | |
| @@ -240,7 +240,7 @@ describe('CaseOfferResolver', () => { | |
| ); | |
| it("Should throw not find error when case offer doesn't exist", async () => { | |
| - const caseOfferId = objectStringId(); | |
| + const caseOfferId = Types.ObjectId().toString(); | |
| const getCaseOffer = dispatchMsNock.get(`/case-offers/${caseOfferId}`).reply(404, { | |
| status: HttpStatus.NOT_FOUND, | |
| @@ -254,9 +254,9 @@ describe('CaseOfferResolver', () => { | |
| }); | |
| describe('respondOnCaseOfferByAdmin', () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const admin: UserContext = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| roles: [Role.ADMIN], | |
| permissions: [Permission.ADMIN_ALL], | |
| }; | |
| @@ -264,7 +264,7 @@ describe('CaseOfferResolver', () => { | |
| const caseOfferDto: CaseOfferDto = { | |
| type: CaseOfferType.INITIAL_DISPATCH, | |
| status: CaseOfferStatus.COMPLETED, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| dispatchedAttorneys: [ | |
| { | |
| attorneyId, | |
| @@ -275,7 +275,7 @@ describe('CaseOfferResolver', () => { | |
| }, | |
| ], | |
| data: createCaseOfferData({}), | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| isUrgent: false, | |
| assignedAttorneyId: attorneyId, | |
| @@ -362,7 +362,7 @@ describe('CaseOfferResolver', () => { | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| it('Should resolve assigned attorney when exists', async () => { | |
| @@ -400,7 +400,7 @@ describe('CaseOfferResolver', () => { | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ADMIN], | |
| }; | |
| it('Should resolve agent user when exists', async () => { | |
| @@ -436,7 +436,7 @@ describe('CaseOfferResolver', () => { | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ADMIN], | |
| }; | |
| it('Should resolve assigning agent user when exists', async () => { | |
| @@ -529,7 +529,7 @@ describe('CaseOfferResolver', () => { | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| it('Should resolve assigned attorney when exists', async () => { | |
| @@ -567,7 +567,7 @@ describe('CaseOfferResolver', () => { | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ADMIN], | |
| }; | |
| it('Should resolve agent user when exists', async () => { | |
| @@ -603,7 +603,7 @@ describe('CaseOfferResolver', () => { | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ADMIN], | |
| }; | |
| it('Should resolve assigning agent user when exists', async () => { | |
| @@ -636,7 +636,7 @@ describe('CaseOfferResolver', () => { | |
| }); | |
| describe('sendCaseOfferReminder', () => { | |
| - const caseOfferId = objectStringId(); | |
| + const caseOfferId = Types.ObjectId().toString(); | |
| const mockIdempotencyKey = 'mockIdempotencyKey'; | |
| describe('success', () => { | |
| it('should return true when resolves', async () => { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/dispatched-attorney.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/dispatched-attorney.resolver.spec.ts | |
| index a6a7a81d6..e74e24eca 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/dispatched-attorney.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-offers/tests/dispatched-attorney.resolver.spec.ts | |
| @@ -7,7 +7,7 @@ import { AttorneyResponseStatus } from '@vinny/dispatch-types'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { Attorney } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { LocationsModule } from '../../locations/locations.module'; | |
| @@ -79,7 +79,7 @@ describe('DispatchedAttorneyResolver', () => { | |
| }); | |
| const dispatchedAttorney: DispatchedAttorney = { | |
| - attorneyId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| response: AttorneyResponseStatus.PENDING, | |
| createdAt: new Date(), | |
| }; | |
| @@ -93,7 +93,7 @@ describe('DispatchedAttorneyResolver', () => { | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/case-status-updates/tests/case-status-update.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/case-status-updates/tests/case-status-update.schema.spec.ts | |
| index e258e3171..8ff0d622c 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/case-status-updates/tests/case-status-update.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/case-status-updates/tests/case-status-update.schema.spec.ts | |
| @@ -2,7 +2,7 @@ import 'reflect-metadata'; | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import fs from 'fs'; | |
| import path from 'path'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { validCreateMutation, validGetCaseStatusUpdatesByCaseIdQuery } from './utils'; | |
| import faker from '@faker-js/faker'; | |
| @@ -16,7 +16,7 @@ describe('CaseStatusUpdate schema', () => { | |
| it('Should pass when the schema is valid', () => { | |
| tester.test(true, validCreateMutation, { | |
| createStatusUpdateRequest: { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| content: 'content', | |
| isExternallyVisible: true, | |
| }, | |
| @@ -35,7 +35,7 @@ describe('CaseStatusUpdate schema', () => { | |
| it('Should pass when the schema is valid', () => { | |
| tester.test(true, validGetCaseStatusUpdatesByCaseIdQuery, { | |
| caseStatusListUpdatesRequest: { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| }, | |
| }); | |
| }); | |
| @@ -54,10 +54,10 @@ mutation DelegateCaseStatusUpdate($caseStatusUpdatesRequest: DelegateCaseStatusU | |
| `; | |
| tester.test(true, mutation, { | |
| caseStatusUpdatesRequest: { | |
| - assigneeId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + assigneeId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| internalNotes: faker.lorem.sentence(), | |
| - delegatedId: objectStringId(), | |
| + delegatedId: Types.ObjectId().toString(), | |
| }, | |
| }); | |
| }); | |
| @@ -90,7 +90,7 @@ mutation DelegateCaseStatusUpdate($caseStatusUpdatesRequest: DelegateCaseStatusU | |
| } | |
| `; | |
| tester.test(false, mutation, { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| }); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/catalog/document-types/test/utils.ts b/apps/attorneys-graphql-gateway-ms/src/catalog/document-types/test/utils.ts | |
| index 4f1df58e2..1e556e058 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/catalog/document-types/test/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/catalog/document-types/test/utils.ts | |
| @@ -1,5 +1,5 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const GetDocumentTypesByServiceTypeIdValidQuery = `query GetDocumentTypesByServiceTypeId($serviceTypeId: String!) { | |
| getDocumentTypesByServiceTypeId(serviceTypeId: $serviceTypeId) { | |
| @@ -53,7 +53,7 @@ export const CreateDocumentTypeInput = { | |
| shouldCreateSchema: faker.datatype.boolean(), | |
| displayName: faker.datatype.string(), | |
| }; | |
| -export const serviceTypeId = objectStringId(); | |
| +export const serviceTypeId = Types.ObjectId().toString(); | |
| export const MockServiceTypeResources = [ | |
| { | |
| @@ -64,7 +64,7 @@ export const MockServiceTypeResources = [ | |
| export const MockDocumentTypeResponse = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...CreateDocumentTypeInput, | |
| }, | |
| ]; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/catalog/service-milestones/test/consts.ts b/apps/attorneys-graphql-gateway-ms/src/catalog/service-milestones/test/consts.ts | |
| index ab3e62f4f..ac7089d78 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/catalog/service-milestones/test/consts.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/catalog/service-milestones/test/consts.ts | |
| @@ -1,6 +1,6 @@ | |
| import faker from '@faker-js/faker'; | |
| import { ServiceMilestonesResultsList } from '@vinny/catalog-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const listServiceMilestonesValidSchema = `query ListServiceMilestones($request: ServiceMilestonesListRequest!) { | |
| listServiceMilestones(request: $request) { | |
| @@ -46,7 +46,7 @@ export const createServiceMilestoneValidSchema = `mutation Mutation($input: Crea | |
| defaultSteps { | |
| completionPercent | |
| name | |
| - } | |
| + } | |
| } | |
| }`; | |
| @@ -73,17 +73,17 @@ export const deleteServiceMilestoneValidSchema = `mutation DeleteServiceMileston | |
| }`; | |
| export const serviceMilestoneDto1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.word.noun(), | |
| }; | |
| export const serviceMilestoneDto2 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.word.noun(), | |
| }; | |
| export const serviceMilestoneDto3 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.word.noun(), | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/catalog/service-milestones/test/service-milestone.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/catalog/service-milestones/test/service-milestone.schema.spec.ts | |
| index a997e0a5c..de345f714 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/catalog/service-milestones/test/service-milestone.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/catalog/service-milestones/test/service-milestone.schema.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| import * as path from 'path'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| createServiceMilestoneValidSchema, | |
| deleteServiceMilestoneValidSchema, | |
| @@ -41,11 +41,11 @@ describe('service milestones schema', () => { | |
| describe('getServiceMilestone', () => { | |
| it('Should pass when the schema is valid', () => { | |
| tester.test(true, getServiceMilestoneByIdValidSchema, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| it('Should not pass when the schema is valid', () => { | |
| - tester.test(false, getServiceMilestoneByIdInvalidSchema, { id: objectStringId() }); | |
| + tester.test(false, getServiceMilestoneByIdInvalidSchema, { id: Types.ObjectId().toString() }); | |
| }); | |
| }); | |
| @@ -57,7 +57,7 @@ describe('service milestones schema', () => { | |
| }); | |
| it('Should not pass when the schema is valid', () => { | |
| tester.test(false, createServiceMilestoneValidSchema, { | |
| - input: { id: objectStringId() }, | |
| + input: { id: Types.ObjectId().toString() }, | |
| }); | |
| }); | |
| }); | |
| @@ -65,7 +65,7 @@ describe('service milestones schema', () => { | |
| describe('updateServiceMilestone', () => { | |
| it('Should pass when the schema is valid', () => { | |
| tester.test(true, updateServiceMilestoneValidSchema, { | |
| - updateServiceMilestoneId: objectStringId(), | |
| + updateServiceMilestoneId: Types.ObjectId().toString(), | |
| input: { | |
| name: faker.word.noun(), | |
| }, | |
| @@ -74,7 +74,7 @@ describe('service milestones schema', () => { | |
| it('Should not pass when the milestone id isnt provided and schema is valid', () => { | |
| tester.test(false, updateServiceMilestoneValidSchema, { | |
| - input: { id: objectStringId() }, | |
| + input: { id: Types.ObjectId().toString() }, | |
| }); | |
| }); | |
| }); | |
| @@ -82,7 +82,7 @@ describe('service milestones schema', () => { | |
| describe('deleteServiceMilestone', () => { | |
| it('Should pass when the schema is valid', () => { | |
| tester.test(true, deleteServiceMilestoneValidSchema, { | |
| - deleteServiceMilestoneId: objectStringId(), | |
| + deleteServiceMilestoneId: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| it('Should not pass when the milestone id isnt provided and schema is valid', () => { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/service-type.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/service-type.resolver.spec.ts | |
| index 12ae3f2b7..1a62249eb 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/service-type.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/service-type.resolver.spec.ts | |
| @@ -7,7 +7,7 @@ import { ServiceCatalogClientModule } from '@vinny/catalog-client'; | |
| import { ListServiceResponse, MockServiceTypeResponse, UpdateServiceTypeInput } from './utils'; | |
| import { CatalogServiceTypesResolver } from '../service-types.resolver'; | |
| import { CatalogServiceTypesApiService } from '../service-types.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { Permission, Role, UserContext } from '@vinny/auth-types'; | |
| const ENV_VARS: Record<string, string> = { | |
| @@ -72,7 +72,7 @@ describe('service-types resolver', () => { | |
| describe('updateServiceType', () => { | |
| const user: UserContext = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| roles: [Role.ADMIN], | |
| permissions: [Permission.ADMIN_ALL], | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/service-type.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/service-type.schema.spec.ts | |
| index a3a0aebc7..100ff90ad 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/service-type.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/service-type.schema.spec.ts | |
| @@ -7,7 +7,7 @@ import { | |
| UpdateServiceTypePayload, | |
| GetServiceTypeValidSchema, | |
| } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| describe('service-type schema', () => { | |
| const schema = fs.readFileSync(path.join(__dirname, '../../..', 'schema.gql'), 'utf8'); | |
| @@ -39,21 +39,21 @@ describe('service-type schema', () => { | |
| describe('updateServiceTypes', () => { | |
| it('Should pass when the schema is valid', () => { | |
| tester.test(true, UpdateServiceTypeValidSchema, { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| input: UpdateServiceTypePayload, | |
| }); | |
| }); | |
| it('Should not pass when the schema is valid', () => { | |
| tester.test(false, UpdateServiceTypeValidSchema, { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| input: { | |
| serviceMilestonesList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| portion: 70, | |
| isProofRequired: true, | |
| - serviceMilestone: { id: objectStringId(), name: 'name' }, | |
| + serviceMilestone: { id: Types.ObjectId().toString(), name: 'name' }, | |
| }, | |
| ], | |
| }, | |
| @@ -64,7 +64,7 @@ describe('service-type schema', () => { | |
| describe('getServiceType', () => { | |
| it('Should pass when the schema is valid', () => { | |
| tester.test(true, GetServiceTypeValidSchema, { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| it('Should not pass when the schema is valid', () => { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/utils.ts b/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/utils.ts | |
| index fc76222c4..3e101b0b8 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/catalog/service-types/test/utils.ts | |
| @@ -1,5 +1,5 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ResourceSelector } from '../models/service-type.model'; | |
| export const ListServiceTypesValidSchema = `query Query($request: ServiceTypesListRequest!) { | |
| @@ -139,19 +139,19 @@ export const UpdateServiceTypeInput = { | |
| ], | |
| serviceMilestonesList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| portion: 40, | |
| isProofRequired: true, | |
| isOptional: true, | |
| }, | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| portion: 50, | |
| isProofRequired: false, | |
| isOptional: true, | |
| }, | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| portion: 10, | |
| isProofRequired: false, | |
| }, | |
| @@ -167,25 +167,25 @@ export const UpdateServiceTypePayload = { | |
| ], | |
| serviceMilestonesList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| portion: 30, | |
| isProofRequired: false, | |
| isOptional: true, | |
| }, | |
| - { serviceMilestoneId: objectStringId(), portion: 70, isProofRequired: true }, | |
| + { serviceMilestoneId: Types.ObjectId().toString(), portion: 70, isProofRequired: true }, | |
| ], | |
| }; | |
| export const MockServiceTypeResponse = [ | |
| { | |
| - id: objectStringId(), | |
| - bpmId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + bpmId: Types.ObjectId().toString(), | |
| serviceCode: faker.datatype.string(), | |
| metadata: { status: 'ACTIVE', createdById: 'CREATE_TEST_ID' }, | |
| content: { | |
| isAddendumProduct: faker.datatype.boolean(), | |
| firm: 'Marble', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| category: 'DIVORCE', | |
| description: { | |
| legalDescription: 'Mock Description', | |
| @@ -206,7 +206,7 @@ export const MockServiceTypeResponse = [ | |
| defaultPricing: {}, | |
| serviceMilestonesList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| portion: 60, | |
| isProofRequired: true, | |
| steps: [ | |
| @@ -221,7 +221,7 @@ export const MockServiceTypeResponse = [ | |
| ], | |
| }, | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| portion: 40, | |
| isProofRequired: false, | |
| }, | |
| @@ -243,7 +243,7 @@ export const ListServiceResponse = { | |
| }; | |
| export const serviceMilestoneDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.jobTitle(), | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/communication-hub/tests/utils.ts b/apps/attorneys-graphql-gateway-ms/src/communication-hub/tests/utils.ts | |
| index c9241bc7b..56375d221 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/communication-hub/tests/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/communication-hub/tests/utils.ts | |
| @@ -1,6 +1,6 @@ | |
| import faker from '@faker-js/faker'; | |
| import { CUSTOMER_SUPPORT_ID } from '../consts'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const supportUserMock = { | |
| id: faker.datatype.string(), | |
| @@ -41,7 +41,7 @@ export const invalidSendEmailReplyMutation = ` | |
| `; | |
| export const sendEmailReplyInput = { | |
| - commId: objectStringId(), | |
| + commId: Types.ObjectId().toString(), | |
| content: faker.lorem.sentence(), | |
| to: [faker.internet.email(), faker.internet.email()], | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/data-requests/tests/const.ts b/apps/attorneys-graphql-gateway-ms/src/data-requests/tests/const.ts | |
| index c9d2b6d9d..2eba45f89 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/data-requests/tests/const.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/data-requests/tests/const.ts | |
| @@ -1,8 +1,8 @@ | |
| import { ServiceDraftsStatus } from '@vinny/data-requests-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| -export const USER_ID = objectStringId(); | |
| -export const USER_ID1 = objectStringId(); | |
| +export const USER_ID = Types.ObjectId().toString(); | |
| +export const USER_ID1 = Types.ObjectId().toString(); | |
| export const GET_USER_DRAFT_SCHEMA_QUERY = `query getUserDraftsRequestSchema($input: UserIdInput!) { | |
| getUserDraftsRequestSchema(input: $input) { | |
| @@ -96,30 +96,30 @@ export const updateServiceDraftsInvalidInput = { | |
| export const serviceDraftslistMock = [ | |
| { | |
| userId: USER_ID, | |
| - caseId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| status: ServiceDraftsStatus.ATTORNEY, | |
| }, | |
| { | |
| userId: USER_ID1, | |
| - caseId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| status: ServiceDraftsStatus.ATTORNEY, | |
| }, | |
| ]; | |
| export const serviceDraftsDto1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId: USER_ID, | |
| - caseId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| status: ServiceDraftsStatus.CLIENT, | |
| }; | |
| export const serviceDraftsDto2 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId: USER_ID, | |
| - caseId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| status: ServiceDraftsStatus.PENDING_ATTORNEY, | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/data-requests/tests/data-requests.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/data-requests/tests/data-requests.resolver.spec.ts | |
| index bd3b7f8ca..50b1c9d92 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/data-requests/tests/data-requests.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/data-requests/tests/data-requests.resolver.spec.ts | |
| @@ -13,7 +13,7 @@ import { | |
| import { DocumentFormat } from '@vinny/documents-types'; | |
| import { ServiceDraftsStatus } from '@vinny/data-requests-types'; | |
| import { ServiceDraftsResolver } from '../service-drafts.resolver'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { createTestingModule } from '@vinny/test-utils'; | |
| const ENV_VARS: Record<string, string> = { | |
| @@ -202,8 +202,8 @@ describe('Data Requests Resolver', () => { | |
| .reply(200, () => 5); | |
| const serviceDraft = { | |
| userId: USER_ID, | |
| - caseId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| status: ServiceDraftsStatus.PENDING_ATTORNEY, | |
| }; | |
| const getServiceDraftsCompletionPercentageResponse = | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/documents/test/documents.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/documents/test/documents.resolver.spec.ts | |
| index 4d9aab1a7..c2c18f4f0 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/documents/test/documents.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/documents/test/documents.resolver.spec.ts | |
| @@ -38,7 +38,7 @@ import { | |
| documentType2, | |
| } from './utils'; | |
| import { DocumentCatalogClientModule } from '@vinny/catalog-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { DeleteDocumentsError, RequestClientDocumentsError } from '../models/document.model'; | |
| import { BusinessFlowManagerClientModule } from '@vinny/business-flow-manager-client'; | |
| import { RequestClientDocumentsErrorMessage } from '../utils'; | |
| @@ -204,7 +204,7 @@ describe('documents resolver', () => { | |
| }); | |
| it('should update fileName and documentTypeId', async () => { | |
| - const updatedDocumentTypeId = objectStringId(); | |
| + const updatedDocumentTypeId = Types.ObjectId().toString(); | |
| const getCaseServicesNock = servicesMsNock | |
| .get(`/services/list/metadata`) | |
| .query({ caseId }) | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/documents/test/documents.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/documents/test/documents.schema.spec.ts | |
| index f3f851296..0c6af97b9 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/documents/test/documents.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/documents/test/documents.schema.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| import { | |
| ListDocumentsValidSchema, | |
| @@ -26,7 +26,7 @@ describe('documents schema', () => { | |
| tester.test(true, ListDocumentsValidSchema, { | |
| request: { | |
| searchTerm: 'search', | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| sortBy: 'fileName', | |
| offset: 5, | |
| limit: 10, | |
| @@ -46,13 +46,21 @@ describe('documents schema', () => { | |
| describe('getDocumentDownloadUrls', () => { | |
| it('Should pass when schema is valid', () => { | |
| tester.test(true, getDocumentDownloadUrlsValidSchema, { | |
| - documentIds: [objectStringId(), objectStringId(), objectStringId()], | |
| + documentIds: [ | |
| + Types.ObjectId().toString(), | |
| + Types.ObjectId().toString(), | |
| + Types.ObjectId().toString(), | |
| + ], | |
| }); | |
| }); | |
| it('Should not pass when schema is invalid', () => { | |
| tester.test(false, getDocumentDownloadUrlsValidSchema, { | |
| - caseIds: [objectStringId(), objectStringId(), objectStringId()], | |
| + caseIds: [ | |
| + Types.ObjectId().toString(), | |
| + Types.ObjectId().toString(), | |
| + Types.ObjectId().toString(), | |
| + ], | |
| }); | |
| }); | |
| }); | |
| @@ -61,8 +69,8 @@ describe('documents schema', () => { | |
| it('Should pass when schema is valid', () => { | |
| tester.test(true, ValidUpdateDocumentSchema, { | |
| request: { | |
| - documentId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + documentId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| documentData: { | |
| fileName: faker.datatype.string(), | |
| }, | |
| @@ -73,7 +81,7 @@ describe('documents schema', () => { | |
| it('Should not pass when request is invalid', () => { | |
| tester.test(false, ValidUpdateDocumentSchema, { | |
| request: { | |
| - documentId: objectStringId(), | |
| + documentId: Types.ObjectId().toString(), | |
| documentData: { | |
| fileName: faker.datatype.string(), | |
| }, | |
| @@ -86,8 +94,8 @@ describe('documents schema', () => { | |
| it('Should pass when schema is valid', () => { | |
| tester.test(true, ValidUpdateMultipleDocumentsSchema, { | |
| request: { | |
| - documentIds: [objectStringId(), objectStringId()], | |
| - caseId: objectStringId(), | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| + caseId: Types.ObjectId().toString(), | |
| documentData: { | |
| fileName: faker.datatype.string(), | |
| }, | |
| @@ -98,7 +106,7 @@ describe('documents schema', () => { | |
| it('Should not pass when request is invalid', () => { | |
| tester.test(false, ValidUpdateMultipleDocumentsSchema, { | |
| request: { | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| documentData: { | |
| fileName: faker.datatype.string(), | |
| }, | |
| @@ -111,8 +119,8 @@ describe('documents schema', () => { | |
| it('should pass when schema is valid', () => { | |
| tester.test(true, ValidDeleteDocumentsSchema, { | |
| request: { | |
| - caseId: objectStringId(), | |
| - documentsIds: [objectStringId(), objectStringId()], | |
| + caseId: Types.ObjectId().toString(), | |
| + documentsIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| }); | |
| }); | |
| @@ -128,21 +136,21 @@ describe('documents schema', () => { | |
| it('should pass when schema is valid', () => { | |
| tester.test(true, validRequestDocumentUploadSchema, { | |
| request: { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| customerVisibility: true, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| fileName: faker.system.fileName(), | |
| sourceApp: 'ATTORNEYS_WEB_APP', | |
| - uploaderMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| }, | |
| }); | |
| }); | |
| it('should not pass when request in invalid', () => { | |
| tester.test(false, validRequestDocumentUploadSchema, { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| customerVisibility: true, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| fileName: faker.system.fileName(), | |
| sourceApp: 'ATTORNEYS_WEB_APP', | |
| uploaderMarbleId: 5, | |
| @@ -153,8 +161,8 @@ describe('documents schema', () => { | |
| it('Should pass when schema is valid', () => { | |
| tester.test(true, ValidRequestClientDocumentsSchema, { | |
| request: { | |
| - documentTypeIds: [objectStringId(), objectStringId()], | |
| - caseId: objectStringId(), | |
| + documentTypeIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| + caseId: Types.ObjectId().toString(), | |
| }, | |
| }); | |
| }); | |
| @@ -162,7 +170,7 @@ describe('documents schema', () => { | |
| it('Should not pass when request is invalid', () => { | |
| tester.test(false, ValidRequestClientDocumentsSchema, { | |
| request: { | |
| - documentTypeIds: [objectStringId(), objectStringId()], | |
| + documentTypeIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| }); | |
| }); | |
| @@ -172,7 +180,7 @@ describe('documents schema', () => { | |
| const query = ValidGetClientRequiredDocumentsSchema; | |
| tester.test(true, query, { | |
| request: { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| }, | |
| }); | |
| }); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/documents/test/utils.ts b/apps/attorneys-graphql-gateway-ms/src/documents/test/utils.ts | |
| index 252956ebf..c0d28f1f2 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/documents/test/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/documents/test/utils.ts | |
| @@ -5,7 +5,7 @@ import { | |
| ServiceMetadataDto, | |
| ServiceStatus, | |
| } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { CaseDocumentsListRequest } from '../models/document.model'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { Attorney, MemberRole, TeamType, User } from '@vinny/users-types'; | |
| @@ -17,26 +17,26 @@ import { | |
| } from '@vinny/documents-types'; | |
| import { DocumentTypeDto } from '@vinny/catalog-types'; | |
| -export const caseId = objectStringId(); | |
| -export const userId = objectStringId(); | |
| -export const attorneyId = objectStringId(); | |
| -export const otherAttorneyId = objectStringId(); | |
| -export const documentTypeId1 = objectStringId(); | |
| -export const documentTypeId2 = objectStringId(); | |
| -export const documentTypeId3 = objectStringId(); | |
| -export const documentTypeId4 = objectStringId(); | |
| +export const caseId = Types.ObjectId().toString(); | |
| +export const userId = Types.ObjectId().toString(); | |
| +export const attorneyId = Types.ObjectId().toString(); | |
| +export const otherAttorneyId = Types.ObjectId().toString(); | |
| +export const documentTypeId1 = Types.ObjectId().toString(); | |
| +export const documentTypeId2 = Types.ObjectId().toString(); | |
| +export const documentTypeId3 = Types.ObjectId().toString(); | |
| +export const documentTypeId4 = Types.ObjectId().toString(); | |
| export const documentDownloadUrl1 = faker.internet.url(); | |
| export const documentDownloadUrl2 = faker.internet.url(); | |
| export const documentDownloadUrl3 = faker.internet.url(); | |
| export const service1: ServiceMetadataDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.PENDING, | |
| userId, | |
| legalTeam: [ | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| { userId: otherAttorneyId, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| createdAt: faker.date.past(), | |
| @@ -44,13 +44,13 @@ export const service1: ServiceMetadataDto = { | |
| }; | |
| export const service2: ServiceMetadataDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.PENDING, | |
| userId, | |
| legalTeam: [ | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| { userId: attorneyId, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| createdAt: faker.date.past(), | |
| @@ -74,7 +74,7 @@ export const otherAttorney: Attorney = { | |
| roles: [Role.ATTORNEY], | |
| attorneyData: { | |
| legalTeam: { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| type: TeamType.LEGAL_TEAM, | |
| members: [ | |
| { | |
| @@ -82,11 +82,11 @@ export const otherAttorney: Attorney = { | |
| role: MemberRole.ATTORNEY, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.CASE_PARALEGAL, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.PARALEGAL_LEAD, | |
| }, | |
| ], | |
| @@ -95,105 +95,105 @@ export const otherAttorney: Attorney = { | |
| }; | |
| export const requestDocumentUploadMock = { | |
| - uploaderMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| caseId, | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.ATTORNEYS_WEB_APP, | |
| customerVisibility: false, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }; | |
| export const document1: DocumentDto = { | |
| s3UploadDate: new Date(), | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| s3Key: faker.random.alphaNumeric(5), | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.GOOGLE_DRIVE, | |
| caseId, | |
| customerVisibility: true, | |
| - uploaderMarbleId: objectStringId(), | |
| - customerMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| classification: DocumentClassification.BANK_STATEMENT, | |
| documentTypeId: documentTypeId1, | |
| }; | |
| export const document2: DocumentDto = { | |
| s3UploadDate: new Date(), | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| s3Key: faker.random.alphaNumeric(5), | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.FLAREX, | |
| caseId, | |
| customerVisibility: false, | |
| - customerMarbleId: objectStringId(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| classification: DocumentClassification.DRIVERS_LICENSE, | |
| documentTypeId: documentTypeId2, | |
| }; | |
| export const document3: DocumentDto = { | |
| s3UploadDate: new Date(), | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| s3Key: faker.random.alphaNumeric(5), | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.NETSUITE, | |
| caseId, | |
| customerVisibility: false, | |
| - uploaderMarbleId: objectStringId(), | |
| - customerMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| classification: DocumentClassification.DRIVERS_LICENSE, | |
| documentTypeId: documentTypeId3, | |
| }; | |
| export const document4: DocumentDto = { | |
| s3UploadDate: new Date(), | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| s3Key: faker.random.alphaNumeric(5), | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.NETSUITE, | |
| caseId, | |
| customerVisibility: false, | |
| uploaderMarbleId: document1.uploaderMarbleId, | |
| - customerMarbleId: objectStringId(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| classification: DocumentClassification.DRIVERS_LICENSE, | |
| documentTypeId: documentTypeId4, | |
| }; | |
| export const documentByAttorney: DocumentDto = { | |
| s3UploadDate: new Date(), | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| s3Key: faker.random.alphaNumeric(5), | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.NETSUITE, | |
| caseId, | |
| customerVisibility: false, | |
| uploaderMarbleId: otherAttorneyId, | |
| - customerMarbleId: objectStringId(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| classification: DocumentClassification.DRIVERS_LICENSE, | |
| documentTypeId: documentTypeId4, | |
| }; | |
| export const documentByAttorney2: DocumentDto = { | |
| s3UploadDate: new Date(), | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| s3Key: faker.random.alphaNumeric(5), | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.NETSUITE, | |
| caseId, | |
| customerVisibility: false, | |
| uploaderMarbleId: otherAttorneyId, | |
| - customerMarbleId: objectStringId(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| classification: DocumentClassification.DRIVERS_LICENSE, | |
| documentTypeId: documentTypeId4, | |
| }; | |
| export const documentUploadResponseMock = { | |
| uploadUrl: faker.internet.url(), | |
| - documentId: objectStringId(), | |
| + documentId: Types.ObjectId().toString(), | |
| document: document1, | |
| }; | |
| export const user1: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| @@ -204,7 +204,7 @@ export const user1: User = { | |
| }; | |
| export const user3: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName() + ' ', //check trimming in uploaderName | |
| @@ -268,7 +268,7 @@ export const UpdateDocumentName = faker.datatype.string(); | |
| export const case1 = { | |
| id: caseId, | |
| userId: userId, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| status: CaseStatus.ACCEPTED, | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/external-attorneys/tests/utils.ts b/apps/attorneys-graphql-gateway-ms/src/external-attorneys/tests/utils.ts | |
| index 5fa7b9b02..e4c8bc384 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/external-attorneys/tests/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/external-attorneys/tests/utils.ts | |
| @@ -3,7 +3,7 @@ import { Test } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { ExternalAttorneysModule } from '../external-attorneys.module'; | |
| import { CreateExternalAttorneyInput } from '../models/external-attorney.model'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { User } from '@vinny/users-types'; | |
| import { ConfigService } from '@nestjs/config'; | |
| @@ -45,8 +45,8 @@ export const getCreatedExternalAttorney = ( | |
| createExternalAttorneyInput: CreateExternalAttorneyInput, | |
| ): User => { | |
| return { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| name: createExternalAttorneyInput.name, | |
| email: createExternalAttorneyInput.email, | |
| phone: createExternalAttorneyInput.phone, | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/lss/mappers/tests/lss-event.mapper.spec.ts b/apps/attorneys-graphql-gateway-ms/src/lss/mappers/tests/lss-event.mapper.spec.ts | |
| index baaed98c8..de7e621ca 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/lss/mappers/tests/lss-event.mapper.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/lss/mappers/tests/lss-event.mapper.spec.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { LssEventDto, LssStatus } from '@vinny/events-types'; | |
| import { LssEventStatus } from '../../model/lss-meeting.model'; | |
| @@ -7,14 +7,14 @@ import { computeLssEventStatus } from '../lss-event.mapper'; | |
| describe('lss-event mapper', () => { | |
| describe('computeLssEventStatus', () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const lssEventOptions = { | |
| attorneyId, | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '48261', | |
| stateId: 'TX', | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| }; | |
| const lssEvent: LssEventDto = mockLssEvent(lssEventOptions); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/lss/test/attorney.lss.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/lss/test/attorney.lss.resolver.spec.ts | |
| index f996b7d2d..778ae20ce 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/lss/test/attorney.lss.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/lss/test/attorney.lss.resolver.spec.ts | |
| @@ -4,7 +4,7 @@ import { EventsClientModule } from '@vinny/events-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { SplitService, getSplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { LocationsModule } from '../../locations/locations.module'; | |
| @@ -108,24 +108,24 @@ describe('AttorneyLssResolver resolver', () => { | |
| }); | |
| const attorney: Attorney = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'John', | |
| last: 'Doe', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| describe('lss meeting', () => { | |
| const lssEventOptions = { | |
| attorneyId: attorney.id, | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '48261', | |
| stateId: 'TX', | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| }; | |
| const lssEvent: LssEventDto = mockLssEvent(lssEventOptions); | |
| @@ -169,7 +169,7 @@ describe('AttorneyLssResolver resolver', () => { | |
| const getLssEvent = eventsMsMock.get(`/events/${lssEvent.id}`).reply(200, lssEvent); | |
| await expect( | |
| - resolver.getLssMeeting(lssEvent.id, { id: objectStringId() }), | |
| + resolver.getLssMeeting(lssEvent.id, { id: Types.ObjectId().toString() }), | |
| ).rejects.toThrowError(`LSS meeting with id ${lssEvent.id} not found`); | |
| getLssEvent.done(); | |
| @@ -192,17 +192,17 @@ describe('AttorneyLssResolver resolver', () => { | |
| describe('lss meetings', () => { | |
| const lssEventOptions = { | |
| attorneyId: attorney.id, | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '48261', | |
| stateId: 'TX', | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| attorneyLssStatus: AttorneyLssStatus.ACCEPTED, | |
| }; | |
| const upcomingLssEvent: LssEventDto = mockLssEvent(lssEventOptions); | |
| const pendingLssEvent: LssEventDto = mockLssEvent({ | |
| ...lssEventOptions, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| lssStatus: LssStatus.CREATED, | |
| attorneyLssStatus: AttorneyLssStatus.PENDING_APPROVAL, | |
| isCompleted: true, | |
| @@ -245,16 +245,16 @@ describe('AttorneyLssResolver resolver', () => { | |
| describe('completed lss meetings', () => { | |
| const lssEventOptions = { | |
| attorneyId: attorney.id, | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '48261', | |
| stateId: 'TX', | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| }; | |
| const completedLssEvent: LssEventDto = mockLssEvent({ | |
| ...lssEventOptions, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| lssStatus: LssStatus.COMPLETED, | |
| salesNotes: SalesNotes.FINANCING, | |
| attorneyLssStatus: AttorneyLssStatus.COMPLETED, | |
| @@ -263,7 +263,7 @@ describe('AttorneyLssResolver resolver', () => { | |
| const completedNoShowLssEvent: LssEventDto = mockLssEvent({ | |
| ...lssEventOptions, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| lssStatus: LssStatus.COMPLETED_NO_SHOW, | |
| attorneyLssStatus: AttorneyLssStatus.COMPLETED_NO_SHOW, | |
| isCompleted: true, | |
| @@ -271,7 +271,7 @@ describe('AttorneyLssResolver resolver', () => { | |
| const completedRejectedLssEvent: LssEventDto = mockLssEvent({ | |
| ...lssEventOptions, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| lssStatus: LssStatus.REJECTED, | |
| attorneyLssStatus: AttorneyLssStatus.REJECTED, | |
| isCompleted: true, | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/lss/test/intake-data.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/lss/test/intake-data.resolver.spec.ts | |
| index a726401fa..4984256ad 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/lss/test/intake-data.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/lss/test/intake-data.resolver.spec.ts | |
| @@ -4,7 +4,7 @@ import { EventsClientModule } from '@vinny/events-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { LocationsModule } from '../../locations/locations.module'; | |
| @@ -95,7 +95,7 @@ describe('IntakeData resolver', () => { | |
| describe('resolve field practiceArea', () => { | |
| const practiceArea: PracticeAreaDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| key: 'FAMILY', | |
| displayName: 'Family', | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-meeting.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-meeting.resolver.spec.ts | |
| index 59f6bde30..cf9771c70 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-meeting.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-meeting.resolver.spec.ts | |
| @@ -4,7 +4,7 @@ import { EventsClientModule } from '@vinny/events-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../administration/practice-areas.module'; | |
| import { LocationsModule } from '../../locations/locations.module'; | |
| @@ -100,10 +100,10 @@ describe('LssMeeting resolver', () => { | |
| describe('isAttorneyCompletedLss field resolver', () => { | |
| const eventLssOptions = { | |
| - attorneyId: objectStringId(), | |
| - eventId: objectStringId(), | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| + eventId: Types.ObjectId().toString(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '12345', | |
| stateId: 'CO', | |
| }; | |
| @@ -121,7 +121,7 @@ describe('LssMeeting resolver', () => { | |
| const event = mockLssEvent({ ...eventLssOptions, lssStatus, isCompleted }); | |
| const lssEvent = convertLssEventDtoToGraphLssMeeting(event); | |
| const lssSummary: LssSummary = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| eventId: eventLssOptions.eventId, | |
| }; | |
| @@ -140,10 +140,10 @@ describe('LssMeeting resolver', () => { | |
| describe('isEditable field resolver', () => { | |
| const eventLssOptions = { | |
| - attorneyId: objectStringId(), | |
| - eventId: objectStringId(), | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| + eventId: Types.ObjectId().toString(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '12345', | |
| stateId: 'CO', | |
| }; | |
| @@ -160,7 +160,7 @@ describe('LssMeeting resolver', () => { | |
| const event = mockLssEvent({ ...eventLssOptions, lssStatus, isCompleted }); | |
| const lssEvent = convertLssEventDtoToGraphLssMeeting(event); | |
| const lssSummary: LssSummary = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| eventId: eventLssOptions.eventId, | |
| }; | |
| @@ -180,10 +180,10 @@ describe('LssMeeting resolver', () => { | |
| describe('lssFormLink field resolver', () => { | |
| it('should return a deep link to lss form', () => { | |
| const eventLssOptions = { | |
| - attorneyId: objectStringId(), | |
| - eventId: objectStringId(), | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| + eventId: Types.ObjectId().toString(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '12345', | |
| stateId: 'CO', | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/case-info.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/case-info.resolver.spec.ts | |
| index 37d293eb6..3714a2823 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/case-info.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/case-info.resolver.spec.ts | |
| @@ -4,7 +4,7 @@ import { EventsClientModule } from '@vinny/events-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../../administration/practice-areas.module'; | |
| import { LocationsModule } from '../../../locations/locations.module'; | |
| @@ -97,7 +97,7 @@ describe('case-info resolver', () => { | |
| describe('resolve field practiceArea', () => { | |
| const practiceArea: PracticeAreaDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| key: 'FAMILY', | |
| displayName: 'Family', | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/lss-summary.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/lss-summary.resolver.spec.ts | |
| index d14fdc138..e89128a8d 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/lss-summary.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/lss-summary.resolver.spec.ts | |
| @@ -10,7 +10,7 @@ import { County } from '@vinny/services-types'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| import { Gender } from '@vinny/users-types'; | |
| import { Request } from 'express'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { AttendeeResolver } from '../../attendee.resolver'; | |
| import { AttorneyLssResolver } from '../../attorney.lss.resolver'; | |
| @@ -110,17 +110,17 @@ describe('lss-summary resolver', () => { | |
| describe('submitLssSummary', () => { | |
| const eventLssOptions = { | |
| - attorneyId: objectStringId(), | |
| - eventId: objectStringId(), | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| + eventId: Types.ObjectId().toString(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '12345', | |
| stateId: 'CO', | |
| }; | |
| const submitLssSummaryOptions = { | |
| ...eventLssOptions, | |
| - serviceTypesIds: [objectStringId(), objectStringId()], | |
| + serviceTypesIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| lssAttorneyResponse: { | |
| attorneyAcceptedCase: true, | |
| }, | |
| @@ -186,7 +186,7 @@ describe('lss-summary resolver', () => { | |
| .get(`/administration/practice-areas/${lssEvent.data.intake.practiceAreaId}`) | |
| .reply(200, practiceArea); | |
| - const lssSummaryId = objectStringId(); | |
| + const lssSummaryId = Types.ObjectId().toString(); | |
| const submitSummary = eventsMsMock | |
| .post(`/lss-summaries`, JSON.stringify(createLssSummaryDto)) | |
| .reply(200, { ...submitLssSummaryPayload, id: lssSummaryId }); | |
| @@ -284,7 +284,7 @@ describe('lss-summary resolver', () => { | |
| await expect( | |
| resolver.submitLssSummary( | |
| - { id: objectStringId() }, | |
| + { id: Types.ObjectId().toString() }, | |
| REQUEST_MOCK, | |
| submitLssSummaryPayload, | |
| ), | |
| @@ -472,7 +472,7 @@ describe('lss-summary resolver', () => { | |
| { | |
| id: submitLssSummaryPayload.recommendedServices[1].serviceTypeId, | |
| name: 'serviceType1', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| isActive: true, | |
| }, | |
| ]; | |
| @@ -514,10 +514,10 @@ describe('lss-summary resolver', () => { | |
| describe('submitRejectedLssSummary', () => { | |
| const eventLssOptions = { | |
| - attorneyId: objectStringId(), | |
| - eventId: objectStringId(), | |
| - customerId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| + eventId: Types.ObjectId().toString(), | |
| + customerId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| fips: '12345', | |
| stateId: 'CO', | |
| }; | |
| @@ -579,7 +579,7 @@ describe('lss-summary resolver', () => { | |
| await expect( | |
| resolver.submitRejectedLssSummary( | |
| - { id: objectStringId() }, | |
| + { id: Types.ObjectId().toString() }, | |
| REQUEST_MOCK, | |
| rejectedLssSummary, | |
| ), | |
| @@ -592,8 +592,8 @@ describe('lss-summary resolver', () => { | |
| describe('submitClientFacingLssSummary', () => { | |
| describe('submit successfully', () => { | |
| - const summaryId = objectStringId(); | |
| - const eventId = objectStringId(); | |
| + const summaryId = Types.ObjectId().toString(); | |
| + const eventId = Types.ObjectId().toString(); | |
| const submitClientFacingLssSummaryInput: SubmitClientFacingLssSummaryInput = { | |
| clientFacingGoals: faker.lorem.paragraph(), | |
| clientFacingSummary: faker.lorem.paragraph(), | |
| @@ -601,7 +601,7 @@ describe('lss-summary resolver', () => { | |
| eventId, | |
| }; | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const eventMock = mockLssEvent({ attorneyId: userId }); | |
| const lssSummaryMock = mockLssSummary({ attorneyId: userId, eventId, summaryId }); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/recommended-service.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/recommended-service.resolver.spec.ts | |
| index dda3342fb..aa528e439 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/recommended-service.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss-summary/recommended-service.resolver.spec.ts | |
| @@ -4,7 +4,7 @@ import { EventsClientModule } from '@vinny/events-client'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaModule } from '../../../administration/practice-areas.module'; | |
| import { LocationsModule } from '../../../locations/locations.module'; | |
| @@ -97,10 +97,10 @@ describe('RecommendedService resolver', () => { | |
| describe('resolve field service on recommended service', () => { | |
| const serviceType: ServiceTypeDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.firstName(), | |
| description: faker.name.lastName(), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| stateIds: [], | |
| isAddendumOnly: false, | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss.utils.ts b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss.utils.ts | |
| index 37216b122..6e01cdb57 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/lss/test/lss.utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/lss/test/lss.utils.ts | |
| @@ -16,7 +16,7 @@ import { | |
| LssStatus, | |
| } from '@vinny/events-types'; | |
| import { Gender } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { IntakeData, LssSummaryInput } from '../model/lss-meeting.model'; | |
| export type WithRequiredProps<T, Key extends keyof T> = T & Required<Pick<T, Key>>; | |
| @@ -232,7 +232,7 @@ export const mockIntakeDataObjectType = (intakeOptions: IntakeDataOptions): Inta | |
| return { | |
| fips: intakeOptions.fips ?? '48261', | |
| stateId: intakeOptions.stateId ?? 'TX', | |
| - practiceAreaId: intakeOptions.practiceAreaId ?? objectStringId(), | |
| + practiceAreaId: intakeOptions.practiceAreaId ?? Types.ObjectId().toString(), | |
| opposingPartyName: { | |
| first: faker.name.firstName(), | |
| middle: faker.name.middleName(), | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/referrals/test/utils.ts b/apps/attorneys-graphql-gateway-ms/src/referrals/test/utils.ts | |
| index a9569012b..e8a45b2f8 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/referrals/test/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/referrals/test/utils.ts | |
| @@ -13,7 +13,7 @@ import { | |
| ReferralStatus, | |
| ReferralType, | |
| } from '@vinny/visitors-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| ExternalAttorneyApplication, | |
| ExternalAttorneyApplicationInput, | |
| @@ -27,7 +27,7 @@ export const ENV_VARS: Record<string, string> = { | |
| SERVICES_MS_URL: 'https://servic.es', | |
| }; | |
| -const attorneyId = objectStringId(); | |
| +const attorneyId = Types.ObjectId().toString(); | |
| export const attorneyContext: UserContext = { | |
| id: attorneyId, | |
| @@ -56,9 +56,9 @@ export const generateReferralInput = (): ReferralInput => { | |
| financialInfo: faker.lorem.sentence(), | |
| }, | |
| caseDetails: { | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| expertises: ['test'], | |
| - courtCaseId: objectStringId(), | |
| + courtCaseId: Types.ObjectId().toString(), | |
| opposingPartyName: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| @@ -104,7 +104,7 @@ export const getReferralDtoResponse = ( | |
| const now = new Date().toISOString(); | |
| return { | |
| ...referralInput, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: now, | |
| updatedAt: now, | |
| submitterUserId: attorneyId, | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/repeat-reminders/tests/consts.ts b/apps/attorneys-graphql-gateway-ms/src/repeat-reminders/tests/consts.ts | |
| index 67e229b2e..47398b263 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/repeat-reminders/tests/consts.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/repeat-reminders/tests/consts.ts | |
| @@ -1,30 +1,30 @@ | |
| import { Role } from '@vinny/auth-types'; | |
| import { ReasonType, ServiceTypeDto, StateIdDto } from '@vinny/services-types'; | |
| import { User } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const mockRepeatReminder = { | |
| reminderId: '1', | |
| - caseId: objectStringId(), | |
| - attorneyId: objectStringId(), | |
| - customerId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| + customerId: Types.ObjectId().toString(), | |
| reason: ReasonType.LIKELY_TO_REPEAT_SERVICE, | |
| - additionalServiceTypeIds: [objectStringId(), objectStringId()], | |
| + additionalServiceTypeIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }; | |
| export const mockUser: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| name: { first: 'John', last: 'Doe' }, | |
| email: '[email protected]', | |
| roles: [Role.CUSTOMER], | |
| }; | |
| export const mockServiceType: ServiceTypeDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'Test Service', | |
| description: 'Test Description', | |
| - practiceAreaId: objectStringId(), | |
| - stateIds: [{ id: objectStringId() } as StateIdDto], | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + stateIds: [{ id: Types.ObjectId().toString() } as StateIdDto], | |
| isAddendumOnly: false, | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/repeat-reminders/tests/repeat-reminders.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/repeat-reminders/tests/repeat-reminders.resolver.spec.ts | |
| index bc7769bcd..1273bf801 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/repeat-reminders/tests/repeat-reminders.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/repeat-reminders/tests/repeat-reminders.resolver.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { TestingModule } from '@nestjs/testing'; | |
| import { RepeatRemindersResolver } from '../repeat-reminders.resolver'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { RepeatRemindersModule } from '../repeat-reminders.module'; | |
| import nock from 'nock'; | |
| import { mockRepeatReminder } from './consts'; | |
| @@ -46,7 +46,7 @@ describe('RepeatRemindersResolver', () => { | |
| it('should return repeat reminders when filter is provided', async () => { | |
| const filter = { | |
| attorneyId: mockRepeatReminder.attorneyId, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| }; | |
| const mockReminders = [mockRepeatReminder]; | |
| servicesMsNock.get('/repeat-reminders').query(filter).reply(200, mockReminders); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/repeats/test/utils.ts b/apps/attorneys-graphql-gateway-ms/src/repeats/test/utils.ts | |
| index b7c542b70..dbebe5647 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/repeats/test/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/repeats/test/utils.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| import { RepeatData } from '@vinny/services-types'; | |
| import { RejectionReason, RepeatInput } from '../models/repeat.model'; | |
| @@ -6,11 +6,11 @@ import { Role, UserContext } from '@vinny/auth-types'; | |
| import { LssCriticalDateType } from '@vinny/events-types'; | |
| const time = new Date(); | |
| -const repeatId = objectStringId(); | |
| -const caseId = objectStringId(); | |
| -const serviceId = objectStringId(); | |
| -const serviceTypeId = objectStringId(); | |
| -const attorneyId = objectStringId(); | |
| +const repeatId = Types.ObjectId().toString(); | |
| +const caseId = Types.ObjectId().toString(); | |
| +const serviceId = Types.ObjectId().toString(); | |
| +const serviceTypeId = Types.ObjectId().toString(); | |
| +const attorneyId = Types.ObjectId().toString(); | |
| export const submittedBy: UserContext = { | |
| id: attorneyId, | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/consts.ts b/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/consts.ts | |
| index d7980cd21..4bb438743 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/consts.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/consts.ts | |
| @@ -5,24 +5,24 @@ import { | |
| ServiceStatus, | |
| ServiceWithdrawalInitiator, | |
| } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| export const attorneyPartialServiceClosureInput1 = { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| isWithdrawalBundle: true, | |
| withdrawalInitiator: ServiceWithdrawalInitiator.ATTORNEY, | |
| status: ServiceClosureStatus.PENDING_WITHDRAWAL, | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 75, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| additionalInformation: faker.lorem.sentence(2), | |
| @@ -37,13 +37,13 @@ export const attorneyPartialServiceClosureInput1 = { | |
| }; | |
| export const attorneyPartialServiceClosureInput2 = { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 75, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| noticeOfWithdrawal: NoticeOfWithdrawal.YES, | |
| @@ -69,8 +69,8 @@ export const serviceClosureInput2 = { | |
| }; | |
| export const attorneyServiceClosureInput1 = { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| noticeOfWithdrawal: NoticeOfWithdrawal.NOT_RELEVANT, | |
| withdrawalInitiator: ServiceWithdrawalInitiator.CLIENT, | |
| attorneyCaseReview: { | |
| @@ -81,17 +81,17 @@ export const attorneyServiceClosureInput1 = { | |
| }, | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 75, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| additionalInformation: faker.lorem.sentence(2), | |
| }; | |
| export const attorneyServiceClosureInput2 = { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| noticeOfWithdrawal: NoticeOfWithdrawal.NO, | |
| attorneyCaseReview: { | |
| meetClientGoals: faker.lorem.sentence(2), | |
| @@ -100,9 +100,9 @@ export const attorneyServiceClosureInput2 = { | |
| }, | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| additionalInformation: faker.lorem.sentence(2), | |
| @@ -111,37 +111,37 @@ export const attorneyServiceClosureInput2 = { | |
| }; | |
| export const attorneyServiceClosuresSubmissionList = [ | |
| - { serviceClosure: attorneyServiceClosureInput1, serviceTypeId: objectStringId() }, | |
| - { serviceClosure: attorneyServiceClosureInput2, serviceTypeId: objectStringId() }, | |
| + { serviceClosure: attorneyServiceClosureInput1, serviceTypeId: Types.ObjectId().toString() }, | |
| + { serviceClosure: attorneyServiceClosureInput2, serviceTypeId: Types.ObjectId().toString() }, | |
| ]; | |
| export const paralegalServiceClosureInput1 = { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 75, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| }; | |
| export const paralegalServiceClosureInput2 = { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 75, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| }; | |
| export const paralegalServiceClosureSubmissionList = [ | |
| - { serviceClosure: paralegalServiceClosureInput1, serviceTypeId: objectStringId() }, | |
| - { serviceClosure: paralegalServiceClosureInput2, serviceTypeId: objectStringId() }, | |
| + { serviceClosure: paralegalServiceClosureInput1, serviceTypeId: Types.ObjectId().toString() }, | |
| + { serviceClosure: paralegalServiceClosureInput2, serviceTypeId: Types.ObjectId().toString() }, | |
| ]; | |
| export const serviceClosureDto1 = { ...attorneyPartialServiceClosureInput1 }; | |
| @@ -172,45 +172,45 @@ export const serviceClosureDto8 = { | |
| percentCompleted: 75, | |
| }; | |
| -export const documentId1 = objectStringId(); | |
| -export const documentId2 = objectStringId(); | |
| -export const documentId3 = objectStringId(); | |
| +export const documentId1 = Types.ObjectId().toString(); | |
| +export const documentId2 = Types.ObjectId().toString(); | |
| +export const documentId3 = Types.ObjectId().toString(); | |
| export const document1 = { | |
| id: documentId1, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| fileName: faker.datatype.string(), | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }; | |
| export const document2 = { | |
| id: documentId2, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| fileName: faker.datatype.string(), | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }; | |
| export const document3 = { | |
| id: documentId3, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| fileName: faker.datatype.string(), | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }; | |
| export const milestoneProgressItem1 = { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 75, | |
| documentIds: [documentId1, documentId2], | |
| }; | |
| export const milestoneProgressItem2 = { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 100, | |
| documentIds: [documentId2, documentId3], | |
| }; | |
| export const mockCatalogServiceType = { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| serviceTypeName: 'test service type', | |
| versionId: faker.datatype.number(), | |
| elements: { | |
| @@ -226,43 +226,43 @@ export const mockCatalogServiceType = { | |
| legalDescription: 'test', | |
| }, | |
| firm: 'Marble', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| isAddendumProduct: faker.datatype.boolean(), | |
| category: 'test category', | |
| isRequiresAdditionalExpenseForClient: faker.datatype.boolean(), | |
| }, | |
| - serviceCode: objectStringId(), | |
| + serviceCode: Types.ObjectId().toString(), | |
| metadata: { | |
| status: 'ACTIVE', | |
| - createdById: objectStringId(), | |
| + createdById: Types.ObjectId().toString(), | |
| }, | |
| stateInfo: {}, | |
| serviceMilestonesList: [ | |
| - { serviceMilestoneId: objectStringId(), portion: 50, isProofRequired: false }, | |
| - { serviceMilestoneId: objectStringId(), portion: 15, isProofRequired: false }, | |
| - { serviceMilestoneId: objectStringId(), portion: 35, isProofRequired: true }, | |
| + { serviceMilestoneId: Types.ObjectId().toString(), portion: 50, isProofRequired: false }, | |
| + { serviceMilestoneId: Types.ObjectId().toString(), portion: 15, isProofRequired: false }, | |
| + { serviceMilestoneId: Types.ObjectId().toString(), portion: 35, isProofRequired: true }, | |
| ], | |
| }; | |
| -export const attorneyId1 = objectStringId(); | |
| -export const attorneyId2 = objectStringId(); | |
| +export const attorneyId1 = Types.ObjectId().toString(); | |
| +export const attorneyId2 = Types.ObjectId().toString(); | |
| export const generateServiceDto = (serviceId: string, attorneyId: string) => { | |
| return { | |
| id: serviceId, | |
| name: faker.name.findName(), | |
| description: faker.lorem.sentence(), | |
| - caseId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| location: { | |
| state: 'California', | |
| county: 'Fresno', | |
| }, | |
| - practiceAreaId: objectStringId(), | |
| - userId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| { userId: attorneyId, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/service-closures.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/service-closures.resolver.spec.ts | |
| index b8752c01c..4144bdfe3 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/service-closures.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/service-closures.resolver.spec.ts | |
| @@ -41,7 +41,7 @@ import { | |
| } from '@vinny/catalog-client'; | |
| import { CaseValidationService } from '../../../shared/validation/case-validation.service'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ValidationModule } from '../../../shared/validation/validation.module'; | |
| const ENV_VARS: Record<string, string> = { | |
| @@ -130,7 +130,7 @@ describe('Service closures resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user is not assigned to some services', async () => { | |
| - const otherAttorneyId = objectStringId(); | |
| + const otherAttorneyId = Types.ObjectId().toString(); | |
| const getServicesNock = servicesMsNock | |
| .get( | |
| `/services/list?ids[]=${attorneyPartialServiceClosureInput1.serviceId}&ids[]=${attorneyPartialServiceClosureInput2.serviceId}`, | |
| @@ -160,16 +160,16 @@ describe('Service closures resolver', () => { | |
| describe('submitPartialServiceClosuresByParalegal', () => { | |
| it('should send partial service closures successfully', async () => { | |
| - const paralegalId = objectStringId(); | |
| + const paralegalId = Types.ObjectId().toString(); | |
| const paralegalServiceClosureInput = [ | |
| { | |
| serviceId: serviceClosureInput1.serviceId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| milestonesProgressList: serviceClosureInput1.milestonesProgressList, | |
| }, | |
| { | |
| serviceId: serviceClosureInput2.serviceId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| milestonesProgressList: serviceClosureInput2.milestonesProgressList, | |
| }, | |
| ]; | |
| @@ -219,7 +219,7 @@ describe('Service closures resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user is not assigned to some services', async () => { | |
| - const otherAttorneyId = objectStringId(); | |
| + const otherAttorneyId = Types.ObjectId().toString(); | |
| const getServicesNock = servicesMsNock | |
| .get( | |
| `/services/list?ids[]=${attorneyServiceClosureInput1.serviceId}&ids[]=${attorneyServiceClosureInput2.serviceId}`, | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/service-closures.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/service-closures.schema.spec.ts | |
| index a2bb0ce03..0fcd3c30e 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/service-closures.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/services/service-closures/test/service-closures.schema.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| const submitPartialServiceClosuresByAttorneyValidSchema = `mutation Mutation($serviceClosures: [AttorneyPartialServiceClosureInput!]!) { | |
| @@ -411,21 +411,21 @@ describe('Service closures schema', () => { | |
| tester.test(true, submitPartialServiceClosuresByAttorneyValidSchema, { | |
| serviceClosures: [ | |
| { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| additionalInformation: 'some info', | |
| withdrawalInitiator: 'CLIENT', | |
| noticeOfWithdrawal: 'YES', | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 0, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| }, | |
| { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: 'PENDING_WITHDRAWAL', | |
| isWithdrawalBundle: true, | |
| additionalInformation: 'some info', | |
| @@ -433,8 +433,8 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 60, | |
| - serviceMilestoneId: objectStringId(), | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| attorneyCaseReview: { | |
| @@ -460,7 +460,7 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 0, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| noticeOfWithdrawal: 'YES', | |
| @@ -473,15 +473,15 @@ describe('Service closures schema', () => { | |
| tester.test(false, submitPartialServiceClosuresByAttorneyValidSchema, { | |
| serviceClosures: [ | |
| { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: 'PENDING_WITHDRAWAL', | |
| isWithdrawalBundle: true, | |
| additionalInformation: 'some info', | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 24.5, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| noticeOfWithdrawal: 'YES', | |
| @@ -494,7 +494,7 @@ describe('Service closures schema', () => { | |
| tester.test(false, submitPartialServiceClosuresByAttorneyValidSchema, { | |
| serviceClosures: [ | |
| { | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| additionalInformation: 'some info', | |
| noticeOfWithdrawal: 'YES', | |
| }, | |
| @@ -508,27 +508,27 @@ describe('Service closures schema', () => { | |
| tester.test(true, submitPartialServiceClosuresByParalegalValidSchema, { | |
| serviceClosures: [ | |
| { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 100, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| }, | |
| { | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 60, | |
| - serviceMilestoneId: objectStringId(), | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| milestonePercentCompleted: 60, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| }, | |
| @@ -543,7 +543,7 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 100, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| }, | |
| @@ -557,7 +557,7 @@ describe('Service closures schema', () => { | |
| tester.test(true, submitServiceClosuresByAttorneyValidSchema, { | |
| input: [ | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| serviceClosure: { | |
| withdrawalInitiator: 'CLIENT', | |
| attorneyCaseReview: { | |
| @@ -570,21 +570,21 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| { | |
| milestonePercentCompleted: 20, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| noticeOfWithdrawal: 'YES', | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: 'PENDING_WITHDRAWAL', | |
| }, | |
| }, | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| serviceClosure: { | |
| additionalInformation: 'ss', | |
| attorneyCaseReview: { | |
| @@ -596,13 +596,13 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| noticeOfWithdrawal: 'YES', | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: 'PENDING_WITHDRAWAL', | |
| }, | |
| }, | |
| @@ -624,11 +624,11 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| noticeOfWithdrawal: 'YES', | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }, | |
| }, | |
| ], | |
| @@ -639,7 +639,7 @@ describe('Service closures schema', () => { | |
| tester.test(false, submitServiceClosuresByAttorneyValidSchema, { | |
| input: [ | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| serviceClosure: { | |
| attorneyCaseReview: { | |
| meetClientGoals: 'meet', | |
| @@ -648,11 +648,11 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| noticeOfWithdrawal: 'YES', | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }, | |
| }, | |
| ], | |
| @@ -663,7 +663,7 @@ describe('Service closures schema', () => { | |
| tester.test(false, submitServiceClosuresByAttorneyValidSchema, { | |
| input: [ | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| serviceClosure: { | |
| attorneyCaseReview: { | |
| meetClientGoals: 'meet', | |
| @@ -673,7 +673,7 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| noticeOfWithdrawal: 'YES', | |
| @@ -687,16 +687,16 @@ describe('Service closures schema', () => { | |
| tester.test(false, submitServiceClosuresByAttorneyValidSchema, { | |
| input: [ | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| serviceClosure: { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| noticeOfWithdrawal: 'YES', | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }, | |
| }, | |
| ], | |
| @@ -709,34 +709,34 @@ describe('Service closures schema', () => { | |
| tester.test(true, submitServiceClosuresByParalegalValidSchema, { | |
| input: [ | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| serviceClosure: { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| { | |
| milestonePercentCompleted: 20, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| }, | |
| }, | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| serviceClosure: { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ], | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| }, | |
| }, | |
| ], | |
| @@ -751,14 +751,14 @@ describe('Service closures schema', () => { | |
| milestonesProgressList: [ | |
| { | |
| milestonePercentCompleted: 70, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| { | |
| milestonePercentCompleted: 20, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }, | |
| }, | |
| ], | |
| @@ -769,7 +769,7 @@ describe('Service closures schema', () => { | |
| describe('deleteServiceClosureValidSchema', () => { | |
| it('Should pass when deleteServiceClosure schema and input are valid', () => { | |
| tester.test(true, deleteServiceClosureValidSchema, { | |
| - servicesIds: [objectStringId()], | |
| + servicesIds: [Types.ObjectId().toString()], | |
| }); | |
| }); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/services/service-types/tests/consts.ts b/apps/attorneys-graphql-gateway-ms/src/services/service-types/tests/consts.ts | |
| index 0373d1a7e..d41ef9efb 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/services/service-types/tests/consts.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/services/service-types/tests/consts.ts | |
| @@ -1,6 +1,6 @@ | |
| import faker from '@faker-js/faker'; | |
| import { ServiceTypeDto } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const getActiveServiceTypesInvalidIdsField = `query GetActiveServiceTypes() { | |
| getActiveServiceTypes() { | |
| @@ -65,9 +65,9 @@ export const getActiveServiceTypesWithFilter = `query ServiceTypes($filter: Serv | |
| }`; | |
| export function buildMockServiceType(code?: string): ServiceTypeDto { | |
| - const id = objectStringId(); | |
| + const id = Types.ObjectId().toString(); | |
| const name = faker.datatype.string(); | |
| - const practiceAreaId = objectStringId(); | |
| + const practiceAreaId = Types.ObjectId().toString(); | |
| const generatedCode = code ?? faker.datatype.string(); | |
| const stateIds = [{ id: 'TX' }, { id: 'CA' }]; | |
| const isActive = true; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/shared/services/test/service-types.loader.spec.ts b/apps/attorneys-graphql-gateway-ms/src/shared/services/test/service-types.loader.spec.ts | |
| index ce5fd02ad..fdb9561de 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/shared/services/test/service-types.loader.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/shared/services/test/service-types.loader.spec.ts | |
| @@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import nock from 'nock'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { faker } from '@faker-js/faker'; | |
| import DataLoader from 'dataloader'; | |
| import { ServiceCatalogClientModule, ServiceCatalogClientService } from '@vinny/catalog-client'; | |
| @@ -56,7 +56,7 @@ describe('ServiceTypesLoaderService', () => { | |
| describe('batchGetServiceTypesByIds', () => { | |
| it('should get services type by batch', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const mockServiceType: ServiceType[] = [ | |
| { | |
| serviceTypeId: serviceTypeId, | |
| @@ -75,15 +75,15 @@ describe('ServiceTypesLoaderService', () => { | |
| legalDescription: 'test', | |
| }, | |
| firm: 'Marble', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| isAddendumProduct: faker.datatype.boolean(), | |
| category: 'test category', | |
| isRequiresAdditionalExpenseForClient: faker.datatype.boolean(), | |
| }, | |
| - serviceCode: objectStringId(), | |
| + serviceCode: Types.ObjectId().toString(), | |
| metadata: { | |
| status: 'ACTIVE', | |
| - createdById: objectStringId(), | |
| + createdById: Types.ObjectId().toString(), | |
| }, | |
| stateInfo: {}, | |
| requiredServiceTypes: { | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/shared/services/test/services.loader.spec.ts b/apps/attorneys-graphql-gateway-ms/src/shared/services/test/services.loader.spec.ts | |
| index e2c298cba..ec300a7dd 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/shared/services/test/services.loader.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/shared/services/test/services.loader.spec.ts | |
| @@ -4,7 +4,7 @@ import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import nock from 'nock'; | |
| import { ServicesClientModule, ServicesClientService } from '@vinny/services-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { faker } from '@faker-js/faker'; | |
| import { ServiceStatus } from '@vinny/services-types'; | |
| import DataLoader from 'dataloader'; | |
| @@ -53,17 +53,17 @@ describe('ServicesLoader', () => { | |
| describe('batchGetServicesByIds', () => { | |
| it('should get services by batch', async () => { | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId().toString(); | |
| const mockService: AttorneyService = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| name: faker.name.firstName(), | |
| - serviceTypeId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [], | |
| status: ServiceStatus.OPEN, | |
| id: serviceId, | |
| location: { | |
| - state: objectStringId(), | |
| + state: Types.ObjectId().toString(), | |
| }, | |
| }; | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/shared/validation/tests/case-validation.service.spec.ts b/apps/attorneys-graphql-gateway-ms/src/shared/validation/tests/case-validation.service.spec.ts | |
| index 884d6c5a4..065e98395 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/shared/validation/tests/case-validation.service.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/shared/validation/tests/case-validation.service.spec.ts | |
| @@ -6,7 +6,7 @@ import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { ServicesClientModule } from '@vinny/services-client'; | |
| import { LegalTeamMemberRole } from '@vinny/services-types'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { CaseValidationService } from '../case-validation.service'; | |
| import { serviceOne, serviceTwo } from '../../../attorneys/tests/utils'; | |
| @@ -22,11 +22,11 @@ const usersMsNock = nock(ENV_VARS.USERS_MS_URL); | |
| const servicesMsNock = nock(ENV_VARS.SERVICES_MS_URL); | |
| describe('CaseValidationService', () => { | |
| - const caseId = objectStringId(); | |
| - const firstAttorneyId = objectStringId(); | |
| - const firstParalegalId = objectStringId(); | |
| - const secondAttorneyId = objectStringId(); | |
| - const secondParalegalId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| + const firstAttorneyId = Types.ObjectId().toString(); | |
| + const firstParalegalId = Types.ObjectId().toString(); | |
| + const secondAttorneyId = Types.ObjectId().toString(); | |
| + const secondParalegalId = Types.ObjectId().toString(); | |
| const firstService = { | |
| ...serviceOne, | |
| @@ -125,7 +125,7 @@ describe('CaseValidationService', () => { | |
| }); | |
| it('should pass when user is on the same team of attorney', async () => { | |
| - const randomUserId = objectStringId(); | |
| + const randomUserId = Types.ObjectId().toString(); | |
| const caseServicesNock = servicesMsNock | |
| .get(`/services/list/metadata`) | |
| .query({ caseId }) | |
| @@ -150,7 +150,7 @@ describe('CaseValidationService', () => { | |
| }); | |
| it('should throw unauthorized exception when user is not part of the legal teams of the attorneys on the case', async () => { | |
| - const randomUserId = objectStringId(); | |
| + const randomUserId = Types.ObjectId().toString(); | |
| const caseServicesNock = servicesMsNock | |
| .get(`/services/list/metadata`) | |
| .query({ caseId }) | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/tasks-lawmatics/tests/utils.ts b/apps/attorneys-graphql-gateway-ms/src/tasks-lawmatics/tests/utils.ts | |
| index beb939e3b..d02857068 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/tasks-lawmatics/tests/utils.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/tasks-lawmatics/tests/utils.ts | |
| @@ -1,18 +1,18 @@ | |
| import { CreateTaskDto, TaskDto } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const mockCreateTaskReq: CreateTaskDto = { | |
| - createdByUserId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + createdByUserId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| description: 'test', | |
| dueDate: new Date(), | |
| taskName: 'test', | |
| - assignTo: [objectStringId()], | |
| - tagIds: [objectStringId()], | |
| + assignTo: [Types.ObjectId().toString()], | |
| + tagIds: [Types.ObjectId().toString()], | |
| }; | |
| export const mockCreatedTaskRes: TaskDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| ...mockCreateTaskReq, | |
| lawmaticsTaskId: '123', | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/tasks/tests/tasks-forms.resolver.spec.ts b/apps/attorneys-graphql-gateway-ms/src/tasks/tests/tasks-forms.resolver.spec.ts | |
| index cdbf914c2..6d912104c 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/tasks/tests/tasks-forms.resolver.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/tasks/tests/tasks-forms.resolver.spec.ts | |
| @@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import nock from 'nock'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { TasksFormsResolver } from '../tasks-forms.resolver'; | |
| import { TasksModule } from '../tasks.module'; | |
| import { | |
| @@ -50,7 +50,7 @@ describe('TasksFormsResolver', () => { | |
| describe('getCallClientFormData', () => { | |
| it('should get call client form for task', async () => { | |
| - const taskId = objectStringId(); | |
| + const taskId = Types.ObjectId().toString(); | |
| const callClientForm: CallClientFormBase = { | |
| summary: 'test summary', | |
| date: new Date(), | |
| @@ -69,7 +69,7 @@ describe('TasksFormsResolver', () => { | |
| }); | |
| it('should return null for call client form not exist', async () => { | |
| - const taskId = objectStringId(); | |
| + const taskId = Types.ObjectId().toString(); | |
| servicesMsNock.get(`/attorney-notes/intro-call/${taskId}`).reply(404); | |
| @@ -82,7 +82,7 @@ describe('TasksFormsResolver', () => { | |
| describe('getServiceClosureForm', () => { | |
| it('should get service closure form for task', async () => { | |
| - const taskId = objectStringId(); | |
| + const taskId = Types.ObjectId().toString(); | |
| const serviceClosureForm: ServiceClosureFormBase = { | |
| serviceRecommendations: ServiceRecommendationsOptions.NO, | |
| serviceOutcome: 'test outcome', | |
| @@ -102,7 +102,7 @@ describe('TasksFormsResolver', () => { | |
| }); | |
| it('should return null for service closure form not exist', async () => { | |
| - const taskId = objectStringId(); | |
| + const taskId = Types.ObjectId().toString(); | |
| servicesMsNock.get(`/attorney-notes/service-closure/${taskId}`).reply(404); | |
| @@ -115,7 +115,7 @@ describe('TasksFormsResolver', () => { | |
| describe('updateTaskForms', () => { | |
| it('should update call client form', async () => { | |
| - const taskId = objectStringId(); | |
| + const taskId = Types.ObjectId().toString(); | |
| const callClientForm: CallClientFormBase = { | |
| summary: 'test summary', | |
| date: new Date(), | |
| @@ -138,7 +138,7 @@ describe('TasksFormsResolver', () => { | |
| }); | |
| it('should update call client form', async () => { | |
| - const taskId = objectStringId(); | |
| + const taskId = Types.ObjectId().toString(); | |
| const serviceClosureForm: ServiceClosureFormBase = { | |
| serviceRecommendations: ServiceRecommendationsOptions.NO, | |
| serviceOutcome: 'test outcome', | |
| @@ -162,7 +162,7 @@ describe('TasksFormsResolver', () => { | |
| }); | |
| it('should throw error when trying to update two forms', async () => { | |
| - const taskId = objectStringId(); | |
| + const taskId = Types.ObjectId().toString(); | |
| const callClientForm: CallClientFormBase = { | |
| summary: 'test summary', | |
| date: new Date(), | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/tests/case-task.mapper.spec.ts b/apps/attorneys-graphql-gateway-ms/src/tests/case-task.mapper.spec.ts | |
| index c19a4d3cf..1b1720b3d 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/tests/case-task.mapper.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/tests/case-task.mapper.spec.ts | |
| @@ -8,7 +8,7 @@ import { | |
| } from '@vinny/flare-engine-types'; | |
| import { convertToCaseTask } from '../tasks/case-task.mapper'; | |
| import { CaseTask } from '../tasks/model/tasks.model'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| describe('convertToCaseTask', () => { | |
| it('should convert a FlareEngineTaskDto to a CaseTask', () => { | |
| @@ -21,7 +21,7 @@ describe('convertToCaseTask', () => { | |
| serviceId: 'serviceId', | |
| lastUpdated: new Date('2023-07-12T14:37:13.238916Z'), | |
| dueDate: new Date('2023-07-13T14:37:13.238916Z'), | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| }; | |
| const result = convertToCaseTask(flareEngineTask); | |
| diff --git a/apps/attorneys-graphql-gateway-ms/src/user-freeze/test/user-freeze.schema.spec.ts b/apps/attorneys-graphql-gateway-ms/src/user-freeze/test/user-freeze.schema.spec.ts | |
| index fc7c41324..872d50fbf 100644 | |
| --- a/apps/attorneys-graphql-gateway-ms/src/user-freeze/test/user-freeze.schema.spec.ts | |
| +++ b/apps/attorneys-graphql-gateway-ms/src/user-freeze/test/user-freeze.schema.spec.ts | |
| @@ -2,7 +2,7 @@ import 'reflect-metadata'; | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| import * as path from 'path'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| const UserFields = ` | |
| @@ -48,7 +48,7 @@ describe('User Freeze Schema', () => { | |
| }`; | |
| tester.test(true, mutation, { | |
| - customerId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| it(`Should not pass if customerId isn't passed`, () => { | |
| @@ -71,7 +71,7 @@ describe('User Freeze Schema', () => { | |
| }`; | |
| tester.test(true, mutation, { | |
| - customerId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| reason: faker.lorem.words(), | |
| }); | |
| }); | |
| diff --git a/apps/auth-ms/src/auth/test/utils.ts b/apps/auth-ms/src/auth/test/utils.ts | |
| index ae1b93246..771ce770f 100644 | |
| --- a/apps/auth-ms/src/auth/test/utils.ts | |
| +++ b/apps/auth-ms/src/auth/test/utils.ts | |
| @@ -1,17 +1,17 @@ | |
| import { faker } from '@faker-js/faker'; | |
| import { RedisService } from '@marbletech/redis'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const mockUser = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| type: 'customer', | |
| }; | |
| export const wrongMockUser = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| name: 'customer name', | |
| type: 'customer', | |
| }; | |
| diff --git a/apps/background-ms/src/attorneys/tests/utils.ts b/apps/background-ms/src/attorneys/tests/utils.ts | |
| index aff3f44d2..cf8e3a5c6 100644 | |
| --- a/apps/background-ms/src/attorneys/tests/utils.ts | |
| +++ b/apps/background-ms/src/attorneys/tests/utils.ts | |
| @@ -1,27 +1,27 @@ | |
| import { ServiceDraftsDto, ServiceDraftsStatus } from '@vinny/data-requests-types'; | |
| import { LegalTeamMemberRole } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| import { BrazeDestinationType, BrazeNotification } from '@vinny/communications-client'; | |
| -export const caseId1 = objectStringId(); | |
| -export const caseId2 = objectStringId(); | |
| -export const caseId3 = objectStringId(); | |
| -export const userId1 = objectStringId(); | |
| -export const userId2 = objectStringId(); | |
| -export const userId3 = objectStringId(); | |
| -export const serviceId1 = objectStringId(); | |
| -export const serviceId2 = objectStringId(); | |
| -export const serviceId3 = objectStringId(); | |
| -export const serviceId4 = objectStringId(); | |
| -export const serviceId5 = objectStringId(); | |
| -export const attorneyId1 = objectStringId(); | |
| -export const attorneyId2 = objectStringId(); | |
| -export const attorneyMarbleId1 = objectStringId(); | |
| -export const attorneyMarbleId2 = objectStringId(); | |
| +export const caseId1 = Types.ObjectId().toString(); | |
| +export const caseId2 = Types.ObjectId().toString(); | |
| +export const caseId3 = Types.ObjectId().toString(); | |
| +export const userId1 = Types.ObjectId().toString(); | |
| +export const userId2 = Types.ObjectId().toString(); | |
| +export const userId3 = Types.ObjectId().toString(); | |
| +export const serviceId1 = Types.ObjectId().toString(); | |
| +export const serviceId2 = Types.ObjectId().toString(); | |
| +export const serviceId3 = Types.ObjectId().toString(); | |
| +export const serviceId4 = Types.ObjectId().toString(); | |
| +export const serviceId5 = Types.ObjectId().toString(); | |
| +export const attorneyId1 = Types.ObjectId().toString(); | |
| +export const attorneyId2 = Types.ObjectId().toString(); | |
| +export const attorneyMarbleId1 = Types.ObjectId().toString(); | |
| +export const attorneyMarbleId2 = Types.ObjectId().toString(); | |
| const createServiceDraftsDto = (userId: string, caseId: string, serviceId: string) => ({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId, | |
| caseId, | |
| serviceId, | |
| diff --git a/apps/background-ms/src/users/tests/utils.ts b/apps/background-ms/src/users/tests/utils.ts | |
| index 2bb9115eb..dcb41831e 100644 | |
| --- a/apps/background-ms/src/users/tests/utils.ts | |
| +++ b/apps/background-ms/src/users/tests/utils.ts | |
| @@ -1,13 +1,13 @@ | |
| import { CaseSubStatus, ServiceStatus } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| -export const cusotmerId1 = objectStringId(); | |
| -export const cusotmerId2 = objectStringId(); | |
| -export const cusotmerId3 = objectStringId(); | |
| -export const cusotmerId4 = objectStringId(); | |
| -export const cusotmerId5 = objectStringId(); | |
| -export const cusotmerId6 = objectStringId(); | |
| -export const cusotmerId7 = objectStringId(); | |
| +export const cusotmerId1 = Types.ObjectId().toString(); | |
| +export const cusotmerId2 = Types.ObjectId().toString(); | |
| +export const cusotmerId3 = Types.ObjectId().toString(); | |
| +export const cusotmerId4 = Types.ObjectId().toString(); | |
| +export const cusotmerId5 = Types.ObjectId().toString(); | |
| +export const cusotmerId6 = Types.ObjectId().toString(); | |
| +export const cusotmerId7 = Types.ObjectId().toString(); | |
| export const generateCustomer = ( | |
| id: string, | |
| @@ -44,43 +44,43 @@ export const listCustomersResponse = { | |
| }; | |
| export const completedCase = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.COMPLETED, | |
| }; | |
| export const case1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.OPEN, | |
| }; | |
| export const case2 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.OPEN, | |
| }; | |
| export const case3 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.OPEN, | |
| }; | |
| export const case4 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.OPEN, | |
| }; | |
| export const case5 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.OPEN, | |
| }; | |
| export const case6 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.OPEN, | |
| }; | |
| diff --git a/apps/business-flow-manager-ms/src/activity-logs/test/activity-logs.controller.spec.ts b/apps/business-flow-manager-ms/src/activity-logs/test/activity-logs.controller.spec.ts | |
| index b59885f94..f05704070 100644 | |
| --- a/apps/business-flow-manager-ms/src/activity-logs/test/activity-logs.controller.spec.ts | |
| +++ b/apps/business-flow-manager-ms/src/activity-logs/test/activity-logs.controller.spec.ts | |
| @@ -4,12 +4,12 @@ import nock from 'nock'; | |
| import { INestApplication, ValidationPipe } from '@nestjs/common'; | |
| import '@vinny/test-utils'; | |
| import { ActivityLogModule } from '../activity-logs.module'; | |
| +import { Types } from 'mongoose'; | |
| import { KafkaProducerService, KafkaTopics } from '@vinny/kafka-client'; | |
| import { ActivityLogType } from '@vinny/activity-logs-types'; | |
| import { importCommons } from '@vinny/test-utils'; | |
| import { ActivityLogService } from '../activity-logs.service'; | |
| import { IDEMPOTENCY_KEY_HEADER } from '@vinny/idempotency'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Activity log controller', () => { | |
| let module: TestingModule, | |
| @@ -52,9 +52,9 @@ describe('Activity log controller', () => { | |
| describe('POST /activity-logs/documents-request', () => { | |
| it('should publish activity log event of type documents request and ignore requests with identical idempotencyKey', async () => { | |
| const functionSpy = jest.spyOn(activityLogService, 'createActivityLogForDocumentsRequest'); | |
| - const caseId = objectStringId(); | |
| - const attorneyId = objectStringId(); | |
| - const documentTypeIds = [objectStringId(), objectStringId()]; | |
| + const caseId = Types.ObjectId().toString(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const documentTypeIds = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| await request(app.getHttpServer()) | |
| .post(`/activity-logs/documents-request`) | |
| .set(IDEMPOTENCY_KEY_HEADER, 'idempotencyKey') | |
| diff --git a/apps/business-flow-manager-ms/src/case-delivery-start-flow/test/consts.ts b/apps/business-flow-manager-ms/src/case-delivery-start-flow/test/consts.ts | |
| index 0087d3f9a..8238206fd 100644 | |
| --- a/apps/business-flow-manager-ms/src/case-delivery-start-flow/test/consts.ts | |
| +++ b/apps/business-flow-manager-ms/src/case-delivery-start-flow/test/consts.ts | |
| @@ -1,14 +1,14 @@ | |
| import faker from '@faker-js/faker'; | |
| import { LegalTeamMemberRole, ServiceStatus } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { CaseDeliveryStartedEventData } from '@vinny/business-flow-manager-types'; | |
| import { KafkaEventDto, KafkaEventType } from '@vinny/kafka-client'; | |
| import { USER_ID } from '../../test-utils/mock'; | |
| -export const caseId = objectStringId(); | |
| +export const caseId = Types.ObjectId().toString(); | |
| -export const paralegalId = objectStringId(); | |
| -export const attorneyId = objectStringId(); | |
| +export const paralegalId = Types.ObjectId().toString(); | |
| +export const attorneyId = Types.ObjectId().toString(); | |
| export const mockAttorney = { | |
| id: attorneyId, | |
| @@ -32,13 +32,13 @@ export const legalTeam = [ | |
| ]; | |
| export const serviceDtoMock = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| caseId, | |
| legalTeam, | |
| userId: USER_ID, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| location: { | |
| state: 'TEXAS', | |
| }, | |
| @@ -68,7 +68,7 @@ export const mockKafkaCaseDeliveryStartedEventData: KafkaEventDto<CaseDeliverySt | |
| caseId, | |
| legalTeam, | |
| }, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| type: KafkaEventType.REQUEST, | |
| time: faker.datatype.string(), | |
| }, | |
| diff --git a/apps/business-flow-manager-ms/src/data-requests/test/utils.ts b/apps/business-flow-manager-ms/src/data-requests/test/utils.ts | |
| index d592b881b..ea8b59074 100644 | |
| --- a/apps/business-flow-manager-ms/src/data-requests/test/utils.ts | |
| +++ b/apps/business-flow-manager-ms/src/data-requests/test/utils.ts | |
| @@ -2,15 +2,15 @@ import faker from '@faker-js/faker'; | |
| import { DataRequestStatus } from '@vinny/data-requests-types'; | |
| import { KafkaEventDto, KafkaEventType } from '@vinny/kafka-client'; | |
| import { ServiceDto, ServiceStatus } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| -export const serviceTypeId = objectStringId(); | |
| -export const serviceId = objectStringId(); | |
| -export const userId = objectStringId(); | |
| -export const caseId = objectStringId(); | |
| -export const dataRequestId1 = objectStringId(); | |
| -export const dataRequestId2 = objectStringId(); | |
| -export const dataRequestId3 = objectStringId(); | |
| +export const serviceTypeId = Types.ObjectId().toString(); | |
| +export const serviceId = Types.ObjectId().toString(); | |
| +export const userId = Types.ObjectId().toString(); | |
| +export const caseId = Types.ObjectId().toString(); | |
| +export const dataRequestId1 = Types.ObjectId().toString(); | |
| +export const dataRequestId2 = Types.ObjectId().toString(); | |
| +export const dataRequestId3 = Types.ObjectId().toString(); | |
| export const createServiceEvent = ( | |
| eventType: KafkaEventType, | |
| @@ -38,7 +38,7 @@ export const serviceDto = { | |
| serviceTypeId, | |
| id: serviceId, | |
| status: ServiceStatus.OPEN, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| location: { | |
| state: 'CA', | |
| }, | |
| diff --git a/apps/business-flow-manager-ms/src/disengagement/tests/utils.ts b/apps/business-flow-manager-ms/src/disengagement/tests/utils.ts | |
| index 113a3b2a3..5e04da6ec 100644 | |
| --- a/apps/business-flow-manager-ms/src/disengagement/tests/utils.ts | |
| +++ b/apps/business-flow-manager-ms/src/disengagement/tests/utils.ts | |
| @@ -1,10 +1,10 @@ | |
| import { CaseSubStatus, ServiceStatus } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| -export const userId1 = objectStringId(); | |
| -export const serviceId1 = objectStringId(); | |
| -export const serviceId2 = objectStringId(); | |
| -export const serviceId3 = objectStringId(); | |
| +export const userId1 = Types.ObjectId().toString(); | |
| +export const serviceId1 = Types.ObjectId().toString(); | |
| +export const serviceId2 = Types.ObjectId().toString(); | |
| +export const serviceId3 = Types.ObjectId().toString(); | |
| export const user1 = { | |
| id: userId1, | |
| @@ -19,13 +19,13 @@ export const user1 = { | |
| }; | |
| export const case1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.OPEN, | |
| }; | |
| export const case2 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| subStatus: CaseSubStatus.OPEN, | |
| }; | |
| diff --git a/apps/business-flow-manager-ms/src/new-client-call/tests/new-client-call.controller.spec.ts b/apps/business-flow-manager-ms/src/new-client-call/tests/new-client-call.controller.spec.ts | |
| index 3b40cf270..aa7e331ad 100644 | |
| --- a/apps/business-flow-manager-ms/src/new-client-call/tests/new-client-call.controller.spec.ts | |
| +++ b/apps/business-flow-manager-ms/src/new-client-call/tests/new-client-call.controller.spec.ts | |
| @@ -13,7 +13,7 @@ import { INestApplication } from '@nestjs/common'; | |
| import { isMatch } from 'lodash'; | |
| import { BrazeDestinationType, BrazeNotification } from '@vinny/communications-client'; | |
| import { NewClientCallService } from '../new-client-call.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { getDateStringByNextDays } from '../../utils'; | |
| import { TeamType, MemberRole } from '@vinny/users-types'; | |
| import { KafkaEventDto } from '@vinny/kafka-client'; | |
| @@ -224,7 +224,7 @@ describe('nccController', () => { | |
| name: { | |
| first: faker.name.firstName(), | |
| }, | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| describe('POST create new client call - happy flow', () => { | |
| diff --git a/apps/business-flow-manager-ms/src/required-documents/test/events-handler.controller.spec.ts b/apps/business-flow-manager-ms/src/required-documents/test/events-handler.controller.spec.ts | |
| index 0a6243cbb..58711e7a2 100644 | |
| --- a/apps/business-flow-manager-ms/src/required-documents/test/events-handler.controller.spec.ts | |
| +++ b/apps/business-flow-manager-ms/src/required-documents/test/events-handler.controller.spec.ts | |
| @@ -19,7 +19,7 @@ import { | |
| CreateDocumentsRepeatDataRequestInputMock, | |
| } from './mock'; | |
| import { DATA_REQUESTS_EVENT_TAGS } from '@vinny/data-requests-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { cloneDeep } from 'lodash'; | |
| import { REQUIRED_DOCUMENTS_TAG } from '../consts'; | |
| import { RequiredDocumentsFlowModule } from '../required-documents-flow.module'; | |
| @@ -92,7 +92,7 @@ describe('RequiredDocumentsFlowEventsHandlerController', () => { | |
| it('should create document data request for document types with forms only', async () => { | |
| const multipleDocumentKafkaPayload = cloneDeep(MockLSSKafkaPayload); | |
| - const addedDocumentTypeId = objectStringId(); | |
| + const addedDocumentTypeId = Types.ObjectId().toString(); | |
| multipleDocumentKafkaPayload.value.data.documentTypeIds.push(addedDocumentTypeId); | |
| const getFormsNock = dataCollectionMsNock | |
| .get( | |
| @@ -140,7 +140,7 @@ describe('RequiredDocumentsFlowEventsHandlerController', () => { | |
| it('should create document data request for document types with forms only', async () => { | |
| const multipleDocumentKafkaPayload = cloneDeep(MockRepeatKafkaPayload); | |
| - const addedDocumentTypeId = objectStringId(); | |
| + const addedDocumentTypeId = Types.ObjectId().toString(); | |
| multipleDocumentKafkaPayload.value.data.documentTypeIds.push(addedDocumentTypeId); | |
| const getFormsNock = dataCollectionMsNock | |
| .get( | |
| @@ -177,8 +177,8 @@ describe('RequiredDocumentsFlowEventsHandlerController', () => { | |
| describe('handleDataRequestEvent', () => { | |
| it('should call sendDocumentDataRequestOpenedNotification endpoint with correct payload', async () => { | |
| const tags = [REQUIRED_DOCUMENTS_TAG, 'LSS_1']; | |
| - const attorneyId = objectStringId(); | |
| - const caseId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const caseId = Types.ObjectId().toString(); | |
| const sendDocumentDataRequestOpenedNotificationNock = businessFlowManagerMsNock | |
| .post( | |
| '/required-documents-flow/send-notification', | |
| diff --git a/apps/business-flow-manager-ms/src/required-documents/test/mock.ts b/apps/business-flow-manager-ms/src/required-documents/test/mock.ts | |
| index 162a3aa22..e5025b5e7 100644 | |
| --- a/apps/business-flow-manager-ms/src/required-documents/test/mock.ts | |
| +++ b/apps/business-flow-manager-ms/src/required-documents/test/mock.ts | |
| @@ -7,7 +7,7 @@ import { | |
| RequestedItemDto, | |
| } from '@vinny/data-requests-types'; | |
| import { Gender } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| ATTORNEY_METADATA_CREATOR_DESCRIPTION, | |
| DOCUMENTS_REQUEST_TAG, | |
| @@ -33,23 +33,23 @@ import { | |
| import { TaskStatus } from '@vinny/scheduler-types'; | |
| export const MockLSSPayload = { | |
| - id: objectStringId(), | |
| - eventId: objectStringId(), | |
| - attorneyId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + eventId: Types.ObjectId().toString(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| clientDetails: { | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| gender: Gender.FEMALE, | |
| }, | |
| recommendedServices: [ | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| - documentTypeIds: [objectStringId()], | |
| + documentTypeIds: [Types.ObjectId().toString()], | |
| }; | |
| export const MockLSSKafkaPayload = { | |
| @@ -58,7 +58,7 @@ export const MockLSSKafkaPayload = { | |
| data: { | |
| ...MockLSSPayload, | |
| }, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| type: KafkaEventType.CREATE, | |
| time: faker.datatype.string(), | |
| }, | |
| @@ -89,14 +89,14 @@ export const CreateDocumentsLSSDataRequestInputMock = { | |
| export const MockDataRequestResponse = { | |
| ...CreateDocumentsLSSDataRequestInputMock, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: DataRequestStatus.CREATED, | |
| }; | |
| export const MockFormsResponse = { | |
| forms: [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| key: MockLSSPayload.documentTypeIds[0], | |
| schema: EXPLICIT_FULL_DATA_SCHEMA_FORM, | |
| @@ -106,23 +106,23 @@ export const MockFormsResponse = { | |
| export const MockRepeatPayload = { | |
| id: faker.datatype.string(), | |
| - caseId: objectStringId(), | |
| - attorneyId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| submittedBy: { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| type: Role.ATTORNEY, | |
| }, | |
| services: { | |
| additionalServices: [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| - practiceAreaId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [], | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| location: { state: faker.datatype.string() }, | |
| }, | |
| ], | |
| @@ -130,14 +130,14 @@ export const MockRepeatPayload = { | |
| }, | |
| events: [], | |
| flowType: 'Touch' as const, | |
| - documentTypeIds: [objectStringId()], | |
| - userId: objectStringId(), | |
| + documentTypeIds: [Types.ObjectId().toString()], | |
| + userId: Types.ObjectId().toString(), | |
| }; | |
| export const MockRepeatFormsResponse = { | |
| forms: [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| key: MockRepeatPayload.documentTypeIds[0], | |
| schema: EXPLICIT_FULL_DATA_SCHEMA_FORM, | |
| @@ -170,7 +170,7 @@ export const CreateDocumentsRepeatDataRequestInputMock = { | |
| export const MockRepeatDataRequestResponse = { | |
| ...CreateDocumentsRepeatDataRequestInputMock, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: DataRequestStatus.CREATED, | |
| }; | |
| @@ -180,14 +180,14 @@ export const MockRepeatKafkaPayload = { | |
| data: { | |
| ...MockRepeatPayload, | |
| }, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| type: KafkaEventType.CREATE, | |
| time: faker.datatype.string(), | |
| }, | |
| }; | |
| -export const UPLOADED_DOCUMENT_IDS_1 = [objectStringId(), objectStringId()]; | |
| -export const UPLOADED_DOCUMENT_IDS_2 = [objectStringId(), objectStringId()]; | |
| -export const caseId = objectStringId(); | |
| +export const UPLOADED_DOCUMENT_IDS_1 = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| +export const UPLOADED_DOCUMENT_IDS_2 = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| +export const caseId = Types.ObjectId().toString(); | |
| export const documentDataPointsSubmissionListDtoMock: DocumentsDataPointsSubmissionDto = { | |
| attorneyId: ATTORNEY_ID, | |
| @@ -204,7 +204,7 @@ export const documentDataPointsSubmissionListDtoMock: DocumentsDataPointsSubmiss | |
| }; | |
| export const lssDataRequestDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: DataRequestStatus.PENDING, | |
| description: LSS_REQUEST_DESCRIPTION, | |
| userId: USER_ID, | |
| @@ -220,7 +220,7 @@ export const lssDataRequestDto = { | |
| }; | |
| export const repeatDataRequestDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: DataRequestStatus.PENDING, | |
| description: REPEAT_REQUEST_DESCRIPTION, | |
| userId: USER_ID, | |
| @@ -245,7 +245,7 @@ export const CreateMockLssDataRequestDtoKafkaPayload = ( | |
| ...lssDataRequestDto, | |
| tags, | |
| }, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| type: KafkaEventType.CREATE, | |
| time: faker.datatype.string(), | |
| tags: pendingTag ? [pendingTag] : [], | |
| @@ -265,13 +265,13 @@ export const createDocumentDataRequestResponse = ( | |
| userId, | |
| items, | |
| metadata: { | |
| - name: objectStringId(), | |
| + name: Types.ObjectId().toString(), | |
| creatorType: DataRequestCreatorType.LEGAL_TEAM, | |
| - creatorId: objectStringId(), | |
| - creatorDescription: objectStringId(), | |
| + creatorId: Types.ObjectId().toString(), | |
| + creatorDescription: Types.ObjectId().toString(), | |
| }, | |
| - tags: tags || [objectStringId()], | |
| - id: objectStringId(), | |
| + tags: tags || [Types.ObjectId().toString()], | |
| + id: Types.ObjectId().toString(), | |
| status: status || DataRequestStatus.PENDING, | |
| })), | |
| }); | |
| @@ -280,19 +280,19 @@ export const UNAVALIABLE_REASON = faker.datatype.string(); | |
| export const UNAVALIABLE_REASON_1 = faker.datatype.string(); | |
| export const mockDocumentRequestPayload = { | |
| - attorneyId: objectStringId(), | |
| - documentTypeIds: [objectStringId(), objectStringId()], | |
| + attorneyId: Types.ObjectId().toString(), | |
| + documentTypeIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }; | |
| export const mockDocumentsRequestFormsResponse = { | |
| forms: [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| key: mockDocumentRequestPayload.documentTypeIds[0], | |
| schema: EXPLICIT_FULL_DATA_SCHEMA_FORM, | |
| }, | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| key: mockDocumentRequestPayload.documentTypeIds[1], | |
| schema: EXPLICIT_FULL_DATA_SCHEMA_FORM, | |
| @@ -335,7 +335,7 @@ export const unavailableDocumentNotificationDtoMock = { | |
| export const delayedTaskDtoslist = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: TaskStatus.COMPLETED, | |
| taskData: { | |
| timeToExecute: new Date(), | |
| @@ -350,7 +350,7 @@ export const delayedTaskDtoslist = [ | |
| updatedAt: new Date(), | |
| }, | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: TaskStatus.SCHEDULED, | |
| taskData: { | |
| timeToExecute: new Date(), | |
| diff --git a/apps/business-flow-manager-ms/src/service-closures-flow/test/consts.ts b/apps/business-flow-manager-ms/src/service-closures-flow/test/consts.ts | |
| index df5c86cdd..a842a2d07 100644 | |
| --- a/apps/business-flow-manager-ms/src/service-closures-flow/test/consts.ts | |
| +++ b/apps/business-flow-manager-ms/src/service-closures-flow/test/consts.ts | |
| @@ -10,25 +10,25 @@ import { | |
| ServiceStatus, | |
| ServiceWithdrawalInitiator, | |
| } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { omit } from 'lodash'; | |
| -export const serviceMilestoneId1 = objectStringId(); | |
| -export const serviceMilestoneId2 = objectStringId(); | |
| -export const serviceMilestoneId3 = objectStringId(); | |
| -export const serviceMilestoneId4 = objectStringId(); | |
| -export const serviceMilestoneId5 = objectStringId(); | |
| +export const serviceMilestoneId1 = Types.ObjectId().toString(); | |
| +export const serviceMilestoneId2 = Types.ObjectId().toString(); | |
| +export const serviceMilestoneId3 = Types.ObjectId().toString(); | |
| +export const serviceMilestoneId4 = Types.ObjectId().toString(); | |
| +export const serviceMilestoneId5 = Types.ObjectId().toString(); | |
| -export const documentId1 = objectStringId(); | |
| -export const documentId2 = objectStringId(); | |
| -export const documentId3 = objectStringId(); | |
| +export const documentId1 = Types.ObjectId().toString(); | |
| +export const documentId2 = Types.ObjectId().toString(); | |
| +export const documentId3 = Types.ObjectId().toString(); | |
| -export const attorneyId = objectStringId(); | |
| -export const paralegalId = objectStringId(); | |
| +export const attorneyId = Types.ObjectId().toString(); | |
| +export const paralegalId = Types.ObjectId().toString(); | |
| export const attorneyServiceClosureInputDto1 = { | |
| - serviceTypeId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| isWithdrawalBundle: true, | |
| status: ServiceClosureStatus.PENDING_WITHDRAWAL, | |
| withdrawalInitiator: ServiceWithdrawalInitiator.ATTORNEY, | |
| @@ -60,8 +60,8 @@ export const attorneyServiceClosureInputDto1 = { | |
| }; | |
| export const attorneyServiceClosureInputDto2 = { | |
| - serviceTypeId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| isWithdrawalBundle: true, | |
| status: ServiceClosureStatus.PENDING_WITHDRAWAL, | |
| withdrawalInitiator: ServiceWithdrawalInitiator.ATTORNEY, | |
| @@ -86,26 +86,26 @@ export const attorneyServiceClosureInputDto2 = { | |
| export const milestones = []; | |
| export const service1LegalTeam = { | |
| - caseManager: { userId: objectStringId(), role: LegalTeamMemberRole.CASE_MANAGER }, | |
| - paralegal: { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + caseManager: { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.CASE_MANAGER }, | |
| + paralegal: { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| attorrney: { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY, | |
| }, | |
| }; | |
| export const paralegalServiceDto1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| description: faker.lorem.sentence(), | |
| - caseId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| location: { | |
| state: 'California', | |
| county: 'Fresno', | |
| }, | |
| - practiceAreaId: objectStringId(), | |
| - userId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| service1LegalTeam.attorrney, | |
| service1LegalTeam.caseManager, | |
| @@ -113,54 +113,54 @@ export const paralegalServiceDto1 = { | |
| ], | |
| }; | |
| export const paralegalServiceDto2 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| description: faker.lorem.sentence(), | |
| caseId: paralegalServiceDto1.caseId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| location: { | |
| state: 'California', | |
| county: 'Fresno', | |
| }, | |
| - practiceAreaId: objectStringId(), | |
| - userId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.CASE_MANAGER }, | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.CASE_MANAGER }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| }; | |
| export const paralegalServiceDto3 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| description: faker.lorem.sentence(), | |
| - caseId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| location: { | |
| state: 'California', | |
| county: 'Fresno', | |
| }, | |
| - practiceAreaId: objectStringId(), | |
| - userId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.CASE_MANAGER }, | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.CASE_MANAGER }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| }; | |
| export const paralegalServiceDto4 = { | |
| ...paralegalServiceDto2, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId: paralegalServiceDto1.caseId, | |
| legalTeam: paralegalServiceDto1.legalTeam, | |
| }; | |
| export const paralegalServiceDto5 = { | |
| ...paralegalServiceDto3, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId: paralegalServiceDto1.caseId, | |
| legalTeam: paralegalServiceDto1.legalTeam, | |
| }; | |
| @@ -250,7 +250,7 @@ export const serviceTypeDto1 = { | |
| legalDescription: 'test', | |
| }, | |
| firm: 'Marble', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| isAddendumProduct: faker.datatype.boolean(), | |
| category: 'test category', | |
| isRequiresAdditionalExpenseForClient: faker.datatype.boolean(), | |
| @@ -258,12 +258,12 @@ export const serviceTypeDto1 = { | |
| stateInfo: {}, | |
| metadata: { | |
| status: 'ACTIVE', | |
| - createdById: objectStringId(), | |
| + createdById: Types.ObjectId().toString(), | |
| }, | |
| defaultPricing: {}, | |
| - serviceCode: objectStringId(), | |
| + serviceCode: Types.ObjectId().toString(), | |
| name: 'test service type 1', | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| }; | |
| export const serviceTypeDto2 = { | |
| @@ -476,12 +476,12 @@ export const milestonesProgressList1 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 25, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ]; | |
| @@ -494,12 +494,12 @@ export const milestonesProgressList3 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 75, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 45 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 35 }, | |
| @@ -510,12 +510,12 @@ export const milestonesProgressList4 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 0, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 35 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 35 }, | |
| @@ -526,12 +526,12 @@ export const milestonesProgressList5 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 25, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 35, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 15 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 45 }, | |
| @@ -542,12 +542,12 @@ export const milestonesProgressList6 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 35, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 65, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 85 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 45 }, | |
| @@ -558,12 +558,12 @@ export const milestonesProgressList7 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 26, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 97, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 82 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 42 }, | |
| @@ -574,12 +574,12 @@ export const milestonesProgressList8 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 36, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 93, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 84 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 48 }, | |
| @@ -590,12 +590,12 @@ export const milestonesProgressList9 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 13, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 84 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 57 }, | |
| @@ -606,12 +606,12 @@ export const milestonesProgressList10 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 82, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 98 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 57 }, | |
| @@ -622,12 +622,12 @@ export const milestonesProgressList11 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 7, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 18 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 89 }, | |
| @@ -638,12 +638,12 @@ export const milestonesProgressList12 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 7, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 18 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 89 }, | |
| @@ -654,12 +654,12 @@ export const milestonesProgressList13 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: null, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 18 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 89 }, | |
| @@ -670,47 +670,47 @@ export const milestonesProgressList14 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 100 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 100 }, | |
| ]; | |
| export const customer1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.CUSTOMER], | |
| }; | |
| export const attorney1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| export const paralegal1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.PARALEGAL], | |
| }; | |
| @@ -718,18 +718,18 @@ export const service1 = { | |
| id: serviceClosureDto1.serviceId, | |
| name: faker.name.findName(), | |
| description: faker.lorem.sentence(), | |
| - caseId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| location: { | |
| state: 'California', | |
| county: 'Fresno', | |
| }, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| userId: customer1.id, | |
| legalTeam: [ | |
| { userId: paralegal1.id, role: LegalTeamMemberRole.PARALEGAL }, | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.CASE_MANAGER }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.CASE_MANAGER }, | |
| { userId: attorney1.id, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| }; | |
| @@ -947,12 +947,12 @@ export const milestonesProgressListForEvent4 = [ | |
| export const caseEventsMock = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| eventType: 'HEARING', | |
| startDate: faker.date.future(), | |
| }, | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| eventType: 'COURT_DATE', | |
| startDate: faker.date.future(), | |
| }, | |
| diff --git a/apps/business-flow-manager-ms/src/service-closures-flow/test/utils.spec.ts b/apps/business-flow-manager-ms/src/service-closures-flow/test/utils.spec.ts | |
| index af9abdce3..d53190a1d 100644 | |
| --- a/apps/business-flow-manager-ms/src/service-closures-flow/test/utils.spec.ts | |
| +++ b/apps/business-flow-manager-ms/src/service-closures-flow/test/utils.spec.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| MILESTONES_PROGRESS_INPUT_NOT_UPDATED, | |
| getPercentCompletedOfService, | |
| @@ -24,13 +24,13 @@ describe('service closure flow utils', () => { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 100, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId4, | |
| milestonePercentCompleted: 50, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| ]; | |
| const serviceMilestonesList = [ | |
| @@ -39,14 +39,14 @@ describe('service closure flow utils', () => { | |
| portion: 65, | |
| isProofRequired: false, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| portion: 35, | |
| isProofRequired: true, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| ]; | |
| const serviceMilestonesListWithOptionalMilestones = [ | |
| @@ -55,7 +55,7 @@ describe('service closure flow utils', () => { | |
| portion: 65, | |
| isProofRequired: false, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| isOptional: true, | |
| }, | |
| { | |
| @@ -63,7 +63,7 @@ describe('service closure flow utils', () => { | |
| portion: 35, | |
| isProofRequired: true, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| isOptional: true, | |
| }, | |
| ]; | |
| @@ -152,17 +152,17 @@ describe('service closure flow utils', () => { | |
| serviceMilestoneId: serviceMilestoneId1, | |
| milestonePercentCompleted: 33, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| ]; | |
| const serviceMilestonesList = [ | |
| @@ -172,7 +172,7 @@ describe('service closure flow utils', () => { | |
| isProofRequired: true, | |
| isOptional: true, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId1, | |
| @@ -180,14 +180,14 @@ describe('service closure flow utils', () => { | |
| isProofRequired: false, | |
| isOptional: true, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| portion: 50, | |
| isProofRequired: true, | |
| updatedAt: new Date(), | |
| - updatedBy: objectStringId(), | |
| + updatedBy: Types.ObjectId().toString(), | |
| }, | |
| ]; | |
| diff --git a/apps/business-flow-manager-ms/src/test-utils/mock.ts b/apps/business-flow-manager-ms/src/test-utils/mock.ts | |
| index a7fa1e8ed..fe294d41f 100644 | |
| --- a/apps/business-flow-manager-ms/src/test-utils/mock.ts | |
| +++ b/apps/business-flow-manager-ms/src/test-utils/mock.ts | |
| @@ -1,14 +1,14 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { User } from '@vinny/users-types'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { DocumentDataRequestType } from '../required-documents/required-documents-flow.types'; | |
| -export const USER_ID = objectStringId(); | |
| -export const ATTORNEY_ID = objectStringId(); | |
| -export const DATA_SCHEMA_ID = objectStringId(); | |
| -export const DOCUMENT_TYPE_ID_1 = objectStringId(); | |
| -export const DOCUMENT_TYPE_ID_2 = objectStringId(); | |
| +export const USER_ID = Types.ObjectId().toString(); | |
| +export const ATTORNEY_ID = Types.ObjectId().toString(); | |
| +export const DATA_SCHEMA_ID = Types.ObjectId().toString(); | |
| +export const DOCUMENT_TYPE_ID_1 = Types.ObjectId().toString(); | |
| +export const DOCUMENT_TYPE_ID_2 = Types.ObjectId().toString(); | |
| export const CUSTOMER: User = { | |
| id: USER_ID, | |
| @@ -100,8 +100,8 @@ export const DATA_REQUESTS_DEREFERENCED_RESPONSE = { | |
| `${DocumentDataRequestType.LSS}_lssDocument1`, | |
| `${DocumentDataRequestType.LSS}_lssDocument2`, | |
| `${DocumentDataRequestType.REPEAT}_repeatDocument1`, | |
| - objectStringId(), | |
| - objectStringId(), | |
| + Types.ObjectId().toString(), | |
| + Types.ObjectId().toString(), | |
| ], | |
| }, | |
| ], | |
| diff --git a/apps/calendars-ms/src/calendly/tests/calendly.controller.spec.ts b/apps/calendars-ms/src/calendly/tests/calendly.controller.spec.ts | |
| index ec83dee8f..c65bd5456 100644 | |
| --- a/apps/calendars-ms/src/calendly/tests/calendly.controller.spec.ts | |
| +++ b/apps/calendars-ms/src/calendly/tests/calendly.controller.spec.ts | |
| @@ -9,7 +9,7 @@ import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { ServicesClientModule, ServicesClientService } from '@vinny/services-client'; | |
| import { MockConfigService } from '@vinny/test-utils'; | |
| import { UsersClientModule, UsersClientService } from '@vinny/users-client'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { KafkaProducerModule, KafkaProducerService, KafkaTopics } from '@vinny/kafka-client'; | |
| import { ConfigurationsModule } from '../../configurations/configurations.module'; | |
| @@ -53,7 +53,6 @@ import { | |
| CalendlyNextStepsWebhookPayload, | |
| } from './utils'; | |
| import { generateCreateLssEventDto } from '@vinny/events-types-test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const mockEnvVars = { | |
| SERVICES_MS_URL: 'http://services:4001', | |
| @@ -238,7 +237,7 @@ describe('Calendly controller', () => { | |
| it('should create new LssEvent with new calendlyId and cancel old event ', async () => { | |
| const createEventSpy = jest.spyOn(eventsClientServices, 'createEvent'); | |
| const deleteEventSpy = jest.spyOn(eventsClientServices, 'cancelEvent'); | |
| - const oldLssEventId = objectStringId(); | |
| + const oldLssEventId = Types.ObjectId().toString(); | |
| const oldLssEvent = generateCreateLssEventDto({ | |
| caseId: userCase?.id, | |
| calendlyEventId: CANCELED_LSS_EVENT_ID.toString(), | |
| diff --git a/apps/calendars-ms/src/calendly/tests/utils.ts b/apps/calendars-ms/src/calendly/tests/utils.ts | |
| index 03e56d3c7..a42934623 100644 | |
| --- a/apps/calendars-ms/src/calendly/tests/utils.ts | |
| +++ b/apps/calendars-ms/src/calendly/tests/utils.ts | |
| @@ -4,7 +4,7 @@ import { CaseDto } from '@vinny/services-types'; | |
| import { User } from '@vinny/users-types'; | |
| import { CaseStatus } from '@vinny/services-types'; | |
| import { CalendlyEventName, EventInviteesResponse } from '@vinny/calendly-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| export const EVENT_TYPE_URI = 'www.test-uri.com/06060606'; | |
| @@ -19,9 +19,9 @@ export const INVITER_ID = '4815162342'; | |
| export const INVITER_EMAIL = '[email protected]'; | |
| export const SCHEDULED_AT = 'test-time'; | |
| export const ATTORNEY_TIME_ZONE = 'greece'; | |
| -export const INTERNAL_EVENT_ID = objectStringId(); | |
| +export const INTERNAL_EVENT_ID = Types.ObjectId().toString(); | |
| export const RESCHEDULE_URL = 'www.reschedule.url.com'; | |
| -export const WRONG_INTERNAL_ID = objectStringId(); | |
| +export const WRONG_INTERNAL_ID = Types.ObjectId().toString(); | |
| export const CalendlyWebhookPayload = { | |
| created_by: 'test', | |
| diff --git a/apps/calendars-ms/src/configurations/schemas/configuration.schema.ts b/apps/calendars-ms/src/configurations/schemas/configuration.schema.ts | |
| index e3710cfd7..4be20676f 100644 | |
| --- a/apps/calendars-ms/src/configurations/schemas/configuration.schema.ts | |
| +++ b/apps/calendars-ms/src/configurations/schemas/configuration.schema.ts | |
| @@ -1,19 +1,18 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document } from 'mongoose'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| import { ConfigurationType } from '../dto/configurations.dto'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| export type ConfigurationDocument = Configuration & Document; | |
| -@Schema({ timestamps: false, versionKey: false, toObject: { getters: true } }) | |
| +@Schema({ timestamps: false, versionKey: false }) | |
| export class Configuration { | |
| @Prop({ required: true }) | |
| calendlyId: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - internalId: string; | |
| + @Prop({ type: SchemaTypes.ObjectId, required: true }) | |
| + internalId: Types.ObjectId; | |
| - @Prop({ type: String, enum: Object.values(ConfigurationType), required: true }) | |
| + @Prop({ type: String, enum: ConfigurationType, required: true }) | |
| type: ConfigurationType; | |
| } | |
| diff --git a/apps/calendars-ms/src/key-date-invitations/dal/schemas/key-date-invitation-metadata.schema.ts b/apps/calendars-ms/src/key-date-invitations/dal/schemas/key-date-invitation-metadata.schema.ts | |
| index 2642193ea..cbf103d0b 100644 | |
| --- a/apps/calendars-ms/src/key-date-invitations/dal/schemas/key-date-invitation-metadata.schema.ts | |
| +++ b/apps/calendars-ms/src/key-date-invitations/dal/schemas/key-date-invitation-metadata.schema.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| -import { Document, Types } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| export type KeyDateInvitationMetadataDocument = KeyDateInvitationMetadata & Document; | |
| @@ -11,7 +11,13 @@ export class KeyDateInvitationMetadata { | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true, index: true, unique: true })) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + required: true, | |
| + unique: true, | |
| + index: true, | |
| + }) | |
| keyDateEventId: string; | |
| @Prop({ | |
| diff --git a/apps/calendars-ms/src/notifications/tests/notifications.controller.integration.spec.ts b/apps/calendars-ms/src/notifications/tests/notifications.controller.integration.spec.ts | |
| index 9a91d9f96..39b362e80 100644 | |
| --- a/apps/calendars-ms/src/notifications/tests/notifications.controller.integration.spec.ts | |
| +++ b/apps/calendars-ms/src/notifications/tests/notifications.controller.integration.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import request from 'supertest'; | |
| import { INestApplication, ValidationPipe } from '@nestjs/common'; | |
| import { TestingModule } from '@nestjs/testing'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { NotificationsModule } from '../notifications.module'; | |
| import { | |
| @@ -69,9 +69,9 @@ describe('NotificationsController', () => { | |
| const twoMinutesAgo = new Date(); | |
| twoMinutesAgo.setMinutes(twoMinutesAgo.getMinutes() - 2); | |
| - const mockAttorney = { id: objectStringId() }; | |
| + const mockAttorney = { id: Types.ObjectId().toString() }; | |
| const mockClient = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { first: faker.name.firstName(), last: faker.name.lastName() }, | |
| }; | |
| @@ -124,7 +124,12 @@ describe('NotificationsController', () => { | |
| it.each([ | |
| ['meeting time has passed', twoMinutesAgo, twoMinutesAgo, mockAttorney.id], | |
| ['meeting time was changed', fifteenMinutesFromNow, faker.date.future(), mockAttorney.id], | |
| - ['attorney was changed', fifteenMinutesFromNow, fifteenMinutesFromNow, objectStringId()], | |
| + [ | |
| + 'attorney was changed', | |
| + fifteenMinutesFromNow, | |
| + fifteenMinutesFromNow, | |
| + Types.ObjectId().toString(), | |
| + ], | |
| ])( | |
| 'should not send a reminder notification when %s', | |
| async (_, currentMeetingTime, requestStartDate, requestAttorneyId) => { | |
| @@ -158,9 +163,9 @@ describe('NotificationsController', () => { | |
| const sevenHoursFromNow = new Date(); | |
| sevenHoursFromNow.setHours(sevenHoursFromNow.getHours() + 7); | |
| - const mockAttorney = { id: objectStringId() }; | |
| + const mockAttorney = { id: Types.ObjectId().toString() }; | |
| const mockClient = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { first: faker.name.firstName(), last: faker.name.lastName() }, | |
| }; | |
| @@ -253,10 +258,10 @@ describe('NotificationsController', () => { | |
| }); | |
| describe('POST /one-on-one-notifications', () => { | |
| - const requestId = objectStringId(); | |
| - const flareId = objectStringId(); | |
| - const marbleId = objectStringId(); | |
| - const mockAttorney = { id: objectStringId() }; | |
| + const requestId = Types.ObjectId().toString(); | |
| + const flareId = Types.ObjectId().toString(); | |
| + const marbleId = Types.ObjectId().toString(); | |
| + const mockAttorney = { id: Types.ObjectId().toString() }; | |
| const startDate = new Date().addHours(12); | |
| const payload: DtoMessageMeeting = { | |
| @@ -302,8 +307,8 @@ describe('NotificationsController', () => { | |
| it('should send one on one notification meeting created', async () => { | |
| const mockEvent = generateMockEvent( | |
| - objectStringId(), | |
| - objectStringId(), | |
| + Types.ObjectId().toString(), | |
| + Types.ObjectId().toString(), | |
| mockAttorney.id, | |
| startDate, | |
| ); | |
| diff --git a/apps/calendars-ms/src/notifications/tests/notifications.events-handler.spec.ts b/apps/calendars-ms/src/notifications/tests/notifications.events-handler.spec.ts | |
| index 980086d74..c9c36ec3c 100644 | |
| --- a/apps/calendars-ms/src/notifications/tests/notifications.events-handler.spec.ts | |
| +++ b/apps/calendars-ms/src/notifications/tests/notifications.events-handler.spec.ts | |
| @@ -1,5 +1,5 @@ | |
| import { TestingModule } from '@nestjs/testing'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| AttendeeStatus, | |
| AttendeeStatusReason, | |
| @@ -64,10 +64,10 @@ describe('Notifications events event handler', () => { | |
| }); | |
| describe('handleEvent', () => { | |
| - const firstAttorneyId = objectStringId(); | |
| + const firstAttorneyId = Types.ObjectId().toString(); | |
| const mockClient = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { first: faker.name.firstName(), last: faker.name.lastName() }, | |
| }; | |
| @@ -312,7 +312,7 @@ describe('Notifications events event handler', () => { | |
| (it) => it.attendeeType == AttendeeType.ATTORNEY, | |
| )!; | |
| const attorneyDeclineEvent = { | |
| - key: objectStringId(), | |
| + key: Types.ObjectId().toString(), | |
| value: { | |
| eventId: 'mock-uuid', | |
| type: KafkaEventType.UPDATE, | |
| @@ -358,7 +358,7 @@ describe('Notifications events event handler', () => { | |
| ); | |
| const customerDeclineEvent = { | |
| - key: objectStringId(), | |
| + key: Types.ObjectId().toString(), | |
| value: { | |
| eventId: 'mock-uuid', | |
| type: KafkaEventType.DELETE, | |
| @@ -401,7 +401,7 @@ describe('Notifications events event handler', () => { | |
| )!; | |
| const forceAcceptEvent = { | |
| - key: objectStringId(), | |
| + key: Types.ObjectId().toString(), | |
| value: { | |
| eventId: 'mock-uuid', | |
| type: KafkaEventType.UPDATE, | |
| diff --git a/apps/calendars-ms/src/notifications/tests/utils.ts b/apps/calendars-ms/src/notifications/tests/utils.ts | |
| index b21932258..6141e9795 100644 | |
| --- a/apps/calendars-ms/src/notifications/tests/utils.ts | |
| +++ b/apps/calendars-ms/src/notifications/tests/utils.ts | |
| @@ -9,11 +9,11 @@ import { | |
| LssEventDto, | |
| } from '@vinny/events-types'; | |
| import { KafkaEventDto, KafkaEventType } from '@vinny/kafka-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export function generateMockEvent( | |
| - eventId = objectStringId(), | |
| - clientId = objectStringId(), | |
| + eventId = Types.ObjectId().toString(), | |
| + clientId = Types.ObjectId().toString(), | |
| attorneyId?: string, | |
| startDate = new Date(), | |
| isCancelled = false, | |
| @@ -49,7 +49,7 @@ export function generateKafkaEvent( | |
| startDate?: Date, | |
| mockEventType: EventType = EventType.LSS_EVENT, | |
| ): KafkaEventDto<Partial<EventDto>> { | |
| - const eventId = objectStringId(); | |
| + const eventId = Types.ObjectId().toString(); | |
| const prevData: Partial<EventDto> | undefined = | |
| eventType === KafkaEventType.UPDATE ? {} : undefined; | |
| if (prevData && previousAttorneyId) { | |
| diff --git a/apps/catalog-ms/src/ad-hoc-tasks/dal/schema/ad-hoc-task-type.schema.ts b/apps/catalog-ms/src/ad-hoc-tasks/dal/schema/ad-hoc-task-type.schema.ts | |
| index a970fb7c8..4dcb26e65 100644 | |
| --- a/apps/catalog-ms/src/ad-hoc-tasks/dal/schema/ad-hoc-task-type.schema.ts | |
| +++ b/apps/catalog-ms/src/ad-hoc-tasks/dal/schema/ad-hoc-task-type.schema.ts | |
| @@ -12,7 +12,7 @@ export class AdHocTaskType { | |
| required: true, | |
| type: String, | |
| unique: true, | |
| - enum: Object.values(FlareEngineTaskType), | |
| + enum: FlareEngineTaskType, | |
| }) | |
| type: FlareEngineTaskType; | |
| diff --git a/apps/catalog-ms/src/documents/dal/document-catalog.dal.ts b/apps/catalog-ms/src/documents/dal/document-catalog.dal.ts | |
| index 148bbe67b..cf664c868 100644 | |
| --- a/apps/catalog-ms/src/documents/dal/document-catalog.dal.ts | |
| +++ b/apps/catalog-ms/src/documents/dal/document-catalog.dal.ts | |
| @@ -1,7 +1,7 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { isValidObjectId, Model } from 'mongoose'; | |
| -import { objectId, schemaToDto } from '@vinny/helpers'; | |
| +import { isValidObjectId, Model, Types } from 'mongoose'; | |
| +import { schemaToDto } from '@vinny/helpers'; | |
| import { | |
| CreateDocumentTypeDto, | |
| DocumentTypeDto, | |
| @@ -61,7 +61,7 @@ export class DocumentCatalogDal { | |
| private buildFilterQuery(filter: GetDocumentTypeFilterDto): Record<string, any> { | |
| return { | |
| ...(filter?.ids && { | |
| - _id: { $in: filter.ids.filter((id: any) => isValidObjectId(id)).map(objectId) }, | |
| + _id: { $in: filter.ids.filter((id: any) => isValidObjectId(id)).map(Types.ObjectId) }, | |
| }), | |
| ...(filter?.category && { category: filter.category }), | |
| ...(filter?.name && { name: filter.name }), | |
| diff --git a/apps/catalog-ms/src/drafts/dal/draft-catalog.dal.ts b/apps/catalog-ms/src/drafts/dal/draft-catalog.dal.ts | |
| index 482e2f73c..44a955c5a 100644 | |
| --- a/apps/catalog-ms/src/drafts/dal/draft-catalog.dal.ts | |
| +++ b/apps/catalog-ms/src/drafts/dal/draft-catalog.dal.ts | |
| @@ -1,5 +1,5 @@ | |
| import { ConflictException, Injectable } from '@nestjs/common'; | |
| -import { isValidObjectId, Model } from 'mongoose'; | |
| +import { isValidObjectId, Model, Types } from 'mongoose'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { DraftType, DraftTypeDocument } from './draft-catalog.schema'; | |
| import { | |
| @@ -9,7 +9,7 @@ import { | |
| DraftTypesResultsList, | |
| UpdateDraftTypeDto, | |
| } from '@vinny/catalog-types'; | |
| -import { getAggregateQuery, objectId } from '@vinny/helpers'; | |
| +import { getAggregateQuery } from '@vinny/helpers'; | |
| const DUPLICATE_KEY_ERROR_MSG_PREFIX = 'E11000 duplicate'; | |
| @@ -62,7 +62,7 @@ export class DraftCatalogDal { | |
| async findAll(filter: DraftTypeFilterDto): Promise<DraftType[]> { | |
| const queryFilter = filter && this.buildFilterQuery(filter); | |
| const draftTypeDocuments = await this.draftCatalogModel.find(queryFilter); | |
| - return draftTypeDocuments.map((dtd) => dtd.toObject()); | |
| + return draftTypeDocuments.map((draftTypeDocument) => draftTypeDocument?.toObject()); | |
| } | |
| async update( | |
| @@ -83,7 +83,7 @@ export class DraftCatalogDal { | |
| ...rest, | |
| ...(ids && { | |
| _id: { | |
| - $in: ids.filter((id) => isValidObjectId(id)).map(objectId), | |
| + $in: ids.filter((id) => isValidObjectId(id)).map(Types.ObjectId), | |
| }, | |
| }), | |
| }; | |
| diff --git a/apps/catalog-ms/src/drafts/dal/draft-catalog.schema.ts b/apps/catalog-ms/src/drafts/dal/draft-catalog.schema.ts | |
| index 66cc6cbc9..bb9dacb19 100644 | |
| --- a/apps/catalog-ms/src/drafts/dal/draft-catalog.schema.ts | |
| +++ b/apps/catalog-ms/src/drafts/dal/draft-catalog.schema.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| -import { Document, Types } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| export type DraftTypeDocument = DraftType & Document; | |
| @@ -21,7 +21,7 @@ export class DraftType { | |
| @Prop({ required: true, type: Boolean }) | |
| atInitialFiling: boolean; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId, get: objectIdToStringGetter }) | |
| documentTypeId: string; | |
| @Prop({ required: true, type: String }) | |
| diff --git a/apps/catalog-ms/src/drafts/tests/draft-catalog.controller.spec.ts b/apps/catalog-ms/src/drafts/tests/draft-catalog.controller.spec.ts | |
| index 89b118cde..718718fce 100644 | |
| --- a/apps/catalog-ms/src/drafts/tests/draft-catalog.controller.spec.ts | |
| +++ b/apps/catalog-ms/src/drafts/tests/draft-catalog.controller.spec.ts | |
| @@ -2,14 +2,13 @@ import request from 'supertest'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import nock from 'nock'; | |
| import { HttpStatus, INestApplication, ValidationPipe } from '@nestjs/common'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { getConnectionToken, MongooseModule } from '@nestjs/mongoose'; | |
| import { closeInMongodConnection, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import normalize from 'normalize-mongoose'; | |
| import { DraftType, DraftTypeSchema } from '../dal/draft-catalog.schema'; | |
| import { DraftCatalogModule } from '../draft-catalog.module'; | |
| import { createDraftTypeDto1, createDraftTypeDto2, createDraftTypeDto3 } from './mocks'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Draft catalog Controller', () => { | |
| let module: TestingModule; | |
| @@ -85,7 +84,7 @@ describe('Draft catalog Controller', () => { | |
| describe('GET /catalog/drafts/:id', () => { | |
| it('should get a draft type by id and throw exception when no document with given id exists', async () => { | |
| - const randomId = objectStringId(); | |
| + const randomId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .get(`/catalog/drafts/${randomId}`) | |
| .expect(HttpStatus.NOT_FOUND); | |
| @@ -112,7 +111,7 @@ describe('Draft catalog Controller', () => { | |
| describe('PATCH /catalog/drafts/:id', () => { | |
| it('should update a draft type by id and throw exception when no document with given id exists', async () => { | |
| - const randomId = objectStringId(); | |
| + const randomId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .patch(`/catalog/drafts/${randomId}`) | |
| .expect(HttpStatus.NOT_FOUND); | |
| diff --git a/apps/catalog-ms/src/drafts/tests/mocks.ts b/apps/catalog-ms/src/drafts/tests/mocks.ts | |
| index a96f97829..220591ea3 100644 | |
| --- a/apps/catalog-ms/src/drafts/tests/mocks.ts | |
| +++ b/apps/catalog-ms/src/drafts/tests/mocks.ts | |
| @@ -1,12 +1,12 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const createDraftTypeDto1 = { | |
| name: 'draft type 1', | |
| description: faker.lorem.sentence(), | |
| formKey: faker.datatype.uuid(), | |
| atInitialFiling: true, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| fileName: faker.system.fileName(), | |
| templateS3Key: faker.system.fileName(), | |
| }; | |
| @@ -16,7 +16,7 @@ export const createDraftTypeDto2 = { | |
| description: faker.lorem.sentence(), | |
| formKey: faker.datatype.uuid(), | |
| atInitialFiling: false, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| fileName: faker.system.fileName(), | |
| templateS3Key: faker.system.fileName(), | |
| }; | |
| @@ -26,7 +26,7 @@ export const createDraftTypeDto3 = { | |
| description: faker.lorem.sentence(), | |
| formKey: faker.datatype.uuid(), | |
| atInitialFiling: true, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| fileName: faker.system.fileName(), | |
| templateS3Key: faker.system.fileName(), | |
| }; | |
| diff --git a/apps/catalog-ms/src/service-milestones/dal/service-milestones.dal.ts b/apps/catalog-ms/src/service-milestones/dal/service-milestones.dal.ts | |
| index 22d38bd3e..a2955c3e9 100644 | |
| --- a/apps/catalog-ms/src/service-milestones/dal/service-milestones.dal.ts | |
| +++ b/apps/catalog-ms/src/service-milestones/dal/service-milestones.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { ConflictException, Injectable, NotFoundException } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model, isValidObjectId } from 'mongoose'; | |
| +import { Model, Types, isValidObjectId } from 'mongoose'; | |
| import { ServiceMilestone, ServiceMilestoneDocument } from './service-milestone.schema'; | |
| import { | |
| CreateServiceMilestoneDto, | |
| @@ -9,7 +9,7 @@ import { | |
| ServiceMilestonesResultsList, | |
| UpdateServiceMilestoneDto, | |
| } from '@vinny/catalog-types'; | |
| -import { getAggregateQuery, objectId } from '@vinny/helpers'; | |
| +import { getAggregateQuery } from '@vinny/helpers'; | |
| const DUPLICATE_KEY_ERROR_MSG_PREFIX = 'E11000 duplicate'; | |
| @@ -37,8 +37,9 @@ export class ServiceMilestonesDal { | |
| async findAll(filter: GetServiceMilestonesFilterDto): Promise<ServiceMilestone[]> { | |
| const serviceMilestonesFilter = filter && this.buildFilterQuery(filter); | |
| - const filtered = await this.serviceMilestoneModel.find(serviceMilestonesFilter); | |
| - return filtered.map((a) => a.toObject()); | |
| + return (await this.serviceMilestoneModel.find(serviceMilestonesFilter)).map( | |
| + (serviceMilestone) => serviceMilestone?.toObject(), | |
| + ); | |
| } | |
| async list(payload: ServiceMilestonesQueryDto): Promise<ServiceMilestonesResultsList> { | |
| @@ -90,7 +91,7 @@ export class ServiceMilestonesDal { | |
| private buildFilterQuery(filter: GetServiceMilestonesFilterDto): Record<string, any> { | |
| return { | |
| ...(filter?.ids && { | |
| - _id: { $in: filter.ids.filter((id: string) => isValidObjectId(id)).map(objectId) }, | |
| + _id: { $in: filter.ids.filter((id: string) => isValidObjectId(id)).map(Types.ObjectId) }, | |
| }), | |
| ...(filter?.name && { name: filter.name }), | |
| }; | |
| diff --git a/apps/catalog-ms/src/service-milestones/test/service-milestones.controller.spec.ts b/apps/catalog-ms/src/service-milestones/test/service-milestones.controller.spec.ts | |
| index 8ae9a78d3..eddc969b5 100644 | |
| --- a/apps/catalog-ms/src/service-milestones/test/service-milestones.controller.spec.ts | |
| +++ b/apps/catalog-ms/src/service-milestones/test/service-milestones.controller.spec.ts | |
| @@ -4,14 +4,13 @@ import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import nock from 'nock'; | |
| import { HttpStatus, INestApplication, ValidationPipe } from '@nestjs/common'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { getConnectionToken, MongooseModule } from '@nestjs/mongoose'; | |
| import { closeInMongodConnection, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import normalize from 'normalize-mongoose'; | |
| import { ServiceMilestone, ServiceMilestoneSchema } from '../dal/service-milestone.schema'; | |
| import { ServiceMilestonesModule } from '../service-milestones.module'; | |
| import { ServiceMilestoneDto } from '@vinny/catalog-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Service milestones Controller', () => { | |
| let module: TestingModule; | |
| @@ -119,7 +118,7 @@ describe('Service milestones Controller', () => { | |
| { name: 'step2', completionPercent: 100 }, | |
| ], | |
| }; | |
| - const randomId = objectStringId(); | |
| + const randomId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .get(`/catalog/service-milestones/${randomId}`) | |
| .expect(HttpStatus.NOT_FOUND); | |
| @@ -320,7 +319,7 @@ describe('Service milestones Controller', () => { | |
| }); | |
| it('should throw not found exception when updating a non existing service milestone', async () => { | |
| const updatePayload = { name: 'update milestone' }; | |
| - const nonExistingMilestoneId = objectStringId(); | |
| + const nonExistingMilestoneId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .patch(`/catalog/service-milestones/${nonExistingMilestoneId}`) | |
| .send(updatePayload) | |
| @@ -346,7 +345,7 @@ describe('Service milestones Controller', () => { | |
| }); | |
| it('should throw not found exception when deleting a non existing service milestone', async () => { | |
| - const nonExistingMilestoneId = objectStringId(); | |
| + const nonExistingMilestoneId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .delete(`/catalog/service-milestones/${nonExistingMilestoneId}`) | |
| .expect(HttpStatus.NOT_FOUND); | |
| diff --git a/apps/catalog-ms/src/services/dal/base-service-catalog-dal.service.ts b/apps/catalog-ms/src/services/dal/base-service-catalog-dal.service.ts | |
| index b6acff94d..c50b9dfb0 100644 | |
| --- a/apps/catalog-ms/src/services/dal/base-service-catalog-dal.service.ts | |
| +++ b/apps/catalog-ms/src/services/dal/base-service-catalog-dal.service.ts | |
| @@ -1,5 +1,5 @@ | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { | |
| ServiceTypeDocument, | |
| ServiceType as ServiceCatalogDoc, | |
| @@ -21,7 +21,7 @@ import { BadRequestException } from '@nestjs/common'; | |
| import { ServiceMilestonesService } from '../../service-milestones/service-milestones.service'; | |
| import { ConfigService } from '@nestjs/config'; | |
| import { getDefaultServiceMilestonesList } from '../utils'; | |
| -import { isObjectId, schemaToDto } from '@vinny/helpers'; | |
| +import { schemaToDto } from '@vinny/helpers'; | |
| const DEFAULT_RETRY_COUNT = 2; | |
| @@ -71,7 +71,7 @@ export class BaseServiceCatalogDalService { | |
| serviceTypeId: string, | |
| ...fieldsToReturn: (keyof ServiceType)[] | |
| ): Promise<ServiceType> { | |
| - if (!isObjectId(serviceTypeId)) { | |
| + if (!Types.ObjectId.isValid(serviceTypeId)) { | |
| throw new BadRequestException(`${serviceTypeId} is not a valid service type id`); | |
| } | |
| const mostRecentServiceType = await this.executeGetServiceQuery( | |
| @@ -91,7 +91,7 @@ export class BaseServiceCatalogDalService { | |
| serviceTypeId: string, | |
| ...fieldsToReturn: (keyof ServiceType)[] | |
| ): Promise<ServiceType> { | |
| - if (!isObjectId(serviceTypeId)) { | |
| + if (!Types.ObjectId.isValid(serviceTypeId)) { | |
| throw new BadRequestException(`${serviceTypeId} is not a valid service type id`); | |
| } | |
| return await this.getLatestServiceByFilter({ serviceTypeId }, fieldsToReturn); | |
| diff --git a/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-content.schema.ts b/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-content.schema.ts | |
| index c8c68ef72..535aae4f6 100644 | |
| --- a/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-content.schema.ts | |
| +++ b/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-content.schema.ts | |
| @@ -1,5 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { SchemaTypes } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| import { | |
| ServiceAiGeneratedContent, | |
| ServiceAiGeneratedContentSchema, | |
| @@ -55,7 +56,11 @@ export const StepForClientSchema = SchemaFactory.createForClass(StepForClient); | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class ServiceContent { | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| practiceAreaId: string; | |
| @Prop({ required: true, type: String, enum: Firm }) | |
| diff --git a/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-metadata.schema.ts b/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-metadata.schema.ts | |
| index 1d22dcfc2..03c194ac9 100644 | |
| --- a/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-metadata.schema.ts | |
| +++ b/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-metadata.schema.ts | |
| @@ -19,7 +19,7 @@ export class ServiceMetadata { | |
| @Prop({ | |
| required: true, | |
| type: String, | |
| - enum: Object.values(ServiceTypeStatus), | |
| + enum: ServiceTypeStatus, | |
| }) | |
| status: ServiceTypeStatus; | |
| } | |
| diff --git a/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-milestone-item.schema.ts b/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-milestone-item.schema.ts | |
| index bb2847dc8..18a6a0bf1 100644 | |
| --- a/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-milestone-item.schema.ts | |
| +++ b/apps/catalog-ms/src/services/dal/schema/service-type-field-schemas/service-milestone-item.schema.ts | |
| @@ -1,5 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { SchemaTypes } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| @Schema({ _id: false }) | |
| export class MilestoneStep { | |
| @@ -14,7 +15,7 @@ export const MilestoneStepSchema = SchemaFactory.createForClass(MilestoneStep); | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class ServiceMilestoneItem { | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId, get: objectIdToStringGetter }) | |
| serviceMilestoneId: string; | |
| @Prop({ required: true, type: Number }) | |
| diff --git a/apps/catalog-ms/src/services/dal/schema/service-type.schema.ts b/apps/catalog-ms/src/services/dal/schema/service-type.schema.ts | |
| index 811f3650e..5f5d7c1d5 100644 | |
| --- a/apps/catalog-ms/src/services/dal/schema/service-type.schema.ts | |
| +++ b/apps/catalog-ms/src/services/dal/schema/service-type.schema.ts | |
| @@ -1,5 +1,5 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document, Types } from 'mongoose'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| import { ServiceResource, ServiceResourceSchema } from './service-resource.schema'; | |
| import { | |
| ServiceMetadata, | |
| @@ -21,7 +21,7 @@ import { | |
| ServiceStateInfo, | |
| ServiceStateInfoSchema, | |
| } from './service-type-field-schemas/service-state-info.schema'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| import { | |
| ServiceMilestoneItem, | |
| ServiceMilestoneItemSchema, | |
| @@ -46,7 +46,12 @@ export class ServiceType { | |
| }) | |
| modifierId: string; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + index: true, | |
| + }) | |
| serviceTypeId: string; | |
| @Prop({ | |
| @@ -105,16 +110,8 @@ export class ServiceType { | |
| content: ServiceContent; | |
| @Prop({ | |
| - type: Map, | |
| - of: ServiceStateInfoSchema, | |
| - default: new Map(), | |
| - get(value: Map<string, ServiceStateInfo & Document>) { | |
| - const newObject: Record<string, ServiceStateInfo> = {}; | |
| - for (const [key, val] of value) { | |
| - if (val) newObject[key] = val?.toObject(); | |
| - } | |
| - return newObject; | |
| - }, | |
| + type: { state: ServiceStateInfoSchema }, | |
| + default: () => ({}), | |
| }) | |
| stateInfo: Record<string, ServiceStateInfo>; | |
| diff --git a/apps/catalog-ms/src/services/dal/service-catalog.dal.ts b/apps/catalog-ms/src/services/dal/service-catalog.dal.ts | |
| index 81897b397..3c7f08faa 100644 | |
| --- a/apps/catalog-ms/src/services/dal/service-catalog.dal.ts | |
| +++ b/apps/catalog-ms/src/services/dal/service-catalog.dal.ts | |
| @@ -10,7 +10,7 @@ import { | |
| import { getAggregateQuery } from '@vinny/helpers'; | |
| import { BaseServiceCatalogDalService } from './base-service-catalog-dal.service'; | |
| import { ServiceType as ServiceTypeDocument } from './schema/service-type.schema'; | |
| -import { objectId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| @Injectable() | |
| export class ServiceCatalogDalService extends BaseServiceCatalogDalService { | |
| @@ -62,7 +62,7 @@ export class ServiceCatalogDalService extends BaseServiceCatalogDalService { | |
| }; | |
| } | |
| - private buildFilterQuery(filter: GetServiceTypesFilterDto): Record<string, unknown> { | |
| + private buildFilterQuery(filter: GetServiceTypesFilterDto): Record<string, any> { | |
| return { | |
| ...(filter.serviceCode && { serviceCode: filter.serviceCode }), | |
| ...(filter.serviceTypeName && { serviceTypeName: filter.serviceTypeName }), | |
| @@ -74,13 +74,13 @@ export class ServiceCatalogDalService extends BaseServiceCatalogDalService { | |
| 'metadata.status': filter.isActive === true ? 'ACTIVE' : 'INACTIVE', | |
| }), | |
| ...(filter.practiceAreaId && { | |
| - 'content.practiceAreaId': objectId(filter.practiceAreaId), | |
| + 'content.practiceAreaId': Types.ObjectId(filter.practiceAreaId), | |
| }), | |
| ...(filter.isAddendumProduct !== undefined && { | |
| 'content.isAddendumProduct': filter.isAddendumProduct === true, | |
| }), | |
| ...(filter.serviceTypeIds && { | |
| - serviceTypeId: { $in: filter.serviceTypeIds.map(objectId) }, | |
| + serviceTypeId: { $in: filter.serviceTypeIds.map(Types.ObjectId) }, | |
| }), | |
| }; | |
| } | |
| diff --git a/apps/catalog-ms/src/services/dal/test/resources-dal.service.spec.ts b/apps/catalog-ms/src/services/dal/test/resources-dal.service.spec.ts | |
| index 44c84798a..f249186ad 100644 | |
| --- a/apps/catalog-ms/src/services/dal/test/resources-dal.service.spec.ts | |
| +++ b/apps/catalog-ms/src/services/dal/test/resources-dal.service.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, getLogger, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken, MongooseModule } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| @@ -19,7 +19,6 @@ import { | |
| mapServiceTypeToObject, | |
| } from '../../test/test-utils'; | |
| import { ConfigService } from '@nestjs/config'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| SERVICES_MS_URL: 'http://services.ms', | |
| @@ -84,19 +83,25 @@ describe('ResourcesDalService', () => { | |
| describe('setResourcesOfService', () => { | |
| it.each([ | |
| - [[], [{ resourceKey: objectStringId() }]], | |
| - [[{ resourceKey: objectStringId() }], []], | |
| - [[{ resourceKey: objectStringId() }], [{ resourceKey: objectStringId() }]], | |
| + [[], [{ resourceKey: Types.ObjectId().toString() }]], | |
| + [[{ resourceKey: Types.ObjectId().toString() }], []], | |
| [ | |
| - [{ resourceKey: objectStringId() }], | |
| - [{ resourceKey: objectStringId() }, { resourceKey: objectStringId() }], | |
| + [{ resourceKey: Types.ObjectId().toString() }], | |
| + [{ resourceKey: Types.ObjectId().toString() }], | |
| + ], | |
| + [ | |
| + [{ resourceKey: Types.ObjectId().toString() }], | |
| + [ | |
| + { resourceKey: Types.ObjectId().toString() }, | |
| + { resourceKey: Types.ObjectId().toString() }, | |
| + ], | |
| ], | |
| ])( | |
| 'should override required resources successfully', | |
| async (prevServicesResources: ServiceResource[], newServicesResources: ServiceResource[]) => { | |
| - const serviceTypeId = objectStringId(); | |
| - const origModifier = objectStringId(); | |
| - const newModifier = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| + const origModifier = Types.ObjectId().toString(); | |
| + const newModifier = Types.ObjectId().toString(); | |
| const expectedService: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId, | |
| @@ -130,8 +135,8 @@ describe('ResourcesDalService', () => { | |
| it.each([0, 1, 3, 5, 20])( | |
| 'should increment version id on change', | |
| async (changesCount: number) => { | |
| - const serviceTypeId = objectStringId(); | |
| - const modifierId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| + const modifierId = Types.ObjectId().toString(); | |
| const expectedService: CreateServiceTypeDto = { | |
| modifierId: modifierId, | |
| diff --git a/apps/catalog-ms/src/services/dal/test/service-catalog-dal.service.spec.ts b/apps/catalog-ms/src/services/dal/test/service-catalog-dal.service.spec.ts | |
| index 229fe4b88..87cc496c1 100644 | |
| --- a/apps/catalog-ms/src/services/dal/test/service-catalog-dal.service.spec.ts | |
| +++ b/apps/catalog-ms/src/services/dal/test/service-catalog-dal.service.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test } from '@nestjs/testing'; | |
| import { ServiceCatalogDalService } from '../service-catalog.dal'; | |
| import { ServiceCatalogDalModule } from '../service-catalog-dal.module'; | |
| @@ -13,7 +13,6 @@ import { | |
| mapServiceTypeToObject, | |
| } from '../../test/test-utils'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| SERVICES_MS_URL: 'http://services.ms', | |
| @@ -60,15 +59,15 @@ describe('ServiceCatalogDalService', () => { | |
| describe('createServiceCatalog', () => { | |
| it('should successfully create service', async () => { | |
| const expectedService: CreateServiceTypeDto = { | |
| - serviceTypeId: objectStringId(), | |
| - modifierId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['testLabel1'], | |
| }, | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['testLabel2'], | |
| }, | |
| ], | |
| @@ -96,11 +95,11 @@ describe('ServiceCatalogDalService', () => { | |
| it('should add empty resource selector array', async () => { | |
| const expectedService: CreateServiceTypeDto = { | |
| - serviceTypeId: objectStringId(), | |
| - modifierId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| ...extraServiceDetails, | |
| @@ -127,8 +126,8 @@ describe('ServiceCatalogDalService', () => { | |
| it('should add empty required resources array', async () => { | |
| const expectedService: CreateServiceTypeDto = { | |
| - serviceTypeId: objectStringId(), | |
| - modifierId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }; | |
| @@ -151,8 +150,8 @@ describe('ServiceCatalogDalService', () => { | |
| it('should enforce uniqueness of service Id and version Id', async () => { | |
| const expectedService: CreateServiceTypeDto = { | |
| - serviceTypeId: objectStringId(), | |
| - modifierId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }; | |
| @@ -167,10 +166,10 @@ describe('ServiceCatalogDalService', () => { | |
| describe('getServiceByServiceId', () => { | |
| it('should get latest version of service', async () => { | |
| - const origModifier1 = objectStringId(); | |
| - const newModifier = objectStringId(); | |
| + const origModifier1 = Types.ObjectId().toString(); | |
| + const newModifier = Types.ObjectId().toString(); | |
| const expectedService: CreateServiceTypeDto = { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| modifierId: origModifier1, | |
| ...extraServiceDetails, | |
| }; | |
| @@ -178,10 +177,10 @@ describe('ServiceCatalogDalService', () => { | |
| await serviceCatalogDalService.createServiceType(expectedService); | |
| const serviceResources = [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| }, | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| }, | |
| ]; | |
| const { versionId } = await resourcesDalService.setResourcesOfService( | |
| @@ -210,8 +209,8 @@ describe('ServiceCatalogDalService', () => { | |
| describe('getServiceByVersionId', () => { | |
| it('should get correct version of service', async () => { | |
| const expectedService: CreateServiceTypeDto = { | |
| - serviceTypeId: objectStringId(), | |
| - modifierId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }; | |
| @@ -219,13 +218,13 @@ describe('ServiceCatalogDalService', () => { | |
| await serviceCatalogDalService.createServiceType(expectedService); | |
| await resourcesDalService.setResourcesOfService( | |
| expectedService.serviceTypeId!, | |
| - objectStringId(), | |
| + Types.ObjectId().toString(), | |
| [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| }, | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| ); | |
| @@ -249,9 +248,9 @@ describe('ServiceCatalogDalService', () => { | |
| describe('getServiceByFilter', () => { | |
| it('should get latest services based on provided filter', async () => { | |
| - const serviceTypeId1 = objectStringId(); | |
| - const serviceTypeId2 = objectStringId(); | |
| - const serviceTypeId3 = objectStringId(); | |
| + const serviceTypeId1 = Types.ObjectId().toString(); | |
| + const serviceTypeId2 = Types.ObjectId().toString(); | |
| + const serviceTypeId3 = Types.ObjectId().toString(); | |
| const service1: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId1, | |
| @@ -319,8 +318,8 @@ describe('ServiceCatalogDalService', () => { | |
| }); | |
| }); | |
| describe('listServiceTypes', () => { | |
| - const serviceTypeId1 = objectStringId(); | |
| - const serviceTypeId2 = objectStringId(); | |
| + const serviceTypeId1 = Types.ObjectId().toString(); | |
| + const serviceTypeId2 = Types.ObjectId().toString(); | |
| const service1: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId1, | |
| diff --git a/apps/catalog-ms/src/services/service-resources/test/resources-selectors.controller.spec.ts b/apps/catalog-ms/src/services/service-resources/test/resources-selectors.controller.spec.ts | |
| index 049a79dcb..b88063ac3 100644 | |
| --- a/apps/catalog-ms/src/services/service-resources/test/resources-selectors.controller.spec.ts | |
| +++ b/apps/catalog-ms/src/services/service-resources/test/resources-selectors.controller.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test } from '@nestjs/testing'; | |
| import { INestApplication } from '@nestjs/common'; | |
| import request from 'supertest'; | |
| @@ -8,7 +8,6 @@ import { CreateServiceTypeDto } from '@vinny/catalog-types'; | |
| import { ServiceCatalogModule } from '../../service-catalog.module'; | |
| import { extraServiceDetailsTypes, getExtraServiceDetails } from '../../test/test-utils'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| SERVICES_MS_URL: 'http://services.ms', | |
| @@ -51,11 +50,11 @@ describe('ResourcesSelectorsController', () => { | |
| describe('getSelectorsOfResourcesByServiceId', () => { | |
| it('should return empty array on no required resources', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await createServiceType({ | |
| serviceTypeId: serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }); | |
| @@ -65,14 +64,14 @@ describe('ResourcesSelectorsController', () => { | |
| }); | |
| it('should return empty array on no labels present', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| ...extraServiceDetails, | |
| @@ -84,18 +83,18 @@ describe('ResourcesSelectorsController', () => { | |
| }); | |
| it('should return unique array on labels exist', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['Test1'], | |
| }, | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['Test1'], | |
| }, | |
| ], | |
| @@ -108,7 +107,7 @@ describe('ResourcesSelectorsController', () => { | |
| }); | |
| it('should return 404 on service not found', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .get(`/services/${serviceTypeId}/document-labels`) | |
| diff --git a/apps/catalog-ms/src/services/service-resources/test/resources.controller.spec.ts b/apps/catalog-ms/src/services/service-resources/test/resources.controller.spec.ts | |
| index 600e9f530..978bc2787 100644 | |
| --- a/apps/catalog-ms/src/services/service-resources/test/resources.controller.spec.ts | |
| +++ b/apps/catalog-ms/src/services/service-resources/test/resources.controller.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test } from '@nestjs/testing'; | |
| import { INestApplication } from '@nestjs/common'; | |
| import request from 'supertest'; | |
| @@ -8,7 +8,6 @@ import { CreateServiceTypeDto, UpdateServiceResourcesDto } from '@vinny/catalog- | |
| import { ServiceCatalogModule } from '../../service-catalog.module'; | |
| import { extraServiceDetailsTypes, getExtraServiceDetails } from '../../test/test-utils'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| SERVICES_MS_URL: 'http://services.ms', | |
| @@ -50,11 +49,11 @@ describe('ResourcesController', () => { | |
| describe('getResourcesByServiceId', () => { | |
| it('should return empty array on no required document', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }); | |
| @@ -64,15 +63,15 @@ describe('ResourcesController', () => { | |
| }); | |
| it('should return only required resource', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const serviceResources = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1'], | |
| }; | |
| await createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [serviceResources], | |
| ...extraServiceDetails, | |
| }); | |
| @@ -83,13 +82,13 @@ describe('ResourcesController', () => { | |
| }); | |
| it('should return filtered resources', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const resource1 = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1'], | |
| }; | |
| const resource2 = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1', 'TEST_LABEL_2'], | |
| }; | |
| @@ -97,7 +96,7 @@ describe('ResourcesController', () => { | |
| await createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: serviceResources, | |
| ...extraServiceDetails, | |
| }); | |
| @@ -109,7 +108,7 @@ describe('ResourcesController', () => { | |
| }); | |
| it('should return 404 on service not found', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .get(`/catalog/services/${serviceTypeId}/resources`) | |
| @@ -119,8 +118,8 @@ describe('ResourcesController', () => { | |
| describe('setResourcesForService', () => { | |
| it('should override required document on service', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| - const modifierId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| + const modifierId = Types.ObjectId().toString(); | |
| const versionId = 1; | |
| await createServiceType({ | |
| @@ -128,7 +127,7 @@ describe('ResourcesController', () => { | |
| modifierId, | |
| serviceResources: [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['Test1'], | |
| }, | |
| ], | |
| @@ -136,7 +135,7 @@ describe('ResourcesController', () => { | |
| }); | |
| const serviceResource = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1'], | |
| }; | |
| await request(app.getHttpServer()) | |
| @@ -150,8 +149,8 @@ describe('ResourcesController', () => { | |
| }); | |
| it('should set required document when none exist', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| - const modifierId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| + const modifierId = Types.ObjectId().toString(); | |
| const versionId = 1; | |
| await createServiceType({ | |
| @@ -161,7 +160,7 @@ describe('ResourcesController', () => { | |
| }); | |
| const serviceResource = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1'], | |
| }; | |
| await request(app.getHttpServer()) | |
| @@ -175,7 +174,7 @@ describe('ResourcesController', () => { | |
| }); | |
| it('should return 404 on service not found', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .put(`/catalog/services/${serviceTypeId}/resources`) | |
| diff --git a/apps/catalog-ms/src/services/service-resources/test/resources.service.spec.ts b/apps/catalog-ms/src/services/service-resources/test/resources.service.spec.ts | |
| index 187444dd0..a6ea09eba 100644 | |
| --- a/apps/catalog-ms/src/services/service-resources/test/resources.service.spec.ts | |
| +++ b/apps/catalog-ms/src/services/service-resources/test/resources.service.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, getLogger, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken, MongooseModule } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| @@ -13,7 +13,6 @@ import { ResourcesModule } from '../resources.module'; | |
| import { ServiceCatalogDalService } from '../../dal/service-catalog.dal'; | |
| import { extraServiceDetailsTypes, getExtraServiceDetails } from '../../test/test-utils'; | |
| import { ConfigService } from '@nestjs/config'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| SERVICES_MS_URL: 'http://services.ms', | |
| @@ -78,11 +77,11 @@ describe('ResourcesService', () => { | |
| describe('getResourcesByServiceId', () => { | |
| it('should return empty array on no required document', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await serviceCatalogDalService.createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }); | |
| @@ -92,15 +91,15 @@ describe('ResourcesService', () => { | |
| }); | |
| it('should return only required document', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const serviceResource = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1'], | |
| }; | |
| await serviceCatalogDalService.createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [serviceResource], | |
| ...extraServiceDetails, | |
| }); | |
| @@ -113,23 +112,23 @@ describe('ResourcesService', () => { | |
| describe('getResourcesByServiceId with filters', () => { | |
| it('should return filtered resources', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const resource1 = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1'], | |
| }; | |
| const resource2 = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1', 'TEST_LABEL_2'], | |
| }; | |
| const resource3 = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1', 'TEST_LABEL_3'], | |
| }; | |
| await serviceCatalogDalService.createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [resource1, resource2, resource3], | |
| ...extraServiceDetails, | |
| }); | |
| @@ -160,11 +159,11 @@ describe('ResourcesService', () => { | |
| describe('getSelectorsOfResourcesByServiceId', () => { | |
| it('should return empty array on no required resources', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await serviceCatalogDalService.createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }); | |
| @@ -175,14 +174,14 @@ describe('ResourcesService', () => { | |
| }); | |
| it('should return empty array on no labels present', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await serviceCatalogDalService.createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| ...extraServiceDetails, | |
| @@ -195,18 +194,18 @@ describe('ResourcesService', () => { | |
| }); | |
| it('should return unique array on labels exist', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await serviceCatalogDalService.createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['Test1'], | |
| }, | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['Test1'], | |
| }, | |
| ], | |
| @@ -222,14 +221,14 @@ describe('ResourcesService', () => { | |
| describe('setResourcesForService', () => { | |
| it('should override required document on service', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await serviceCatalogDalService.createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| serviceResources: [ | |
| { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['Test1'], | |
| }, | |
| ], | |
| @@ -237,10 +236,10 @@ describe('ResourcesService', () => { | |
| }); | |
| const serviceResource = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1'], | |
| }; | |
| - await resourcesService.setResourcesForService(serviceTypeId, objectStringId(), [ | |
| + await resourcesService.setResourcesForService(serviceTypeId, Types.ObjectId().toString(), [ | |
| serviceResource, | |
| ]); | |
| @@ -250,19 +249,19 @@ describe('ResourcesService', () => { | |
| }); | |
| it('should set required document when none exist', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| await serviceCatalogDalService.createServiceType({ | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }); | |
| const serviceResource = { | |
| - resourceKey: objectStringId(), | |
| + resourceKey: Types.ObjectId().toString(), | |
| resourceSelector: ['TEST_LABEL_1'], | |
| }; | |
| - await resourcesService.setResourcesForService(serviceTypeId, objectStringId(), [ | |
| + await resourcesService.setResourcesForService(serviceTypeId, Types.ObjectId().toString(), [ | |
| serviceResource, | |
| ]); | |
| diff --git a/apps/catalog-ms/src/services/service-states/test/states.controller.spec.ts b/apps/catalog-ms/src/services/service-states/test/states.controller.spec.ts | |
| index d4e8d3e87..cf2b731dd 100644 | |
| --- a/apps/catalog-ms/src/services/service-states/test/states.controller.spec.ts | |
| +++ b/apps/catalog-ms/src/services/service-states/test/states.controller.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test } from '@nestjs/testing'; | |
| import { INestApplication } from '@nestjs/common'; | |
| import request from 'supertest'; | |
| @@ -11,7 +11,6 @@ import { ServiceCatalogModule } from '../../service-catalog.module'; | |
| import { ServicesMsMigrationService } from '../../services-ms-migration/services-ms-migration.service'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| import nock from 'nock'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| SERVICES_MS_URL: 'http://services.ms', | |
| @@ -56,7 +55,7 @@ describe('StatesController', () => { | |
| describe('GET /catalog/services/:serviceTypeId/states/:stateId', () => { | |
| it('should return state info', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const pricing: ServicePricing = { | |
| approximateFilingFees: Math.floor(Math.random() * 1000), | |
| price: Math.floor(Math.random() * 1000), | |
| @@ -68,7 +67,7 @@ describe('StatesController', () => { | |
| const createPayload: CreateServiceTypeDto = { | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| stateInfo: { | |
| CA: { | |
| @@ -85,7 +84,7 @@ describe('StatesController', () => { | |
| }); | |
| it('should return 404 on service not found', async () => { | |
| - const notExistServiceId = objectStringId(); | |
| + const notExistServiceId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .get(`/services/${notExistServiceId}/states/CA`) | |
| @@ -93,11 +92,11 @@ describe('StatesController', () => { | |
| }); | |
| it('should return 404 on state not found', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const createPayload: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }; | |
| await request(app.getHttpServer()).post('/catalog/services').send(createPayload).expect(201); | |
| @@ -108,7 +107,7 @@ describe('StatesController', () => { | |
| describe('PATCH /catalog/services/:serviceTypeId/states/:stateId', () => { | |
| it('should create new stateInfo on not exist', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const pricing: ServicePricing = { | |
| approximateFilingFees: Math.floor(Math.random() * 1000), | |
| price: Math.floor(Math.random() * 1000), | |
| @@ -126,12 +125,12 @@ describe('StatesController', () => { | |
| const createPayload: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| }; | |
| await request(app.getHttpServer()).post('/catalog/services').send(createPayload).expect(201); | |
| - const modifierId = objectStringId(); | |
| + const modifierId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .patch(`/catalog/services/${serviceTypeId}/states/CA`) | |
| .send({ | |
| @@ -169,7 +168,7 @@ describe('StatesController', () => { | |
| }); | |
| it('should update existing stateInfo', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const pricing1: ServicePricing = { | |
| approximateFilingFees: Math.floor(Math.random() * 1000), | |
| @@ -190,7 +189,7 @@ describe('StatesController', () => { | |
| const createPayload: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| stateInfo: { | |
| CA: { | |
| @@ -206,7 +205,7 @@ describe('StatesController', () => { | |
| // do nothing | |
| }); | |
| - const modifierId = objectStringId(); | |
| + const modifierId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .patch(`/catalog/services/${serviceTypeId}/states/CA`) | |
| .send({ | |
| @@ -246,7 +245,7 @@ describe('StatesController', () => { | |
| describe('DELETE /catalog/services/:serviceTypeId/states/:stateId', () => { | |
| it('should delete single configured state', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const pricing: ServicePricing = { | |
| approximateFilingFees: Math.floor(Math.random() * 1000), | |
| @@ -259,7 +258,7 @@ describe('StatesController', () => { | |
| const createPayload: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| stateInfo: { | |
| CA: { | |
| @@ -275,7 +274,7 @@ describe('StatesController', () => { | |
| // do nothing | |
| }); | |
| - const modifierId = objectStringId(); | |
| + const modifierId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .delete(`/catalog/services/${serviceTypeId}/states/CA`) | |
| .send({ modifierId }) | |
| @@ -307,11 +306,11 @@ describe('StatesController', () => { | |
| ], | |
| [{}], | |
| ])('should delete state', async (pricing: ServicePricing) => { | |
| - const serviceTypeId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| const createPayload: CreateServiceTypeDto = { | |
| serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetails, | |
| stateInfo: { | |
| CA: { | |
| @@ -324,7 +323,7 @@ describe('StatesController', () => { | |
| }; | |
| await request(app.getHttpServer()).post('/catalog/services').send(createPayload).expect(201); | |
| - const modifierId = objectStringId(); | |
| + const modifierId = Types.ObjectId().toString(); | |
| servicesMsNock | |
| .patch(`/service-types/${serviceTypeId}`, { | |
| diff --git a/apps/catalog-ms/src/services/services-ms-migration/services-ms-migration.service.ts b/apps/catalog-ms/src/services/services-ms-migration/services-ms-migration.service.ts | |
| index f89077b14..b1885e271 100644 | |
| --- a/apps/catalog-ms/src/services/services-ms-migration/services-ms-migration.service.ts | |
| +++ b/apps/catalog-ms/src/services/services-ms-migration/services-ms-migration.service.ts | |
| @@ -3,7 +3,7 @@ import { CreateServiceTypeDto, UpdateServiceTypeDto } from '@vinny/catalog-types | |
| import { ServicesClientService } from '@vinny/services-client'; | |
| import { CreateServiceTypeRequest, UpdateServiceTypeRequest } from '@vinny/services-types'; | |
| import { ConfigService } from '@nestjs/config'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| @Injectable() | |
| @@ -26,7 +26,7 @@ export class ServicesMsMigrationService { | |
| serviceTypeId: createService.serviceTypeId, | |
| }, | |
| ); | |
| - return objectStringId(); | |
| + return Types.ObjectId().toString(); | |
| } | |
| const servicesMsCreateRequest = await this.convertCatalogDtoToServicesDto(createService); | |
| diff --git a/apps/catalog-ms/src/services/test/services-catalog.controller.spec.ts b/apps/catalog-ms/src/services/test/services-catalog.controller.spec.ts | |
| index 91db8d064..2b2c36d46 100644 | |
| --- a/apps/catalog-ms/src/services/test/services-catalog.controller.spec.ts | |
| +++ b/apps/catalog-ms/src/services/test/services-catalog.controller.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test } from '@nestjs/testing'; | |
| import { INestApplication, ValidationPipe } from '@nestjs/common'; | |
| import request from 'supertest'; | |
| @@ -32,7 +32,6 @@ import { ServicesMsMigrationService } from '../services-ms-migration/services-ms | |
| import nock from 'nock'; | |
| import { KafkaProducerModule, KafkaProducerService } from '@vinny/kafka-client'; | |
| import { ServiceMilestonesService } from '../../service-milestones/service-milestones.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| type ServiceTypeResponse = CreateServiceTypeDto & { createdAt: Date; updatedAt: Date }; | |
| @@ -109,7 +108,7 @@ describe('ServicesCatalogController', () => { | |
| await request(app.getHttpServer()).post('/catalog/services').send(createPayload).expect(201); | |
| const addResourcePayload: UpdateServiceResourcesDto = { | |
| - serviceResources: [{ resourceKey: objectStringId() }], | |
| + serviceResources: [{ resourceKey: Types.ObjectId().toString() }], | |
| modifierId: newModifier, | |
| }; | |
| await request(app.getHttpServer()) | |
| @@ -141,7 +140,7 @@ describe('ServicesCatalogController', () => { | |
| }; | |
| await request(app.getHttpServer()).post('/catalog/services').send(createPayload).expect(201); | |
| - const resourceKey = objectStringId(); | |
| + const resourceKey = Types.ObjectId().toString(); | |
| const addResourcePayload: UpdateServiceResourcesDto = { | |
| modifierId: newModifier, | |
| serviceResources: [ | |
| @@ -171,7 +170,7 @@ describe('ServicesCatalogController', () => { | |
| }); | |
| it('should return 404 on service not found', async () => { | |
| - const notExistServicId = objectStringId(); | |
| + const notExistServicId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()).get(`/services/${notExistServicId}`).expect(404); | |
| }); | |
| @@ -180,7 +179,7 @@ describe('ServicesCatalogController', () => { | |
| describe('GET /catalog/services', () => { | |
| it('should return correct service according to filter', async () => { | |
| const serviceTypeId1 = serviceTypeId; | |
| - const serviceTypeId2 = objectStringId(); | |
| + const serviceTypeId2 = Types.ObjectId().toString(); | |
| const modifierId = origModifier; | |
| const createPayload1: CreateServiceTypeDto = { | |
| @@ -232,7 +231,7 @@ describe('ServicesCatalogController', () => { | |
| it('should return 409 on duplication of service id', async () => { | |
| const createPayload: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetailsWithCreatedBy, | |
| }; | |
| await request(app.getHttpServer()).post('/catalog/services').send(createPayload).expect(201); | |
| @@ -241,7 +240,7 @@ describe('ServicesCatalogController', () => { | |
| const anotherCreatePayload: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetailsWithCreatedBy, | |
| }; | |
| await request(app.getHttpServer()) | |
| @@ -296,7 +295,7 @@ describe('ServicesCatalogController', () => { | |
| const serviceMilestonesList = genMockServiceMilestonesList(serviceMilestonesPortions); | |
| const createPayload: CreateServiceTypeDto = { | |
| serviceTypeId: serviceTypeId, | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetailsWithCreatedBy, | |
| serviceMilestonesList, | |
| }; | |
| @@ -425,7 +424,7 @@ describe('ServicesCatalogController', () => { | |
| describe('POST /catalog/services with services-ms migration', () => { | |
| it('should create service in services-ms on service creation with not serviceTypeId', async () => { | |
| const createPayload: CreateServiceTypeDto = { | |
| - modifierId: objectStringId(), | |
| + modifierId: Types.ObjectId().toString(), | |
| ...extraServiceDetailsWithCreatedBy, | |
| }; | |
| createServiceTypeSpy = jest | |
| @@ -589,7 +588,7 @@ describe('ServicesCatalogController', () => { | |
| }; | |
| const createPayload: CreateServiceTypeDto = { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| modifierId: origModifier, | |
| ...extraServiceDetails, | |
| serviceMilestonesList: [serviceMilestoneItem], | |
| diff --git a/apps/catalog-ms/src/services/test/test-utils.ts b/apps/catalog-ms/src/services/test/test-utils.ts | |
| index 44357556e..34c79ed81 100644 | |
| --- a/apps/catalog-ms/src/services/test/test-utils.ts | |
| +++ b/apps/catalog-ms/src/services/test/test-utils.ts | |
| @@ -8,12 +8,12 @@ import { | |
| ServiceType, | |
| } from '@vinny/catalog-types'; | |
| import { v4 as uuidv4 } from 'uuid'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { mapServiceResourcesToObject } from '../dal/test/utils'; | |
| import { ServiceMilestoneItem, ServiceMetadata } from '@vinny/catalog-types'; | |
| import { getDefaultServiceMilestonesList } from '../utils'; | |
| -export const generalServiceMilestoneId = objectStringId(); | |
| +export const generalServiceMilestoneId = Types.ObjectId().toString(); | |
| export type extraServiceDetailsTypes = Pick< | |
| CreateServiceTypeDto, | |
| @@ -40,7 +40,7 @@ export function getExtraServiceDetails(): extraServiceDetailsTypes { | |
| isLastService: false, | |
| isAddendumProduct: false, | |
| firm: 'Marble', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| category: 'DIVORCE', | |
| description: { | |
| legalDescription: 'Mock Description', | |
| @@ -98,9 +98,9 @@ export const someMilestonePortionIsNotIntegerMessage = [ | |
| 'serviceMilestonesList.0.portion must be an integer number', | |
| 'serviceMilestonesList.1.portion must be an integer number', | |
| ]; | |
| -export const serviceTypeId = objectStringId(); | |
| -export const origModifier = objectStringId(); | |
| -export const newModifier = objectStringId(); | |
| +export const serviceTypeId = Types.ObjectId().toString(); | |
| +export const origModifier = Types.ObjectId().toString(); | |
| +export const newModifier = Types.ObjectId().toString(); | |
| export const genMockServiceMilestonesList = (milestonePortions: number[]): ServiceMilestoneItem[] => | |
| milestonePortions.reduce<ServiceMilestoneItem[]>((milestoneList, portion) => { | |
| return [ | |
| @@ -109,7 +109,7 @@ export const genMockServiceMilestonesList = (milestonePortions: number[]): Servi | |
| isOptional: true, | |
| isProofRequired: true, | |
| portion, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| steps: [ | |
| { name: 'step1', completionPercent: 50 }, | |
| { name: 'step2', completionPercent: 100 }, | |
| @@ -124,19 +124,19 @@ export const serviceMilestonesList = [ | |
| isOptional: true, | |
| isProofRequired: true, | |
| portion: 30, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| { | |
| isOptional: true, | |
| isProofRequired: true, | |
| portion: 40, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| }, | |
| { | |
| isOptional: true, | |
| isProofRequired: true, | |
| portion: 30, | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| steps: [ | |
| { name: 'step1', completionPercent: 50 }, | |
| { name: 'step2', completionPercent: 100 }, | |
| diff --git a/apps/communications-ms/src/communications/braze/tests/braze.controller.spec.ts b/apps/communications-ms/src/communications/braze/tests/braze.controller.spec.ts | |
| index 79d0c67e4..bf1983f1a 100644 | |
| --- a/apps/communications-ms/src/communications/braze/tests/braze.controller.spec.ts | |
| +++ b/apps/communications-ms/src/communications/braze/tests/braze.controller.spec.ts | |
| @@ -15,7 +15,7 @@ import { BrazeApiController } from '../braze.controller'; | |
| import { BrazeNotification } from '@vinny/communications-client'; | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { EventsHandlerController } from '../event-handler.controller'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| @@ -25,7 +25,6 @@ import { IDEMPOTENCY_KEY_HEADER } from '@vinny/idempotency'; | |
| import request from 'supertest'; | |
| import { INestApplication } from '@nestjs/common'; | |
| import { BrazeModule } from '../braze.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| let brazeNock: nock.Scope; | |
| @@ -251,7 +250,7 @@ describe('Braze controller', () => { | |
| .set(IDEMPOTENCY_KEY_HEADER, sameIdempotencyKey) | |
| .send({ | |
| event: BrazeNotification.DISENGAGEMENT_PROCESS_STARTED, | |
| - marbelId: objectStringId(), | |
| + marbelId: Types.ObjectId().toString(), | |
| }); | |
| await request(app.getHttpServer()) | |
| @@ -259,7 +258,7 @@ describe('Braze controller', () => { | |
| .set(IDEMPOTENCY_KEY_HEADER, sameIdempotencyKey) | |
| .send({ | |
| event: BrazeNotification.DISENGAGEMENT_PROCESS_STARTED, | |
| - marbelId: objectStringId(), | |
| + marbelId: Types.ObjectId().toString(), | |
| }); | |
| expect(sendMessageSpy).toHaveBeenCalledTimes(1); | |
| @@ -277,17 +276,17 @@ describe('Braze controller', () => { | |
| .set(IDEMPOTENCY_KEY_HEADER, 'idempotency_key') | |
| .send({ | |
| event: BrazeNotification.DISENGAGEMENT_PROCESS_STARTED, | |
| - marbelId: objectStringId(), | |
| + marbelId: Types.ObjectId().toString(), | |
| }); | |
| await request(app.getHttpServer()).post('/braze/send-message').send({ | |
| event: BrazeNotification.DISENGAGEMENT_PROCESS_STARTED, | |
| - marbelId: objectStringId(), | |
| + marbelId: Types.ObjectId().toString(), | |
| }); | |
| await request(app.getHttpServer()).post('/braze/send-message').send({ | |
| event: BrazeNotification.DISENGAGEMENT_PROCESS_STARTED, | |
| - marbelId: objectStringId(), | |
| + marbelId: Types.ObjectId().toString(), | |
| }); | |
| expect(sendMessageSpy).toHaveBeenCalledTimes(3); | |
| @@ -307,7 +306,7 @@ describe('Braze controller', () => { | |
| .set(IDEMPOTENCY_KEY_HEADER, idempotencyKey1) | |
| .send({ | |
| event: BrazeNotification.DISENGAGEMENT_PROCESS_STARTED, | |
| - marbelId: objectStringId(), | |
| + marbelId: Types.ObjectId().toString(), | |
| }); | |
| await request(app.getHttpServer()) | |
| @@ -315,7 +314,7 @@ describe('Braze controller', () => { | |
| .set(IDEMPOTENCY_KEY_HEADER, idempotencyKey2) | |
| .send({ | |
| event: BrazeNotification.DISENGAGEMENT_PROCESS_STARTED, | |
| - marbelId: objectStringId(), | |
| + marbelId: Types.ObjectId().toString(), | |
| }); | |
| expect(sendMessageSpy).toHaveBeenCalledTimes(2); | |
| diff --git a/apps/communications-ms/src/communications/braze/tests/braze.mocks.ts b/apps/communications-ms/src/communications/braze/tests/braze.mocks.ts | |
| index 540107d0b..6b2a1dfa4 100644 | |
| --- a/apps/communications-ms/src/communications/braze/tests/braze.mocks.ts | |
| +++ b/apps/communications-ms/src/communications/braze/tests/braze.mocks.ts | |
| @@ -12,7 +12,7 @@ import { | |
| VerificationIdentifierType, | |
| } from '@vinny/communications-client'; | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ConfigService } from '@nestjs/config'; | |
| import { KafkaEventDto, KafkaEventType } from '@vinny/kafka-client'; | |
| import { | |
| @@ -26,7 +26,7 @@ import { | |
| import { Role } from '@vinny/auth-types'; | |
| import { AttorneyOverallScore } from '@vinny/stats-types'; | |
| -const userId = objectStringId(); | |
| +const userId = Types.ObjectId().toString(); | |
| export const brazeCommunicationMockRequest: BrazeCommunicationRequestObject = { | |
| userId, | |
| @@ -40,7 +40,7 @@ export const brazeCommunicationMockRequest: BrazeCommunicationRequestObject = { | |
| lastName: 'Green', | |
| }; | |
| -export const userIdInboudSms = objectStringId(); | |
| +export const userIdInboudSms = Types.ObjectId().toString(); | |
| export const brazeInboundSmsMockRequest: BrazeSegmentInboundSmsRequest = { | |
| context: { | |
| @@ -62,7 +62,7 @@ export const brazeInboundSmsMockRequest: BrazeSegmentInboundSmsRequest = { | |
| export const brazePhoneVerificationCodeParams: BrazeMessageParams = { | |
| event: BrazeNotification.BRAZE_VERIFICATION_CODE, | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| properties: { | |
| destinationType: BrazeDestinationType.CUSTOMER, | |
| verificationMethod: VerificationIdentifierType.PHONE, | |
| @@ -72,38 +72,38 @@ export const brazePhoneVerificationCodeParams: BrazeMessageParams = { | |
| export const brazeCustomerLoginParams: BrazeMessageParams = { | |
| event: BrazeNotification.BRAZE_CUSTOMER_LOGIN, | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| properties: { | |
| loginUrl1: faker.internet.url(), | |
| }, | |
| }; | |
| export const loginCodeParams: BrazeLoginCodeEmailParams = { | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| code: faker.datatype.string(), | |
| }; | |
| export const loginCodeToAnonymoseParams: BrazeLoginCodeEmailToAnonymousProfileParams = { | |
| - brazeAlias: { name: objectStringId(), label: objectStringId() }, | |
| + brazeAlias: { name: Types.ObjectId().toString(), label: Types.ObjectId().toString() }, | |
| code: faker.datatype.string(), | |
| }; | |
| export const loginLinkParams: BrazeLoginLinkEmailParams = { | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| loginUrl1: faker.internet.url(), | |
| destinationType: BrazeDestinationType.CUSTOMER, | |
| }; | |
| export const loginLinkToAnonymoseParams: BrazeLoginLinkEmailToAnonymousProfileParams = { | |
| - brazeAlias: { name: objectStringId(), label: objectStringId() }, | |
| + brazeAlias: { name: Types.ObjectId().toString(), label: Types.ObjectId().toString() }, | |
| loginUrl1: faker.internet.url(), | |
| }; | |
| export const anonymousMessagewithTempMarbleId: BrazeAnonymousMessageParams = { | |
| event: BrazeNotification.CLOSED_WON_EVENT, | |
| - tempMarbleId: objectStringId(), | |
| + tempMarbleId: Types.ObjectId().toString(), | |
| brazeAlias: { | |
| - name: objectStringId(), | |
| - label: objectStringId(), | |
| + name: Types.ObjectId().toString(), | |
| + label: Types.ObjectId().toString(), | |
| }, | |
| properties: {}, | |
| }; | |
| @@ -118,7 +118,7 @@ export const anonymousMessageWithoutTempMarbleId: BrazeAnonymousMessageParams = | |
| }; | |
| export const caseUpdateEmailParams: BrazeCaseUpdateEmailParams = { | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| caseUpdateText: faker.lorem.sentences(2), | |
| }; | |
| @@ -136,8 +136,8 @@ export const ENV_VARS = { | |
| }; | |
| export const testUser: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| emailAlias: '[email protected]', | |
| phone: '19166237999', | |
| @@ -157,8 +157,8 @@ export const testUser: User = { | |
| }; | |
| export const testCustomer: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| phone: '19166237888', | |
| name: { | |
| @@ -177,8 +177,8 @@ export const testCustomer: User = { | |
| }; | |
| export const testCustomerUndefinedField: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| phone: '19166237888', | |
| name: { | |
| @@ -195,7 +195,7 @@ export const testCustomerUndefinedField: User = { | |
| }; | |
| export const testCustomerMissingMarbleId: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| marbleId: '', | |
| email: '[email protected]', | |
| phone: '19166237888', | |
| @@ -218,8 +218,8 @@ export const attorneyOverallScoreMock: AttorneyOverallScore = { | |
| }; | |
| export const testParalegalUser: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| phone: '19166237999', | |
| name: { | |
| @@ -233,8 +233,8 @@ export const testParalegalUser: User = { | |
| }; | |
| export const testExternalStaffUser: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| phone: '19166237999', | |
| name: { | |
| @@ -245,8 +245,8 @@ export const testExternalStaffUser: User = { | |
| }; | |
| export const testAttorneyAndParalegallUser: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| phone: '19166237999', | |
| name: { | |
| @@ -260,8 +260,8 @@ export const testAttorneyAndParalegallUser: User = { | |
| }; | |
| export const testUserWithStatus: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| phone: '19166237999', | |
| name: { | |
| @@ -278,8 +278,8 @@ export const testUserWithStatus: User = { | |
| }; | |
| export const testUserWithinHouse: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| phone: '19166237999', | |
| name: { | |
| @@ -297,8 +297,8 @@ export const testUserWithinHouse: User = { | |
| }; | |
| export const testCustomerUser: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| phone: '19166237999', | |
| name: { | |
| @@ -680,27 +680,27 @@ export const updateMessageObjectByInHouse = { | |
| }; | |
| export const practiceArea1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| displayName: 'PRACTICEAREA1', | |
| }; | |
| export const practiceArea2 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| displayName: 'PRACTICEAREA2', | |
| }; | |
| export const stateMock = { | |
| states: [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'NY', | |
| }, | |
| ], | |
| }; | |
| export const updateAttorneyPracticeAreasUser: User = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| name: { first: faker.name.firstName(), last: faker.name.lastName() }, | |
| email: faker.internet.email(), | |
| diff --git a/apps/communications-ms/src/communications/call/dal/schema/call.schema.ts b/apps/communications-ms/src/communications/call/dal/schema/call.schema.ts | |
| index 009c6b865..49ce53090 100644 | |
| --- a/apps/communications-ms/src/communications/call/dal/schema/call.schema.ts | |
| +++ b/apps/communications-ms/src/communications/call/dal/schema/call.schema.ts | |
| @@ -13,7 +13,7 @@ export class Call implements BaseCommunication { | |
| createdAt?: Date; | |
| updatedAt?: Date; | |
| - @Prop({ type: String, enum: Object.values(CallSource), index: true }) | |
| + @Prop({ type: String, enum: CallSource, index: true }) | |
| source?: string; | |
| @Prop() | |
| diff --git a/apps/communications-ms/src/communications/call/tests/utils.ts b/apps/communications-ms/src/communications/call/tests/utils.ts | |
| index 2d5884396..9020c17e7 100644 | |
| --- a/apps/communications-ms/src/communications/call/tests/utils.ts | |
| +++ b/apps/communications-ms/src/communications/call/tests/utils.ts | |
| @@ -2,7 +2,7 @@ import { CommunicationType, DirectionType } from '@vinny/communications-types'; | |
| import { CallDto } from '../dtos/call.dto'; | |
| import { CallSource } from '../types'; | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { CallDALService } from '../dal/call.dal'; | |
| import { CommunicationPointDalService } from '../../communicationspoint/dal/communicationpoint.dal'; | |
| import { CallDocument } from '../dal/schema/call.schema'; | |
| @@ -10,8 +10,8 @@ import { CallDocument } from '../dal/schema/call.schema'; | |
| export const internalUserPhone = faker.phone.phoneNumber(); | |
| export const externalUserPhone = faker.phone.phoneNumber(); | |
| export const internalUserEmail = faker.internet.email(); | |
| -export const fakeInternalUserId = objectStringId(); | |
| -export const fakeExternalUserId = objectStringId(); | |
| +export const fakeInternalUserId = Types.ObjectId().toString(); | |
| +export const fakeExternalUserId = Types.ObjectId().toString(); | |
| export const mockCallDto = ( | |
| sourceCallId: string, | |
| diff --git a/apps/communications-ms/src/communications/communication-data-bridge/tests/communication-data-bridge.controller.spec.ts b/apps/communications-ms/src/communications/communication-data-bridge/tests/communication-data-bridge.controller.spec.ts | |
| index 6fa063830..e0f21fac0 100644 | |
| --- a/apps/communications-ms/src/communications/communication-data-bridge/tests/communication-data-bridge.controller.spec.ts | |
| +++ b/apps/communications-ms/src/communications/communication-data-bridge/tests/communication-data-bridge.controller.spec.ts | |
| @@ -8,7 +8,7 @@ import { SmsDALService } from '../../sms/dal/sms.dal'; | |
| import { EmailMessagesDal } from '../../../proxy-email/email-messages/email-messages.dal'; | |
| import request from 'supertest'; | |
| import { CommunicationTicketService } from '../../communicationTicket/communicationTicket.service'; | |
| -import { connection } from 'mongoose'; | |
| +import { Types, connection } from 'mongoose'; | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { KafkaEventType, KafkaProducerService, KafkaTopics } from '@vinny/kafka-client'; | |
| import { CommunicationPointDalService } from '../../communicationspoint/dal/communicationpoint.dal'; | |
| @@ -24,7 +24,6 @@ import { olderThanTwentyFourHoursAgo } from './utils'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { CommunicationDataBridgeService } from '../communication-data-bridge.service'; | |
| import { createEmail } from '../../../proxy-email/email-messages/tests/utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| export const ENV_VARS = { | |
| USERS_MS_URL: 'https://users.es', | |
| @@ -95,9 +94,9 @@ describe('Communication Data Bridge Controller', () => { | |
| describe('list', () => { | |
| it('should return a list of communication points', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const customerId = objectStringId(); | |
| - const customerId2 = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const customerId = Types.ObjectId().toString(); | |
| + const customerId2 = Types.ObjectId().toString(); | |
| await createSms( | |
| attorneyId, | |
| customerId, | |
| @@ -161,7 +160,7 @@ describe('Communication Data Bridge Controller', () => { | |
| }); | |
| describe('send overdue email notification', () => { | |
| - const customerId = objectStringId(); | |
| + const customerId = Types.ObjectId().toString(); | |
| it('should send email kafka event', async () => { | |
| await createEmail( | |
| mockAttorney1.id.toString(), | |
| @@ -192,8 +191,8 @@ describe('Communication Data Bridge Controller', () => { | |
| describe('Test update operations', () => { | |
| it('resolve', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const customerId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const customerId = Types.ObjectId().toString(); | |
| await createSms( | |
| attorneyId, | |
| customerId, | |
| @@ -226,9 +225,9 @@ describe('Communication Data Bridge Controller', () => { | |
| it('delegate', async () => { | |
| const delegateSpy = jest.spyOn(communicationPointService, 'delegate'); | |
| - const attorneyId = objectStringId(); | |
| - const customerId = objectStringId(); | |
| - const delegatedId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const customerId = Types.ObjectId().toString(); | |
| + const delegatedId = Types.ObjectId().toString(); | |
| const internalNotes = faker.lorem.sentence(); | |
| await createSms( | |
| attorneyId, | |
| @@ -261,10 +260,10 @@ describe('Communication Data Bridge Controller', () => { | |
| it('delegate with custom customerId', async () => { | |
| const delegateSpy = jest.spyOn(communicationPointService, 'delegate'); | |
| - const attorneyId = objectStringId(); | |
| - const customerId = objectStringId(); | |
| - const customCustomerId = objectStringId(); | |
| - const delegatedId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const customerId = Types.ObjectId().toString(); | |
| + const customCustomerId = Types.ObjectId().toString(); | |
| + const delegatedId = Types.ObjectId().toString(); | |
| const internalNotes = faker.lorem.sentence(); | |
| await createSms( | |
| attorneyId, | |
| @@ -298,7 +297,7 @@ describe('Communication Data Bridge Controller', () => { | |
| describe('getUnresolvedCommunicationData', () => { | |
| it('sender id is not provided, should return only emails', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| await createSms( | |
| attorneyId, | |
| undefined, | |
| @@ -329,8 +328,8 @@ describe('Communication Data Bridge Controller', () => { | |
| }); | |
| it('Respond to unresolved communications', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const customerId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const customerId = Types.ObjectId().toString(); | |
| await createSms( | |
| attorneyId, | |
| customerId, | |
| @@ -402,8 +401,8 @@ describe('Communication Data Bridge Controller', () => { | |
| }); | |
| it('should filter out emails that the recipient is not in the `to` list', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const customerId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const customerId = Types.ObjectId().toString(); | |
| await createEmail( | |
| attorneyId, | |
| customerId, | |
| @@ -429,11 +428,11 @@ describe('Communication Data Bridge Controller', () => { | |
| }); | |
| it('should filter unresolved communication points by caseId', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const customerId1 = objectStringId(); | |
| - const customerId2 = objectStringId(); | |
| - const caseId1 = objectStringId(); | |
| - const caseId2 = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const customerId1 = Types.ObjectId().toString(); | |
| + const customerId2 = Types.ObjectId().toString(); | |
| + const caseId1 = Types.ObjectId().toString(); | |
| + const caseId2 = Types.ObjectId().toString(); | |
| await createSms( | |
| attorneyId, | |
| @@ -469,8 +468,8 @@ describe('Communication Data Bridge Controller', () => { | |
| describe('getById', () => { | |
| it('should return a communication point by id', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const customerId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const customerId = Types.ObjectId().toString(); | |
| await createSms( | |
| attorneyId, | |
| customerId, | |
| @@ -491,7 +490,7 @@ describe('Communication Data Bridge Controller', () => { | |
| }); | |
| it('should return nothing if the communication point does not exist', async () => { | |
| const result = await request(app.getHttpServer()) | |
| - .get(`/communication-data-bridge/${objectStringId()}`) | |
| + .get(`/communication-data-bridge/${Types.ObjectId().toString()}`) | |
| .expect(200); | |
| expect(result.body).toBeDefined(); | |
| expect(result.body.commId).toBeUndefined(); | |
| diff --git a/apps/communications-ms/src/communications/communicationTicket/communicationTicket.service.ts b/apps/communications-ms/src/communications/communicationTicket/communicationTicket.service.ts | |
| index 5ca430e8b..2bac8c37e 100644 | |
| --- a/apps/communications-ms/src/communications/communicationTicket/communicationTicket.service.ts | |
| +++ b/apps/communications-ms/src/communications/communicationTicket/communicationTicket.service.ts | |
| @@ -5,6 +5,7 @@ import { | |
| CommunicationTicket, | |
| CommunicationTicketDocument, | |
| } from './dal/schema/communicationTicket.schema'; | |
| +import { Types } from 'mongoose'; | |
| import { CreateCommunicationTicketRequestDto } from '@vinny/communications-types'; | |
| import { CommunicationPointService } from '../communicationspoint/communicationpoint.service'; | |
| import { CommunicationPointDto } from '@vinny/communications-client'; | |
| @@ -72,8 +73,8 @@ export class CommunicationTicketService { | |
| ): CommunicationTicket { | |
| return { | |
| ...communicationTicket, | |
| - createdByUserId: communicationTicket.createdByUserId, | |
| - assignee: communicationTicket.assignee, | |
| + createdByUserId: Types.ObjectId(communicationTicket.createdByUserId), | |
| + assignee: Types.ObjectId(communicationTicket.assignee), | |
| }; | |
| } | |
| } | |
| diff --git a/apps/communications-ms/src/communications/communicationTicket/dal/schema/communicationTicket.schema.ts b/apps/communications-ms/src/communications/communicationTicket/dal/schema/communicationTicket.schema.ts | |
| index 8e2e00296..d9327917b 100644 | |
| --- a/apps/communications-ms/src/communications/communicationTicket/dal/schema/communicationTicket.schema.ts | |
| +++ b/apps/communications-ms/src/communications/communicationTicket/dal/schema/communicationTicket.schema.ts | |
| @@ -1,10 +1,9 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { Document, Types } from 'mongoose'; | |
| import { CommunicationTicketSource } from '@vinny/communications-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| export type CommunicationTicketDocument = CommunicationTicket & Document; | |
| -@Schema({ _id: true, id: true, timestamps: true, toObject: { getters: true } }) | |
| +@Schema({ _id: true, id: true, timestamps: true }) | |
| export class CommunicationTicket { | |
| _id?: Types.ObjectId; | |
| id?: string; | |
| @@ -14,11 +13,11 @@ export class CommunicationTicket { | |
| @Prop({ type: String, enum: CommunicationTicketSource }) | |
| source?: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - assignee: string; | |
| + @Prop({ required: true }) | |
| + assignee: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - createdByUserId: string; | |
| + @Prop({ required: true }) | |
| + createdByUserId: Types.ObjectId; | |
| @Prop() | |
| description?: string; | |
| diff --git a/apps/communications-ms/src/communications/communicationTicket/dal/test/communicationTicket.dal.spec.ts b/apps/communications-ms/src/communications/communicationTicket/dal/test/communicationTicket.dal.spec.ts | |
| index 7de92e07c..bcc9ac5be 100644 | |
| --- a/apps/communications-ms/src/communications/communicationTicket/dal/test/communicationTicket.dal.spec.ts | |
| +++ b/apps/communications-ms/src/communications/communicationTicket/dal/test/communicationTicket.dal.spec.ts | |
| @@ -1,13 +1,12 @@ | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { CommunicationTicket } from '../schema/communicationTicket.schema'; | |
| import { CommunicationTicketDALService } from '../communicationTicket.dal'; | |
| import { CommunicationTicketSource } from '@vinny/communications-types'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| import { CommunicationTicketModule } from '../../communicationTicket.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('CommunicationTicketDALService', () => { | |
| let communicationTicketDalService: CommunicationTicketDALService; | |
| @@ -43,8 +42,8 @@ describe('CommunicationTicketDALService', () => { | |
| it('should successfully create CommunicationTickets', async () => { | |
| const communicationTicket: CommunicationTicket = { | |
| source: CommunicationTicketSource.SALESFORCE, | |
| - assignee: objectStringId(), | |
| - createdByUserId: objectStringId(), | |
| + assignee: Types.ObjectId(), | |
| + createdByUserId: Types.ObjectId(), | |
| subject: 'some subject', | |
| dueDate: new Date(), | |
| }; | |
| @@ -58,8 +57,8 @@ describe('CommunicationTicketDALService', () => { | |
| it('should successfully find CommunicationTickets by assignee', async () => { | |
| const communicationTicket: CommunicationTicket = { | |
| source: CommunicationTicketSource.SALESFORCE, | |
| - assignee: objectStringId(), | |
| - createdByUserId: objectStringId(), | |
| + assignee: Types.ObjectId(), | |
| + createdByUserId: Types.ObjectId(), | |
| subject: 'some subject', | |
| dueDate: new Date(), | |
| }; | |
| @@ -76,8 +75,8 @@ describe('CommunicationTicketDALService', () => { | |
| it('should successfully create CommunicationTickets without dueDate (optional)', async () => { | |
| const communicationTicket: CommunicationTicket = { | |
| source: CommunicationTicketSource.SALESFORCE, | |
| - assignee: objectStringId(), | |
| - createdByUserId: objectStringId(), | |
| + assignee: Types.ObjectId(), | |
| + createdByUserId: Types.ObjectId(), | |
| subject: 'some subject', | |
| }; | |
| const createdCommunicationTicket = | |
| diff --git a/apps/communications-ms/src/communications/communicationTicket/dal/types.ts b/apps/communications-ms/src/communications/communicationTicket/dal/types.ts | |
| index ec4e60050..1249d5686 100644 | |
| --- a/apps/communications-ms/src/communications/communicationTicket/dal/types.ts | |
| +++ b/apps/communications-ms/src/communications/communicationTicket/dal/types.ts | |
| @@ -1,4 +1,5 @@ | |
| +import { Types } from 'mongoose'; | |
| export interface FindCommunicationTicketFilter { | |
| - assignee?: string; | |
| - createdByUserId?: string; | |
| + assignee?: Types.ObjectId; | |
| + createdByUserId?: Types.ObjectId; | |
| } | |
| diff --git a/apps/communications-ms/src/communications/communicationTicket/test/communicationTicket.service.spec.ts b/apps/communications-ms/src/communications/communicationTicket/test/communicationTicket.service.spec.ts | |
| index e419e08e4..08767d4a3 100644 | |
| --- a/apps/communications-ms/src/communications/communicationTicket/test/communicationTicket.service.spec.ts | |
| +++ b/apps/communications-ms/src/communications/communicationTicket/test/communicationTicket.service.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, getLogger, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken, MongooseModule } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { CommunicationTicketDALService } from '../dal/communicationTicket.dal'; | |
| import { CommunicationTicketService } from '../communicationTicket.service'; | |
| @@ -19,7 +19,6 @@ import { KafkaProducerModule, KafkaProducerService } from '@vinny/kafka-client'; | |
| import { CommunicationPointService } from '../../communicationspoint/communicationpoint.service'; | |
| import { CommunicationPointModule } from '../../communicationspoint/communicationpoint.module'; | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('CommunicationTicketService', () => { | |
| let dal: CommunicationTicketDALService; | |
| @@ -88,8 +87,8 @@ describe('CommunicationTicketService', () => { | |
| it('should successfully create CommunicationTickets', async () => { | |
| const communicationTicket: CreateCommunicationTicketRequestDto = { | |
| source: CommunicationTicketSource.SALESFORCE, | |
| - assignee: objectStringId(), | |
| - createdByUserId: objectStringId(), | |
| + assignee: Types.ObjectId().toString(), | |
| + createdByUserId: Types.ObjectId().toString(), | |
| subject: 'some subject', | |
| dueDate: new Date(), | |
| }; | |
| @@ -109,8 +108,8 @@ describe('CommunicationTicketService', () => { | |
| it('should successfully create CommunicationTickets without dueDate (optional)', async () => { | |
| const communicationTicket: CreateCommunicationTicketRequestDto = { | |
| source: CommunicationTicketSource.SALESFORCE, | |
| - assignee: objectStringId(), | |
| - createdByUserId: objectStringId(), | |
| + assignee: Types.ObjectId().toString(), | |
| + createdByUserId: Types.ObjectId().toString(), | |
| subject: 'some subject', | |
| }; | |
| const createdCommunicationTicket = await controller.create(communicationTicket); | |
| diff --git a/apps/communications-ms/src/communications/communicationspoint/dal/communicationpoint.dal.ts b/apps/communications-ms/src/communications/communicationspoint/dal/communicationpoint.dal.ts | |
| index 511395cfb..a2fb59502 100644 | |
| --- a/apps/communications-ms/src/communications/communicationspoint/dal/communicationpoint.dal.ts | |
| +++ b/apps/communications-ms/src/communications/communicationspoint/dal/communicationpoint.dal.ts | |
| @@ -1,8 +1,8 @@ | |
| import { FlareLogger } from '@vinny/logger'; | |
| -import { Aggregate, FilterQuery, Model } from 'mongoose'; | |
| +import { Aggregate, FilterQuery, Model, Types } from 'mongoose'; | |
| import { CommunicationPoint, CommunicationPointDocument } from './schema/communicationpoint.schema'; | |
| -import { getAggregateQuery, objectId, schemaToDto } from '@vinny/helpers'; | |
| +import { getAggregateQuery, schemaToDto } from '@vinny/helpers'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { | |
| CommunicationPointDto, | |
| @@ -80,10 +80,10 @@ export class CommunicationPointDalService { | |
| const pipeline = [ | |
| { | |
| $match: { | |
| - recipientId: objectId(communicationPointUnresolvedRequest.attorneyId), | |
| + recipientId: Types.ObjectId(communicationPointUnresolvedRequest.attorneyId), | |
| isResolved: false, | |
| delegatedId: { $exists: false }, | |
| - ...(caseId && { caseId: objectId(caseId) }), | |
| + ...(caseId && { caseId: Types.ObjectId(caseId) }), | |
| $or: [ | |
| { | |
| type: CommunicationType.EmailMessage, | |
| @@ -187,12 +187,12 @@ export class CommunicationPointDalService { | |
| if (filter) { | |
| const { participants, recipientId, types } = filter; | |
| filterQuery = { | |
| - ...(recipientId && { recipientId: objectId(recipientId) }), | |
| + ...(recipientId && { recipientId: Types.ObjectId(recipientId) }), | |
| ...(types && { type: { $in: types } }), | |
| ...(participants && participants.length > 0 | |
| ? { | |
| $and: participants.map((id) => ({ | |
| - $or: [{ senderId: objectId(id) }, { recipientId: objectId(id) }], | |
| + $or: [{ senderId: Types.ObjectId(id) }, { recipientId: Types.ObjectId(id) }], | |
| })), | |
| } | |
| : {}), | |
| @@ -223,8 +223,8 @@ export class CommunicationPointDalService { | |
| const results = await this.model.aggregate([ | |
| { | |
| $match: { | |
| - caseId: { $in: caseIds.map((id) => objectId(id)) }, | |
| - recipientId: { $ne: objectId(attorneyId) }, | |
| + caseId: { $in: caseIds.map((id) => Types.ObjectId(id)) }, | |
| + recipientId: { $ne: Types.ObjectId(attorneyId) }, | |
| senderId: { $exists: true }, | |
| $or: [ | |
| { | |
| @@ -284,7 +284,7 @@ export class CommunicationPointDalService { | |
| totalOverdue: { $sum: 1 }, | |
| }, | |
| }, | |
| - { $project: { attorneyId: { $toString: '$_id' }, totalOverdue: 1, _id: 0 } }, | |
| + { $project: { attorneyId: '$_id', totalOverdue: 1, _id: 0 } }, | |
| ]); | |
| } | |
| } | |
| diff --git a/apps/communications-ms/src/communications/communicationspoint/dal/schema/communicationpoint.schema.ts b/apps/communications-ms/src/communications/communicationspoint/dal/schema/communicationpoint.schema.ts | |
| index 3dc8517f0..8cad3d89c 100644 | |
| --- a/apps/communications-ms/src/communications/communicationspoint/dal/schema/communicationpoint.schema.ts | |
| +++ b/apps/communications-ms/src/communications/communicationspoint/dal/schema/communicationpoint.schema.ts | |
| @@ -1,7 +1,7 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { CommunicationPointResolvedBy, CommunicationType } from '@vinny/communications-types'; | |
| -import { Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| import { Role } from '@vinny/auth-types'; | |
| @Schema({ _id: true, id: true, timestamps: true, toObject: { getters: true } }) | |
| @@ -14,22 +14,35 @@ export class CommunicationPoint { | |
| @Prop({ type: Date, required: true }) | |
| commCreatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true, index: true, unique: true })) | |
| + @Prop({ | |
| + required: true, | |
| + unique: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + index: true, | |
| + }) | |
| commId: string; | |
| - @Prop({ enum: Object.values(CommunicationType), type: String, require: true, index: true }) | |
| + @Prop({ type: CommunicationType, enum: CommunicationType, require: true, index: true }) | |
| type: CommunicationType; | |
| @Prop({ index: true }) | |
| source?: string; | |
| - @Prop(objectIdPropHandler()) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| senderId?: string; | |
| @Prop({ type: [{ type: String, enum: Role }] }) | |
| senderRoles?: Role[]; | |
| - @Prop(objectIdPropHandler({ index: true })) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + index: true, | |
| + }) | |
| recipientId?: string; | |
| @Prop({ type: [{ type: String, enum: Role }] }) | |
| @@ -38,7 +51,7 @@ export class CommunicationPoint { | |
| @Prop({ default: false }) | |
| isResolved: boolean; | |
| - @Prop({ enum: Object.values(CommunicationPointResolvedBy), type: String, required: false }) | |
| + @Prop({ enum: CommunicationPointResolvedBy, required: false, type: CommunicationPointResolvedBy }) | |
| resolvedBy?: CommunicationPointResolvedBy; | |
| @Prop() | |
| @@ -50,7 +63,7 @@ export class CommunicationPoint { | |
| @Prop() | |
| externalId?: string; | |
| - @Prop(objectIdPropHandler({ index: true, nullable: true })) | |
| + @Prop({ nullable: true, type: SchemaTypes.ObjectId, get: objectIdToStringGetter, index: true }) | |
| caseId?: string; | |
| @Prop({ type: Boolean, default: true }) | |
| diff --git a/apps/communications-ms/src/communications/communicationspoint/dal/test/communicationpoint.dal.spec.ts b/apps/communications-ms/src/communications/communicationspoint/dal/test/communicationpoint.dal.spec.ts | |
| index 672a04e75..3f8e47de6 100644 | |
| --- a/apps/communications-ms/src/communications/communicationspoint/dal/test/communicationpoint.dal.spec.ts | |
| +++ b/apps/communications-ms/src/communications/communicationspoint/dal/test/communicationpoint.dal.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { BaseCommunicationModule } from '../../../baseCommunication/baseCommunicationModule'; | |
| import { CommunicationPointDalService } from '../communicationpoint.dal'; | |
| @@ -8,7 +8,6 @@ import { CommunicationType } from '@vinny/communications-types'; | |
| import { generateCommunicationPointDto } from './utils'; | |
| import { CommunicationPointModule } from '../../communicationpoint.module'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('CommunicationPointDalService', () => { | |
| let communicationPointDalService: CommunicationPointDalService; | |
| @@ -57,7 +56,7 @@ describe('CommunicationPointDalService', () => { | |
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | |
| // @ts-ignore | |
| communicationPointDalService.create({ | |
| - commId: objectStringId(), | |
| + commId: Types.ObjectId().toHexString(), | |
| type: CommunicationType.EmailMessage, | |
| }), | |
| ).rejects.toThrow(); | |
| @@ -83,9 +82,9 @@ describe('CommunicationPointDalService', () => { | |
| }); | |
| it('Should fail to create multiple CommunicationPoints', async () => { | |
| const dtosArr = [ | |
| - { commId: objectStringId(), type: CommunicationType.EmailMessage }, | |
| - { commId: objectStringId(), type: CommunicationType.SMS }, | |
| - { commId: objectStringId(), type: CommunicationType.Call }, | |
| + { commId: Types.ObjectId().toHexString(), type: CommunicationType.EmailMessage }, | |
| + { commId: Types.ObjectId().toHexString(), type: CommunicationType.SMS }, | |
| + { commId: Types.ObjectId().toHexString(), type: CommunicationType.Call }, | |
| ]; | |
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | |
| // @ts-ignore | |
| diff --git a/apps/communications-ms/src/communications/communicationspoint/dal/test/utils.ts b/apps/communications-ms/src/communications/communicationspoint/dal/test/utils.ts | |
| index 6582924b3..aa2eb6d6a 100644 | |
| --- a/apps/communications-ms/src/communications/communicationspoint/dal/test/utils.ts | |
| +++ b/apps/communications-ms/src/communications/communicationspoint/dal/test/utils.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { CommunicationPointDto } from '@vinny/communications-client'; | |
| import { CommunicationType } from '@vinny/communications-types'; | |
| @@ -6,7 +6,7 @@ export const generateCommunicationPointDto = (numInstances: number): Communicati | |
| const communicationPointDtos: CommunicationPointDto[] = []; | |
| for (let i = 0; i < numInstances; i++) { | |
| const communicationPointDto: CommunicationPointDto = { | |
| - commId: objectStringId(), | |
| + commId: Types.ObjectId().toHexString(), | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.EmailMessage, | |
| }; | |
| diff --git a/apps/communications-ms/src/communications/communicationspoint/test/communicationpoint.controller.spec.ts b/apps/communications-ms/src/communications/communicationspoint/test/communicationpoint.controller.spec.ts | |
| index d7a1155bc..adb9c21d4 100644 | |
| --- a/apps/communications-ms/src/communications/communicationspoint/test/communicationpoint.controller.spec.ts | |
| +++ b/apps/communications-ms/src/communications/communicationspoint/test/communicationpoint.controller.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import request from 'supertest'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { INestApplication, ValidationPipe } from '@nestjs/common'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { CommunicationPointController } from '../communicationpoint.controller'; | |
| @@ -14,7 +14,6 @@ import { Role } from '@vinny/auth-types'; | |
| import { CommunicationPointDalService } from '../dal/communicationpoint.dal'; | |
| import { CommunicationPointService } from '../communicationpoint.service'; | |
| import { generateObjectIds, generateRandomDates } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| export const ENV_VARS = { | |
| USERS_MS_URL: 'https://users.es', | |
| @@ -22,7 +21,7 @@ export const ENV_VARS = { | |
| }; | |
| export const mockAttorney1: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| address: { | |
| street: faker.address.streetName(), | |
| state: faker.address.state(), | |
| @@ -35,7 +34,7 @@ export const mockAttorney1: User = { | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| describe('Communication Point Controller', () => { | |
| @@ -93,15 +92,15 @@ describe('Communication Point Controller', () => { | |
| describe('Create', () => { | |
| it('should create a communication point', async () => { | |
| - const objectId = objectStringId(); | |
| + const objectId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .post('/communication-point') | |
| .send({ | |
| commId: objectId, | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.EmailMessage, | |
| - recipientId: objectStringId(), | |
| - senderId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| + senderId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| }) | |
| .expect(201); | |
| @@ -115,15 +114,15 @@ describe('Communication Point Controller', () => { | |
| }); | |
| it('should fail to create a communication point with invalid type', async () => { | |
| - const objectId = objectStringId(); | |
| + const objectId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .post('/communication-point') | |
| .send({ | |
| commId: objectId, | |
| commCreatedAt: new Date(), | |
| commType: 'invalid', | |
| - recipientId: objectStringId(), | |
| - senderId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| + senderId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| }) | |
| .expect(400); | |
| @@ -131,10 +130,10 @@ describe('Communication Point Controller', () => { | |
| }); | |
| it('create several communications points', async () => { | |
| - const objectId1 = objectStringId(); | |
| - const objectId2 = objectStringId(); | |
| - const objectId3 = objectStringId(); | |
| - const recipientId = objectStringId(); | |
| + const objectId1 = Types.ObjectId().toString(); | |
| + const objectId2 = Types.ObjectId().toString(); | |
| + const objectId3 = Types.ObjectId().toString(); | |
| + const recipientId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .post('/communication-point/bulk') | |
| .send([ | |
| @@ -143,28 +142,28 @@ describe('Communication Point Controller', () => { | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.EmailMessage, | |
| recipientId, | |
| - senderId: objectStringId(), | |
| + senderId: Types.ObjectId().toString(), | |
| }, | |
| { | |
| commId: objectId2, | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.Call, | |
| recipientId, | |
| - senderId: objectStringId(), | |
| + senderId: Types.ObjectId().toString(), | |
| }, | |
| { | |
| commId: objectId3, | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.SMS, | |
| recipientId, | |
| - senderId: objectStringId(), | |
| + senderId: Types.ObjectId().toString(), | |
| }, | |
| { | |
| - commId: objectStringId(), | |
| + commId: Types.ObjectId().toString(), | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.EmailMessage, | |
| recipientId, | |
| - senderId: objectStringId(), | |
| + senderId: Types.ObjectId().toString(), | |
| isResolved: true, | |
| }, | |
| ]) | |
| @@ -206,7 +205,7 @@ describe('Communication Point Controller', () => { | |
| .expect(201); | |
| }); | |
| it('kafka event was sent', async () => { | |
| - const objectId1 = objectStringId(); | |
| + const objectId1 = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .post('/communication-point/bulk') | |
| .send([ | |
| @@ -215,7 +214,7 @@ describe('Communication Point Controller', () => { | |
| commCreatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 24 * 3), | |
| type: CommunicationType.EmailMessage, | |
| recipientId: mockAttorney1.id, | |
| - senderId: objectStringId(), | |
| + senderId: Types.ObjectId().toString(), | |
| }, | |
| ]) | |
| .expect(201); | |
| @@ -225,7 +224,7 @@ describe('Communication Point Controller', () => { | |
| expect(emitSpy).toBeCalledWith( | |
| KafkaTopics.OVERDUE_COMMUNICATION_EMAIL, | |
| expect.objectContaining({ | |
| - key: mockAttorney1.id, | |
| + key: Types.ObjectId(mockAttorney1.id), | |
| }), | |
| ); | |
| }); | |
| @@ -233,15 +232,15 @@ describe('Communication Point Controller', () => { | |
| describe('Update', () => { | |
| it('should resolve and unresolve a communication point', async () => { | |
| - const objectId = objectStringId(); | |
| + const objectId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .post('/communication-point') | |
| .send({ | |
| commId: objectId, | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.EmailMessage, | |
| - recipientId: objectStringId(), | |
| - senderId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| + senderId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| }) | |
| .expect(201); | |
| @@ -276,8 +275,8 @@ describe('Communication Point Controller', () => { | |
| commId: 'objectId', | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.Ticket, | |
| - recipientId: objectStringId(), | |
| - senderId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| + senderId: Types.ObjectId().toString(), | |
| isResolved: false, | |
| }); | |
| @@ -294,8 +293,8 @@ describe('Communication Point Controller', () => { | |
| commId: 'objectId', | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.Ticket, | |
| - recipientId: objectStringId(), | |
| - senderId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| + senderId: Types.ObjectId().toString(), | |
| isResolved: false, | |
| }); | |
| @@ -308,16 +307,16 @@ describe('Communication Point Controller', () => { | |
| }); | |
| it('should mark communication point delegation handled with externalId', async () => { | |
| - const objectId = objectStringId(); | |
| - const externalId = objectStringId(); | |
| + const objectId = Types.ObjectId().toString(); | |
| + const externalId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .post('/communication-point') | |
| .send({ | |
| commId: objectId, | |
| commCreatedAt: new Date(), | |
| type: CommunicationType.EmailMessage, | |
| - recipientId: objectStringId(), | |
| - senderId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| + senderId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| }) | |
| .expect(201); | |
| @@ -339,7 +338,7 @@ describe('Communication Point Controller', () => { | |
| describe('FindLastInformedForCaseIds', () => { | |
| it('should return last informed date for case ids', async () => { | |
| const objectIds = generateObjectIds(4); | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const caseIds = generateObjectIds(4); | |
| const dates = generateRandomDates(4); | |
| await request(app.getHttpServer()) | |
| @@ -349,7 +348,7 @@ describe('Communication Point Controller', () => { | |
| commId: objectIds[0], | |
| commCreatedAt: dates[0], | |
| type: CommunicationType.EmailMessage, | |
| - recipientId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| senderId: attorneyId, | |
| caseId: caseIds[0], | |
| }, | |
| @@ -357,7 +356,7 @@ describe('Communication Point Controller', () => { | |
| commId: objectIds[1], | |
| commCreatedAt: dates[1], | |
| type: CommunicationType.Call, | |
| - recipientId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| senderId: attorneyId, | |
| caseId: caseIds[1], | |
| }, | |
| @@ -365,7 +364,7 @@ describe('Communication Point Controller', () => { | |
| commId: objectIds[2], | |
| commCreatedAt: dates[2], | |
| type: CommunicationType.SMS, | |
| - recipientId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| senderId: attorneyId, | |
| caseId: caseIds[2], | |
| }, | |
| @@ -373,7 +372,7 @@ describe('Communication Point Controller', () => { | |
| commId: objectIds[3], | |
| commCreatedAt: dates[3], | |
| type: CommunicationType.Call, | |
| - recipientId: objectStringId(), | |
| + recipientId: Types.ObjectId().toString(), | |
| senderId: attorneyId, | |
| isResolved: true, | |
| caseId: caseIds[3], | |
| diff --git a/apps/communications-ms/src/communications/sms-magic/test/consts.ts b/apps/communications-ms/src/communications/sms-magic/test/consts.ts | |
| index 5dcc06e0b..62cc84221 100644 | |
| --- a/apps/communications-ms/src/communications/sms-magic/test/consts.ts | |
| +++ b/apps/communications-ms/src/communications/sms-magic/test/consts.ts | |
| @@ -1,12 +1,12 @@ | |
| import { DirectionType } from '@vinny/communications-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { SmsMagicSmsRequest } from '../types'; | |
| export const agentPhone = '0123456789'; | |
| export const customerPhone = '0987654321'; | |
| export const smsMagicInboundSmsRequestMock = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| sent_from: customerPhone, | |
| sent_to: agentPhone, | |
| msg: 'hello world', | |
| @@ -14,7 +14,7 @@ export const smsMagicInboundSmsRequestMock = { | |
| }; | |
| export const smsMagicOutboundSmsRequestMock: SmsMagicSmsRequest = { | |
| - sourceSmsId: objectStringId(), | |
| + sourceSmsId: Types.ObjectId().toString(), | |
| internalUserPhone: agentPhone, | |
| externalUserPhone: customerPhone, | |
| direction: DirectionType.OUTBOUND, | |
| diff --git a/apps/communications-ms/src/communications/sms/dal/schema/sms.schema.ts b/apps/communications-ms/src/communications/sms/dal/schema/sms.schema.ts | |
| index 0d4e57799..e8c934047 100644 | |
| --- a/apps/communications-ms/src/communications/sms/dal/schema/sms.schema.ts | |
| +++ b/apps/communications-ms/src/communications/sms/dal/schema/sms.schema.ts | |
| @@ -10,7 +10,7 @@ export class Sms implements BaseCommunication { | |
| createdAt?: Date; | |
| id?: string; | |
| - @Prop({ type: String, enum: Object.values(SmsSource), index: true }) | |
| + @Prop({ type: String, enum: SmsSource, index: true }) | |
| source?: string; | |
| @Prop() | |
| diff --git a/apps/communications-ms/src/communications/sms/dal/test/sms.dal.spec.ts b/apps/communications-ms/src/communications/sms/dal/test/sms.dal.spec.ts | |
| index 3d88e7cd9..f1d75215d 100644 | |
| --- a/apps/communications-ms/src/communications/sms/dal/test/sms.dal.spec.ts | |
| +++ b/apps/communications-ms/src/communications/sms/dal/test/sms.dal.spec.ts | |
| @@ -1,13 +1,12 @@ | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { SmsDALService } from '../sms.dal'; | |
| import { getSegmentClient, SegmentClient } from '@marbletech/segment-client'; | |
| import { SmsSource } from '@vinny/communications-types'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| import { SmsModule } from '../../sms.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('SmsDalService', () => { | |
| let smsDalService: SmsDALService; | |
| @@ -38,7 +37,7 @@ describe('SmsDalService', () => { | |
| describe('compound unique index: source & sourceSmsId', () => { | |
| it('should throw an error when trying to create a document with identical source and sourceSmsId', async () => { | |
| - const smsDtoId = objectStringId(); | |
| + const smsDtoId = Types.ObjectId().toString(); | |
| await expect( | |
| smsDalService.create({ | |
| diff --git a/apps/communications-ms/src/communications/userContact/dal/schema/userContact.schema.ts b/apps/communications-ms/src/communications/userContact/dal/schema/userContact.schema.ts | |
| index ff5fbc5ce..cb88396d4 100644 | |
| --- a/apps/communications-ms/src/communications/userContact/dal/schema/userContact.schema.ts | |
| +++ b/apps/communications-ms/src/communications/userContact/dal/schema/userContact.schema.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| @Schema({ _id: true, id: true, timestamps: true, toObject: { getters: true } }) | |
| export class UserContact { | |
| @@ -9,7 +9,13 @@ export class UserContact { | |
| createdAt?: Date; | |
| updatedAt?: Date; | |
| - @Prop(objectIdPropHandler({ required: true, index: true, unique: true })) | |
| + @Prop({ | |
| + required: true, | |
| + unique: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + index: true, | |
| + }) | |
| userId: string; | |
| @Prop({ type: [String], require: true }) | |
| diff --git a/apps/communications-ms/src/communications/userContact/test/userContact.service.spec.ts b/apps/communications-ms/src/communications/userContact/test/userContact.service.spec.ts | |
| index 07beaab35..53a6c12e3 100644 | |
| --- a/apps/communications-ms/src/communications/userContact/test/userContact.service.spec.ts | |
| +++ b/apps/communications-ms/src/communications/userContact/test/userContact.service.spec.ts | |
| @@ -9,7 +9,7 @@ import { rootMongooseTestModule } from '@vinny/test-utils'; | |
| import normalize from 'normalize-mongoose'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| describe('UserContactService', () => { | |
| let userContactService: UserContactService; | |
| @@ -48,7 +48,7 @@ describe('UserContactService', () => { | |
| describe('create', () => { | |
| it('should create a new user contact', async () => { | |
| const userContactDto: UserContactDto = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toHexString(), | |
| contacts: ['contact1', 'contact2'], | |
| }; | |
| @@ -60,7 +60,7 @@ describe('UserContactService', () => { | |
| }); | |
| it('should fail to create a new user contact if this user already exists', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toHexString(); | |
| const userContactDto: UserContactDto = { | |
| userId, | |
| contacts: ['contact1', 'contact2'], | |
| @@ -78,10 +78,10 @@ describe('UserContactService', () => { | |
| describe('updateContacts', () => { | |
| it('should create a new user contact if it does not exist', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toHexString(); | |
| const userContacts = await userContactDalService.findOne(userId); | |
| expect(userContacts).toBeNull(); | |
| - const contactId = objectStringId(); | |
| + const contactId = Types.ObjectId().toHexString(); | |
| const updatedUserContact = await userContactService.updateContacts(userId, contactId); | |
| @@ -90,8 +90,8 @@ describe('UserContactService', () => { | |
| expect(updatedUserContact?.contacts).toContain(contactId); | |
| }); | |
| it('should update the contacts of a user', async () => { | |
| - const userId = objectStringId(); | |
| - const newContactId = objectStringId(); | |
| + const userId = Types.ObjectId().toHexString(); | |
| + const newContactId = Types.ObjectId().toHexString(); | |
| const updatedUserContact = await userContactService.updateContacts(userId, newContactId); | |
| @@ -99,7 +99,7 @@ describe('UserContactService', () => { | |
| expect(updatedUserContact?.userId).toEqual(userId); | |
| expect(updatedUserContact?.contacts).toContain(newContactId); | |
| - const newContactId2 = objectStringId(); | |
| + const newContactId2 = Types.ObjectId().toHexString(); | |
| const updatedUserContact2 = await userContactService.updateContacts(userId, newContactId2); | |
| @@ -110,7 +110,7 @@ describe('UserContactService', () => { | |
| describe('findOne', () => { | |
| it('should find a user contact by user ID', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toHexString(); | |
| await userContactService.create({ | |
| userId, | |
| @@ -123,7 +123,7 @@ describe('UserContactService', () => { | |
| }); | |
| it('should return null if user contact is not found', async () => { | |
| - const nonExistingUserId = objectStringId(); | |
| + const nonExistingUserId = Types.ObjectId().toHexString(); | |
| const foundUserContact = await userContactService.findOne(nonExistingUserId); | |
| diff --git a/apps/communications-ms/src/proxy-email/email-messages/email-messages.dal.ts b/apps/communications-ms/src/proxy-email/email-messages/email-messages.dal.ts | |
| index abfaf797b..37f5452b5 100644 | |
| --- a/apps/communications-ms/src/proxy-email/email-messages/email-messages.dal.ts | |
| +++ b/apps/communications-ms/src/proxy-email/email-messages/email-messages.dal.ts | |
| @@ -6,8 +6,8 @@ import { | |
| EmailMessagesResultsList, | |
| ListEmailMessagesDto, | |
| } from '@vinny/communications-types'; | |
| -import { getAggregateQuery, objectId } from '@vinny/helpers'; | |
| -import { Model } from 'mongoose'; | |
| +import { getAggregateQuery } from '@vinny/helpers'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { EmailMessage, EmailMessageDocument } from './schema/email-messages.schema'; | |
| @Injectable() | |
| @@ -30,7 +30,7 @@ export class EmailMessagesDal { | |
| const { filter, pagination, sort } = payload; | |
| const filterQuery: Record<string, any> = { isDeliveryFailed: { $exists: false } }; | |
| if (filter?.caseId) { | |
| - filterQuery.caseId = objectId(filter.caseId); | |
| + filterQuery.caseId = Types.ObjectId(filter.caseId); | |
| } | |
| const aggregatedQuery = getAggregateQuery({ | |
| filter: filterQuery, | |
| diff --git a/apps/communications-ms/src/proxy-email/email-messages/schema/email-messages.schema.ts b/apps/communications-ms/src/proxy-email/email-messages/schema/email-messages.schema.ts | |
| index 4d0510796..40cf21110 100644 | |
| --- a/apps/communications-ms/src/proxy-email/email-messages/schema/email-messages.schema.ts | |
| +++ b/apps/communications-ms/src/proxy-email/email-messages/schema/email-messages.schema.ts | |
| @@ -1,14 +1,18 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { Role } from '@vinny/auth-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| -import { Document, Types } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| import { EmailSources } from '@vinny/communications-types'; | |
| export type EmailMessageDocument = EmailMessage & Document; | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class AttachmentData { | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| documentId: string; | |
| @Prop({ | |
| @@ -51,7 +55,12 @@ export class EmailMessage { | |
| }) | |
| emailMessageId?: string; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + required: false, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + index: true, | |
| + }) | |
| caseId?: string; | |
| @Prop({ | |
| @@ -75,25 +84,32 @@ export class EmailMessage { | |
| }) | |
| to: string[]; | |
| - @Prop(objectIdPropHandler()) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| senderUserId?: string; | |
| @Prop({ | |
| - enum: Object.values(Role), | |
| type: String, | |
| + enum: Role, | |
| }) | |
| senderRole?: Role; | |
| @Prop({ required: true }) | |
| recipientEmail: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| recipientUserId: string; | |
| @Prop({ | |
| required: true, | |
| type: String, | |
| - enum: Object.values(Role), | |
| + enum: Role, | |
| }) | |
| recipientRole: Role; | |
| @@ -124,7 +140,7 @@ export class EmailMessage { | |
| @Prop({ required: false, index: true }) | |
| isDeliveryFailed?: boolean; | |
| - @Prop({ required: false, enum: Object.values(EmailSources), type: String }) | |
| + @Prop({ required: false, enum: EmailSources, type: EmailSources }) | |
| source?: EmailSources; | |
| } | |
| diff --git a/apps/communications-ms/src/proxy-email/email-messages/tests/utils.ts b/apps/communications-ms/src/proxy-email/email-messages/tests/utils.ts | |
| index db526f857..c507fd00a 100644 | |
| --- a/apps/communications-ms/src/proxy-email/email-messages/tests/utils.ts | |
| +++ b/apps/communications-ms/src/proxy-email/email-messages/tests/utils.ts | |
| @@ -19,7 +19,7 @@ import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| import { CommunicationPointModule } from '../../../communications/communicationspoint/communicationpoint.module'; | |
| import { EmailMessagesDal } from '../email-messages.dal'; | |
| import { CommunicationPointDalService } from '../../../communications/communicationspoint/dal/communicationpoint.dal'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { AttachmentDto } from '@vinny/communications-client'; | |
| export const createEmailMessagesTestModule = () => { | |
| @@ -135,8 +135,8 @@ export async function createEmail( | |
| ): Promise<EmailMessageDto> { | |
| const emailAddress = faker.internet.email(); | |
| const email = await emailDALService.create({ | |
| - messageId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + messageId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| createdAt: createdAt, | |
| subject: subject || 'subject', | |
| textContent: content || 'content', | |
| diff --git a/apps/data-collection-ms/src/data-points/data-points.controller.e2e.spec.ts b/apps/data-collection-ms/src/data-points/data-points.controller.e2e.spec.ts | |
| index be310c04e..70f4bce52 100644 | |
| --- a/apps/data-collection-ms/src/data-points/data-points.controller.e2e.spec.ts | |
| +++ b/apps/data-collection-ms/src/data-points/data-points.controller.e2e.spec.ts | |
| @@ -29,7 +29,7 @@ import { | |
| SchemaProperties, | |
| } from '@vinny/data-collection-test-utils'; | |
| import { closeInMongodConnection, rootMongooseTestModule } from '@vinny/test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| const mockEnvVars = { | |
| USERS_MS_URL: 'https://users-ms.flare.com', | |
| @@ -531,7 +531,7 @@ describe('Data Points Controller', () => { | |
| }); | |
| describe('documents', () => { | |
| it('should succeed adding document data points', async () => { | |
| - const documentTypeId = objectStringId(); | |
| + const documentTypeId = Types.ObjectId().toString(); | |
| catalogNock | |
| .get(`/catalog/documents/${documentTypeId}`) | |
| .reply(200, { id: documentTypeId }); | |
| @@ -563,7 +563,7 @@ describe('Data Points Controller', () => { | |
| .expect(200); | |
| }); | |
| it('should succeed adding document data points on a nested object', async () => { | |
| - const documentTypeId = objectStringId(); | |
| + const documentTypeId = Types.ObjectId().toString(); | |
| catalogNock | |
| .get(`/catalog/documents/${documentTypeId}`) | |
| .reply(200, { id: documentTypeId }); | |
| diff --git a/apps/data-collection-ms/src/data-schemas/dal/data-schema.dal.ts b/apps/data-collection-ms/src/data-schemas/dal/data-schema.dal.ts | |
| index 039b2a505..efeca9105 100644 | |
| --- a/apps/data-collection-ms/src/data-schemas/dal/data-schema.dal.ts | |
| +++ b/apps/data-collection-ms/src/data-schemas/dal/data-schema.dal.ts | |
| @@ -1,7 +1,7 @@ | |
| import { HttpException, Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { DataSchema } from './schema/data-schema.schema'; | |
| import { | |
| CreateDataSchemaDto, | |
| @@ -10,7 +10,6 @@ import { | |
| } from '@vinny/data-collection-types'; | |
| import { plainToInstance } from 'class-transformer'; | |
| import mongoose from 'mongoose'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class DataSchemaDal { | |
| @@ -38,7 +37,7 @@ export class DataSchemaDal { | |
| try { | |
| return convertMongoSchemaToDto( | |
| await this.dataSchemasModel.findByIdAndUpdate( | |
| - objectId(id), | |
| + Types.ObjectId(id), | |
| { | |
| ...dataSchemaRequest, | |
| dataSchema: JSON.stringify(dataSchemaRequest.schema), | |
| diff --git a/apps/data-collection-ms/src/data-schemas/data-schemas.controller.e2e.spec.ts b/apps/data-collection-ms/src/data-schemas/data-schemas.controller.e2e.spec.ts | |
| index cb4c30af7..19d222992 100644 | |
| --- a/apps/data-collection-ms/src/data-schemas/data-schemas.controller.e2e.spec.ts | |
| +++ b/apps/data-collection-ms/src/data-schemas/data-schemas.controller.e2e.spec.ts | |
| @@ -10,7 +10,7 @@ import { MongooseModule, MongooseModuleOptions } from '@nestjs/mongoose'; | |
| import { closeInMongodConnection, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import { DataSchema, DataSchemaSchema } from './dal/schema/data-schema.schema'; | |
| import faker from '@faker-js/faker'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { MockConfigService } from '@vinny/test-utils'; | |
| import { camelCase, capitalize, cloneDeep } from 'lodash'; | |
| @@ -51,7 +51,6 @@ import { | |
| noKeysErrorDetails, | |
| noKeysErrorMessage, | |
| } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const mockEnvVars: Record<string, string> = { | |
| CATALOG_MS_URL: 'https://ca.ta.log', | |
| @@ -760,7 +759,7 @@ describe('Data Schemas Controller', () => { | |
| describe('Update data schema documents', () => { | |
| describe('Valid requests', () => { | |
| - const documentTypeId = objectStringId(); | |
| + const documentTypeId = Types.ObjectId().toString(); | |
| const documentTypeName = faker.datatype.string(); | |
| let dataSchemaId: string | undefined, documentTypeResponse: nock.Scope; | |
| beforeEach(async () => { | |
| @@ -1102,7 +1101,7 @@ describe('Data Schemas Controller', () => { | |
| }); | |
| }); | |
| describe('documents', () => { | |
| - const documentTypeId = objectStringId(); | |
| + const documentTypeId = Types.ObjectId().toString(); | |
| describe('Valid Requests', () => { | |
| it('flare_document specified and document type exists - success', async () => { | |
| const documentTypeResponse = catalogMsNock | |
| @@ -1172,7 +1171,7 @@ describe('Data Schemas Controller', () => { | |
| }); | |
| describe('Invalid Requests', () => { | |
| it('flare_document specified and one document type exists and one isnt - failure', async () => { | |
| - const notExistingDocumentTypeId = objectStringId(); | |
| + const notExistingDocumentTypeId = Types.ObjectId().toString(); | |
| const documentTypeResponse = catalogMsNock | |
| .get(`/catalog/documents/${documentTypeId}`) | |
| .reply(200, { id: documentTypeId }); | |
| diff --git a/apps/data-collection-ms/src/forms/@haggholm/is-json-schema-subset/is-json-schema-subset.ts b/apps/data-collection-ms/src/forms/@haggholm/is-json-schema-subset/is-json-schema-subset.ts | |
| index b0c238754..30c30eccd 100644 | |
| --- a/apps/data-collection-ms/src/forms/@haggholm/is-json-schema-subset/is-json-schema-subset.ts | |
| +++ b/apps/data-collection-ms/src/forms/@haggholm/is-json-schema-subset/is-json-schema-subset.ts | |
| @@ -266,23 +266,23 @@ function getArrayErrors( | |
| const inputMinItems = hasOwnProperty.call(input, 'minItems') | |
| ? input.minItems | |
| : Array.isArray(input.items) | |
| - ? input.items.length | |
| - : null; | |
| + ? input.items.length | |
| + : null; | |
| const targetMinItems = hasOwnProperty.call(target, 'minItems') | |
| ? target.minItems | |
| : Array.isArray(target.items) | |
| - ? target.items.length | |
| - : null; | |
| + ? target.items.length | |
| + : null; | |
| const inputMaxItems = hasOwnProperty.call(input, 'maxItems') | |
| ? input.maxItems | |
| : Array.isArray(input.items) | |
| - ? input.items.length | |
| - : null; | |
| + ? input.items.length | |
| + : null; | |
| const targetMaxItems = hasOwnProperty.call(target, 'maxItems') | |
| ? target.maxItems | |
| : Array.isArray(target.items) | |
| - ? target.items.length | |
| - : null; | |
| + ? target.items.length | |
| + : null; | |
| if (targetMinItems !== null) { | |
| if (inputMinItems === null) { | |
| diff --git a/apps/data-collection-ms/src/forms/dal/forms.dal.ts b/apps/data-collection-ms/src/forms/dal/forms.dal.ts | |
| index a39e13ae5..1e822fb73 100644 | |
| --- a/apps/data-collection-ms/src/forms/dal/forms.dal.ts | |
| +++ b/apps/data-collection-ms/src/forms/dal/forms.dal.ts | |
| @@ -1,12 +1,11 @@ | |
| import { HttpException, Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { CreateFormDto, FormDto, UpdateFormDto } from '@vinny/data-collection-types'; | |
| import { plainToInstance } from 'class-transformer'; | |
| import mongoose from 'mongoose'; | |
| import { Form } from './schema/forms.schema'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class FormsDal { | |
| @@ -34,7 +33,7 @@ export class FormsDal { | |
| try { | |
| return convertMongoSchemaToDto( | |
| await this.formModel.findByIdAndUpdate( | |
| - objectId(id), | |
| + Types.ObjectId(id), | |
| { | |
| ...formRequest, | |
| dataSchema: JSON.stringify(formRequest.schema), | |
| diff --git a/apps/data-collection-ms/src/forms/forms.controller.e2e.spec.ts b/apps/data-collection-ms/src/forms/forms.controller.e2e.spec.ts | |
| index 39ddac44d..eae387a6d 100644 | |
| --- a/apps/data-collection-ms/src/forms/forms.controller.e2e.spec.ts | |
| +++ b/apps/data-collection-ms/src/forms/forms.controller.e2e.spec.ts | |
| @@ -39,7 +39,7 @@ import { | |
| createFormSchema, | |
| SchemaProperties, | |
| } from '@vinny/data-collection-test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| const objectContaining = expect.objectContaining; | |
| const mockEnvVars = { CATALOG_MS_URL: 'https://catalog-ms.flare.com' }; | |
| @@ -169,7 +169,7 @@ describe('Forms Controller', () => { | |
| }); | |
| describe('documents', () => { | |
| it('should successfully create a form containing a document field', async () => { | |
| - const documentTypeId = objectStringId(); | |
| + const documentTypeId = Types.ObjectId().toString(); | |
| catalogNock | |
| .get(`/catalog/documents/${documentTypeId}`) | |
| .reply(200, { id: documentTypeId }); | |
| @@ -194,7 +194,7 @@ describe('Forms Controller', () => { | |
| }); | |
| it('should successfully create and fill a form containing a nested document field', async () => { | |
| - const documentTypeId = objectStringId(); | |
| + const documentTypeId = Types.ObjectId().toString(); | |
| catalogNock | |
| .get(`/catalog/documents/${documentTypeId}`) | |
| .reply(200, { id: documentTypeId }); | |
| @@ -768,7 +768,7 @@ describe('Forms Controller', () => { | |
| describe('createDocumentForms', () => { | |
| it('valid single document request', async () => { | |
| - const documentTypeId = objectStringId(); | |
| + const documentTypeId = Types.ObjectId().toString(); | |
| catalogNock.get(`/catalog/documents/${documentTypeId}`).reply(200, { id: documentTypeId }); | |
| const dataSchemaPayload = createDataSchemaWithProperties([SchemaProperties.DRIVING_LICENSE], { | |
| [SchemaProperties.DRIVING_LICENSE]: documentTypeId, | |
| @@ -789,7 +789,7 @@ describe('Forms Controller', () => { | |
| ); | |
| }); | |
| it('valid multiple document request', async () => { | |
| - const documentTypeId = objectStringId(); | |
| + const documentTypeId = Types.ObjectId().toString(); | |
| catalogNock.get(`/catalog/documents/${documentTypeId}`).reply(200, { id: documentTypeId }); | |
| const dataSchemaPayload = createDataSchemaWithProperties( | |
| [SchemaProperties.MULTIPLE_DRIVING_LICENSE], | |
| diff --git a/apps/data-collection-ms/src/wills/dal/schemas/wills-forms.schema.ts b/apps/data-collection-ms/src/wills/dal/schemas/wills-forms.schema.ts | |
| index e587872f7..5739d360f 100644 | |
| --- a/apps/data-collection-ms/src/wills/dal/schemas/wills-forms.schema.ts | |
| +++ b/apps/data-collection-ms/src/wills/dal/schemas/wills-forms.schema.ts | |
| @@ -6,9 +6,8 @@ import { | |
| ResiduarySubSteps, | |
| WillStepStatuses, | |
| } from '@vinny/wills-types'; | |
| -import { Types } from 'mongoose'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| import { mongooseLeanVirtuals } from 'mongoose-lean-virtuals'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| @Schema({ _id: false, id: false }) | |
| class WillStepInfoBase { | |
| @@ -52,15 +51,15 @@ class ResiduaryStepInfo extends WillStepInfoBase { | |
| } | |
| export const ResiduaryStepInfoSchema = SchemaFactory.createForClass(ResiduaryStepInfo); | |
| -@Schema({ _id: true, id: true, timestamps: true, toObject: { getters: true } }) | |
| +@Schema({ _id: true, id: true, timestamps: true }) | |
| export class WillFormSteps { | |
| _id: Types.ObjectId; | |
| id: string; | |
| createdAt?: Date; | |
| updatedAt?: Date; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| - userId: string; | |
| + @Prop({ required: true, index: true, type: SchemaTypes.ObjectId }) | |
| + userId: Types.ObjectId; | |
| @Prop({ required: true, type: BasicInfoStepInfo }) | |
| basicInformation: BasicInfoStepInfo; | |
| @@ -85,5 +84,5 @@ export class WillFormSteps { | |
| } | |
| export const WillFormStepsSchema = SchemaFactory.createForClass(WillFormSteps); | |
| -export type WillFormStepsDocument = WillFormSteps; | |
| +export type WillFormStepsDocument = WillFormSteps & Document; | |
| WillFormStepsSchema.plugin(mongooseLeanVirtuals); | |
| diff --git a/apps/data-collection-ms/src/wills/dal/schemas/wills.schema.ts b/apps/data-collection-ms/src/wills/dal/schemas/wills.schema.ts | |
| index e3905906c..4d30e9d01 100644 | |
| --- a/apps/data-collection-ms/src/wills/dal/schemas/wills.schema.ts | |
| +++ b/apps/data-collection-ms/src/wills/dal/schemas/wills.schema.ts | |
| @@ -66,7 +66,7 @@ class Pet { | |
| @Prop({ required: true }) | |
| name: string; | |
| - @Prop({ required: true, enum: Object.values(Species), type: String }) | |
| + @Prop({ required: true, enum: Species, type: String }) | |
| species: Species; | |
| } | |
| @@ -183,7 +183,7 @@ class WillPersonalData { | |
| @Prop({ type: AddressSchema }) | |
| address?: Address; | |
| - @Prop({ enum: Object.values(PersonalStatues), type: String }) | |
| + @Prop({ enum: PersonalStatues, type: String }) | |
| personalStatus?: PersonalStatues; | |
| @Prop({ type: BasePersonSchema }) | |
| @@ -315,13 +315,13 @@ export class WillDataPoints { | |
| @Prop() | |
| statement?: string; | |
| - @Prop({ enum: Object.values(Ceremony), type: String }) | |
| + @Prop({ enum: Ceremony, type: String }) | |
| ceremony?: Ceremony; | |
| @Prop() | |
| ceremonyAdditionalInfo?: string; | |
| - @Prop({ enum: Object.values(Burial), type: String }) | |
| + @Prop({ enum: Burial, type: String }) | |
| burial?: Burial; | |
| @Prop() | |
| @@ -332,6 +332,6 @@ export class WillDataPoints { | |
| } | |
| export const WillDataPointsSchema = SchemaFactory.createForClass(WillDataPoints); | |
| -export type WillDataPointsDocument = WillDataPoints; | |
| +export type WillDataPointsDocument = WillDataPoints & Document; | |
| WillDataPointsSchema.plugin(mongooseLeanVirtuals); | |
| diff --git a/apps/data-collection-ms/src/wills/dal/wills-forms.dal.ts b/apps/data-collection-ms/src/wills/dal/wills-forms.dal.ts | |
| index 8451625f0..973b13199 100644 | |
| --- a/apps/data-collection-ms/src/wills/dal/wills-forms.dal.ts | |
| +++ b/apps/data-collection-ms/src/wills/dal/wills-forms.dal.ts | |
| @@ -34,15 +34,16 @@ export class WillsFormsDALService { | |
| }) as WillFormStepsDocument; | |
| } | |
| - async findById(id: string): Promise<WillFormStepsDocument | null> { | |
| + async findById(id: string): Promise<LeanDocument<WillFormStepsDocument> | null> { | |
| const result = await this.willsFormsModel | |
| - .findOne(_.omitBy({ _id: id }, _.isUndefined)); | |
| + .findOne(_.omitBy({ _id: id }, _.isUndefined)) | |
| + .lean({ virtuals: true }); | |
| - return result && (result.toObject({ virtuals: true }) as WillFormStepsDocument); | |
| + return result; | |
| } | |
| async findByUserId(userId: string): Promise<Array<LeanDocument<WillFormStepsDocument>>> { | |
| - const result = await this.willsFormsModel.find({ userId }); | |
| - return result && result.map((doc) => doc.toObject({ virtuals: true })); | |
| + const result = await this.willsFormsModel.find({ userId }).lean({ virtuals: true }); | |
| + return result; | |
| } | |
| } | |
| diff --git a/apps/data-collection-ms/src/wills/dal/wills.dal.ts b/apps/data-collection-ms/src/wills/dal/wills.dal.ts | |
| index ebfad62e3..1817cb28a 100644 | |
| --- a/apps/data-collection-ms/src/wills/dal/wills.dal.ts | |
| +++ b/apps/data-collection-ms/src/wills/dal/wills.dal.ts | |
| @@ -13,22 +13,23 @@ export class WillsDALService { | |
| ) {} | |
| async create(willsRequest: CreateWillFormRequestDto): Promise<WillDataPointsDocument> { | |
| - const created = await this.willsModel.create(willsRequest); | |
| - | |
| - return created && (created.toObject({ virtuals: true }) as WillDataPointsDocument); | |
| + const result = (await this.willsModel.create(willsRequest)).toObject({ | |
| + virtuals: true, | |
| + }) as WillDataPointsDocument; | |
| + return result; | |
| } | |
| async findById(id: string): Promise<LeanDocument<WillDataPointsDocument> | null> { | |
| const result = await this.willsModel | |
| - .findOne(_.omitBy({ _id: id }, _.isUndefined)); | |
| + .findOne(_.omitBy({ _id: id }, _.isUndefined)) | |
| + .lean({ virtuals: true }); | |
| - return result && (result.toObject({ virtuals: true }) as WillDataPointsDocument); | |
| + return result; | |
| } | |
| async findAllByUserId(id: string): Promise<Array<LeanDocument<WillDataPointsDocument>>> { | |
| - const result = await this.willsModel.find({ userId: id }); | |
| - | |
| - return result && result.map((doc) => doc.toObject({ virtuals: true })); | |
| + const result = await this.willsModel.find({ userId: id }).lean({ virtuals: true }); | |
| + return result; | |
| } | |
| async patch( | |
| @@ -54,8 +55,9 @@ export class WillsDALService { | |
| { | |
| new: true, | |
| }, | |
| - ); | |
| + ) | |
| + .lean({ virtuals: true }); | |
| - return result && (result.toObject({ virtuals: true }) as WillDataPointsDocument); | |
| + return result; | |
| } | |
| } | |
| diff --git a/apps/data-collection-ms/src/wills/test/wills-forms.controller.spec.ts b/apps/data-collection-ms/src/wills/test/wills-forms.controller.spec.ts | |
| index 432648d1e..57f4ba321 100644 | |
| --- a/apps/data-collection-ms/src/wills/test/wills-forms.controller.spec.ts | |
| +++ b/apps/data-collection-ms/src/wills/test/wills-forms.controller.spec.ts | |
| @@ -1,7 +1,11 @@ | |
| -import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| -import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { closeInMongodConnection, getLogger, rootMongooseTestModule } from '@vinny/test-utils'; | |
| +import { getConnectionToken, MongooseModule } from '@nestjs/mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| +import { ConfigModule } from '@nestjs/config'; | |
| +import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| +import { getSplitService, SplitService } from '@marbletech/split'; | |
| +import { WillFormSteps, WillFormStepsSchema } from '../dal/schemas/wills-forms.schema'; | |
| import faker from '@faker-js/faker'; | |
| import { WillsFormsService } from '../wills-forms.service'; | |
| import { willFormStepsMockDto } from './utils'; | |
| @@ -13,7 +17,6 @@ import { | |
| WillStepStatuses, | |
| } from '@vinny/wills-types'; | |
| import { cloneDeep } from 'lodash'; | |
| -import { WillsModule } from '../wills.module'; | |
| describe('WillsController', () => { | |
| let connection: Connection; | |
| @@ -22,9 +25,22 @@ describe('WillsController', () => { | |
| beforeEach(async () => { | |
| const module: TestingModule = await Test.createTestingModule({ | |
| - imports: [WillsModule, ...importCommons()], | |
| + imports: [ | |
| + ConfigModule, | |
| + rootMongooseTestModule({ useUnifiedTopology: true }), | |
| + MongooseModule.forFeature([ | |
| + { | |
| + name: WillFormSteps.name, | |
| + schema: WillFormStepsSchema, | |
| + }, | |
| + ]), | |
| + ], | |
| + providers: [WillsFormsService, getLogger(), FlareLogger, WillsFormsDALService], | |
| }) | |
| - .overrideCommons() | |
| + .overrideProvider(FlareLogger) | |
| + .useValue(FlareLoggerMock) | |
| + .overrideProvider(SplitService) | |
| + .useValue(getSplitService().useValue) | |
| .compile(); | |
| connection = await module.get(getConnectionToken()); | |
| @@ -49,13 +65,13 @@ describe('WillsController', () => { | |
| expect(willFormStepsInfo).toEqual( | |
| expect.objectContaining({ | |
| ...willFormStepsMockDto, | |
| - userId: willFormStepsMockDto.userId, | |
| + userId: Types.ObjectId(willFormStepsMockDto.userId), | |
| }), | |
| ); | |
| expect(exitingFormSteps).toEqual( | |
| expect.objectContaining({ | |
| ...willFormStepsMockDto, | |
| - userId: willFormStepsMockDto.userId, | |
| + userId: Types.ObjectId(willFormStepsMockDto.userId), | |
| }), | |
| ); | |
| }); | |
| @@ -67,7 +83,7 @@ describe('WillsController', () => { | |
| await willsFormsService.create(invalidInput as WillFormStepsDto); | |
| } catch (err: any) { | |
| expect(err.message).toContain( | |
| - 'WillFormSteps validation failed: userId: Path `userId` is required.', | |
| + 'WillFormSteps validation failed: userId: Cast to ObjectId failed for value', | |
| ); | |
| } | |
| }); | |
| @@ -117,7 +133,7 @@ describe('WillsController', () => { | |
| expect.objectContaining({ | |
| ...updatedRes, | |
| ...updateReq, | |
| - userId: willFormStepsMockDto.userId, | |
| + userId: Types.ObjectId(willFormStepsMockDto.userId), | |
| }), | |
| ); | |
| }); | |
| diff --git a/apps/data-requests-ms/src/docoloco/dal/schema/docoloco.schema.ts b/apps/data-requests-ms/src/docoloco/dal/schema/docoloco.schema.ts | |
| index ba2f1c5db..3a1c5b70a 100644 | |
| --- a/apps/data-requests-ms/src/docoloco/dal/schema/docoloco.schema.ts | |
| +++ b/apps/data-requests-ms/src/docoloco/dal/schema/docoloco.schema.ts | |
| @@ -27,12 +27,7 @@ export class ServiceDrafts { | |
| @IsNotEmpty() | |
| caseId: string; | |
| - @Prop({ | |
| - required: true, | |
| - type: String, | |
| - enum: Object.values(ServiceDraftsStatus), | |
| - default: ServiceDraftsStatus.CLIENT, | |
| - }) | |
| + @Prop({ required: true, enum: ServiceDraftsStatus, type: ServiceDraftsStatus }) | |
| @IsEnum(ServiceDraftsStatus) | |
| @IsNotEmpty() | |
| status: ServiceDraftsStatus; | |
| diff --git a/apps/data-requests-ms/src/docoloco/test/docoloco.controller.spec.ts b/apps/data-requests-ms/src/docoloco/test/docoloco.controller.spec.ts | |
| index 8e6377e17..ef2cabb54 100644 | |
| --- a/apps/data-requests-ms/src/docoloco/test/docoloco.controller.spec.ts | |
| +++ b/apps/data-requests-ms/src/docoloco/test/docoloco.controller.spec.ts | |
| @@ -31,7 +31,7 @@ import { BrazeDestinationType, BrazeNotification } from '@vinny/communications-c | |
| import { JSONSchema7Flare } from '@vinny/data-collection-types'; | |
| import { DocumentFormat } from '@vinny/documents-types'; | |
| import { isMatch } from 'lodash'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| createServiceDrafts, | |
| generateCreateServiceDraftsPayload, | |
| @@ -195,16 +195,16 @@ describe('Docoloco Controller', () => { | |
| }); | |
| it('should return only service drafts with given userId and status ATTORNEY/PENDING_ATTORNEY', async () => { | |
| - const userId1 = objectStringId(); | |
| - const userId2 = objectStringId(); | |
| + const userId1 = Types.ObjectId().toString(); | |
| + const userId2 = Types.ObjectId().toString(); | |
| const serviceDraftsRequests = [ | |
| { userId: userId1, status: ServiceDraftsStatus.ATTORNEY }, | |
| { userId: userId1, status: ServiceDraftsStatus.PENDING_ATTORNEY }, | |
| { userId: userId1, status: ServiceDraftsStatus.ATTORNEY }, | |
| { userId: userId1, status: ServiceDraftsStatus.CLIENT }, | |
| { userId: userId2, status: ServiceDraftsStatus.ATTORNEY }, | |
| - { userId: objectStringId(), status: ServiceDraftsStatus.ATTORNEY }, | |
| - { userId: objectStringId(), status: ServiceDraftsStatus.PENDING_ATTORNEY }, | |
| + { userId: Types.ObjectId().toString(), status: ServiceDraftsStatus.ATTORNEY }, | |
| + { userId: Types.ObjectId().toString(), status: ServiceDraftsStatus.PENDING_ATTORNEY }, | |
| ]; | |
| for (const payload of serviceDraftsRequests) { | |
| @@ -257,7 +257,7 @@ describe('Docoloco Controller', () => { | |
| }); | |
| it("should return empty list when filter doesn't fit", async () => { | |
| - const userIds = [objectStringId(), objectStringId()]; | |
| + const userIds = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| const { | |
| body: { serviceDraftsList }, | |
| } = await request(app.getHttpServer()) | |
| @@ -718,7 +718,7 @@ describe('Docoloco Controller', () => { | |
| }); | |
| describe('POST /docoloco/:userId/data-points/completion-percentage', () => { | |
| it('should return completion percentage of user drafts data points', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const { getUserDataRequestsSpy, nockGetDraftDataPoints } = | |
| arrangeCompletionPercentageMocks(userId); | |
| @@ -738,7 +738,7 @@ describe('Docoloco Controller', () => { | |
| }); | |
| it('should return completion percentage of user drafts data points (data request = COMPLETED)', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const { getUserDataRequestsSpy, nockGetDraftDataPoints } = | |
| arrangeCompletionPercentageMocks(userId); | |
| @@ -797,7 +797,7 @@ describe('Docoloco Controller', () => { | |
| describe('GET /docoloco/feed-metadata', () => { | |
| it('should return HIDE when there are no pending attorney drafts', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| servicesNock | |
| .get('/services/list/metadata') | |
| @@ -814,10 +814,10 @@ describe('Docoloco Controller', () => { | |
| }); | |
| it('should return SHOW when there are pending attorney drafts', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const caseId1 = objectStringId(); | |
| - const caseId2 = objectStringId(); | |
| - const userId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const caseId1 = Types.ObjectId().toString(); | |
| + const caseId2 = Types.ObjectId().toString(); | |
| + const userId = Types.ObjectId().toString(); | |
| servicesNock | |
| .get('/services/list/metadata') | |
| @@ -827,7 +827,7 @@ describe('Docoloco Controller', () => { | |
| await docolocoDal.createServiceDrafts({ | |
| caseId: caseId1, | |
| userId, | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| status: ServiceDraftsStatus.PENDING_ATTORNEY, | |
| }); | |
| @@ -841,7 +841,7 @@ describe('Docoloco Controller', () => { | |
| }); | |
| it('should handle empty services array from services-ms', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| servicesNock.get('/services/list/metadata').query(true).reply(200, []); | |
| diff --git a/apps/data-requests-ms/src/docoloco/test/events-handler.controller.spec.ts b/apps/data-requests-ms/src/docoloco/test/events-handler.controller.spec.ts | |
| index 0e8ee573a..6cbc2617f 100644 | |
| --- a/apps/data-requests-ms/src/docoloco/test/events-handler.controller.spec.ts | |
| +++ b/apps/data-requests-ms/src/docoloco/test/events-handler.controller.spec.ts | |
| @@ -198,7 +198,6 @@ describe('events handler Controller', () => { | |
| }), | |
| ); | |
| }, | |
| - 10000, | |
| ); | |
| describe('insertDraftExistingDataPoints', () => { | |
| let updateUserDraftDataPointsMock: jest.SpyInstance; | |
| diff --git a/apps/data-requests-ms/src/docoloco/test/mocks.ts b/apps/data-requests-ms/src/docoloco/test/mocks.ts | |
| index e6a0ab634..c536dcfa1 100644 | |
| --- a/apps/data-requests-ms/src/docoloco/test/mocks.ts | |
| +++ b/apps/data-requests-ms/src/docoloco/test/mocks.ts | |
| @@ -7,7 +7,7 @@ import { | |
| } from '@vinny/data-requests-types'; | |
| import { KafkaEventDto, KafkaEventType } from '@vinny/kafka-client'; | |
| import { ServiceDto, ServiceStatus } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { DRAFTS_DATA_REQUEST_DESCRIPTION, DRAFTS_REQUEST_NAME, DRAFTS_TAG } from '../consts'; | |
| import { EventType, LssEventDto, LssStatus } from '@vinny/events-types'; | |
| @@ -49,12 +49,12 @@ export const generateDraftResponseMock: GenerateDraftResponse = { | |
| downloadUrl: faker.internet.url(), | |
| }; | |
| -export const serviceTypeId = objectStringId(); | |
| -export const serviceId = objectStringId(); | |
| -export const userId = objectStringId(); | |
| -export const caseId = objectStringId(); | |
| -export const draftResourceKey1 = objectStringId(); | |
| -export const draftResourceKey2 = objectStringId(); | |
| +export const serviceTypeId = Types.ObjectId().toString(); | |
| +export const serviceId = Types.ObjectId().toString(); | |
| +export const userId = Types.ObjectId().toString(); | |
| +export const caseId = Types.ObjectId().toString(); | |
| +export const draftResourceKey1 = Types.ObjectId().toString(); | |
| +export const draftResourceKey2 = Types.ObjectId().toString(); | |
| export const createServiceEvent = ( | |
| eventType: KafkaEventType, | |
| @@ -84,7 +84,7 @@ export const serviceDto = { | |
| serviceTypeId, | |
| id: serviceId, | |
| status: ServiceStatus.OPEN, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| location: { | |
| state: 'TX', | |
| }, | |
| @@ -125,7 +125,7 @@ export const expectedDataRequestPayload = { | |
| export const userMockResponse = { | |
| name: { first: 'John', last: 'Doe' }, | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const generateClientLssEventWithOpposingPartyNameMock = ( | |
| diff --git a/apps/dispatch-ms/package.json b/apps/dispatch-ms/package.json | |
| index d0214895a..84c3c54c0 100644 | |
| --- a/apps/dispatch-ms/package.json | |
| +++ b/apps/dispatch-ms/package.json | |
| @@ -8,7 +8,7 @@ | |
| "lint": "eslint -f mo --cache --cache-location ./.cache/.eslintcache .", | |
| "build": "webpack -c ../../.build/.base/webpack.config.js", | |
| "watch": "webpack --watch -c ../../.build/.base/webpack.config.js", | |
| - "test": "jest --passWithNoTests --logHeapUsage --silent", | |
| + "test": "jest --passWithNoTests --logHeapUsage", | |
| "test:watch": "jest --watch", | |
| "isolate": "turbo prune dispatch-ms --docker", | |
| "format": "prettier --cache-location ./.cache/.prettier --list-different \"./src/**/*.ts\"", | |
| diff --git a/apps/dispatch-ms/src/case-offers/dal/case-offers.dal.ts b/apps/dispatch-ms/src/case-offers/dal/case-offers.dal.ts | |
| index aa9df63a8..655eec198 100644 | |
| --- a/apps/dispatch-ms/src/case-offers/dal/case-offers.dal.ts | |
| +++ b/apps/dispatch-ms/src/case-offers/dal/case-offers.dal.ts | |
| @@ -6,7 +6,7 @@ import { | |
| CreateCaseOfferRequestDto, | |
| FilterCaseOffersDto, | |
| } from '@vinny/dispatch-types'; | |
| -import { Model, UpdateQuery } from 'mongoose'; | |
| +import { Model, Types, UpdateQuery } from 'mongoose'; | |
| import { | |
| ACTIVE_CASE_OFFER_WITH_SAME_CASE_ID_ALREADY_EXISTS, | |
| CaseOffersErrors, | |
| @@ -21,7 +21,6 @@ import { | |
| UpdateCaseOfferFilter, | |
| } from './../types'; | |
| import { CaseOffer, CaseOfferDocument } from './schemas/case-offers.schema'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class CaseOffersDal { | |
| @@ -74,10 +73,10 @@ export class CaseOffersDal { | |
| ]; | |
| const caseOffer = await this.caseOffersModel.findOneAndUpdate( | |
| { | |
| - _id: objectId(data.caseOfferId), | |
| + _id: Types.ObjectId(data.caseOfferId), | |
| dispatchedAttorneys: { | |
| $elemMatch: { | |
| - attorneyId: data.attorneyId, | |
| + attorneyId: Types.ObjectId(data.attorneyId), | |
| response: { $in: allowedAttorneyCaseOfferStatuses }, | |
| }, | |
| }, | |
| @@ -100,16 +99,16 @@ export class CaseOffersDal { | |
| async assignAttorney(request: AssignAttorneyRequestDto): Promise<CaseOffer | null> { | |
| const caseOffer = await this.caseOffersModel.findOneAndUpdate( | |
| { | |
| - _id: objectId(request.caseOfferId), | |
| + _id: Types.ObjectId(request.caseOfferId), | |
| status: { $in: ACTIVE_CASE_OFFERS_STATUSES }, | |
| assignedAttorneyId: { $exists: false }, | |
| }, | |
| { | |
| $set: { | |
| status: CaseOfferStatus.COMPLETED, | |
| - assignedAttorneyId: request.attorneyId, | |
| + assignedAttorneyId: Types.ObjectId(request.attorneyId), | |
| ...(request.assigningAgentUserId && { | |
| - assigningAgentUserId: request.assigningAgentUserId, | |
| + assigningAgentUserId: Types.ObjectId(request.assigningAgentUserId), | |
| }), | |
| closedReason: request.closedReason, | |
| assignedAt: new Date(), | |
| @@ -138,7 +137,7 @@ export class CaseOffersDal { | |
| const caseOffer = await this.caseOffersModel.findOneAndUpdate( | |
| { | |
| - _id: objectId(id), | |
| + _id: Types.ObjectId(id), | |
| status: { $in: allowedCaseOfferStatuses }, | |
| }, | |
| updateQuery, | |
| @@ -151,7 +150,7 @@ export class CaseOffersDal { | |
| private constructFindQuery(filter: FilterCaseOffersDto) { | |
| const attorneyMatchQuery = { | |
| ...(filter.attorneyId && { | |
| - attorneyId: filter.attorneyId, | |
| + attorneyId: Types.ObjectId(filter.attorneyId), | |
| }), | |
| ...(filter.attorneyResponseStatuses?.length && { | |
| response: { $in: filter.attorneyResponseStatuses }, | |
| diff --git a/apps/dispatch-ms/src/case-offers/dal/schemas/case-offers-data.schema.ts b/apps/dispatch-ms/src/case-offers/dal/schemas/case-offers-data.schema.ts | |
| index 4f6fd0471..be9b02fdd 100644 | |
| --- a/apps/dispatch-ms/src/case-offers/dal/schemas/case-offers-data.schema.ts | |
| +++ b/apps/dispatch-ms/src/case-offers/dal/schemas/case-offers-data.schema.ts | |
| @@ -1,11 +1,16 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { Appearance, CriticalDateType, RepeatRejectionReason } from '@vinny/dispatch-types'; | |
| import { PartialName } from '@vinny/users-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { SchemaTypes } from 'mongoose'; | |
| +import { objectIdToStringGetter } from './schema.utils'; | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class ServiceType { | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + required: true, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| id: string; | |
| } | |
| @@ -81,9 +86,13 @@ export class CaseOfferData { | |
| stateId?: string; | |
| @Prop() | |
| fips?: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + required: true, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| customerId: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ type: SchemaTypes.ObjectId, required: true, get: objectIdToStringGetter }) | |
| practiceAreaId: string; | |
| @Prop({ type: [ServiceTypeSchema], default: [] }) | |
| serviceTypes: ServiceType[]; | |
| @@ -101,7 +110,7 @@ export class CaseOfferData { | |
| criticalDates?: CriticalDate[]; | |
| @Prop({ type: CaseInfoSchema }) | |
| caseInfo?: CaseInfo; | |
| - @Prop(objectIdPropHandler()) | |
| + @Prop({ type: SchemaTypes.ObjectId, get: objectIdToStringGetter }) | |
| lssAttorneyId?: string; | |
| @Prop({ type: ClientDetailsSchema }) | |
| clientDetails?: ClientDetails; | |
| diff --git a/apps/dispatch-ms/src/case-offers/dal/schemas/case-offers.schema.ts b/apps/dispatch-ms/src/case-offers/dal/schemas/case-offers.schema.ts | |
| index 647055c0e..0c9653fdb 100644 | |
| --- a/apps/dispatch-ms/src/case-offers/dal/schemas/case-offers.schema.ts | |
| +++ b/apps/dispatch-ms/src/case-offers/dal/schemas/case-offers.schema.ts | |
| @@ -9,9 +9,9 @@ import { | |
| CaseOfferType, | |
| } from '@vinny/dispatch-types'; | |
| import { Exclude } from 'class-transformer'; | |
| -import { Document, Types, now } from 'mongoose'; | |
| +import { Document, SchemaTypes, Types, now } from 'mongoose'; | |
| import { CaseOfferData, CaseOfferDataSchema } from './case-offers-data.schema'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { objectIdToStringGetter } from './schema.utils'; | |
| export type CaseOfferDocument = CaseOffer & Document; | |
| @@ -27,7 +27,12 @@ const GradualDispatchDataSchema = SchemaFactory.createForClass(GradualDispatchDa | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class AttorneyCaseOffer { | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + index: true, | |
| + }) | |
| attorneyId: string; | |
| @Prop({ | |
| @@ -89,7 +94,11 @@ export class CaseOffer { | |
| }) | |
| type: CaseOfferType; | |
| - @Prop(objectIdPropHandler()) | |
| + @Prop({ | |
| + required: false, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| assignedAttorneyId?: string; | |
| @Prop({ default: [] }) | |
| @@ -113,13 +122,21 @@ export class CaseOffer { | |
| @Prop({ default: false }) | |
| isUrgent?: boolean; | |
| - @Prop(objectIdPropHandler()) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| agentUserId?: string; | |
| - @Prop(objectIdPropHandler()) | |
| + @Prop({ type: SchemaTypes.ObjectId, get: objectIdToStringGetter }) | |
| assigningAgentUserId?: string; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + required: true, | |
| + index: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| caseId: string; | |
| @Prop({ type: CaseOfferDataSchema }) | |
| diff --git a/apps/dispatch-ms/src/case-offers/dal/schemas/schema.utils.ts b/apps/dispatch-ms/src/case-offers/dal/schemas/schema.utils.ts | |
| new file mode 100644 | |
| index 000000000..9ea72e736 | |
| --- /dev/null | |
| +++ b/apps/dispatch-ms/src/case-offers/dal/schemas/schema.utils.ts | |
| @@ -0,0 +1,3 @@ | |
| +import { Types } from 'mongoose'; | |
| + | |
| +export const objectIdToStringGetter = (v: Types.ObjectId): string => v?.toString(); | |
| diff --git a/apps/dispatch-ms/src/case-offers/tests/case-offers.controller.spec.ts b/apps/dispatch-ms/src/case-offers/tests/case-offers.controller.spec.ts | |
| index 876fa5d00..395b6379d 100644 | |
| --- a/apps/dispatch-ms/src/case-offers/tests/case-offers.controller.spec.ts | |
| +++ b/apps/dispatch-ms/src/case-offers/tests/case-offers.controller.spec.ts | |
| @@ -8,13 +8,12 @@ import { | |
| } from '@vinny/dispatch-types'; | |
| import { generateDispatchFullRequest } from '@vinny/dispatch-types-test-utils'; | |
| import { updateCaseOffer } from '../../../tests/utils'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { CaseOffersService } from '../case-offers.service'; | |
| import { CaseOffer, CaseOfferDocument } from '../dal/schemas/case-offers.schema'; | |
| import { CaseOffersErrors } from '../../exceptions/errors'; | |
| import { CaseOffersController } from '../case-offers.controller'; | |
| import { createCaseOffersTestModule } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Case Offers Controller', () => { | |
| let controller: CaseOffersController; | |
| @@ -46,8 +45,8 @@ describe('Case Offers Controller', () => { | |
| let caseOfferWithFirstAttorney: CaseOfferDto; | |
| let caseOfferWithBothAttorneys: CaseOfferDto; | |
| - const firstAttorneyId = objectStringId(); | |
| - const secondAttorneyId = objectStringId(); | |
| + const firstAttorneyId = Types.ObjectId().toString(); | |
| + const secondAttorneyId = Types.ObjectId().toString(); | |
| beforeEach(async () => { | |
| caseOfferWithoutAttorneys = await service.create(generateDispatchFullRequest({})); | |
| @@ -293,8 +292,8 @@ describe('Case Offers Controller', () => { | |
| describe('findById', () => { | |
| describe('should get case offers by filter', () => { | |
| it('Should retrieve case offer by id when exists', async () => { | |
| - const firstAttorneyId = objectStringId(); | |
| - const secondAttorneyId = objectStringId(); | |
| + const firstAttorneyId = Types.ObjectId().toString(); | |
| + const secondAttorneyId = Types.ObjectId().toString(); | |
| let caseOffer = await service.create(generateDispatchFullRequest({})); | |
| caseOffer = await service.addAttorneysToCaseOffer(caseOffer.id, [ | |
| firstAttorneyId, | |
| @@ -304,7 +303,7 @@ describe('Case Offers Controller', () => { | |
| expect(result).toEqual(caseOffer); | |
| }); | |
| it("Should throw not found exception when case offer doesn't exist", async () => { | |
| - await expect(controller.findById(objectStringId())).rejects.toThrowError( | |
| + await expect(controller.findById(Types.ObjectId().toString())).rejects.toThrowError( | |
| CaseOffersErrors.NOT_FOUND, | |
| ); | |
| }); | |
| diff --git a/apps/dispatch-ms/src/case-offers/tests/case-offers.service.spec.ts b/apps/dispatch-ms/src/case-offers/tests/case-offers.service.spec.ts | |
| index 0610604ee..b86bed91d 100644 | |
| --- a/apps/dispatch-ms/src/case-offers/tests/case-offers.service.spec.ts | |
| +++ b/apps/dispatch-ms/src/case-offers/tests/case-offers.service.spec.ts | |
| @@ -18,7 +18,7 @@ import { | |
| generateCreateCaseOfferFullRequest, | |
| generateDispatchFullRequest, | |
| } from '@vinny/dispatch-types-test-utils'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { | |
| CaseOffersErrors, | |
| UPDATING_NON_ACTIVE_CASE_OFFER_IS_FORBIDDEN, | |
| @@ -27,7 +27,6 @@ import { CaseOffersService } from '../case-offers.service'; | |
| import { AssignAttorneyRequestDto, UpdateAttorneyCaseOfferDto, UpdateCaseOfferDto } from '../types'; | |
| import { CaseOffer, CaseOfferDocument } from '../dal/schemas/case-offers.schema'; | |
| import { createCaseOffersTestModule } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Case Offers Service', () => { | |
| let service: CaseOffersService; | |
| @@ -79,7 +78,7 @@ describe('Case Offers Service', () => { | |
| describe('success', () => { | |
| it('Should add attorney to dispatched attorneys list', async () => { | |
| const createCaseOfferRequest = generateDispatchFullRequest({}); | |
| - const attorneysId = [objectStringId(), objectStringId()]; | |
| + const attorneysId = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| const caseOffer = await service.create(createCaseOfferRequest); | |
| const { dispatchedAttorneys, ..._ } = await service.addAttorneysToCaseOffer( | |
| caseOffer.id, | |
| @@ -96,9 +95,9 @@ describe('Case Offers Service', () => { | |
| it('Should add only non existing attorneys to dispatched attorneys list', async () => { | |
| const createCaseOfferRequest = generateDispatchFullRequest({}); | |
| - const attorneyId = objectStringId(); | |
| - const attorneysId = [objectStringId(), attorneyId]; | |
| - const additionalAttorneysId = [objectStringId(), attorneyId]; | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const attorneysId = [Types.ObjectId().toString(), attorneyId]; | |
| + const additionalAttorneysId = [Types.ObjectId().toString(), attorneyId]; | |
| const caseOffer = await service.create(createCaseOfferRequest); | |
| const { dispatchedAttorneys, ..._ } = await service.addAttorneysToCaseOffer( | |
| @@ -126,10 +125,10 @@ describe('Case Offers Service', () => { | |
| }); | |
| describe('fail', () => { | |
| it('Should throw not found error when case offer not found', async () => { | |
| - const attorneysId = [objectStringId(), objectStringId()]; | |
| + const attorneysId = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| await expect( | |
| - service.addAttorneysToCaseOffer(objectStringId(), attorneysId), | |
| + service.addAttorneysToCaseOffer(Types.ObjectId().toString(), attorneysId), | |
| ).rejects.toThrowError(CaseOffersErrors.NOT_FOUND); | |
| }); | |
| }); | |
| @@ -147,7 +146,7 @@ describe('Case Offers Service', () => { | |
| 'Should update attorney case offer with $response response by source: $source', | |
| async ({ response, source, responseReason, responseAdditionalNotes }) => { | |
| const createCaseOfferRequest = generateDispatchFullRequest({}); | |
| - const attorneysId = [objectStringId(), objectStringId()]; | |
| + const attorneysId = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| const caseOffer = await service.create(createCaseOfferRequest); | |
| await service.addAttorneysToCaseOffer(caseOffer.id, attorneysId); | |
| @@ -182,7 +181,7 @@ describe('Case Offers Service', () => { | |
| it('Should override REJECTED response with ACCEPTED and reset responseReason and responseAdditionalNotes fields', async () => { | |
| const createCaseOfferRequest = generateDispatchFullRequest({}); | |
| - const attorneysId = [objectStringId(), objectStringId()]; | |
| + const attorneysId = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| const caseOffer = await service.create(createCaseOfferRequest); | |
| await service.addAttorneysToCaseOffer(caseOffer.id, attorneysId); | |
| @@ -239,7 +238,7 @@ describe('Case Offers Service', () => { | |
| }); | |
| }); | |
| describe('fail', () => { | |
| - const attorneysId = [objectStringId(), objectStringId()]; | |
| + const attorneysId = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| let caseOffer: CaseOfferDto; | |
| beforeEach(async () => { | |
| @@ -250,7 +249,7 @@ describe('Case Offers Service', () => { | |
| it('Should not update attorney case offer when attorney is not part of dispatched attorneys list', async () => { | |
| const updateCaseOffer: UpdateAttorneyCaseOfferDto = { | |
| caseOfferId: caseOffer.id, | |
| - attorneyId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| response: AttorneyResponseStatus.ACCEPTED, | |
| source: CaseOfferResponseSource.ATTORNEY, | |
| }; | |
| @@ -262,8 +261,8 @@ describe('Case Offers Service', () => { | |
| it('Should not update attorney case offer when case offer was not found', async () => { | |
| const updateCaseOffer: UpdateAttorneyCaseOfferDto = { | |
| - caseOfferId: objectStringId(), | |
| - attorneyId: objectStringId(), | |
| + caseOfferId: Types.ObjectId().toString(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| response: AttorneyResponseStatus.ACCEPTED, | |
| source: CaseOfferResponseSource.ATTORNEY, | |
| }; | |
| @@ -292,15 +291,15 @@ describe('Case Offers Service', () => { | |
| describe('assignAttorneyOnCaseOffer', () => { | |
| describe('success', () => { | |
| it.each` | |
| - source | closedReason | assigningAgentUserId | caseOfferStatus | |
| - ${CaseOfferResponseSource.ATTORNEY} | ${CaseOfferClosedReason.ASSIGNED_AUTOMATICALLY} | ${undefined} | ${CaseOfferStatus.PENDING} | |
| - ${CaseOfferResponseSource.AGENT} | ${CaseOfferClosedReason.ASSIGNED_BY_AGENT} | ${objectStringId()} | ${CaseOfferStatus.PENDING} | |
| - ${CaseOfferResponseSource.AGENT} | ${CaseOfferClosedReason.ASSIGNED_BY_AGENT} | ${objectStringId()} | ${CaseOfferStatus.INTERNAL} | |
| + source | closedReason | assigningAgentUserId | caseOfferStatus | |
| + ${CaseOfferResponseSource.ATTORNEY} | ${CaseOfferClosedReason.ASSIGNED_AUTOMATICALLY} | ${undefined} | ${CaseOfferStatus.PENDING} | |
| + ${CaseOfferResponseSource.AGENT} | ${CaseOfferClosedReason.ASSIGNED_BY_AGENT} | ${Types.ObjectId().toString()} | ${CaseOfferStatus.PENDING} | |
| + ${CaseOfferResponseSource.AGENT} | ${CaseOfferClosedReason.ASSIGNED_BY_AGENT} | ${Types.ObjectId().toString()} | ${CaseOfferStatus.INTERNAL} | |
| `( | |
| 'Should assign attorney on case offer when case offer status is $caseOfferStatus and set all relevant fields', | |
| async ({ source, closedReason, assigningAgentUserId, caseOfferStatus }) => { | |
| const createCaseOfferRequest = generateDispatchFullRequest({}); | |
| - const attorneysId = [objectStringId(), objectStringId()]; | |
| + const attorneysId = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| const caseOffer = await service.create(createCaseOfferRequest); | |
| await service.addAttorneysToCaseOffer(caseOffer.id, attorneysId); | |
| await updateCaseOffer({ | |
| @@ -335,7 +334,7 @@ describe('Case Offers Service', () => { | |
| ); | |
| }); | |
| describe('fail', () => { | |
| - const attorneysId = [objectStringId(), objectStringId()]; | |
| + const attorneysId = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| let caseOffer: CaseOfferDto; | |
| beforeEach(async () => { | |
| @@ -433,7 +432,7 @@ describe('Case Offers Service', () => { | |
| describe('fail', () => { | |
| it('Should throw not found exception when case offer was not found', async () => { | |
| await expect( | |
| - service.updateActiveCaseOffer(objectStringId(), updateCaseOfferRequest), | |
| + service.updateActiveCaseOffer(Types.ObjectId().toString(), updateCaseOfferRequest), | |
| ).rejects.toThrowError(CaseOffersErrors.NOT_FOUND); | |
| }); | |
| }); | |
| diff --git a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.cancel-dispatch.integration.spec.ts b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.cancel-dispatch.integration.spec.ts | |
| index c7cb0b86c..404a91f10 100644 | |
| --- a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.cancel-dispatch.integration.spec.ts | |
| +++ b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.cancel-dispatch.integration.spec.ts | |
| @@ -3,7 +3,7 @@ import { HttpStatus, INestApplication } from '@nestjs/common'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { TestingModule } from '@nestjs/testing'; | |
| import { generateDispatchFullRequest } from '@vinny/dispatch-types-test-utils'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import request from 'supertest'; | |
| import { updateCaseOffer } from '../../../tests/utils'; | |
| import { CaseOffersErrors } from '../../exceptions/errors'; | |
| @@ -15,7 +15,6 @@ import { CaseOfferClosedReason, CaseOfferStatus } from '@vinny/dispatch-types'; | |
| import { CaseOffersService } from '../../case-offers/case-offers.service'; | |
| import { CaseOffer, CaseOfferDocument } from '../../case-offers/dal/schemas/case-offers.schema'; | |
| import { createDispatchTestModule } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Cancel Dispatch Flow', () => { | |
| let controller: DispatchEngineController; | |
| @@ -67,7 +66,7 @@ describe('Cancel Dispatch Flow', () => { | |
| describe('fail', () => { | |
| it("Should throw not found exception when case offer doesn't exist", async () => { | |
| await request(app.getHttpServer()) | |
| - .delete(`/dispatch/case-offers/${objectStringId()}`) | |
| + .delete(`/dispatch/case-offers/${Types.ObjectId().toString()}`) | |
| .send({ reason: CaseOfferClosedReason.CLOSED_LOST }) | |
| .expect({ | |
| status: HttpStatus.NOT_FOUND, | |
| diff --git a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.controller.spec.ts b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.controller.spec.ts | |
| index 3442561b2..ef09c69a8 100644 | |
| --- a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.controller.spec.ts | |
| +++ b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.controller.spec.ts | |
| @@ -6,7 +6,7 @@ import { | |
| createCaseOfferDto, | |
| generateDispatchFullRequest, | |
| } from '@vinny/dispatch-types-test-utils'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { updateCaseOffer } from '../../../tests/utils'; | |
| import { CaseOffersErrors } from '../../exceptions/errors'; | |
| import { DispatchEngineController } from '../dispatch-engine.controller'; | |
| @@ -42,7 +42,6 @@ import { DispatchNotificationsService } from '../dispatch-notifications.service' | |
| import { NotificationType } from '@vinny/notifications-types'; | |
| import { BrazeNotification } from '@vinny/communications-client'; | |
| import { StateConfigurationsDal } from '../../state-configurations/dal/state-configurations.dal'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const usersMsMock = nock(ENV_VARS.USERS_MS_URL); | |
| const schedulerMock = nock(ENV_VARS.SCHEDULER_MS_URL); | |
| @@ -107,7 +106,7 @@ describe('Dispatch engine Controller', () => { | |
| ${CaseOfferType.REPEAT_DISPATCH} | |
| `('success', ({ type }) => { | |
| describe(`Should dispatch successfully and return case offer with type ${type}`, () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| let dispatchRequest: DispatchRequestDto; | |
| let attorneysFilter: any; | |
| let scheduleTask: any; | |
| @@ -147,8 +146,8 @@ describe('Dispatch engine Controller', () => { | |
| }); | |
| it('with dispatch attorneys list and location is required', async () => { | |
| const attorneysForDispatch = [ | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| ]; | |
| const attorneys = usersMsMock | |
| .get(`/attorneys`) | |
| @@ -229,8 +228,8 @@ describe('Dispatch engine Controller', () => { | |
| it('when there is already canceled case offer on same caseId', async () => { | |
| const attorneysForDispatch = [ | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| ]; | |
| const attorneys = usersMsMock | |
| .get(`/attorneys`) | |
| @@ -255,11 +254,11 @@ describe('Dispatch engine Controller', () => { | |
| it('with non empty attorneysIdsToExclude when the attorney is not relevant to the dispatch - dispatched list should remain the same', async () => { | |
| const attorneysForDispatch = [ | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| ]; | |
| - const attorneysIdsToExclude = [objectStringId()]; | |
| + const attorneysIdsToExclude = [Types.ObjectId().toString()]; | |
| const attorneys = usersMsMock | |
| .get(`/attorneys`) | |
| .query(attorneysFilter) | |
| @@ -293,8 +292,8 @@ describe('Dispatch engine Controller', () => { | |
| it('with non empty attorneysIdsToExclude when the attorney is relevant to the dispatch - dispatched list should exclude him from the list', async () => { | |
| const attorneysForDispatch = [ | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| ]; | |
| const attorneysIdsToExclude = [attorneysForDispatch[0].id]; | |
| @@ -337,7 +336,7 @@ describe('Dispatch engine Controller', () => { | |
| ${CaseOfferType.REPEAT_DISPATCH} | |
| `('failure with case offer type $type', ({ type }) => { | |
| describe('Should fail creating case Offer when active case offer with same caseId exists', () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| let caseOffer: CaseOfferDto; | |
| let createCaseOfferRequest: DispatchRequestDto; | |
| let attorneysFilter: any; | |
| @@ -377,8 +376,8 @@ describe('Dispatch engine Controller', () => { | |
| .reply(200, {}); | |
| const attorneysForDispatch = [ | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| ]; | |
| const attorneys = usersMsMock | |
| .get(`/attorneys`) | |
| @@ -426,7 +425,7 @@ describe('Dispatch engine Controller', () => { | |
| ${CaseOfferType.REPEAT_DISPATCH} | |
| `('respondOnCaseOffer with type $type', ({ type }) => { | |
| let caseOffer: CaseOfferDto; | |
| - const attorneysIds = [objectStringId(), objectStringId()]; | |
| + const attorneysIds = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| beforeEach(async () => { | |
| const createCaseOfferRequest = generateDispatchFullRequest({ | |
| practiceAreaId: familyPracticeArea.id, | |
| @@ -568,7 +567,11 @@ describe('Dispatch engine Controller', () => { | |
| }; | |
| await expect( | |
| - controller.respondOnCaseOffer(responseDto, objectStringId(), attorneysIds[0]), | |
| + controller.respondOnCaseOffer( | |
| + responseDto, | |
| + Types.ObjectId().toString(), | |
| + attorneysIds[0], | |
| + ), | |
| ).rejects.toThrow(CaseOffersErrors.NOT_FOUND); | |
| }); | |
| @@ -579,7 +582,7 @@ describe('Dispatch engine Controller', () => { | |
| }; | |
| await expect( | |
| - controller.respondOnCaseOffer(responseDto, caseOffer.id, objectStringId()), | |
| + controller.respondOnCaseOffer(responseDto, caseOffer.id, Types.ObjectId().toString()), | |
| ).rejects.toThrow(); | |
| }); | |
| @@ -659,13 +662,13 @@ describe('Dispatch engine Controller', () => { | |
| const responseDto: CreateAttorneyResponseDto = { | |
| response: AttorneyCaseOfferResponse.ACCEPTED, | |
| source: CaseOfferResponseSource.AGENT, | |
| - assigningAgentUserId: objectStringId(), | |
| + assigningAgentUserId: Types.ObjectId().toString(), | |
| }; | |
| it.each` | |
| - assignedAttorneyId | description | caseOfferStatus | |
| - ${objectStringId()} | ${'assign attorney when attorney is not part of the dispatched list and add him to the list'} | ${CaseOfferStatus.PENDING} | |
| - ${attorneysIds[0]} | ${'assign attorney when attorney is part of the dispatched list'} | ${CaseOfferStatus.PENDING} | |
| - ${attorneysIds[0]} | ${'assign attorney when caseOfferStatus is INTERNAL'} | ${CaseOfferStatus.INTERNAL} | |
| + assignedAttorneyId | description | caseOfferStatus | |
| + ${Types.ObjectId().toString()} | ${'assign attorney when attorney is not part of the dispatched list and add him to the list'} | ${CaseOfferStatus.PENDING} | |
| + ${attorneysIds[0]} | ${'assign attorney when attorney is part of the dispatched list'} | ${CaseOfferStatus.PENDING} | |
| + ${attorneysIds[0]} | ${'assign attorney when caseOfferStatus is INTERNAL'} | ${CaseOfferStatus.INTERNAL} | |
| `( | |
| 'should update attorney case offer and $description', | |
| async ({ assignedAttorneyId, caseOfferStatus }) => { | |
| @@ -733,7 +736,7 @@ describe('Dispatch engine Controller', () => { | |
| const assignByAgent: CreateAttorneyResponseDto = { | |
| response: AttorneyCaseOfferResponse.ACCEPTED, | |
| source: CaseOfferResponseSource.AGENT, | |
| - assigningAgentUserId: objectStringId(), | |
| + assigningAgentUserId: Types.ObjectId().toString(), | |
| }; | |
| const rejectedResponse = await controller.respondOnCaseOffer( | |
| @@ -804,7 +807,11 @@ describe('Dispatch engine Controller', () => { | |
| }; | |
| await expect( | |
| - controller.respondOnCaseOffer(responseDto, objectStringId(), attorneysIds[0]), | |
| + controller.respondOnCaseOffer( | |
| + responseDto, | |
| + Types.ObjectId().toString(), | |
| + attorneysIds[0], | |
| + ), | |
| ).rejects.toThrow(CaseOffersErrors.NOT_FOUND); | |
| }); | |
| @@ -870,16 +877,16 @@ describe('Dispatch engine Controller', () => { | |
| let caseOffer: CaseOfferDto; | |
| let getFirstAttorneysRequest: nock.Scope; | |
| const firstPendingAttorney = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| const secondPendingAttorney = { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| const pendingAttorneys = [firstPendingAttorney, secondPendingAttorney]; | |
| - const rejectingAttorneyId = objectStringId(); | |
| + const rejectingAttorneyId = Types.ObjectId().toString(); | |
| beforeEach(async () => { | |
| caseOffer = await caseOfferService.create(generateDispatchFullRequest({})); | |
| caseOffer = await caseOfferService.addAttorneysToCaseOffer(caseOffer.id, [ | |
| diff --git a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.dispatch-prioritization-rank.integration.spec.ts b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.dispatch-prioritization-rank.integration.spec.ts | |
| index 7645f486a..9f4492d77 100644 | |
| --- a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.dispatch-prioritization-rank.integration.spec.ts | |
| +++ b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.dispatch-prioritization-rank.integration.spec.ts | |
| @@ -3,7 +3,7 @@ import { HttpStatus, INestApplication } from '@nestjs/common'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { TestingModule } from '@nestjs/testing'; | |
| import { generateCreateCaseOfferFullRequest } from '@vinny/dispatch-types-test-utils'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import request from 'supertest'; | |
| import { DispatchEngineController } from '../dispatch-engine.controller'; | |
| import { CaseOfferStatus, DispatchMethod } from '@vinny/dispatch-types'; | |
| @@ -32,7 +32,6 @@ import { CaseOffersErrors, GENERAL_ERROR } from '../../exceptions/errors'; | |
| import { DispatchMessagesService } from '../dispatch-messages.services'; | |
| import { DispatchNotificationsService } from '../dispatch-notifications.service'; | |
| import { StateConfigurationsService } from '../../state-configurations/state-configurations.service'; | |
| -import { objectId } from '@vinny/helpers'; | |
| const usersMsMock = nock(ENV_VARS.USERS_MS_URL); | |
| const statsMsMock = nock(ENV_VARS.STATS_MS_URL); | |
| @@ -378,7 +377,7 @@ describe('Gradual Dispatch Flow - dispatch prioritization rank', () => { | |
| }), | |
| ); | |
| await caseOffersModel.findOneAndUpdate( | |
| - { _id: objectId(caseOffer.id) }, | |
| + { _id: Types.ObjectId(caseOffer.id) }, | |
| { status, 'gradualDispatchData.prioritizationRank': 1 }, | |
| ); | |
| const response = await request(app.getHttpServer()) | |
| @@ -400,7 +399,7 @@ describe('Gradual Dispatch Flow - dispatch prioritization rank', () => { | |
| it('should fail when case offers dispatch method in not gradual dispatch', async () => { | |
| const caseOffer = await caseOfferService.create(generateCreateCaseOfferFullRequest({})); | |
| await caseOffersModel.findOneAndUpdate( | |
| - { _id: objectId(caseOffer.id) }, | |
| + { _id: Types.ObjectId(caseOffer.id) }, | |
| { 'gradualDispatchData.prioritizationRank': 1 }, | |
| ); | |
| const response = await request(app.getHttpServer()) | |
| @@ -446,7 +445,7 @@ describe('Gradual Dispatch Flow - dispatch prioritization rank', () => { | |
| }), | |
| ); | |
| await caseOffersModel.findOneAndUpdate( | |
| - { _id: objectId(caseOffer.id) }, | |
| + { _id: Types.ObjectId(caseOffer.id) }, | |
| { 'gradualDispatchData.prioritizationRank': 2 }, | |
| ); | |
| const response = await request(app.getHttpServer()) | |
| @@ -471,7 +470,7 @@ describe('Gradual Dispatch Flow - dispatch prioritization rank', () => { | |
| }), | |
| ); | |
| await caseOffersModel.findOneAndUpdate( | |
| - { _id: objectId(caseOffer.id) }, | |
| + { _id: Types.ObjectId(caseOffer.id) }, | |
| { status: CaseOfferStatus.INTERNAL, 'gradualDispatchData.prioritizationRank': 1 }, | |
| ); | |
| const response = await request(app.getHttpServer()) | |
| diff --git a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.service.spec.ts b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.service.spec.ts | |
| index 1cb8e22a5..c22551eb1 100644 | |
| --- a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.service.spec.ts | |
| +++ b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.service.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import { closeInMongodConnection } from '@vinny/test-utils'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { generateDispatchFullRequest } from '@vinny/dispatch-types-test-utils'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { DispatchEngineController } from '../dispatch-engine.controller'; | |
| import { | |
| @@ -19,7 +19,6 @@ import { CaseOffer, CaseOfferDocument } from '../../case-offers/dal/schemas/case | |
| import { createAttorneyDto, createDispatchTestModule, ENV_VARS, familyPracticeArea } from './utils'; | |
| import { updateCaseOffer } from '../../../tests/utils'; | |
| import { StateConfigurationsDal } from '../../state-configurations/dal/state-configurations.dal'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const usersMsMock = nock(ENV_VARS.USERS_MS_URL); | |
| const schedulerMock = nock(ENV_VARS.SCHEDULER_MS_URL); | |
| @@ -97,8 +96,8 @@ describe('Dispatch engine Service', () => { | |
| }); | |
| it('Should enable manual assignment when dispatch is urgent', async () => { | |
| const attorneysForDispatch = [ | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| - createAttorneyDto({ attorneyId: objectStringId() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| + createAttorneyDto({ attorneyId: Types.ObjectId().toString() }), | |
| ]; | |
| const attorneys = usersMsMock | |
| @@ -112,7 +111,7 @@ describe('Dispatch engine Service', () => { | |
| expect(caseOffer.isManuallyAssignable).toBeTruthy(); | |
| }); | |
| it('Should enable manual assignment when all dispatched attorneys have rejected the case offer', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const attorneysForDispatch = [createAttorneyDto({ attorneyId })]; | |
| const attorneys = usersMsMock | |
| @@ -151,7 +150,7 @@ describe('Dispatch engine Service', () => { | |
| }); | |
| it('Should enable manual assignment when case offers status moves to INTERNAL', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const attorneysForDispatch = [createAttorneyDto({ attorneyId })]; | |
| const attorneys = usersMsMock | |
| @@ -196,7 +195,7 @@ describe('Dispatch engine Service', () => { | |
| jest.useFakeTimers(); | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const attorneysForDispatch = [createAttorneyDto({ attorneyId })]; | |
| const attorneys = usersMsMock | |
| diff --git a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.update-dispatch.integration.spec.ts b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.update-dispatch.integration.spec.ts | |
| index a38237f0e..042b625e3 100644 | |
| --- a/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.update-dispatch.integration.spec.ts | |
| +++ b/apps/dispatch-ms/src/dispatch-engine/tests/dispatch-engine.update-dispatch.integration.spec.ts | |
| @@ -4,7 +4,7 @@ import { HttpStatus, INestApplication } from '@nestjs/common'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { TestingModule } from '@nestjs/testing'; | |
| import { generateDispatchFullRequest } from '@vinny/dispatch-types-test-utils'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import request from 'supertest'; | |
| import { DispatchEngineController } from '../dispatch-engine.controller'; | |
| @@ -16,7 +16,6 @@ import { | |
| CaseOffersErrors, | |
| UPDATING_NON_ACTIVE_CASE_OFFER_IS_FORBIDDEN, | |
| } from '../../exceptions/errors'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Update Dispatch Flow', () => { | |
| let controller: DispatchEngineController; | |
| @@ -82,7 +81,7 @@ describe('Update Dispatch Flow', () => { | |
| describe('fail', () => { | |
| it("Should throw not found exception when case offer doesn't exist", async () => { | |
| await request(app.getHttpServer()) | |
| - .patch(`/dispatch/case-offers/${objectStringId()}`) | |
| + .patch(`/dispatch/case-offers/${Types.ObjectId().toString()}`) | |
| .send({ status: UpdateDispatchStatus.INTERNAL }) | |
| .expect(404) | |
| .expect({ | |
| diff --git a/apps/dispatch-ms/src/prioritization-ranks/dal/prioritization-ranks.dal.ts b/apps/dispatch-ms/src/prioritization-ranks/dal/prioritization-ranks.dal.ts | |
| index a67a2bcb0..a5f743f85 100644 | |
| --- a/apps/dispatch-ms/src/prioritization-ranks/dal/prioritization-ranks.dal.ts | |
| +++ b/apps/dispatch-ms/src/prioritization-ranks/dal/prioritization-ranks.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Injectable, OnApplicationBootstrap } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { FilterQuery, Model } from 'mongoose'; | |
| +import { FilterQuery, Model, Types } from 'mongoose'; | |
| import { | |
| PrioritizationRank, | |
| PrioritizationRankDocument, | |
| @@ -9,7 +9,6 @@ import { DEFAULT_PRIORITIZATION_RANKS_INTERVAL_IN_MILLISECONDS } from '../consts | |
| import { UpdatePrioritizationRankPayload } from '../types'; | |
| import { LAST_PRIORITIZATION_RANK } from '../../consts'; | |
| import { FilterPrioritizationRanksDto } from '@vinny/dispatch-types'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class PrioritizationRanksDal implements OnApplicationBootstrap { | |
| @@ -49,7 +48,7 @@ export class PrioritizationRanksDal implements OnApplicationBootstrap { | |
| ): Promise<PrioritizationRank | null> { | |
| const rankDoc = await this.priotritizationRankModel.findOneAndUpdate( | |
| { | |
| - _id: objectId(id), | |
| + _id: Types.ObjectId(id), | |
| }, | |
| updateRequest, | |
| { new: true }, | |
| diff --git a/apps/dispatch-ms/src/state-configurations/dal/state-configurations.dal.ts b/apps/dispatch-ms/src/state-configurations/dal/state-configurations.dal.ts | |
| index 566033367..2b3b3e58f 100644 | |
| --- a/apps/dispatch-ms/src/state-configurations/dal/state-configurations.dal.ts | |
| +++ b/apps/dispatch-ms/src/state-configurations/dal/state-configurations.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Injectable, OnApplicationBootstrap } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { FilterQuery, Model } from 'mongoose'; | |
| +import { FilterQuery, Model, Types } from 'mongoose'; | |
| import { FilterStateConfigurationDto } from '@vinny/dispatch-types'; | |
| import { | |
| StateConfiguration, | |
| @@ -8,7 +8,6 @@ import { | |
| } from './schemas/state-configurations.schema'; | |
| import { stateIds } from '../consts'; | |
| import { UpdateStateConfigurationPayload } from '../types'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class StateConfigurationsDal implements OnApplicationBootstrap { | |
| @@ -44,7 +43,7 @@ export class StateConfigurationsDal implements OnApplicationBootstrap { | |
| ): Promise<StateConfiguration | null> { | |
| const configDoc = await this.stateConfigurationModel.findOneAndUpdate( | |
| { | |
| - _id: objectId(id), | |
| + _id: Types.ObjectId(id), | |
| }, | |
| updateRequest, | |
| { new: true }, | |
| diff --git a/apps/documents-ms/src/agreements/contract-templates/dal/schema/contract-templates.schema.ts b/apps/documents-ms/src/agreements/contract-templates/dal/schema/contract-templates.schema.ts | |
| index 0b5251265..1d1ccef37 100644 | |
| --- a/apps/documents-ms/src/agreements/contract-templates/dal/schema/contract-templates.schema.ts | |
| +++ b/apps/documents-ms/src/agreements/contract-templates/dal/schema/contract-templates.schema.ts | |
| @@ -1,7 +1,7 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { AgreementType } from '@vinny/documents-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| -import { Document, Types } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| export type ContractTemplateDocument = ContractTemplate & Document; | |
| @@ -25,7 +25,7 @@ export class ContractTemplate { | |
| }) | |
| agreementType: AgreementType; | |
| - @Prop(objectIdPropHandler()) | |
| + @Prop({ type: SchemaTypes.ObjectId, get: objectIdToStringGetter }) | |
| practiceAreaId?: string; | |
| @Prop({ | |
| diff --git a/apps/documents-ms/src/documents/dal/documents.dal.ts b/apps/documents-ms/src/documents/dal/documents.dal.ts | |
| index 59ac31d71..893719df6 100644 | |
| --- a/apps/documents-ms/src/documents/dal/documents.dal.ts | |
| +++ b/apps/documents-ms/src/documents/dal/documents.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Injectable, NotFoundException } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { DocumentsSchemaDocument, Documents } from './schema/documents.schema'; | |
| import _ from 'lodash'; | |
| import { CreateDocumentDto } from '../dtos/documents.dto'; | |
| @@ -13,7 +13,7 @@ import { | |
| } from '@vinny/documents-types'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| import mongoose from 'mongoose'; | |
| -import { getAggregateQuery, objectId } from '@vinny/helpers'; | |
| +import { getAggregateQuery } from '@vinny/helpers'; | |
| @Injectable() | |
| export class DocumentsDALService { | |
| @@ -186,7 +186,7 @@ export class DocumentsDALService { | |
| ...rest, | |
| ...(ids && { | |
| _id: { | |
| - $in: ids.filter((id) => mongoose.isValidObjectId(id)).map(objectId), | |
| + $in: ids.filter((id) => mongoose.isValidObjectId(id)).map(Types.ObjectId), | |
| }, | |
| }), | |
| ...(isUploaded !== undefined && { | |
| diff --git a/apps/documents-ms/src/documents/dal/schema/documents.schema.ts b/apps/documents-ms/src/documents/dal/schema/documents.schema.ts | |
| index f8f61d286..3b8dc16e0 100644 | |
| --- a/apps/documents-ms/src/documents/dal/schema/documents.schema.ts | |
| +++ b/apps/documents-ms/src/documents/dal/schema/documents.schema.ts | |
| @@ -1,7 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { SourceApps, DocumentClassification } from '@vinny/documents-types'; | |
| import { Types } from 'mongoose'; | |
| -import { enumPropHandler } from '@vinny/helpers'; | |
| @Schema({ _id: true, id: true, timestamps: true }) | |
| export class Documents { | |
| @@ -14,7 +13,7 @@ export class Documents { | |
| @Prop({ required: true }) | |
| fileName: string; | |
| - @Prop({ required: true, enum: Object.values(SourceApps), type: String }) | |
| + @Prop({ required: true, enum: SourceApps, type: String }) | |
| sourceApp: SourceApps; | |
| @Prop() | |
| @@ -32,7 +31,7 @@ export class Documents { | |
| @Prop({ required: true }) | |
| customerVisibility: boolean; | |
| - @Prop(enumPropHandler(DocumentClassification)) | |
| + @Prop({ enum: DocumentClassification, type: String }) | |
| classification?: DocumentClassification; | |
| @Prop() | |
| diff --git a/apps/documents-ms/src/documents/tests/documents.controller.spec.ts b/apps/documents-ms/src/documents/tests/documents.controller.spec.ts | |
| index aae61ef22..f8acfe77a 100644 | |
| --- a/apps/documents-ms/src/documents/tests/documents.controller.spec.ts | |
| +++ b/apps/documents-ms/src/documents/tests/documents.controller.spec.ts | |
| @@ -8,7 +8,7 @@ import { KafkaProducerModule, KafkaProducerService, KafkaTopics } from '@vinny/k | |
| import { ServicesClientService } from '@vinny/services-client'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { User } from '@vinny/users-types'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { S3CreatedPayload, VinnyS3Service } from '@vinny/vinny-s3'; | |
| import { ENV_VARS } from '../../tests/utils'; | |
| import { DocumentsDALService } from '../dal/documents.dal'; | |
| @@ -33,7 +33,6 @@ import { DocumentsModule } from '../documents.module'; | |
| import { S3_TOKEN } from '@ntegral/nestjs-s3'; | |
| import S3 from 'aws-sdk/clients/s3'; | |
| import { Request, Service } from 'aws-sdk/lib/core'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('DocumentsController', () => { | |
| let documentsController: DocumentsController; | |
| @@ -137,8 +136,8 @@ describe('DocumentsController', () => { | |
| .spyOn(servicesClient, 'getCasesMetadata') | |
| .mockImplementation(async () => [ | |
| mockCase, | |
| - { ...mockCase, id: objectStringId() }, | |
| - { ...mockCase, id: objectStringId() }, | |
| + { ...mockCase, id: Types.ObjectId().toString() }, | |
| + { ...mockCase, id: Types.ObjectId().toString() }, | |
| ]); | |
| jest | |
| @@ -156,7 +155,7 @@ describe('DocumentsController', () => { | |
| sourceApp: SourceApps.MY_MARBLE_WEB, | |
| classification: DocumentClassification.OTHER, | |
| customerVisibility: true, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }); | |
| expect(documentsDALService.create).toBeCalled(); | |
| @@ -248,7 +247,7 @@ describe('DocumentsController', () => { | |
| }); | |
| it('should fail to get document by id', async () => { | |
| - await expect(documentsController.findById(objectStringId())).rejects.toThrowError( | |
| + await expect(documentsController.findById(Types.ObjectId().toString())).rejects.toThrowError( | |
| 'document not found', | |
| ); | |
| }); | |
| @@ -499,8 +498,8 @@ describe('DocumentsController', () => { | |
| describe('list deleted documents', () => { | |
| it('should get documents either not deleted or deleted only by specific user', async () => { | |
| - const userId = objectStringId(); | |
| - const userId2 = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| + const userId2 = Types.ObjectId().toString(); | |
| const { id: id1 } = await documentsDALService.create(createDocumentMock1); | |
| const { id: id2 } = await documentsDALService.create(createDocumentMock2); | |
| const { id: id3 } = await documentsDALService.create(createDocumentMock3); | |
| @@ -528,7 +527,7 @@ describe('DocumentsController', () => { | |
| describe('update', () => { | |
| it('should throw not found exception when document does not exist', async () => { | |
| - await expect(documentsController.update(objectStringId(), {})).rejects.toThrow( | |
| + await expect(documentsController.update(Types.ObjectId().toString(), {})).rejects.toThrow( | |
| NotFoundException, | |
| ); | |
| }); | |
| @@ -558,7 +557,7 @@ describe('DocumentsController', () => { | |
| describe('delete', () => { | |
| it('should mark document as deleted and delete s3 url', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const { id } = await documentsDALService.create(createDocumentMock1); | |
| await request(app.getHttpServer()) | |
| .delete(`/documents/${id}`) | |
| @@ -574,7 +573,7 @@ describe('DocumentsController', () => { | |
| }); | |
| it('should throw an error when s3 deletion wasnt successful', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const { id } = await documentsDALService.create({ | |
| ...createDocumentMock1, | |
| s3Key: InvalidKey, | |
| @@ -591,8 +590,8 @@ describe('DocumentsController', () => { | |
| }); | |
| it('should throw an error when document for delete not found', async () => { | |
| - const userId = objectStringId(); | |
| - const documentId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| + const documentId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .delete(`/documents/${documentId}`) | |
| .send({ | |
| diff --git a/apps/documents-ms/src/documents/tests/documents.utils.ts b/apps/documents-ms/src/documents/tests/documents.utils.ts | |
| index fde9c1595..64e86663a 100644 | |
| --- a/apps/documents-ms/src/documents/tests/documents.utils.ts | |
| +++ b/apps/documents-ms/src/documents/tests/documents.utils.ts | |
| @@ -1,15 +1,15 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { KafkaEventType } from '@vinny/kafka-client'; | |
| import { SourceApps, DocumentClassification, S3DocumentCopyRequest } from '@vinny/documents-types'; | |
| import { KafkaEventS3UploadData, CreateDocumentDto } from '../dtos/documents.dto'; | |
| import { CaseStatus } from '@vinny/services-types'; | |
| import faker from '@faker-js/faker'; | |
| -export const DOCUMENT_TYPE_ID = objectStringId(); | |
| +export const DOCUMENT_TYPE_ID = Types.ObjectId().toString(); | |
| export const mockCase = { | |
| - id: objectStringId(), | |
| - userId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| practiceAreaId: '1', | |
| createdAt: new Date(), | |
| status: CaseStatus.ACCEPTED, | |
| @@ -19,40 +19,40 @@ export const createDocumentMock1: CreateDocumentDto = { | |
| s3Key: '123', | |
| fileName: 'document.png', | |
| sourceApp: SourceApps.LAWMATICS, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| customerVisibility: true, | |
| - uploaderMarbleId: objectStringId(), | |
| - customerMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| s3UploadDate: new Date(), | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }; | |
| export const createDocumentMock2: CreateDocumentDto = { | |
| s3Key: '1234', | |
| fileName: 'document.txt', | |
| sourceApp: SourceApps.MY_MARBLE_WEB, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| customerVisibility: true, | |
| - uploaderMarbleId: objectStringId(), | |
| - customerMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| s3UploadDate: new Date(), | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }; | |
| export const createDocumentMock3: CreateDocumentDto = { | |
| s3Key: faker.random.alphaNumeric(5), | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.GOOGLE_DRIVE, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| customerVisibility: true, | |
| - uploaderMarbleId: objectStringId(), | |
| - customerMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| s3UploadDate: new Date(), | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }; | |
| export const mockUser = { | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| id: mockCase.userId, | |
| }; | |
| diff --git a/apps/documents-ms/src/drafts/tests/mocks.ts b/apps/documents-ms/src/drafts/tests/mocks.ts | |
| index d00a21538..3847e7f19 100644 | |
| --- a/apps/documents-ms/src/drafts/tests/mocks.ts | |
| +++ b/apps/documents-ms/src/drafts/tests/mocks.ts | |
| @@ -6,7 +6,7 @@ import { | |
| SourceApps, | |
| } from '@vinny/documents-types'; | |
| import { DocumentTypeDto } from '@vinny/catalog-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const MockEnvVars = { | |
| KAFKA_BROKERS: 'dummy', | |
| @@ -32,21 +32,21 @@ export const FilledTokensAggregated = { | |
| const document: DocumentDto = { | |
| s3UploadDate: new Date(), | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| s3Key: faker.random.alphaNumeric(5), | |
| fileName: faker.system.fileName(), | |
| sourceApp: SourceApps.GOOGLE_DRIVE, | |
| caseId: 'case-id', | |
| customerVisibility: true, | |
| - uploaderMarbleId: objectStringId(), | |
| - customerMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| classification: DocumentClassification.BANK_STATEMENT, | |
| documentTypeId: 'document-type-id', | |
| }; | |
| const mockDocumentUploadResponse = { | |
| uploadUrl: faker.internet.url(), | |
| - documentId: objectStringId(), | |
| + documentId: Types.ObjectId().toString(), | |
| document: document, | |
| }; | |
| @@ -60,7 +60,7 @@ export const mockDocumentMock = { | |
| }; | |
| export const mockDocumentType: DocumentTypeDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'General', | |
| category: faker.datatype.string(), | |
| description: faker.datatype.string(), | |
| diff --git a/apps/documents-ms/src/files/dal/files.dal.ts b/apps/documents-ms/src/files/dal/files.dal.ts | |
| index 3a5adfdbe..56fd9f952 100644 | |
| --- a/apps/documents-ms/src/files/dal/files.dal.ts | |
| +++ b/apps/documents-ms/src/files/dal/files.dal.ts | |
| @@ -1,10 +1,9 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { FlareLogger, FnLogger } from '@vinny/logger'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { CreateFilePayload, FilesFilter } from '../entities/file.entity'; | |
| import { File, FileDocument } from '../schemas/files.schema'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class FilesDal { | |
| @@ -17,7 +16,7 @@ export class FilesDal { | |
| try { | |
| return await this.filesModel.create({ | |
| ...createFilePayload, | |
| - relatedEntityId: objectId(createFilePayload.relatedEntityId), | |
| + relatedEntityId: Types.ObjectId(createFilePayload.relatedEntityId), | |
| }); | |
| } catch (error) { | |
| this.logger.error('create file failed', { createFilePayload, error }); | |
| @@ -46,7 +45,7 @@ export class FilesDal { | |
| @FnLogger() | |
| async find(filter: FilesFilter): Promise<File[]> { | |
| const formattedFilter = filter.relatedEntityId | |
| - ? { ...filter, relatedEntityId: filter.relatedEntityId } | |
| + ? { ...filter, relatedEntityId: Types.ObjectId(filter.relatedEntityId) } | |
| : filter; | |
| const document = await this.filesModel.find(formattedFilter); | |
| return document; | |
| @@ -62,7 +61,7 @@ export class FilesDal { | |
| } | |
| async deleteManyByIds(fileIds: string[]): Promise<void> { | |
| try { | |
| - const objectIds = fileIds.map((id) => objectId(id)); | |
| + const objectIds = fileIds.map((id) => Types.ObjectId(id)); | |
| await this.filesModel.deleteMany({ _id: { $in: objectIds } }); | |
| } catch (error) { | |
| this.logger.error('delete multiple files failed', { fileIds, error }); | |
| diff --git a/apps/documents-ms/src/files/files.service.ts b/apps/documents-ms/src/files/files.service.ts | |
| index c30bcbed2..bca150d2e 100644 | |
| --- a/apps/documents-ms/src/files/files.service.ts | |
| +++ b/apps/documents-ms/src/files/files.service.ts | |
| @@ -11,6 +11,7 @@ import { | |
| import { FlareLogger, FnLogger } from '@vinny/logger'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import _ from 'lodash'; | |
| +import { Types } from 'mongoose'; | |
| import { S3CreatedPayload, VinnyS3Service } from '@vinny/vinny-s3'; | |
| import { FilesDal } from './dal/files.dal'; | |
| import { FilesFilter } from './entities/file.entity'; | |
| @@ -61,7 +62,7 @@ export class FilesService { | |
| const updatedFile = await this.filesDal.findOneAndUpdate( | |
| { | |
| classification, | |
| - relatedEntityId: relatedEntityId, | |
| + relatedEntityId: Types.ObjectId(relatedEntityId), | |
| }, | |
| { s3Key, fileName, s3UploadDate: undefined }, | |
| ); | |
| diff --git a/apps/documents-ms/src/files/schemas/files.schema.ts b/apps/documents-ms/src/files/schemas/files.schema.ts | |
| index 59883ccfd..b991eb03b 100644 | |
| --- a/apps/documents-ms/src/files/schemas/files.schema.ts | |
| +++ b/apps/documents-ms/src/files/schemas/files.schema.ts | |
| @@ -1,17 +1,16 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { EntityType, FileClassification } from '@vinny/documents-types'; | |
| import { SchemaTypes, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| -@Schema({ timestamps: true, autoIndex: true, toObject: { getters: true } }) | |
| +@Schema({ timestamps: true, autoIndex: true }) | |
| export class File { | |
| _id: Types.ObjectId; | |
| id: string; | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - relatedEntityId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + relatedEntityId: Types.ObjectId; | |
| @Prop({ required: true, type: String, enum: FileClassification }) | |
| classification: FileClassification; | |
| diff --git a/apps/documents-ms/src/files/tests/files.controller.spec.ts b/apps/documents-ms/src/files/tests/files.controller.spec.ts | |
| index 157d8b58f..7242f620d 100644 | |
| --- a/apps/documents-ms/src/files/tests/files.controller.spec.ts | |
| +++ b/apps/documents-ms/src/files/tests/files.controller.spec.ts | |
| @@ -10,7 +10,7 @@ import { EntityType, FileClassification } from '@vinny/documents-types'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import faker from '@faker-js/faker'; | |
| import { ConfigService } from '@nestjs/config'; | |
| @@ -18,17 +18,16 @@ import normalize from 'normalize-mongoose'; | |
| import { VinnyS3Module } from '@vinny/vinny-s3'; | |
| import { ENV_VARS, MockConfigService } from '../../tests/utils'; | |
| import { createUploadFileRequest, MockVinnyS3Service } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const userMock = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'Yana', | |
| last: 'Shaynis', | |
| }, | |
| email: '[email protected]', | |
| phone: '+972546344576', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| describe('FilesController', () => { | |
| @@ -138,7 +137,7 @@ describe('FilesController', () => { | |
| expect.objectContaining({ | |
| id: fileId, | |
| ...uploadFileRequest, | |
| - relatedEntityId: uploadFileRequest.relatedEntityId, | |
| + relatedEntityId: Types.ObjectId(uploadFileRequest.relatedEntityId), | |
| }), | |
| ); | |
| expect(uploadUrl).toEqual(expect.any(String)); | |
| @@ -232,7 +231,7 @@ describe('FilesController', () => { | |
| }); | |
| it("should throw NotFound Exception when file doesn't exist", async () => { | |
| - const fileId = objectStringId(); | |
| + const fileId = Types.ObjectId().toString(); | |
| await expect(filesController.getFileById(fileId, true)).rejects.toThrowError( | |
| `File with id ${fileId} not found`, | |
| ); | |
| @@ -314,7 +313,7 @@ describe('FilesController', () => { | |
| it('should return empty array when there are no files matching filter', async () => { | |
| const filter = { | |
| - relatedEntityId: objectStringId(), | |
| + relatedEntityId: Types.ObjectId().toString(), | |
| }; | |
| const files = await filesController.getFiles(filter); | |
| @@ -329,7 +328,7 @@ describe('FilesController', () => { | |
| it('should return empty array when the file matches the filter has no s3UploadedDate', async () => { | |
| await filesModel.findOneAndUpdate( | |
| - { relatedEntityId: userMock.id }, | |
| + { relatedEntityId: Types.ObjectId(userMock.id) }, | |
| { s3UploadDate: undefined }, | |
| ); | |
| @@ -389,7 +388,10 @@ describe('FilesController', () => { | |
| it('should throw NotFoundException when no files match the filter', async () => { | |
| await expect( | |
| - filesController.deleteFilesByFilter(objectStringId(), FileClassification.PROFILE_IMAGE), | |
| + filesController.deleteFilesByFilter( | |
| + Types.ObjectId().toString(), | |
| + FileClassification.PROFILE_IMAGE, | |
| + ), | |
| ).rejects.toThrowError('No files found to delete'); | |
| }); | |
| }); | |
| diff --git a/apps/documents-ms/src/files/tests/files.service.spec.ts b/apps/documents-ms/src/files/tests/files.service.spec.ts | |
| index 37662ec07..aedb9b457 100644 | |
| --- a/apps/documents-ms/src/files/tests/files.service.spec.ts | |
| +++ b/apps/documents-ms/src/files/tests/files.service.spec.ts | |
| @@ -8,7 +8,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { EntityType, FileClassification } from '@vinny/documents-types'; | |
| import normalize from 'normalize-mongoose'; | |
| @@ -17,7 +17,6 @@ import { FilesController } from '../files.controller'; | |
| import { FilesService } from '../files.service'; | |
| import { ENV_VARS, MockConfigService } from '../../tests/utils'; | |
| import { MockVinnyS3Service } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('FilesService', () => { | |
| let filesService: FilesService; | |
| @@ -80,13 +79,13 @@ describe('FilesService', () => { | |
| describe('handleFileUploadedToS3', () => { | |
| it('should update s3UploadDate in db when file record exists', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const file = await filesModel.create({ | |
| fileName: 'yana.png', | |
| relatedEntityType: EntityType.USER, | |
| - relatedEntityId: userId, | |
| + relatedEntityId: Types.ObjectId(userId), | |
| classification: FileClassification.PROFILE_IMAGE, | |
| - s3Key: `users/${userId}/${objectStringId()}.png`, | |
| + s3Key: `users/${userId}/${Types.ObjectId()}.png`, | |
| }); | |
| const requestData: S3CreatedPayload = { | |
| @@ -114,19 +113,19 @@ describe('FilesService', () => { | |
| }); | |
| describe('deleteFilesByFilter', () => { | |
| it('should delete files from db and s3 when files exist', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const files = await filesModel.create([ | |
| { | |
| fileName: 'test1.png', | |
| relatedEntityType: EntityType.USER, | |
| - relatedEntityId: userId, | |
| + relatedEntityId: Types.ObjectId(userId), | |
| classification: FileClassification.PROFILE_IMAGE, | |
| s3Key: `users/${userId}/test1.png`, | |
| }, | |
| { | |
| fileName: 'test2.png', | |
| relatedEntityType: EntityType.USER, | |
| - relatedEntityId: userId, | |
| + relatedEntityId: Types.ObjectId(userId), | |
| classification: FileClassification.PROFILE_IMAGE, | |
| s3Key: `users/${userId}/test2.png`, | |
| }, | |
| @@ -144,7 +143,7 @@ describe('FilesService', () => { | |
| }); | |
| it('should throw NotFoundException when no files match filter', async () => { | |
| - const nonExistentId = objectStringId(); | |
| + const nonExistentId = Types.ObjectId().toString(); | |
| await expect( | |
| filesService.deleteFilesByFilter({ relatedEntityId: nonExistentId }), | |
| ).rejects.toThrow('No files found to delete'); | |
| diff --git a/apps/documents-ms/src/files/tests/utils.ts b/apps/documents-ms/src/files/tests/utils.ts | |
| index ef3396d76..eb62901da 100644 | |
| --- a/apps/documents-ms/src/files/tests/utils.ts | |
| +++ b/apps/documents-ms/src/files/tests/utils.ts | |
| @@ -7,7 +7,7 @@ import { | |
| S3_USER_FILES_FOLDER, | |
| VinnyS3Service, | |
| } from '@vinny/vinny-s3'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { v4 as uuid } from 'uuid'; | |
| import path from 'path'; | |
| @@ -24,7 +24,7 @@ export const createUploadFileRequest = ({ | |
| fileName: fileName || faker.system.fileName(), | |
| classification: FileClassification.PROFILE_IMAGE, | |
| relatedEntityType: EntityType.USER, | |
| - relatedEntityId: relatedEntityId ?? objectStringId(), | |
| + relatedEntityId: relatedEntityId ?? Types.ObjectId().toString(), | |
| }; | |
| }; | |
| diff --git a/apps/events-ms/src/events/base-classes/dal/schemas/base-event.schema.ts b/apps/events-ms/src/events/base-classes/dal/schemas/base-event.schema.ts | |
| index 78712940a..e0aa9ad64 100644 | |
| --- a/apps/events-ms/src/events/base-classes/dal/schemas/base-event.schema.ts | |
| +++ b/apps/events-ms/src/events/base-classes/dal/schemas/base-event.schema.ts | |
| @@ -10,7 +10,6 @@ import { | |
| import { AttorneyLssCancellationReason } from '@vinny/events-types'; | |
| import { DateTime } from 'luxon'; | |
| import { Document, Schema as MongooseSchema, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| @Schema({ | |
| _id: false, | |
| @@ -29,7 +28,13 @@ export class Attendee { | |
| @Prop({ required: false, type: String, enum: Object.values(AttendeeStatusReason) }) | |
| attendeeStatusReason?: AttendeeStatusReason; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: Types.ObjectId, | |
| + get: (v: Types.ObjectId) => v.toString(), | |
| + set: (v: string) => Types.ObjectId(v), | |
| + index: true, | |
| + }) | |
| id: string; | |
| @Prop({ required: false, type: String, enum: Object.values(AttorneyLssCancellationReason) }) | |
| @@ -49,7 +54,13 @@ export const AttendeeSchema = SchemaFactory.createForClass(Attendee); | |
| // discriminatorKey: 'requestType' // For future use | |
| }) | |
| export class ChangeRequest { | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: Types.ObjectId, | |
| + get: (v: Types.ObjectId) => v.toString(), | |
| + set: (v: string) => Types.ObjectId(v), | |
| + index: true, | |
| + }) | |
| userId: string; | |
| @Prop({ required: true, type: String, enum: Object.values(ChangeRequestType) }) | |
| diff --git a/apps/events-ms/src/events/common/events.controller.ts b/apps/events-ms/src/events/common/events.controller.ts | |
| index fea4fb645..18ec1405d 100644 | |
| --- a/apps/events-ms/src/events/common/events.controller.ts | |
| +++ b/apps/events-ms/src/events/common/events.controller.ts | |
| @@ -40,13 +40,13 @@ import { FeedItemDisplay, FeedItemMetadata, GetFeedItemMetadataInput } from '@vi | |
| import { IdempotencyInterceptor, IDEMPOTENCY_KEY_HEADER } from '@vinny/idempotency'; | |
| import { getLoggingInterceptor } from '@vinny/logger'; | |
| import { polymorphicPipe } from '@vinny/transformers'; | |
| +import { isMongoId } from 'class-validator'; | |
| import { VALIDATION_PIPELINE_CONFIG } from '../../configs'; | |
| import { EventsMsErrorMessages } from '../../consts'; | |
| import { ChangeRequestService } from './change-request.service'; | |
| import { EventsFeedService } from './events-feed.service'; | |
| import { EventsService } from './events.service'; | |
| import { convertListEventsRequestDtoToListEventsDto } from './utils'; | |
| -import { isObjectId } from '@vinny/helpers'; | |
| const UPDATE_DTO_PIPE = polymorphicPipe( | |
| EventGroups.typesMap.update, | |
| @@ -111,7 +111,7 @@ export class EventsController { | |
| @ApiBadRequestResponse() | |
| @ApiNotFoundResponse({ description: EventsMsErrorMessages.EVENT_NOT_FOUND_MESSAGE }) | |
| async findById(@Param('id') id: string): Promise<ResultEventDtos> { | |
| - if (!isObjectId(id)) throw new NotFoundException({ id }); | |
| + if (!isMongoId(id)) throw new NotFoundException({ id }); | |
| const event = await this.eventsService.findById(id); | |
| @@ -131,7 +131,7 @@ export class EventsController { | |
| @Param('id') id: string, | |
| @Body() updatePayload: UpdateEventDtos, | |
| ): Promise<ResultEventDtos> { | |
| - if (!isObjectId(id)) throw new NotFoundException({ id }); | |
| + if (!isMongoId(id)) throw new NotFoundException({ id }); | |
| const { eventType } = await this.eventsService.findById(id); | |
| const updatePayloadWithEventType = { | |
| @@ -157,7 +157,7 @@ export class EventsController { | |
| @HttpCode(HttpStatus.OK) | |
| @UseInterceptors(getLoggingInterceptor({ logLevel: 'log' })) | |
| async remove(@Param('id') id: string): Promise<ResultEventDtos> { | |
| - if (!isObjectId(id)) throw new NotFoundException({ id }); | |
| + if (!isMongoId(id)) throw new NotFoundException({ id }); | |
| return await this.eventsService.remove(id); | |
| } | |
| @@ -174,7 +174,7 @@ export class EventsController { | |
| @Param('id') id: string, | |
| @Body() createDto: ChangeRequestDto, | |
| ): Promise<ResultEventDtos> { | |
| - if (!isObjectId(id)) throw new NotFoundException({ id }); | |
| + if (!isMongoId(id)) throw new NotFoundException({ id }); | |
| return this.changeRequestsService.create(id, createDto); | |
| } | |
| diff --git a/apps/events-ms/src/events/common/tests/events.controller.spec.ts b/apps/events-ms/src/events/common/tests/events.controller.spec.ts | |
| index ae42c1d0e..3390729c5 100644 | |
| --- a/apps/events-ms/src/events/common/tests/events.controller.spec.ts | |
| +++ b/apps/events-ms/src/events/common/tests/events.controller.spec.ts | |
| @@ -1,6 +1,7 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| -import { BadRequestException } from '@nestjs/common'; | |
| +import { closeInMongodConnection, rootMongooseTestModule } from '@vinny/test-utils'; | |
| +import { BadRequestException, Logger } from '@nestjs/common'; | |
| +import { ConfigService } from '@nestjs/config'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { | |
| @@ -33,20 +34,42 @@ import { | |
| attendeeId4, | |
| ATTENDEES, | |
| } from '@vinny/events-types-test-utils'; | |
| -import { KafkaEventType, KafkaProducerService, KafkaTopics } from '@vinny/kafka-client'; | |
| +import { IdempotencyModule } from '@vinny/idempotency'; | |
| +import { | |
| + KafkaEventType, | |
| + KafkaProducerModule, | |
| + KafkaProducerService, | |
| + KafkaTopics, | |
| +} from '@vinny/kafka-client'; | |
| +import { FlareLogger } from '@vinny/logger'; | |
| import { generateCreateAcceptedLssSummaryDto } from '@vinny/events-types-test-utils'; | |
| import { DateTime } from 'luxon'; | |
| import { Connection } from 'mongoose'; | |
| +import normalize from 'normalize-mongoose'; | |
| import { AlreadyCancelledEx, BadInputEx, NotFoundEx } from '../../../exceptions'; | |
| +import { LssSummariesDal } from '../../../related-resources/lss-summary/dal'; | |
| import { LssSummariesController } from '../../../related-resources/lss-summary/lss-summaries.controller'; | |
| +import { LssSummariesService } from '../../../related-resources/lss-summary/lss-summaries.service'; | |
| +import { EventsMongooseModule } from '../../base-classes/base-event.module'; | |
| +import { ChangeRequestService } from '../change-request.service'; | |
| +import { EventsDal } from '../dal/events.dal'; | |
| +import { EventsService } from '../events.service'; | |
| +import { EventDal } from '../../event/dal/event.dal'; | |
| +import { EventService } from '../../event/event.service'; | |
| +import { LssEventDal } from '../../lss-event/dal/lss-event.dal'; | |
| import { LssEventService } from '../../lss-event/lss-event.service'; | |
| +import { ChangeRequestDal } from '../dal/change-request.dal'; | |
| import { EventsController } from '../events.controller'; | |
| +import { CalendarEventService } from '../../calendar-event/calendar-event.service'; | |
| +import { CalendarEventDal } from '../../calendar-event/dal/calendar-event.dal'; | |
| import { FeedItemDisplay } from '@vinny/feed-types'; | |
| import { Role } from '@vinny/auth-types'; | |
| +import { EventsFeedService } from '../events-feed.service'; | |
| import { generateCreateCalendarEventDto } from './utils'; | |
| import { CalendarMeetingType } from '@vinny/calendars-types'; | |
| -import { EventsModule } from '../events.module'; | |
| -import { LssSummariesModule } from '../../../related-resources/lss-summary/lss-summaries.module'; | |
| +import { KeyDateEventService } from '../../key-date-event/key-date-event.service'; | |
| +import { KeyDateEventDal } from '../../key-date-event/dal/key-date-event.dal'; | |
| +import { LegalCortexClientModule } from '@vinny/legal-cortex-client'; | |
| describe('EventsController', () => { | |
| let connection: Connection; | |
| @@ -57,7 +80,41 @@ describe('EventsController', () => { | |
| beforeEach(async () => { | |
| const module: TestingModule = await Test.createTestingModule({ | |
| - imports: [EventsModule, LssSummariesModule, ...importCommons()], | |
| + imports: [ | |
| + rootMongooseTestModule({ | |
| + connectionFactory: (connection) => { | |
| + connection.plugin(normalize); | |
| + return connection; | |
| + }, | |
| + useCreateIndex: true, | |
| + useUnifiedTopology: true, | |
| + }), | |
| + EventsMongooseModule, | |
| + LegalCortexClientModule, | |
| + KafkaProducerModule.register(), | |
| + IdempotencyModule, | |
| + ], | |
| + controllers: [EventsController, LssSummariesController], | |
| + providers: [ | |
| + FlareLogger, | |
| + EventsDal, | |
| + EventsService, | |
| + EventDal, | |
| + EventService, | |
| + LssEventDal, | |
| + LssEventService, | |
| + CalendarEventDal, | |
| + CalendarEventService, | |
| + LssSummariesDal, | |
| + LssSummariesService, | |
| + ChangeRequestDal, | |
| + ChangeRequestService, | |
| + ConfigService, | |
| + Logger, | |
| + EventsFeedService, | |
| + KeyDateEventService, | |
| + KeyDateEventDal, | |
| + ], | |
| }) | |
| .overrideCommons() | |
| .compile(); | |
| @@ -873,10 +930,7 @@ describe('EventsController', () => { | |
| expect(updatedEvent).toMatchObject({ | |
| ...event, | |
| data: restOfEventData, | |
| - // eslint-disable-next-line prettier/prettier | |
| - attendees: [...event.attendees | |
| - .filter((x) => x.attendeeType === AttendeeType.CLIENT), | |
| - ...event.attendees | |
| + attendees: [...event.attendees.filter((x) => x.attendeeType === AttendeeType.CLIENT),...event.attendees | |
| .filter((x) => x.attendeeType == AttendeeType.ATTORNEY) | |
| .map((x) => ({ | |
| ...x, | |
| diff --git a/apps/events-ms/src/events/lss-event/dal/schemas/lss-event.schema.ts b/apps/events-ms/src/events/lss-event/dal/schemas/lss-event.schema.ts | |
| index 53c9bf51b..15c905275 100644 | |
| --- a/apps/events-ms/src/events/lss-event/dal/schemas/lss-event.schema.ts | |
| +++ b/apps/events-ms/src/events/lss-event/dal/schemas/lss-event.schema.ts | |
| @@ -7,10 +7,10 @@ import { | |
| SalesNotes, | |
| } from '@vinny/events-types'; | |
| import { LssAction, LssStatus } from '@vinny/events-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| import { Gender, PartialName } from '@vinny/users-types'; | |
| import { DateTime } from 'luxon'; | |
| -import { Document, Types } from 'mongoose'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| import { Attendee, BaseEvent } from '../../../base-classes/dal/schemas'; | |
| import { | |
| Child, | |
| @@ -109,7 +109,11 @@ export class LssEventData { | |
| }) | |
| lssStatus: LssStatus = LssStatus.CREATED; | |
| - @Prop(objectIdPropHandler({ required: false })) | |
| + @Prop({ | |
| + required: false, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| assignedAttorneyId?: string; | |
| @Prop({ | |
| diff --git a/apps/events-ms/src/events/lss-event/dal/schemas/lss-summary.schema.ts b/apps/events-ms/src/events/lss-event/dal/schemas/lss-summary.schema.ts | |
| index 2ed793652..7ae9be10d 100644 | |
| --- a/apps/events-ms/src/events/lss-event/dal/schemas/lss-summary.schema.ts | |
| +++ b/apps/events-ms/src/events/lss-event/dal/schemas/lss-summary.schema.ts | |
| @@ -8,7 +8,7 @@ import { | |
| LssRejectionReason, | |
| } from '@vinny/events-types'; | |
| import { Gender, PartialName } from '@vinny/users-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class LssAttorneyResponse { | |
| @@ -81,7 +81,11 @@ export class CaseInfo { | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class RecommendedService { | |
| - @Prop(objectIdPropHandler()) | |
| + @Prop({ | |
| + type: SchemaTypes.ObjectId, | |
| + get: (v: Types.ObjectId) => v?.toString(), | |
| + set: (v: string) => Types.ObjectId(v), | |
| + }) | |
| serviceTypeId?: string; | |
| @Prop() | |
| details?: string; | |
| diff --git a/apps/events-ms/src/related-resources/lss-summary/dal/lss-summaries.dal.ts b/apps/events-ms/src/related-resources/lss-summary/dal/lss-summaries.dal.ts | |
| index 4052a9e37..81b13bac1 100644 | |
| --- a/apps/events-ms/src/related-resources/lss-summary/dal/lss-summaries.dal.ts | |
| +++ b/apps/events-ms/src/related-resources/lss-summary/dal/lss-summaries.dal.ts | |
| @@ -10,12 +10,11 @@ import { | |
| UpdateLssSummaryDto, | |
| } from '@vinny/events-types'; | |
| import { flatten } from 'flat'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { EventsMsErrorMessages } from '../../../consts'; | |
| import { Attendee } from '../../../events/base-classes/dal/schemas'; | |
| import { LssEventDocument, LssSummary } from '../../../events/lss-event/dal/schemas'; | |
| import { BadInputEx, EventsMsException, NotFoundEx } from '../../../exceptions'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class LssSummariesDal { | |
| @@ -37,9 +36,7 @@ export class LssSummariesDal { | |
| eventId, | |
| { | |
| 'data.lssStatus': getStatusFromDto(createLssSummaryDto), | |
| - $push: { | |
| - [SUMMARY_ARRAY_PATH]: { _id: objectId(objectStringId()), ...createLssSummaryDto }, | |
| - }, | |
| + $push: { [SUMMARY_ARRAY_PATH]: { _id: Types.ObjectId(), ...createLssSummaryDto } }, | |
| }, | |
| { | |
| new: true, | |
| @@ -72,7 +69,7 @@ export class LssSummariesDal { | |
| async findById(summaryId: string): Promise<LssSummary | null> { | |
| const lssEventDoc = await this.lssEventModel.findOne( | |
| { | |
| - [`${SUMMARY_ARRAY_PATH}._id`]: objectId(summaryId), | |
| + [`${SUMMARY_ARRAY_PATH}._id`]: Types.ObjectId(summaryId), | |
| }, | |
| 'data.summaries', | |
| ); | |
| @@ -118,7 +115,7 @@ export class LssSummariesDal { | |
| { | |
| [SUMMARY_ARRAY_PATH]: { | |
| $elemMatch: { | |
| - _id: objectId(summaryId), | |
| + _id: Types.ObjectId(summaryId), | |
| }, | |
| }, | |
| }, | |
| @@ -159,7 +156,7 @@ export class LssSummariesDal { | |
| async getEventIdBySummaryId(summaryId: string): Promise<string | null> { | |
| const lssEventDoc = await this.lssEventModel.findOne( | |
| { | |
| - [`${SUMMARY_ARRAY_PATH}._id`]: objectId(summaryId), | |
| + [`${SUMMARY_ARRAY_PATH}._id`]: Types.ObjectId(summaryId), | |
| }, | |
| '_id id', | |
| ); | |
| diff --git a/apps/events-ms/src/related-resources/lss-summary/lss-summaries.controller.ts b/apps/events-ms/src/related-resources/lss-summary/lss-summaries.controller.ts | |
| index eabd57faa..2a14145c3 100644 | |
| --- a/apps/events-ms/src/related-resources/lss-summary/lss-summaries.controller.ts | |
| +++ b/apps/events-ms/src/related-resources/lss-summary/lss-summaries.controller.ts | |
| @@ -26,10 +26,10 @@ import { | |
| UpdateLssSummaryDto, | |
| } from '@vinny/events-types'; | |
| import { IdempotencyInterceptor } from '@vinny/idempotency'; | |
| +import { isMongoId } from 'class-validator'; | |
| import { LssSummariesService } from './lss-summaries.service'; | |
| import { LSS_SUMMARY_PIPE } from './utils'; | |
| import { getLoggingInterceptor } from '@vinny/logger'; | |
| -import { isObjectId } from '@vinny/helpers'; | |
| const SWAGGER_CREATE_INPUT_SCHEMA = { | |
| oneOf: [ | |
| @@ -77,7 +77,7 @@ export class LssSummariesController { | |
| async findById( | |
| @Param('summaryId') summaryId: string, | |
| ): Promise<LssSummaryDto | LssRejectedSummaryDto> { | |
| - if (!isObjectId(summaryId)) throw new NotFoundException(); | |
| + if (!isMongoId(summaryId)) throw new NotFoundException(); | |
| const lssSummary = await this.lssSummariesService.findById(summaryId); | |
| @@ -96,7 +96,7 @@ export class LssSummariesController { | |
| async getGeneratedClientFacingSummary( | |
| @Param('summaryId') summaryId: string, | |
| ): Promise<GeneratedClientFacingSummaryDTO> { | |
| - if (!isObjectId(summaryId)) throw new NotFoundException(); | |
| + if (!isMongoId(summaryId)) throw new NotFoundException(); | |
| const generatedClientFacingSummaryDTO = | |
| await this.lssSummariesService.getGeneratedClientFacingSummary(summaryId); | |
| @@ -115,7 +115,7 @@ export class LssSummariesController { | |
| @Param('summaryId') summaryId: string, | |
| @Body() updateDto: UpdateLssSummaryDto, | |
| ): Promise<LssSummaryDto | LssRejectedSummaryDto> { | |
| - if (!isObjectId(summaryId)) throw new NotFoundException(); | |
| + if (!isMongoId(summaryId)) throw new NotFoundException(); | |
| const lssSummary = await this.lssSummariesService.update(summaryId, updateDto); | |
| diff --git a/apps/events-ms/src/related-resources/lss-summary/lss-summaries.module.ts b/apps/events-ms/src/related-resources/lss-summary/lss-summaries.module.ts | |
| index c69b4a5ce..7c05ec9da 100644 | |
| --- a/apps/events-ms/src/related-resources/lss-summary/lss-summaries.module.ts | |
| +++ b/apps/events-ms/src/related-resources/lss-summary/lss-summaries.module.ts | |
| @@ -1,15 +1,15 @@ | |
| import { Module } from '@nestjs/common'; | |
| import { IdempotencyModule } from '@vinny/idempotency'; | |
| +import { Logger } from 'nestjs-pino'; | |
| import { BaseEventModule } from '../../events/base-classes/base-event.module'; | |
| import { LssSummariesDal } from './dal'; | |
| import { LssSummariesController } from './lss-summaries.controller'; | |
| import { LssSummariesService } from './lss-summaries.service'; | |
| import { LegalCortexClientModule } from '@vinny/legal-cortex-client'; | |
| -import { FlareLogger } from '@vinny/logger'; | |
| @Module({ | |
| imports: [BaseEventModule, IdempotencyModule, LegalCortexClientModule], | |
| controllers: [LssSummariesController], | |
| - providers: [FlareLogger, LssSummariesService, LssSummariesDal], | |
| + providers: [Logger, LssSummariesService, LssSummariesDal], | |
| }) | |
| export class LssSummariesModule {} | |
| diff --git a/apps/events-ms/src/utils.ts b/apps/events-ms/src/utils.ts | |
| index 35a1b61d2..ea6b25120 100644 | |
| --- a/apps/events-ms/src/utils.ts | |
| +++ b/apps/events-ms/src/utils.ts | |
| @@ -12,10 +12,9 @@ import { | |
| import { ClassConstructor, ClassTransformOptions, plainToInstance } from 'class-transformer'; | |
| import { validateSync } from 'class-validator'; | |
| import _ from 'lodash'; | |
| -import { FilterQuery } from 'mongoose'; | |
| +import { FilterQuery, Types } from 'mongoose'; | |
| import { LssEventDocument } from './events/lss-event/dal/schemas'; | |
| import { DateTime } from 'luxon'; | |
| -import { objectId } from '@vinny/helpers'; | |
| export function schemaToDto<T extends object, V>( | |
| cls: ClassConstructor<T>, | |
| @@ -49,7 +48,7 @@ export function schemaToDto<T extends object, V>( | |
| } | |
| export function buildEventsQuery(filter: FilterEventDto): Record<string, any> { | |
| - const _id = filter.id && filter.id; | |
| + const _id = filter.id && Types.ObjectId(filter.id); | |
| if (!filter.eventType && filter.attorneyLssStatuses) { | |
| throw new BadRequestException('Attorney LSS statuses can only be filtered with event type'); | |
| @@ -85,7 +84,7 @@ export function buildEventsQuery(filter: FilterEventDto): Record<string, any> { | |
| const attendeeIdsFilter = filter.attendeeIds && { | |
| attendees: { | |
| $elemMatch: { | |
| - id: { $in: filter.attendeeIds.map(objectId) }, | |
| + id: { $in: filter.attendeeIds.map(Types.ObjectId) }, | |
| }, | |
| }, | |
| }; | |
| @@ -93,7 +92,7 @@ export function buildEventsQuery(filter: FilterEventDto): Record<string, any> { | |
| const allAttendeeIdsFilter = filter.allAttendeeIds && { | |
| attendees: { | |
| $all: filter.allAttendeeIds.map((id) => ({ | |
| - $elemMatch: { id: objectId(id) }, | |
| + $elemMatch: { id: Types.ObjectId(id) }, | |
| })), | |
| }, | |
| }; | |
| diff --git a/apps/graphql-gateway-ms/src/attorney-public-info/tests/attorney-public-info.mock.ts b/apps/graphql-gateway-ms/src/attorney-public-info/tests/attorney-public-info.mock.ts | |
| index 2d1a437fd..d9a490754 100644 | |
| --- a/apps/graphql-gateway-ms/src/attorney-public-info/tests/attorney-public-info.mock.ts | |
| +++ b/apps/graphql-gateway-ms/src/attorney-public-info/tests/attorney-public-info.mock.ts | |
| @@ -1,7 +1,8 @@ | |
| import { LegalTeamMember, LegalTeamMemberRole, ServiceMetadataDto } from '@vinny/services-types'; | |
| +import { Types } from 'mongoose'; | |
| -export const mockCustomerId = 'customer-123'; | |
| -export const mockAttorneyId = 'attorney-456'; | |
| +export const mockCustomerId = Types.ObjectId('customer-123').toString(); | |
| +export const mockAttorneyId = Types.ObjectId('attorney-456').toString(); | |
| export const createServiceMetadata = (legalTeam: LegalTeamMember[] = []): ServiceMetadataDto[] => [ | |
| { | |
| diff --git a/apps/graphql-gateway-ms/src/catalog/document-types/test/consts.ts b/apps/graphql-gateway-ms/src/catalog/document-types/test/consts.ts | |
| index b3ecc283c..d7132f594 100644 | |
| --- a/apps/graphql-gateway-ms/src/catalog/document-types/test/consts.ts | |
| +++ b/apps/graphql-gateway-ms/src/catalog/document-types/test/consts.ts | |
| @@ -1,9 +1,9 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| -export const documentTypeId1 = objectStringId(); | |
| -export const documentTypeId2 = objectStringId(); | |
| -export const documentTypeId3 = objectStringId(); | |
| +export const documentTypeId1 = Types.ObjectId().toString(); | |
| +export const documentTypeId2 = Types.ObjectId().toString(); | |
| +export const documentTypeId3 = Types.ObjectId().toString(); | |
| export const SUPPORTED_UPLOAD_DOCUMENT_TYPE_IDS_MOCK = `${documentTypeId1},${documentTypeId2},${documentTypeId3}`; | |
| diff --git a/apps/graphql-gateway-ms/src/data-requests/tests/const.ts b/apps/graphql-gateway-ms/src/data-requests/tests/const.ts | |
| index 0c870b083..b064d4240 100644 | |
| --- a/apps/graphql-gateway-ms/src/data-requests/tests/const.ts | |
| +++ b/apps/graphql-gateway-ms/src/data-requests/tests/const.ts | |
| @@ -1,12 +1,12 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| -export const USER_ID = objectStringId(); | |
| -export const ATTORNEY_ID = objectStringId(); | |
| -export const DOCUMENT_TYPE_ID_1 = objectStringId(); | |
| -export const DOCUMENT_TYPE_ID_2 = objectStringId(); | |
| -export const UPLOADED_DOCUMENT_IDS_1 = [objectStringId(), objectStringId()]; | |
| -export const UPLOADED_DOCUMENT_IDS_2 = [objectStringId(), objectStringId()]; | |
| +export const USER_ID = Types.ObjectId().toString(); | |
| +export const ATTORNEY_ID = Types.ObjectId().toString(); | |
| +export const DOCUMENT_TYPE_ID_1 = Types.ObjectId().toString(); | |
| +export const DOCUMENT_TYPE_ID_2 = Types.ObjectId().toString(); | |
| +export const UPLOADED_DOCUMENT_IDS_1 = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| +export const UPLOADED_DOCUMENT_IDS_2 = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| export const GET_DOCUMENTS_QUERY = `query GetRequiredDocuments { | |
| getRequiredDocuments { | |
| diff --git a/apps/graphql-gateway-ms/src/data-requests/tests/data-requests.resolver.spec.ts b/apps/graphql-gateway-ms/src/data-requests/tests/data-requests.resolver.spec.ts | |
| index 24256d081..af475b852 100644 | |
| --- a/apps/graphql-gateway-ms/src/data-requests/tests/data-requests.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/data-requests/tests/data-requests.resolver.spec.ts | |
| @@ -18,7 +18,7 @@ import { | |
| } from './const'; | |
| import { DataPointsSubmissionError } from '../model/data-requests.model'; | |
| import { BusinessFlowManagerClientModule } from '@vinny/business-flow-manager-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { DataRequestsClientModule } from '@vinny/data-requests-client'; | |
| import { NotFoundException } from '@nestjs/common'; | |
| @@ -73,8 +73,8 @@ describe('Data Requests Resolver', () => { | |
| describe('getRequiredDocuments', () => { | |
| it('should get required documents for user', async () => { | |
| - const lssIds = [objectStringId(), objectStringId()]; | |
| - const repeatIds = [objectStringId()]; | |
| + const lssIds = [Types.ObjectId().toString(), Types.ObjectId().toString()]; | |
| + const repeatIds = [Types.ObjectId().toString()]; | |
| const getRequiredDocumentsNock = businessFlowManagerClientNock | |
| .get(`/required-documents-flow/${USER_ID}`) | |
| .reply(200, { | |
| diff --git a/apps/graphql-gateway-ms/src/devices/tests/devices.resolver.spec.ts b/apps/graphql-gateway-ms/src/devices/tests/devices.resolver.spec.ts | |
| index a2b382efe..655d9db58 100644 | |
| --- a/apps/graphql-gateway-ms/src/devices/tests/devices.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/devices/tests/devices.resolver.spec.ts | |
| @@ -7,7 +7,7 @@ import { DeviceResolver } from '../devices.resolver'; | |
| import { MockConfigService } from '@vinny/test-utils'; | |
| import { NotificationsClientModule } from '@vinny/notifications-client'; | |
| import { DevicesService } from '../devices.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { registerDeviceInput } from './consts'; | |
| const ENV_VARS = { | |
| @@ -53,7 +53,7 @@ describe('Devices resolver', () => { | |
| describe('registerDevice', () => { | |
| it('should register a device with token', async () => { | |
| - const mockUserContext = { id: objectStringId() }; | |
| + const mockUserContext = { id: Types.ObjectId().toString() }; | |
| const registerDeviceRequest = notificationsMsNock | |
| .post('/devices', { | |
| diff --git a/apps/graphql-gateway-ms/src/documents/test/consts.ts b/apps/graphql-gateway-ms/src/documents/test/consts.ts | |
| index 703bc66a4..8ca53b594 100644 | |
| --- a/apps/graphql-gateway-ms/src/documents/test/consts.ts | |
| +++ b/apps/graphql-gateway-ms/src/documents/test/consts.ts | |
| @@ -1,20 +1,20 @@ | |
| import { Document, SourceApps } from '@vinny/documents-types'; | |
| import { faker } from '@faker-js/faker'; | |
| -import { objectStringId, objectId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { UpdateDocumentError } from '../model/documents.model'; | |
| import { CaseDto, CaseStatus } from '@vinny/services-types'; | |
| import { DocumentTypeDto } from '@vinny/catalog-types'; | |
| -export const userId = objectId(objectStringId()); | |
| -export const caseId = objectId(objectStringId()); | |
| -export const documentTypeId1 = objectStringId(); | |
| -export const documentTypeId2 = objectStringId(); | |
| -export const documentTypeId3 = objectStringId(); | |
| +export const userId = Types.ObjectId(); | |
| +export const caseId = Types.ObjectId(); | |
| +export const documentTypeId1 = Types.ObjectId().toString(); | |
| +export const documentTypeId2 = Types.ObjectId().toString(); | |
| +export const documentTypeId3 = Types.ObjectId().toString(); | |
| export const caseMock: CaseDto = { | |
| id: String(caseId), | |
| userId: String(userId), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: String(Types.ObjectId()), | |
| createdAt: new Date(), | |
| status: CaseStatus.ACCEPTED, | |
| }; | |
| @@ -34,13 +34,13 @@ export const generateMockDocument = ({ | |
| s3UploadDate?: Date; | |
| documentTypeId: string; | |
| }): Document => ({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| s3Key: faker.datatype.string(), | |
| s3UploadDate, | |
| sourceApp, | |
| caseId, | |
| - uploaderMarbleId: objectStringId(), | |
| - customerMarbleId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| + customerMarbleId: Types.ObjectId().toString(), | |
| customerVisibility, | |
| fileName, | |
| documentTypeId, | |
| @@ -121,7 +121,7 @@ export const MockPayload = { | |
| fileName: 'case manager.jpeg', | |
| sourceApp: SourceApps.MY_MARBLE_WEB, | |
| customerVisibility: true, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }; | |
| export const successUpdateResponse = { | |
| @@ -187,7 +187,7 @@ export const requestDocumentUploadPayload = { | |
| fileName: 'case manager.jpeg', | |
| sourceApp: 'MY_MARBLE_WEB', | |
| customerVisibility: true, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }, | |
| }; | |
| @@ -234,7 +234,7 @@ export const getCustomerDocumentsValidQuery = `query GetCustomerDocuments { | |
| howToObtain | |
| importanceDescription | |
| } | |
| - id | |
| + id | |
| documentTypeId | |
| customerVisibility | |
| customerMarbleId | |
| @@ -258,7 +258,7 @@ export const renameDocumentValidMutation = ` | |
| success, | |
| error | |
| } | |
| - } | |
| + } | |
| `; | |
| export const removeDocumentCustomerVisibilityValidMutation = ` | |
| @@ -267,5 +267,5 @@ export const removeDocumentCustomerVisibilityValidMutation = ` | |
| success, | |
| error | |
| } | |
| - } | |
| + } | |
| `; | |
| diff --git a/apps/graphql-gateway-ms/src/documents/test/documents.resolver.spec.ts b/apps/graphql-gateway-ms/src/documents/test/documents.resolver.spec.ts | |
| index 4ae6e7273..e0b46e8ae 100644 | |
| --- a/apps/graphql-gateway-ms/src/documents/test/documents.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/documents/test/documents.resolver.spec.ts | |
| @@ -31,7 +31,7 @@ import { | |
| documentType3, | |
| documentTypeId2, | |
| } from './consts'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { Permission } from '@vinny/auth-types'; | |
| import { DocumentTypesDataLoader } from '../../shared/document-types/document-types.loader'; | |
| import { DocumentCatalogClientModule, DocumentCatalogClientService } from '@vinny/catalog-client'; | |
| @@ -138,7 +138,7 @@ describe('documents resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user id on case != context user id', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const findCaseRequest = servicesMsNock.get(`/cases/${caseId}`).reply(200, caseMock); | |
| await expect(resolver.getDocumentsByCaseId({ id: userId }, caseMock.id)).rejects.toThrowError( | |
| `Unauthorized access to case resources by user with id ${userId}`, | |
| @@ -147,7 +147,7 @@ describe('documents resolver', () => { | |
| }); | |
| it('should not throw UnauthorizedException when user id on case != admin id ', async () => { | |
| - const differentUserId = objectStringId(); | |
| + const differentUserId = Types.ObjectId().toString(); | |
| const findDocumentsRequest = documentsMsNock | |
| .get(`/documents?caseId=${caseId}&customerVisibility=true`) | |
| .reply(200, [mockDocument1, mockDocument2]); | |
| @@ -220,34 +220,34 @@ describe('documents resolver', () => { | |
| s3UploadDate: new Date(), | |
| fileName: 'LAWMATICS.PNG', | |
| sourceApp: SourceApps.LAWMATICS, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }), | |
| generateMockDocument({ | |
| caseId: caseMock.id, | |
| s3UploadDate: new Date(), | |
| fileName: 'LAWMATICS.PNG', | |
| sourceApp: SourceApps.LAWMATICS, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }), | |
| generateMockDocument({ | |
| caseId: caseMock.id, | |
| s3UploadDate: new Date(), | |
| fileName: 'MYMARBLE.PNG', | |
| sourceApp: SourceApps.MY_MARBLE_MOBILE, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }), | |
| generateMockDocument({ | |
| caseId: caseMock.id, | |
| s3UploadDate: new Date(), | |
| fileName: 'MYMARBLE.PNG', | |
| sourceApp: SourceApps.MY_MARBLE_MOBILE, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }), | |
| generateMockDocument({ | |
| caseId: caseMock.id, | |
| s3UploadDate: new Date(), | |
| sourceApp: SourceApps.FLAREX, | |
| - documentTypeId: objectStringId(), | |
| + documentTypeId: Types.ObjectId().toString(), | |
| }), | |
| ]; | |
| const findCasesRequest = servicesMsNock.get(`/cases?userId=${userId}`).reply(200, [caseMock]); | |
| @@ -289,7 +289,7 @@ describe('documents resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user id on case != context user id', async () => { | |
| - const differentUserId = objectStringId(); | |
| + const differentUserId = Types.ObjectId().toString(); | |
| const findCaseRequest = servicesMsNock.get(`/cases/${caseId}`).reply(200, caseMock); | |
| const getDocumentByIdRequest = documentsMsNock | |
| .get(`/documents/${mockDocument1.id}`) | |
| @@ -321,7 +321,7 @@ describe('documents resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user id on case != context user id', async () => { | |
| - const differentUserId = objectStringId(); | |
| + const differentUserId = Types.ObjectId().toString(); | |
| const findCaseRequest = servicesMsNock | |
| .get(`/cases/${MockPayload.caseId}`) | |
| @@ -379,7 +379,7 @@ describe('documents resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user id on case != context user id', async () => { | |
| - const differentUserId = objectStringId(); | |
| + const differentUserId = Types.ObjectId().toString(); | |
| const findCaseRequest = servicesMsNock.get(`/cases/${caseId}`).reply(200, caseMock); | |
| const getDocumentByIdRequest = documentsMsNock | |
| @@ -434,7 +434,7 @@ describe('documents resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user id on case != context user id', async () => { | |
| - const differentUserId = objectStringId(); | |
| + const differentUserId = Types.ObjectId().toString(); | |
| const findCaseRequest = servicesMsNock.get(`/cases/${caseId}`).reply(200, caseMock); | |
| const getDocumentByIdRequest = documentsMsNock | |
| diff --git a/apps/graphql-gateway-ms/src/practice-area/tests/practice-areas.service.spec.ts b/apps/graphql-gateway-ms/src/practice-area/tests/practice-areas.service.spec.ts | |
| index 3032402c7..eb2eb5dd6 100644 | |
| --- a/apps/graphql-gateway-ms/src/practice-area/tests/practice-areas.service.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/practice-area/tests/practice-areas.service.spec.ts | |
| @@ -4,7 +4,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { ServicesClientModule } from '@vinny/services-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { PracticeAreaService } from '../practice-areas.service'; | |
| @@ -16,7 +16,7 @@ const servicesMsNock = nock(ENV_VARS.SERVICES_MS_URL); | |
| describe('practice area service', () => { | |
| const mockPracticeArea = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| key: faker.lorem.words(1), | |
| displayName: faker.lorem.words(2), | |
| }; | |
| diff --git a/apps/graphql-gateway-ms/src/services/cases/test/cases.resolver.spec.ts b/apps/graphql-gateway-ms/src/services/cases/test/cases.resolver.spec.ts | |
| index c23414541..61ce04f36 100644 | |
| --- a/apps/graphql-gateway-ms/src/services/cases/test/cases.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/services/cases/test/cases.resolver.spec.ts | |
| @@ -8,7 +8,7 @@ import { CasesResolver } from '../cases.resolver'; | |
| import { CasesModule } from '../cases.module'; | |
| import { CasesApiService } from '../cases.service'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { Permission } from '@vinny/auth-types'; | |
| import { CasesError } from '../../models/case.model'; | |
| import { | |
| @@ -143,7 +143,7 @@ describe('cases resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user id != context user id', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| await expect(resolver.getCasesByUserId({ id: userId }, theCase.userId)).rejects.toThrowError( | |
| `Unauthorized access, can't get cases of another user`, | |
| @@ -151,7 +151,7 @@ describe('cases resolver', () => { | |
| }); | |
| it('should not throw UnauthorizedException when user id != context admin id', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getCasesByUserIdRequest = servicesMsNock | |
| .get(`/cases?userId=${theCase.userId}`) | |
| .reply(200, [theCase]); | |
| @@ -166,8 +166,8 @@ describe('cases resolver', () => { | |
| }); | |
| it('should return case with intro calls ', async () => { | |
| - const userId = objectStringId(); | |
| - const attorneyId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const introCall: IntroCall = { strategyReviewCallCompleteDate: faker.date.past() }; | |
| const getCaseByIdRequest = servicesMsNock.get(`/cases?userId=${userId}`).reply(200, [ | |
| { | |
| @@ -196,7 +196,7 @@ describe('cases resolver', () => { | |
| }); | |
| it('should get customer cases', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| servicesMsNock.get(`/cases?userId=${userId}`).reply(200, MockCase); | |
| const caseFetched = await resolver.getCustomerCases({ id: userId }); | |
| caseFetched && expect(caseFetched[0].id).toEqual(MockCase[0].id); | |
| @@ -251,7 +251,7 @@ describe('cases resolver', () => { | |
| }); | |
| it('should throw UnauthorizedException when user id on case != context user id', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getCaseByIdRequest = servicesMsNock.get(`/cases/${theCase.id}`).reply(200, theCase); | |
| await expect(resolver.getCaseById({ id: userId }, theCase.id)).rejects.toThrowError( | |
| `Unauthorized access to case resources by user with id ${userId}`, | |
| @@ -260,7 +260,7 @@ describe('cases resolver', () => { | |
| }); | |
| it('should not throw UnauthorizedException when user id on case != admin id ', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getCaseByIdRequest = servicesMsNock.get(`/cases/${theCase.id}`).reply(200, theCase); | |
| const caseResult = await resolver.getCaseById( | |
| diff --git a/apps/graphql-gateway-ms/src/services/cases/test/cases.schema.spec.ts b/apps/graphql-gateway-ms/src/services/cases/test/cases.schema.spec.ts | |
| index 1a66d0c3e..f0f4e98ac 100644 | |
| --- a/apps/graphql-gateway-ms/src/services/cases/test/cases.schema.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/services/cases/test/cases.schema.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| import { getCaseByIdInvalidQuery, getCaseByIdValidQuery } from './consts'; | |
| @@ -98,13 +98,13 @@ describe('cases schema', () => { | |
| describe('getCaseById', () => { | |
| it('Should pass if the query is valid', () => { | |
| tester.test(true, getCaseByIdValidQuery, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| it('Should not pass if the query is invalid', () => { | |
| tester.test(false, getCaseByIdInvalidQuery, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }); | |
| }); | |
| }); | |
| diff --git a/apps/graphql-gateway-ms/src/services/cases/test/mocks.ts b/apps/graphql-gateway-ms/src/services/cases/test/mocks.ts | |
| index e8f761c2d..1af61ebd8 100644 | |
| --- a/apps/graphql-gateway-ms/src/services/cases/test/mocks.ts | |
| +++ b/apps/graphql-gateway-ms/src/services/cases/test/mocks.ts | |
| @@ -1,5 +1,5 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| CaseDto, | |
| EventResponse, | |
| @@ -28,13 +28,13 @@ export const MockCase: CaseDto[] = [ | |
| ]; | |
| export const practiceAreaMockFamily: PracticeAreaDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| key: 'FAMILY', | |
| displayName: 'Family', | |
| }; | |
| export const practiceAreaMockImmigration: PracticeAreaDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| key: 'IMMIGRATION', | |
| displayName: 'Immigration', | |
| }; | |
| @@ -50,9 +50,9 @@ export const theCase = { | |
| }; | |
| export const theCase1 = { | |
| - id: objectStringId(), | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| strategyReviewCallComplete: true, | |
| opposingParty: faker.lorem.sentence(), | |
| @@ -61,12 +61,12 @@ export const theCase1 = { | |
| export const theCase2 = { | |
| ...theCase1, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }; | |
| export const theCase3 = { | |
| ...theCase1, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }; | |
| export const theCaseImmigration = { | |
| @@ -89,7 +89,7 @@ export const attorneyMock = { | |
| ...userMock, | |
| id: faker.database.mongodbObjectId(), | |
| attorneyData: { | |
| - practiceAreasIds: [objectStringId()], | |
| + practiceAreasIds: [Types.ObjectId().toString()], | |
| isActive: true, | |
| }, | |
| }; | |
| @@ -110,16 +110,16 @@ export const attorneyMock2 = { | |
| }; | |
| export const serviceDtoWithAttorney: ServiceDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| caseId: theCase.id, | |
| legalTeam: [ | |
| { userId: paralegalMock.id, role: LegalTeamMemberRole.PARALEGAL }, | |
| { userId: attorneyMock.id, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| location: { | |
| state: 'some state', | |
| }, | |
| @@ -128,23 +128,23 @@ export const serviceDtoWithAttorney: ServiceDto = { | |
| export const serviceDtoWithCaseManager: ServiceDto = { | |
| ...serviceDtoWithAttorney, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| legalTeam: [{ userId: caseManagerMock.id, role: LegalTeamMemberRole.CASE_MANAGER }], | |
| }; | |
| export const serviceDto: ServiceDto = { | |
| ...serviceDtoWithAttorney, | |
| legalTeam: [ | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }; | |
| const createEventResponseMock = () => ({ | |
| - id: objectStringId(), | |
| - parentId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + parentId: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| description: faker.lorem.sentence(), | |
| locations: 'Test Location', | |
| @@ -171,32 +171,32 @@ const createLssEventMock = (): LssEventDto => ({ | |
| lssStatus: LssStatus.COMPLETED_NO_SHOW, | |
| intake: { | |
| fips: '01234', | |
| - stateId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + stateId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| }, | |
| }, | |
| attendees: [ | |
| { | |
| attendeeType: AttendeeType.ATTORNEY, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }, | |
| { | |
| attendeeType: AttendeeType.CLIENT, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| caseId: theCase1.id, | |
| endDate, | |
| eventType: EventType.LSS_EVENT, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| isCancelled: false, | |
| isCompleted: false, | |
| requests: [], | |
| startDate, | |
| - bookeeEventId: objectStringId(), | |
| - bookeeMeetingId: objectStringId(), | |
| + bookeeEventId: Types.ObjectId().toString(), | |
| + bookeeMeetingId: Types.ObjectId().toString(), | |
| syncInfo: { | |
| - salesforceOpportunityId: objectStringId(), | |
| + salesforceOpportunityId: Types.ObjectId().toString(), | |
| }, | |
| }); | |
| @@ -210,9 +210,9 @@ export const GetPreClientDeletedEventsResponse = { | |
| export const serviceCatalogMock1: CatalogServiceType = { | |
| serviceTypeName: faker.name.findName(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| content: { | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| category: 'patition', | |
| isLastService: false, | |
| description: { whatComesNext: ['step1', 'step2'], legalDescription: 'legal description' }, | |
| @@ -221,9 +221,9 @@ export const serviceCatalogMock1: CatalogServiceType = { | |
| export const serviceCatalogMock2: CatalogServiceType = { | |
| serviceTypeName: faker.name.findName(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| content: { | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| category: 'consolting', | |
| isLastService: false, | |
| description: { | |
| @@ -234,10 +234,10 @@ export const serviceCatalogMock2: CatalogServiceType = { | |
| }; | |
| export const serviceMock1: ServiceDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| caseId: theCase.id, | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| legalTeam: [{ userId: '1', role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }], | |
| location: { | |
| state: 'some state', | |
| @@ -245,7 +245,7 @@ export const serviceMock1: ServiceDto = { | |
| status: ServiceStatus.CANCELED, | |
| description: faker.lorem.word(), | |
| practiceAreaId: practiceAreaMockFamily.id, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| progress: { | |
| milestones: { | |
| [faker.database.mongodbObjectId()]: { | |
| @@ -263,32 +263,32 @@ export const serviceMock1: ServiceDto = { | |
| export const serviceMock2 = { | |
| ...serviceMock1, | |
| legalTeam: [{ userId: '2', role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }], | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: ServiceStatus.COMPLETED, | |
| }; | |
| export const serviceMock3 = { | |
| ...serviceMock1, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }; | |
| export const serviceMock4 = { | |
| ...serviceMock1, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }; | |
| export const serviceMock5 = { | |
| ...serviceMock1, | |
| serviceTypeId: '4436454', | |
| status: ServiceStatus.PENDING, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }; | |
| export const serviceMock6 = { | |
| ...serviceMock1, | |
| serviceTypeId: '44364556', | |
| status: ServiceStatus.PENDING, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }; | |
| export const serviceMockImmigration = { | |
| @@ -297,11 +297,11 @@ export const serviceMockImmigration = { | |
| }; | |
| export const serviceMockWithoutServiceType = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: faker.lorem.word(), | |
| - responsibleAttorneyId: objectStringId(), | |
| + responsibleAttorneyId: Types.ObjectId().toString(), | |
| description: faker.lorem.word(), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| }; | |
| export const caseFormQuestionnaire: CaseForm = { | |
| diff --git a/apps/graphql-gateway-ms/src/services/repeats/test/utils.ts b/apps/graphql-gateway-ms/src/services/repeats/test/utils.ts | |
| index 1b252a438..092a764a1 100644 | |
| --- a/apps/graphql-gateway-ms/src/services/repeats/test/utils.ts | |
| +++ b/apps/graphql-gateway-ms/src/services/repeats/test/utils.ts | |
| @@ -1,12 +1,12 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { RepeatSupportRequestInput, RepeatSupportRequestTypeEnum } from '../../models/repeat.model'; | |
| export const validSubmitRepeatSupportRequestPayload: RepeatSupportRequestInput = { | |
| - repeatId: objectStringId(), | |
| + repeatId: Types.ObjectId.toString(), | |
| message: 'a valid message', | |
| supportRequestType: RepeatSupportRequestTypeEnum.SERVICES, | |
| }; | |
| -export const userId = objectStringId(); | |
| +export const userId = Types.ObjectId().toString(); | |
| export const submitRepeatSupportRequestMutation = ` | |
| mutation Mutation($input: RepeatSupportRequestInput!) { | |
| diff --git a/apps/graphql-gateway-ms/src/services/repeats/tests/mock.ts b/apps/graphql-gateway-ms/src/services/repeats/tests/mock.ts | |
| index a0794d47b..38ea2e233 100644 | |
| --- a/apps/graphql-gateway-ms/src/services/repeats/tests/mock.ts | |
| +++ b/apps/graphql-gateway-ms/src/services/repeats/tests/mock.ts | |
| @@ -1,16 +1,16 @@ | |
| import faker from '@faker-js/faker'; | |
| import { RepeatStatus } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| -export const MockUserId = objectStringId(); | |
| +export const MockUserId = Types.ObjectId().toString(); | |
| export const MockRepeat = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| attorneyNotes: faker.datatype.string(), | |
| - attorneyId: objectStringId(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| status: RepeatStatus.APPROVED, | |
| services: { | |
| - addedServicesTypeIds: [objectStringId()], | |
| + addedServicesTypeIds: [Types.ObjectId().toString()], | |
| removedServicesIds: [], | |
| }, | |
| events: [ | |
| diff --git a/apps/graphql-gateway-ms/src/services/repeats/tests/repeats.schema.spec.ts b/apps/graphql-gateway-ms/src/services/repeats/tests/repeats.schema.spec.ts | |
| index 940bc7a6d..4d100f591 100644 | |
| --- a/apps/graphql-gateway-ms/src/services/repeats/tests/repeats.schema.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/services/repeats/tests/repeats.schema.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import EasyGraphQLTester from 'easygraphql-tester'; | |
| import * as fs from 'fs'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import * as path from 'path'; | |
| import { updateRepeatValidMutation, updateRepeatInvalidMutation } from './consts'; | |
| @@ -13,14 +13,14 @@ describe('repeats schema', () => { | |
| describe('updateRepeat', () => { | |
| it('Should pass if the mutation is valid', () => { | |
| tester.test(true, updateRepeatValidMutation, { | |
| - repeatId: objectStringId(), | |
| + repeatId: Types.ObjectId().toString(), | |
| payload: { status: 'OPEN' }, | |
| }); | |
| }); | |
| it('Should not pass if the mutation is invalid', () => { | |
| tester.test(false, updateRepeatInvalidMutation, { | |
| - repeatId: objectStringId(), | |
| + repeatId: Types.ObjectId().toString(), | |
| payload: { status: 'OPEN' }, | |
| }); | |
| }); | |
| diff --git a/apps/graphql-gateway-ms/src/services/services/test/consts.ts b/apps/graphql-gateway-ms/src/services/services/test/consts.ts | |
| index 9f9948aea..b875997a5 100644 | |
| --- a/apps/graphql-gateway-ms/src/services/services/test/consts.ts | |
| +++ b/apps/graphql-gateway-ms/src/services/services/test/consts.ts | |
| @@ -1,30 +1,30 @@ | |
| import faker from '@faker-js/faker'; | |
| import { ServiceTypeDto } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ServiceType } from '../../models/service-type.model'; | |
| import { ServiceStatus } from '../../models/service.model'; | |
| export const theService1 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| - practiceAreaId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [], | |
| - serviceTypeId: objectStringId(), | |
| - userId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| location: { | |
| state: 'some state', | |
| }, | |
| status: ServiceStatus.OPEN, | |
| }; | |
| export const theService2 = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.name.findName(), | |
| - practiceAreaId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [], | |
| - serviceTypeId: objectStringId(), | |
| - userId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| location: { | |
| state: 'some state', | |
| }, | |
| @@ -40,7 +40,7 @@ export const serviceTypeDtoMock1: ServiceTypeDto = { | |
| name: `service test ${faker.datatype.number()}`, | |
| description: `service description ${faker.datatype.number()}`, | |
| category: `service category ${faker.datatype.number()}`, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| stateIds: [ | |
| { | |
| id: faker.datatype.number(1).toString(), | |
| @@ -74,10 +74,10 @@ export const serviceTypeDtoMock2: ServiceTypeDto = { | |
| ...serviceTypeDtoMock1, | |
| id: theService2.serviceTypeId, | |
| whatIsIncluded: ` | |
| - | |
| - | |
| + | |
| + | |
| ${someLine} | |
| - | |
| + | |
| `, | |
| }; | |
| diff --git a/apps/graphql-gateway-ms/src/users/auth/test/auth.resolver.spec.ts b/apps/graphql-gateway-ms/src/users/auth/test/auth.resolver.spec.ts | |
| index 48bafc887..ef81d7cbc 100644 | |
| --- a/apps/graphql-gateway-ms/src/users/auth/test/auth.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/users/auth/test/auth.resolver.spec.ts | |
| @@ -4,7 +4,7 @@ import { AuthClientModule, AuthClientService } from '@vinny/auth-client'; | |
| import { AuthApiService } from '../auth.service'; | |
| import { AuthResolver } from '../auth.resolver'; | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { TokenTypes } from '@vinny/auth-types'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| @@ -50,8 +50,8 @@ describe('auth resolver', () => { | |
| }); | |
| it('should return a new token if existing token is valid', async () => { | |
| const token = await authClientService.tokenize({ | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| sessionType: TokenTypes.Token, | |
| }); | |
| const newToken = await authClientService.refreshToken({ token }); | |
| diff --git a/apps/graphql-gateway-ms/src/users/login/test/login.impersonate.resolver.spec.ts b/apps/graphql-gateway-ms/src/users/login/test/login.impersonate.resolver.spec.ts | |
| index 7a605781b..cc4ed9564 100644 | |
| --- a/apps/graphql-gateway-ms/src/users/login/test/login.impersonate.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/users/login/test/login.impersonate.resolver.spec.ts | |
| @@ -7,7 +7,7 @@ import { LoginImpersonateResolver } from '../login.impersonate.resolver'; | |
| import { LoginApiService } from '../login.service'; | |
| import { UsersModule } from '../../users.module'; | |
| import { AuthClientModule, AuthClientService } from '@vinny/auth-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| import { Permission, Role, UserContext } from '@vinny/auth-types'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| @@ -21,7 +21,7 @@ const mockUser = { | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.CUSTOMER], | |
| }; | |
| @@ -31,7 +31,7 @@ describe('login impersonate resolver', () => { | |
| let usersClientService: UsersClientService; | |
| let authClientService: AuthClientService; | |
| const userContext: UserContext = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| roles: [Role.ADMIN], | |
| permissions: [Permission.ADMIN_ALL], | |
| }; | |
| @@ -60,7 +60,7 @@ describe('login impersonate resolver', () => { | |
| }); | |
| describe('loginImpersonate', () => { | |
| - const user = { id: objectStringId(), ...mockUser }; | |
| + const user = { id: Types.ObjectId().toHexString(), ...mockUser }; | |
| const validToken = 'some-valid-token'; | |
| beforeEach(() => { | |
| jest.spyOn(authClientService, 'tokenize').mockImplementation(() => { | |
| diff --git a/apps/graphql-gateway-ms/src/users/login/test/login.resolver.spec.ts b/apps/graphql-gateway-ms/src/users/login/test/login.resolver.spec.ts | |
| index a93480688..f458c429f 100644 | |
| --- a/apps/graphql-gateway-ms/src/users/login/test/login.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/users/login/test/login.resolver.spec.ts | |
| @@ -18,7 +18,7 @@ import { | |
| } from './utils'; | |
| import { AuthClientModule, AuthClientService } from '@vinny/auth-client'; | |
| import { user } from '@vinny/users-test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| @@ -115,7 +115,7 @@ describe('login resolver', () => { | |
| ); | |
| describe('loginByToken', () => { | |
| - const user = { id: objectStringId(), ...mockUser }; | |
| + const user = { id: Types.ObjectId().toHexString(), ...mockUser }; | |
| const validToken = 'some-valid-token'; | |
| const invalidToken = 'some-invalid-token'; | |
| const newToken = 'new-token'; | |
| @@ -154,6 +154,6 @@ export const mockUser = { | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.CUSTOMER], | |
| }; | |
| diff --git a/apps/graphql-gateway-ms/src/users/test/attorney-practice-area.resolver.spec.ts b/apps/graphql-gateway-ms/src/users/test/attorney-practice-area.resolver.spec.ts | |
| index cd166f9ac..00a8dc89f 100644 | |
| --- a/apps/graphql-gateway-ms/src/users/test/attorney-practice-area.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/users/test/attorney-practice-area.resolver.spec.ts | |
| @@ -6,7 +6,7 @@ import { AttorneyPracticeAreaResolver } from '../attorney-practice-area.resolver | |
| import { PracticeAreaService } from '../../practice-area/practice-areas.service'; | |
| import { PracticeAreaModule } from '../../practice-area/practice-areas.module'; | |
| import { UsersModule } from '../users.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { AttorneyPracticeArea } from '../model/users.model'; | |
| import { PracticeArea } from '../../practice-area/models/practice-areas.model'; | |
| import faker from '@faker-js/faker'; | |
| @@ -48,7 +48,7 @@ describe('AttorneyPracticeAreaResolver', () => { | |
| }); | |
| it('should get attorney practice area', async () => { | |
| - const practiceAreaId = objectStringId(); | |
| + const practiceAreaId = Types.ObjectId().toString(); | |
| const attorneyPracticeAreaMock: AttorneyPracticeArea = { | |
| practiceAreaId: practiceAreaId, | |
| locations: [], | |
| diff --git a/apps/graphql-gateway-ms/src/users/test/consts.ts b/apps/graphql-gateway-ms/src/users/test/consts.ts | |
| index dcefd4845..2783e527d 100644 | |
| --- a/apps/graphql-gateway-ms/src/users/test/consts.ts | |
| +++ b/apps/graphql-gateway-ms/src/users/test/consts.ts | |
| @@ -1,14 +1,14 @@ | |
| import faker from '@faker-js/faker'; | |
| import { ServiceMetadataDto } from '@vinny/services-types'; | |
| -import { objectStringId, objectId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { User } from '../model/users.model'; | |
| export const MockUsersList = [ | |
| { | |
| - id: objectId(objectStringId()), | |
| + id: Types.ObjectId(), | |
| }, | |
| { | |
| - id: objectId(objectStringId()), | |
| + id: Types.ObjectId(), | |
| }, | |
| ]; | |
| @@ -75,10 +75,10 @@ export const flagVisitedOnboardingWizardInvalidMutation = `mutation flagVisitedO | |
| }`; | |
| export const createServiceMetadataDto = (userId: string): ServiceMetadataDto => ({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId, | |
| - serviceTypeId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| createdAt: new Date(), | |
| updatedAt: new Date(), | |
| }); | |
| @@ -91,7 +91,7 @@ export const userMock = (id: string): User => ({ | |
| }, | |
| email: faker.internet.email(), | |
| emailAlias: faker.internet.email(undefined, undefined, 'my.marble'), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [], | |
| address: { | |
| state: 'Texas', | |
| diff --git a/apps/graphql-gateway-ms/src/users/test/users.resolver.spec.ts b/apps/graphql-gateway-ms/src/users/test/users.resolver.spec.ts | |
| index 22e081330..e60d57cc7 100644 | |
| --- a/apps/graphql-gateway-ms/src/users/test/users.resolver.spec.ts | |
| +++ b/apps/graphql-gateway-ms/src/users/test/users.resolver.spec.ts | |
| @@ -5,7 +5,7 @@ import { UsersApiService } from '../users.service'; | |
| import { UsersResolver } from '../users.resolver'; | |
| import { MockUsersList, createServiceMetadataDto, userMock } from './consts'; | |
| import { CustomersListFilter, UsersError } from '../model/users.model'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import nock from 'nock'; | |
| @@ -102,7 +102,7 @@ describe('users resolver', () => { | |
| error, | |
| success, | |
| } = await resolver.getAuthenticatedUser({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| }); | |
| expect(authenticatedUser).toBeUndefined(); | |
| expect(success).toBeFalsy(); | |
| @@ -158,7 +158,7 @@ describe('users resolver', () => { | |
| describe('resolve field hasCase', () => { | |
| it('should return true when there are services with given user id', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getServicesMetadata = servicesMsNock | |
| .get(`/services/list/metadata`) | |
| .query({ userId }) | |
| @@ -172,7 +172,7 @@ describe('users resolver', () => { | |
| describe('resolve field casesStatuses', () => { | |
| it('should return cases statuses false for userId without cases', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getCasesByFilterSpy = jest.spyOn(servicesClientService, 'getCasesByFilter'); | |
| getCasesByFilterSpy.mockReturnValue( | |
| @@ -194,7 +194,7 @@ describe('users resolver', () => { | |
| }); | |
| }); | |
| it('should return cases statuses ACCEPTED, PENDING for userId', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getCasesByFilterSpy = jest.spyOn(servicesClientService, 'getCasesByFilter'); | |
| const caseAcceptedDtoMock = { id: uuid(), status: CaseStatus.ACCEPTED } as CaseDto; | |
| const casePendingDtoMock = { id: uuid(), status: CaseStatus.PENDING } as CaseDto; | |
| @@ -219,7 +219,7 @@ describe('users resolver', () => { | |
| }); | |
| it('should return cases statuses REJECTED for userId', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getCasesByFilterSpy = jest.spyOn(servicesClientService, 'getCasesByFilter'); | |
| const caseRejectedDtoMock = { id: uuid(), status: CaseStatus.REJECTED } as CaseDto; | |
| @@ -244,7 +244,7 @@ describe('users resolver', () => { | |
| }); | |
| it('should return false when there are no services with given user id', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getServicesMetadata = servicesMsNock | |
| .get(`/services/list/metadata`) | |
| .query({ userId }) | |
| @@ -257,7 +257,7 @@ describe('users resolver', () => { | |
| }); | |
| it('should return null when ServicesClientService.getServicesMetadata throws error', async () => { | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const getServicesMetadata = servicesMsNock | |
| .get(`/services/list/metadata`) | |
| .query({ userId }) | |
| @@ -271,7 +271,7 @@ describe('users resolver', () => { | |
| }); | |
| describe('listCustomers', () => { | |
| - const user = userMock(objectStringId()); | |
| + const user = userMock(Types.ObjectId().toString()); | |
| it('should get list with 1 customer', async () => { | |
| const filter: CustomersListFilter = { | |
| diff --git a/apps/graphql-gateway-ms/src/visitors/tests/consts.ts b/apps/graphql-gateway-ms/src/visitors/tests/consts.ts | |
| index f5bfbad12..97bf4af37 100644 | |
| --- a/apps/graphql-gateway-ms/src/visitors/tests/consts.ts | |
| +++ b/apps/graphql-gateway-ms/src/visitors/tests/consts.ts | |
| @@ -1,5 +1,5 @@ | |
| import { faker } from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { CreateVisitorInput, Visitor } from '../models/visitors.model'; | |
| export const visitorId = faker.database.mongodbObjectId(); | |
| @@ -56,8 +56,8 @@ query GetVisitorById($visitorId: String!) { | |
| }`; | |
| export const getVisitorResponse: Visitor = { | |
| - id: objectStringId(), | |
| - anonymousId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + anonymousId: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| @@ -122,7 +122,7 @@ mutation CreateVisitor($payload: CreateVisitorInput!) { | |
| }`; | |
| export const createVisitorInput: CreateVisitorInput = { | |
| - anonymousId: objectStringId(), | |
| + anonymousId: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| diff --git a/apps/kafka-tester-ms/src/kafka-events/schemas/kafka-events.schema.ts b/apps/kafka-tester-ms/src/kafka-events/schemas/kafka-events.schema.ts | |
| index e7e854540..620c1eb29 100644 | |
| --- a/apps/kafka-tester-ms/src/kafka-events/schemas/kafka-events.schema.ts | |
| +++ b/apps/kafka-tester-ms/src/kafka-events/schemas/kafka-events.schema.ts | |
| @@ -15,7 +15,7 @@ export class KafkaEvent { | |
| @Prop({ | |
| required: true, | |
| type: String, | |
| - enum: Object.values(KafkaTopics), | |
| + enum: KafkaTopics, | |
| }) | |
| topic: string; | |
| diff --git a/apps/lawmatics-ms/src/cases/test/case-notes.controller.spec.ts b/apps/lawmatics-ms/src/cases/test/case-notes.controller.spec.ts | |
| index 2f53bd485..3bd14fc10 100644 | |
| --- a/apps/lawmatics-ms/src/cases/test/case-notes.controller.spec.ts | |
| +++ b/apps/lawmatics-ms/src/cases/test/case-notes.controller.spec.ts | |
| @@ -2,7 +2,7 @@ import { ContextIdFactory } from '@nestjs/core'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { | |
| @@ -13,7 +13,6 @@ import { LawmaticsEntityType } from '../../lawmatics-client/dtos/common-types'; | |
| import { CasesController } from '../cases.controller'; | |
| import { CasesModule } from '../cases.module'; | |
| import { CreateCaseNoteBody } from '../dtos/case-note.dto'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const mockEnvVars = { | |
| LAWMATICS_TOKEN: 'DUMMYTOKEN', | |
| @@ -64,7 +63,7 @@ describe('CasesController', () => { | |
| describe('createCaseNote', () => { | |
| it('should create a note', async () => { | |
| - const [_caseNoteId, caseId] = [objectStringId(), objectStringId()]; | |
| + const [_caseNoteId, caseId] = [Types.ObjectId(), Types.ObjectId()]; | |
| const caseNoteBody: CreateCaseNoteBody = { | |
| name: 'NAME', | |
| body: 'BODY', | |
| @@ -115,7 +114,7 @@ describe('CasesController', () => { | |
| }); | |
| it('should throw an error when there is no case config', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId(); | |
| const caseNoteBody: CreateCaseNoteBody = { | |
| name: 'NAME', | |
| body: 'BODY', | |
| diff --git a/apps/lawmatics-ms/src/cases/test/cases-event-handler.controller.spec.ts b/apps/lawmatics-ms/src/cases/test/cases-event-handler.controller.spec.ts | |
| index fe8e73d7c..cf8ec5ad3 100644 | |
| --- a/apps/lawmatics-ms/src/cases/test/cases-event-handler.controller.spec.ts | |
| +++ b/apps/lawmatics-ms/src/cases/test/cases-event-handler.controller.spec.ts | |
| @@ -7,7 +7,7 @@ import { ServicesClientService } from '@vinny/services-client'; | |
| import { CaseDto, CaseStatus } from '@vinny/services-types'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { User } from '@vinny/users-types'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { | |
| @@ -30,7 +30,6 @@ import { EventHandlerController } from '../cases-event-handler.controller'; | |
| import { CasesService } from '../cases.service'; | |
| import { createUserMock, userEventMock } from './utils'; | |
| import { CasesModule } from '../cases.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('EventHandlerController', () => { | |
| const contactFields = | |
| @@ -108,17 +107,17 @@ describe('EventHandlerController', () => { | |
| phone: '+972548319666', | |
| }; | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const today = new Date(); | |
| const firstCase = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: today, | |
| userId: userId, | |
| practiceAreaId: '1', | |
| status: CaseStatus.ACCEPTED, | |
| }; | |
| const secondCase = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: today, | |
| userId: userId, | |
| practiceAreaId: '2', | |
| @@ -129,12 +128,12 @@ describe('EventHandlerController', () => { | |
| await configurationModel.insertMany([ | |
| { | |
| - internalId: firstCase.id, | |
| + internalId: Types.ObjectId(firstCase.id), | |
| lawmaticsId: '1', | |
| type: ConfigurationType.CASE, | |
| }, | |
| { | |
| - internalId: secondCase.id, | |
| + internalId: Types.ObjectId(secondCase.id), | |
| lawmaticsId: '2', | |
| type: ConfigurationType.CASE, | |
| }, | |
| @@ -231,10 +230,10 @@ describe('EventHandlerController', () => { | |
| county: 'West Cringe', | |
| }, | |
| }; | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const today = new Date(); | |
| const firstCase: CaseDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: today, | |
| userId: userId, | |
| practiceAreaId: '1', | |
| @@ -245,7 +244,7 @@ describe('EventHandlerController', () => { | |
| await configurationModel.insertMany([ | |
| { | |
| - internalId: firstCase.id, | |
| + internalId: Types.ObjectId(firstCase.id), | |
| lawmaticsId: '1', | |
| type: ConfigurationType.CASE, | |
| }, | |
| @@ -342,10 +341,10 @@ describe('EventHandlerController', () => { | |
| county: 'West Cringe', | |
| }, | |
| }; | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const today = new Date(); | |
| const firstCase = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: today, | |
| userId: userId, | |
| practiceAreaId: '1', | |
| @@ -356,7 +355,7 @@ describe('EventHandlerController', () => { | |
| await configurationModel.insertMany([ | |
| { | |
| - internalId: firstCase.id, | |
| + internalId: Types.ObjectId(firstCase.id), | |
| lawmaticsId: '1', | |
| type: ConfigurationType.CASE, | |
| }, | |
| @@ -433,7 +432,7 @@ describe('EventHandlerController', () => { | |
| it('should not call updateContacts on cases service when kafka event type is CREATE', async () => { | |
| const updateContactsSpy = jest.spyOn(casesService, 'updateContacts'); | |
| const userCreateEvent = userEventMock( | |
| - objectStringId(), | |
| + Types.ObjectId().toString(), | |
| KafkaEventType.CREATE, | |
| createUserMock, | |
| ); | |
| diff --git a/apps/lawmatics-ms/src/cases/test/cases.controller.spec.ts b/apps/lawmatics-ms/src/cases/test/cases.controller.spec.ts | |
| index 66aec86f0..5e691e725 100644 | |
| --- a/apps/lawmatics-ms/src/cases/test/cases.controller.spec.ts | |
| +++ b/apps/lawmatics-ms/src/cases/test/cases.controller.spec.ts | |
| @@ -3,7 +3,7 @@ import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { CourtAppearance, Gender } from '@vinny/services-types'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| import { | |
| @@ -35,7 +35,6 @@ import { CasesModule } from '../cases.module'; | |
| import { convertEnumToFormattedValue, convertLssNotesToCustomFields } from '../utils'; | |
| import { mockCaseConfig, mockCaseData, mockContactObject } from './utils'; | |
| import { ContextIdFactory } from '@nestjs/core'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const REPEAT_BASE_LINK = 'https://attorneys.marble.co/repeat/summary/'; | |
| @@ -296,7 +295,7 @@ describe('CasesController', () => { | |
| name: additionalFieldName, | |
| }); | |
| const configFromDb = await configurationModel.findOne({ | |
| - internalId: caseData.id, | |
| + internalId: Types.ObjectId(caseData.id), | |
| }); | |
| expect(additionalFieldMapService.create).toBeCalled(); | |
| @@ -473,7 +472,7 @@ describe('CasesController', () => { | |
| await casesController.createCase(caseData); | |
| const configFromDb = await configurationModel.findOne({ | |
| - internalId: caseData.id, | |
| + internalId: Types.ObjectId(caseData.id), | |
| }); | |
| expect(additionalFieldMapService.create).toBeCalled(); | |
| @@ -660,7 +659,7 @@ describe('CasesController', () => { | |
| await casesController.createCase(caseData); | |
| const configFromDb = await configurationModel.findOne({ | |
| - internalId: caseData.id, | |
| + internalId: Types.ObjectId(caseData.id), | |
| }); | |
| expect(additionalFieldMapService.create).toBeCalled(); | |
| @@ -1109,7 +1108,7 @@ describe('CasesController', () => { | |
| name: CaseLssFormAdditionalFields.LSS_SUMMARY, | |
| }); | |
| const configFromDb: ConfigurationDocument[] = await configurationModel.find({ | |
| - internalId: caseData.id, | |
| + internalId: Types.ObjectId(caseData.id), | |
| }); | |
| expect(spyOnCreate).toBeCalled(); | |
| @@ -1182,7 +1181,7 @@ describe('CasesController', () => { | |
| await casesController.delete(caseData.id); | |
| const configFromDb = await configurationModel.findOne({ | |
| - internalId: caseData.id, | |
| + internalId: Types.ObjectId(caseData.id), | |
| }); | |
| deleteContactReq.done(); | |
| expect(configFromDb).toBeNull; | |
| @@ -1198,7 +1197,7 @@ describe('CasesController', () => { | |
| describe('getCase', () => { | |
| it('should get case', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId(); | |
| const strategyReviewCallDate = faker.date.recent(); | |
| const intakeMeetingDate = faker.date.recent(); | |
| await configurationModel.insertMany([ | |
| @@ -1546,7 +1545,7 @@ describe('CasesController', () => { | |
| // name: CaseLssFormAdditionalFields.LSS_SUMMARY, | |
| // }); | |
| // const configFromDb: ConfigurationDocument[] = await configurationModel.find({ | |
| - // internalId: caseData.id, | |
| + // internalId: Types.ObjectId(caseData.id), | |
| // }); | |
| // expect(spyOnCreate).toBeCalled(); | |
| diff --git a/apps/lawmatics-ms/src/cases/test/utils.ts b/apps/lawmatics-ms/src/cases/test/utils.ts | |
| index c6c4bb639..9f64bd2c4 100644 | |
| --- a/apps/lawmatics-ms/src/cases/test/utils.ts | |
| +++ b/apps/lawmatics-ms/src/cases/test/utils.ts | |
| @@ -1,6 +1,6 @@ | |
| import faker from '@faker-js/faker'; | |
| import { KafkaEventDto, KafkaEventType } from '@vinny/kafka-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { UpdateUserDto, UserDto } from '@vinny/users-types'; | |
| import { CreateLssNotesPayload, IntakeData } from '@vinny/services-types'; | |
| import { AddressObject, CaseData, ConfigurationType } from '@vinny/lawmatics-types'; | |
| @@ -19,7 +19,7 @@ export const mockCaseData = ({ | |
| lssNotes, | |
| intakeData, | |
| }: MockCaseDataInput): CaseData => ({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| firstName: faker.name.firstName(), | |
| lastName: faker.name.lastName(), | |
| email: faker.internet.email(), | |
| @@ -51,14 +51,14 @@ export const userEventMock = ( | |
| }); | |
| export const createUserMock: UserDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const mockContactObject = (lawmaticsId: string, userId?: string, caseId?: string) => ({ | |
| @@ -96,7 +96,7 @@ export const mockContactObject = (lawmaticsId: string, userId?: string, caseId?: | |
| }); | |
| export const mockConfig = (lawmaticsId: string, type: ConfigurationType) => ({ | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId(), | |
| lawmaticsId, | |
| type, | |
| }); | |
| diff --git a/apps/lawmatics-ms/src/communicationsPublishers/emailsPublisher/emailPlugins/test/customEmailPlugin.service.spec.ts b/apps/lawmatics-ms/src/communicationsPublishers/emailsPublisher/emailPlugins/test/customEmailPlugin.service.spec.ts | |
| index 5375892b2..c7aa7773a 100644 | |
| --- a/apps/lawmatics-ms/src/communicationsPublishers/emailsPublisher/emailPlugins/test/customEmailPlugin.service.spec.ts | |
| +++ b/apps/lawmatics-ms/src/communicationsPublishers/emailsPublisher/emailPlugins/test/customEmailPlugin.service.spec.ts | |
| @@ -13,7 +13,7 @@ import { ServicesClientService } from '@vinny/services-client'; | |
| import { ActivityIdentifiers, CaseDto, CaseStatus } from '@vinny/services-types'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { User } from '@vinny/users-types'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import { ConfigurationModule } from '../../../../configurations/configurations.module'; | |
| @@ -25,7 +25,6 @@ import { CustomEmailConverter } from '../customEmailPlugin.service'; | |
| import { CUSTOM_EMAIL_EXAMPLE } from './consts'; | |
| import { DirectionType } from '@vinny/communications-types'; | |
| import { TENANT_ID_HEADER } from '@vinny/tenancy'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const EmailTestConstants = { | |
| internal: { | |
| @@ -33,14 +32,14 @@ const EmailTestConstants = { | |
| lawmaticsUserId: CUSTOM_EMAIL_EXAMPLE.relationships.owner.data.id, | |
| phone: '+1098765432', | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }, | |
| external: { | |
| userId: 'externalUserId', | |
| lawmaticsUserId: 'externalId', | |
| phone: '+1234567890', | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }, | |
| lawmaticsCaseId: CUSTOM_EMAIL_EXAMPLE.relationships.recipient.data.id, | |
| caseId: 'userTestCaseId', | |
| diff --git a/apps/lawmatics-ms/src/communicationsPublishers/emailsPublisher/emailPlugins/test/quickSendEmailPlugin.service.spec.ts b/apps/lawmatics-ms/src/communicationsPublishers/emailsPublisher/emailPlugins/test/quickSendEmailPlugin.service.spec.ts | |
| index 98ab32f3d..48e563428 100644 | |
| --- a/apps/lawmatics-ms/src/communicationsPublishers/emailsPublisher/emailPlugins/test/quickSendEmailPlugin.service.spec.ts | |
| +++ b/apps/lawmatics-ms/src/communicationsPublishers/emailsPublisher/emailPlugins/test/quickSendEmailPlugin.service.spec.ts | |
| @@ -14,7 +14,7 @@ import { ActivityIdentifiers, CaseDto, CaseStatus } from '@vinny/services-types' | |
| import { TENANT_ID_HEADER } from '@vinny/tenancy'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { User } from '@vinny/users-types'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import { ConfigurationModule } from '../../../../configurations/configurations.module'; | |
| @@ -25,7 +25,6 @@ import { EmailsPublisherModule } from '../../emailsPublisher.module'; | |
| import { QuickSendEmailConverter } from '../quickSendEmailPlugin.service'; | |
| import { QUICK_SEND_EMAIL_EXAMPLE } from './consts'; | |
| import { DirectionType } from '@vinny/communications-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const EmailTestConstants = { | |
| internal: { | |
| @@ -33,13 +32,13 @@ const EmailTestConstants = { | |
| lawmaticsUserId: QUICK_SEND_EMAIL_EXAMPLE.relationships.owner.data.id, | |
| phone: '+1098765432', | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }, | |
| external: { | |
| userId: 'externalUserId', | |
| phone: '+1234567890', | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }, | |
| lawmaticsCaseId: QUICK_SEND_EMAIL_EXAMPLE.relationships.recipient.data.id, | |
| caseId: 'userTestCaseId', | |
| diff --git a/apps/lawmatics-ms/src/communicationsPublishers/smsPublisher/smsPlugins/test/smsLawmaticsPlugin.service.spec.ts b/apps/lawmatics-ms/src/communicationsPublishers/smsPublisher/smsPlugins/test/smsLawmaticsPlugin.service.spec.ts | |
| index 374c457a9..aa80e45b4 100644 | |
| --- a/apps/lawmatics-ms/src/communicationsPublishers/smsPublisher/smsPlugins/test/smsLawmaticsPlugin.service.spec.ts | |
| +++ b/apps/lawmatics-ms/src/communicationsPublishers/smsPublisher/smsPlugins/test/smsLawmaticsPlugin.service.spec.ts | |
| @@ -11,21 +11,20 @@ import { TENANT_ID_HEADER } from '@vinny/tenancy'; | |
| import { defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { User } from '@vinny/users-types'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection } from '@vinny/test-utils'; | |
| import { ConfigurationsService } from '../../../../configurations/configurations.service'; | |
| import { SmsPublisherModule } from '../../smsPublisher.module'; | |
| import { SmsLawmaticsConverter } from '../smsLawmaticsPlugin.service'; | |
| import { TWILIO_MESSAGE_QUEUED, TWILIO_MESSAGE_RECEIVED } from './consts'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const SentSmsTestConstants = { | |
| to: { | |
| phone: '+16193506274', | |
| userId: 'externalUserId', | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }, | |
| from: { | |
| phone: '+16193047265', | |
| @@ -42,7 +41,7 @@ const ReceivedEmailTestConstants = { | |
| phone: '+12144772646', | |
| userId: 'externalUserId', | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }, | |
| lawmaticsCaseId: TWILIO_MESSAGE_RECEIVED.relationships.recipient.data.id, | |
| caseId: 'userTestCaseId', | |
| diff --git a/apps/lawmatics-ms/src/configurations/configurations.service.ts b/apps/lawmatics-ms/src/configurations/configurations.service.ts | |
| index 29272d2d1..d19ba3222 100644 | |
| --- a/apps/lawmatics-ms/src/configurations/configurations.service.ts | |
| +++ b/apps/lawmatics-ms/src/configurations/configurations.service.ts | |
| @@ -1,6 +1,7 @@ | |
| import { SearchConfigurationFilter } from './dal/types'; | |
| import { Inject, Injectable } from '@nestjs/common'; | |
| import { FlareLogger, FnLogger } from '@vinny/logger'; | |
| +import { Types } from 'mongoose'; | |
| import { ConfigurationsDal } from './dal/configurations.dal'; | |
| import { | |
| ConfigurationFilter, | |
| @@ -31,7 +32,7 @@ export class ConfigurationsService { | |
| type: ConfigurationType, | |
| ): Promise<Configuration | null> { | |
| return await this.configurationsDal.delete({ | |
| - internalId: internalId, | |
| + internalId: Types.ObjectId(internalId), | |
| type, | |
| }); | |
| } | |
| @@ -42,7 +43,7 @@ export class ConfigurationsService { | |
| ): Promise<Configuration | null> { | |
| try { | |
| return await this.configurationsDal.findConfiguration({ | |
| - internalId: internalId, | |
| + internalId: Types.ObjectId(internalId), | |
| type, | |
| }); | |
| } catch (error) { | |
| @@ -82,7 +83,7 @@ export class ConfigurationsService { | |
| if (!configuration) { | |
| return null; | |
| } | |
| - return { ...configuration, internalId: configuration.internalId?.toString() }; | |
| + return { ...configuration.toJSON(), internalId: configuration.internalId?.toString() }; | |
| } catch (error) { | |
| this.logger.error('getConfigByLawmaticsIdAndType', { error }); | |
| throw error; | |
| @@ -120,7 +121,7 @@ export class ConfigurationsService { | |
| @FnLogger() | |
| async getConfiguration(filter: ConfigurationFilter): Promise<ConfigurationOutput | null> { | |
| const configuration = await this.configurationsDal.findConfiguration({ | |
| - ...(filter?.internalId && { internalId: filter.internalId }), | |
| + ...(filter?.internalId && { internalId: Types.ObjectId(filter.internalId) }), | |
| ...(filter?.lawmaticsId && { lawmaticsId: filter.lawmaticsId }), | |
| type: filter?.type, | |
| }); | |
| diff --git a/apps/lawmatics-ms/src/configurations/dal/configurations.dal.ts b/apps/lawmatics-ms/src/configurations/dal/configurations.dal.ts | |
| index 4e0bf1f1e..1db9a40b8 100644 | |
| --- a/apps/lawmatics-ms/src/configurations/dal/configurations.dal.ts | |
| +++ b/apps/lawmatics-ms/src/configurations/dal/configurations.dal.ts | |
| @@ -15,13 +15,13 @@ export class ConfigurationsDal { | |
| createConfiguration: Partial<ConfigurationInput>, | |
| ): Promise<Configuration> { | |
| const result = await this.configurationModel.create(createConfiguration); | |
| - return result.toObject(); | |
| + return result.toJSON(); | |
| } | |
| async delete(filter: FilterQuery<ConfigurationDocument>): Promise<Configuration | null> { | |
| const result = await this.configurationModel.findOneAndDelete(filter); | |
| - return !result ? result : result.toObject(); | |
| + return !result ? result : result.toJSON(); | |
| } | |
| async upsert( | |
| @@ -33,12 +33,11 @@ export class ConfigurationsDal { | |
| new: true, | |
| }); | |
| - return result.toObject(); | |
| + return result.toJSON(); | |
| } | |
| async findAll(): Promise<Array<Configuration>> { | |
| - const ret = await this.configurationModel.find(); | |
| - return ret.map((doc) => doc.toObject() as Configuration); | |
| + return this.configurationModel.find() || []; | |
| } | |
| async findAllByFilter(filter: SearchConfigurationFilter): Promise<ConfigurationDocument[]> { | |
| @@ -50,20 +49,18 @@ export class ConfigurationsDal { | |
| typesFilter = { type: { $in: filter.types } }; | |
| } | |
| } | |
| - const result = await this.configurationModel | |
| + return (await this.configurationModel | |
| .find({ | |
| ...(filter.lawmaticsIds && { lawmaticsId: { $in: filter.lawmaticsIds } }), | |
| ...(filter.internalIds && { internalId: { $in: filter.internalIds } }), | |
| ...typesFilter, | |
| - }); | |
| - | |
| - return result ? result.map((doc) => doc.toObject() as ConfigurationDocument) : []; | |
| + }) | |
| + .lean()) || []; | |
| } | |
| async findConfiguration( | |
| findConfiguration: Partial<Configuration>, | |
| ): Promise<ConfigurationDocument | null> { | |
| - const res = await this.configurationModel.findOne(findConfiguration); | |
| - return res && (res.toObject() as ConfigurationDocument); | |
| + return await this.configurationModel.findOne(findConfiguration); | |
| } | |
| } | |
| diff --git a/apps/lawmatics-ms/src/configurations/schemas/configuration.schema.ts b/apps/lawmatics-ms/src/configurations/schemas/configuration.schema.ts | |
| index 51b5b0177..665faf132 100644 | |
| --- a/apps/lawmatics-ms/src/configurations/schemas/configuration.schema.ts | |
| +++ b/apps/lawmatics-ms/src/configurations/schemas/configuration.schema.ts | |
| @@ -1,11 +1,10 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document, Types } from 'mongoose'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| export type ConfigurationDocument = Configuration & Document; | |
| -@Schema({ _id: true, id: true, timestamps: true, toObject: { getters: true } }) | |
| +@Schema({ _id: true, id: true, timestamps: true }) | |
| export class Configuration { | |
| _id: Types.ObjectId; | |
| @@ -14,8 +13,8 @@ export class Configuration { | |
| @Prop({ required: true }) | |
| lawmaticsId: string; | |
| - @Prop(objectIdPropHandler()) | |
| - internalId: string; | |
| + @Prop({ type: SchemaTypes.ObjectId }) | |
| + internalId: Types.ObjectId; | |
| @Prop() | |
| value: string; | |
| diff --git a/apps/lawmatics-ms/src/configurations/test/utils.ts b/apps/lawmatics-ms/src/configurations/test/utils.ts | |
| index 40b0632db..5d0ab7997 100644 | |
| --- a/apps/lawmatics-ms/src/configurations/test/utils.ts | |
| +++ b/apps/lawmatics-ms/src/configurations/test/utils.ts | |
| @@ -1,10 +1,10 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| export const MockServiceWithValue = { | |
| lawmaticsId: faker.datatype.string(), | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| type: ConfigurationType.PRACTICE_AREA, | |
| value: faker.datatype.string(), | |
| firstStageId: faker.datatype.string(), | |
| @@ -12,6 +12,6 @@ export const MockServiceWithValue = { | |
| export const MockService = { | |
| lawmaticsId: faker.datatype.string(), | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| type: ConfigurationType.SERVICE, | |
| }; | |
| diff --git a/apps/lawmatics-ms/src/custom-field-maps/dal/additional-fields-map.dal.ts b/apps/lawmatics-ms/src/custom-field-maps/dal/additional-fields-map.dal.ts | |
| index 497ab310c..dc0e18136 100644 | |
| --- a/apps/lawmatics-ms/src/custom-field-maps/dal/additional-fields-map.dal.ts | |
| +++ b/apps/lawmatics-ms/src/custom-field-maps/dal/additional-fields-map.dal.ts | |
| @@ -16,7 +16,7 @@ export class AdditionalFieldMapDal { | |
| async create(payload: CreateAdditionalFieldMapInput): Promise<AdditionalFieldMap> { | |
| const result = await this.additionalFieldMapModel.create(payload); | |
| - return result.toObject(); | |
| + return result.toJSON(); | |
| } | |
| async findByNameAndObjectType( | |
| @@ -27,11 +27,10 @@ export class AdditionalFieldMapDal { | |
| name, | |
| objectType, | |
| }); | |
| - return result?.toObject(); | |
| + return result?.toJSON(); | |
| } | |
| async findAll(filter?: FilterQuery<AdditionalFieldMapDocument>): Promise<AdditionalFieldMap[]> { | |
| - const res = await this.additionalFieldMapModel.find(filter || {}); | |
| - return res.map((doc) => doc.toObject()); | |
| + return this.additionalFieldMapModel.find(filter || {}).lean(); | |
| } | |
| } | |
| diff --git a/apps/lawmatics-ms/src/custom-field-maps/schemas/additional-field-map.schema.ts b/apps/lawmatics-ms/src/custom-field-maps/schemas/additional-field-map.schema.ts | |
| index f2bd094d9..439e1747c 100644 | |
| --- a/apps/lawmatics-ms/src/custom-field-maps/schemas/additional-field-map.schema.ts | |
| +++ b/apps/lawmatics-ms/src/custom-field-maps/schemas/additional-field-map.schema.ts | |
| @@ -18,7 +18,7 @@ export class AdditionalFieldMap { | |
| @Prop({ enum: ObjectType, type: String, required: true }) | |
| objectType: ObjectType; | |
| - @Prop({ enum: Object.values(FieldType), type: String, required: true }) | |
| + @Prop({ enum: FieldType, type: String, required: true }) | |
| fieldType: FieldType; | |
| @Prop({ required: true }) | |
| diff --git a/apps/lawmatics-ms/src/diff-scanner/dal/diff-scanner-metadata.dal.ts b/apps/lawmatics-ms/src/diff-scanner/dal/diff-scanner-metadata.dal.ts | |
| index 67f86bf9e..769061427 100644 | |
| --- a/apps/lawmatics-ms/src/diff-scanner/dal/diff-scanner-metadata.dal.ts | |
| +++ b/apps/lawmatics-ms/src/diff-scanner/dal/diff-scanner-metadata.dal.ts | |
| @@ -5,7 +5,6 @@ import { | |
| DiffScannerMetadata, | |
| DiffScannerMetadataDocument, | |
| } from '../schemas/diff-scanner-metadata.schema'; | |
| -import { materialize } from '@vinny/helpers'; | |
| @Injectable() | |
| export class DiffScannerMetadataDal { | |
| @@ -17,39 +16,35 @@ export class DiffScannerMetadataDal { | |
| async findByProcessName( | |
| processName: string, | |
| ): Promise<LeanDocument<DiffScannerMetadataDocument> | null> { | |
| - return materialize( | |
| - async () => | |
| - await this.diffScannerMetadataModel | |
| - .findOne({ | |
| - processName, | |
| - }), | |
| - ); | |
| + return this.diffScannerMetadataModel | |
| + .findOne({ | |
| + processName, | |
| + }) | |
| + .lean(); | |
| } | |
| async markAsRunning( | |
| processName: string, | |
| scanId: string, | |
| ): Promise<LeanDocument<DiffScannerMetadataDocument>> { | |
| - return materialize( | |
| - async () => | |
| - await this.diffScannerMetadataModel | |
| - .findOneAndUpdate( | |
| - { | |
| - processName, | |
| - }, | |
| - { | |
| - isRunning: true, | |
| - scanId, | |
| - $currentDate: { | |
| - updatedAt: true, | |
| - }, | |
| - }, | |
| - { | |
| - new: true, | |
| - upsert: true, | |
| - }, | |
| - ), | |
| - ); | |
| + return this.diffScannerMetadataModel | |
| + .findOneAndUpdate( | |
| + { | |
| + processName, | |
| + }, | |
| + { | |
| + isRunning: true, | |
| + scanId, | |
| + $currentDate: { | |
| + updatedAt: true, | |
| + }, | |
| + }, | |
| + { | |
| + new: true, | |
| + upsert: true, | |
| + }, | |
| + ) | |
| + .lean(); | |
| } | |
| async updateLastRun( | |
| @@ -57,25 +52,23 @@ export class DiffScannerMetadataDal { | |
| lastRun?: Date, | |
| isRunning = false, | |
| ): Promise<LeanDocument<DiffScannerMetadataDocument>> { | |
| - return materialize( | |
| - async () => | |
| - await this.diffScannerMetadataModel | |
| - .findOneAndUpdate( | |
| - { | |
| - processName, | |
| - }, | |
| - { | |
| - isRunning, | |
| - lastRun, | |
| - $currentDate: { | |
| - updatedAt: true, | |
| - }, | |
| - }, | |
| - { | |
| - new: true, | |
| - omitUndefined: true, | |
| - }, | |
| - ), | |
| - ); | |
| + return this.diffScannerMetadataModel | |
| + .findOneAndUpdate( | |
| + { | |
| + processName, | |
| + }, | |
| + { | |
| + isRunning, | |
| + lastRun, | |
| + $currentDate: { | |
| + updatedAt: true, | |
| + }, | |
| + }, | |
| + { | |
| + new: true, | |
| + omitUndefined: true, | |
| + }, | |
| + ) | |
| + .lean(); | |
| } | |
| } | |
| diff --git a/apps/lawmatics-ms/src/events/test/case-events.controller.spec.ts b/apps/lawmatics-ms/src/events/test/case-events.controller.spec.ts | |
| index 78df57576..e6923cb5a 100644 | |
| --- a/apps/lawmatics-ms/src/events/test/case-events.controller.spec.ts | |
| +++ b/apps/lawmatics-ms/src/events/test/case-events.controller.spec.ts | |
| @@ -2,7 +2,7 @@ import { ContextIdFactory } from '@nestjs/core'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { ConfigurationType, EventData } from '@vinny/lawmatics-types'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { | |
| @@ -36,7 +36,6 @@ import { | |
| import { EventsModule } from '../events.module'; | |
| import { ServicesEventsController } from '../services-events.controller'; | |
| import { CasesEventsController } from '../cases-events.controller'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const mockEnvVars = { | |
| LAWMATICS_TOKEN: 'DUMMYTOKEN', | |
| @@ -93,7 +92,7 @@ describe('EventsController', () => { | |
| describe('createServiceEvent', () => { | |
| it('should create an event, update it and delete', async () => { | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId(); | |
| const serviceEventBody = createEventMock; | |
| await configurationModel.insertMany([ | |
| @@ -251,7 +250,7 @@ describe('EventsController', () => { | |
| }); | |
| it('should throw an error because there is no such service', async () => { | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId(); | |
| await expect( | |
| servicesEventsController.createServiceEvent(serviceId.toString(), createEventMock), | |
| ).rejects.toThrowError(`getRawMatter - matter not found in configurations`); | |
| @@ -260,7 +259,7 @@ describe('EventsController', () => { | |
| describe('createCaseEvent', () => { | |
| it('should create an event with users on open matter', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| eventTypeConfig, | |
| @@ -365,7 +364,7 @@ describe('EventsController', () => { | |
| }); | |
| }); | |
| it('should create an event without users when there is not users on open matter and update its name', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| eventTypeConfig, | |
| @@ -450,7 +449,7 @@ describe('EventsController', () => { | |
| expect(updateResult).toEqual({ ...result, ...updateEventPayload }); | |
| }); | |
| it('should create an event with users only from open matter', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| eventTypeConfig, | |
| @@ -563,7 +562,7 @@ describe('EventsController', () => { | |
| }); | |
| }); | |
| it('should create an event with combined users from open matters', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| eventTypeConfig, | |
| @@ -675,7 +674,7 @@ describe('EventsController', () => { | |
| }); | |
| }); | |
| it('should create an event with unified users from open matters ', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId(); | |
| const eventTypeConfig = { | |
| value: 'COURT_DATE', | |
| @@ -797,7 +796,7 @@ describe('EventsController', () => { | |
| describe('getServiceEvents', () => { | |
| it('should get an events list', async () => { | |
| const startDate = new Date(); | |
| - const [serviceEventId, serviceId] = [objectStringId(), objectStringId()]; | |
| + const [serviceEventId, serviceId] = [Types.ObjectId(), Types.ObjectId()]; | |
| const eventTypeConfig = { | |
| value: 'COURT_DATE', | |
| lawmaticsId: '1', | |
| @@ -870,7 +869,7 @@ describe('EventsController', () => { | |
| describe('getCaseEvents', () => { | |
| it('should get an events list', async () => { | |
| const startDate = new Date(); | |
| - const [caseEventId, caseId] = [objectStringId(), objectStringId()]; | |
| + const [caseEventId, caseId] = [Types.ObjectId(), Types.ObjectId()]; | |
| const eventTypeConfig = { | |
| value: 'COURT_DATE', | |
| lawmaticsId: '1', | |
| diff --git a/apps/lawmatics-ms/src/events/test/utils.ts b/apps/lawmatics-ms/src/events/test/utils.ts | |
| index d23ed92ce..55d99780c 100644 | |
| --- a/apps/lawmatics-ms/src/events/test/utils.ts | |
| +++ b/apps/lawmatics-ms/src/events/test/utils.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| import { | |
| MockCaseManager, | |
| @@ -15,7 +15,7 @@ const endDate = new Date(startDate); | |
| endDate.setMinutes(endDate.getMinutes() + 30); | |
| export const createEventMock: CreateEventBody = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| startDate: startDate.toISOString(), | |
| endDate: endDate.toISOString(), | |
| timezone: 'America/Chicago', | |
| diff --git a/apps/lawmatics-ms/src/files/test/files.controller.spec.ts b/apps/lawmatics-ms/src/files/test/files.controller.spec.ts | |
| index a65575450..fa924ac0c 100644 | |
| --- a/apps/lawmatics-ms/src/files/test/files.controller.spec.ts | |
| +++ b/apps/lawmatics-ms/src/files/test/files.controller.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ConfigurationsService } from '../../configurations/configurations.service'; | |
| import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| @@ -16,7 +16,6 @@ import { SourceApps } from '@vinny/documents-types'; | |
| import { SqsService } from '@ssut/nestjs-sqs'; | |
| import { ContextIdFactory } from '@nestjs/core'; | |
| import { FilesModule } from '../files.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| jest.mock('aws-sdk', () => { | |
| const SQSMocked = { | |
| @@ -27,10 +26,10 @@ jest.mock('aws-sdk', () => { | |
| }; | |
| }); | |
| -const INTERNAL_ID = objectStringId(); | |
| +const INTERNAL_ID = Types.ObjectId().toString(); | |
| const LAWMATICS_CASE_ID = '4815162342'; | |
| const LAWMATICS_DOCUMENT_ID = '4223161584'; | |
| -const DOCUMENT_ID = objectStringId(); | |
| +const DOCUMENT_ID = Types.ObjectId().toString(); | |
| const LAWMATICS_HTTP_MOCK = nock(mockLawmaticsEnvVars.LAWMATICS_BASE_URL, { | |
| reqheaders: { | |
| Authorization: `Bearer ${mockLawmaticsEnvVars.LAWMATICS_TOKEN}`, | |
| @@ -210,10 +209,10 @@ describe('Files Controller', () => { | |
| const lawmaticsMatterId = '2323232323'; | |
| const lawmaticsDocId = '12345678'; | |
| - const marblelawCaseId = objectStringId(); | |
| - const marblelawServiceId = objectStringId(); | |
| - const marblelawDocId = objectStringId(); | |
| - const marbleUserId = objectStringId(); | |
| + const marblelawCaseId = Types.ObjectId().toString(); | |
| + const marblelawServiceId = Types.ObjectId().toString(); | |
| + const marblelawDocId = Types.ObjectId().toString(); | |
| + const marbleUserId = Types.ObjectId().toString(); | |
| const amazonS3BaseUrl = 'https://s3.amazon.com'; | |
| const documentSrcUri = '/lawmatics/src'; | |
| diff --git a/apps/lawmatics-ms/src/files/test/utils.ts b/apps/lawmatics-ms/src/files/test/utils.ts | |
| index 5598bcd3e..088373bba 100644 | |
| --- a/apps/lawmatics-ms/src/files/test/utils.ts | |
| +++ b/apps/lawmatics-ms/src/files/test/utils.ts | |
| @@ -1,6 +1,6 @@ | |
| import faker from '@faker-js/faker'; | |
| import { DocumentTypeDto } from '@vinny/catalog-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const filesUploadLawmaticsResponse = { | |
| id: '6005258', | |
| @@ -26,7 +26,7 @@ export const filesUploadLawmaticsResponse = { | |
| }; | |
| export const documentType1: DocumentTypeDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'General', | |
| category: faker.datatype.string(), | |
| description: faker.datatype.string(), | |
| diff --git a/apps/lawmatics-ms/src/interactions/test/interactions.service.spec.ts b/apps/lawmatics-ms/src/interactions/test/interactions.service.spec.ts | |
| index febd7b83e..b6cf4a081 100644 | |
| --- a/apps/lawmatics-ms/src/interactions/test/interactions.service.spec.ts | |
| +++ b/apps/lawmatics-ms/src/interactions/test/interactions.service.spec.ts | |
| @@ -13,7 +13,7 @@ import { ServiceMetadataDto, TicketActivityDto } from '@vinny/services-types'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { SupportRequestStatus, User } from '@vinny/users-types'; | |
| import { generateTicketDataMock } from '@vinny/users-test-utils'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { v4 as uuid } from 'uuid'; | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| @@ -27,7 +27,6 @@ import { LawmaticsInteractionClient } from '../../lawmatics-client/lawmatics-int | |
| import { InteractionsModule } from '../interactions.module'; | |
| import { InteractionsService } from '../interactions.service'; | |
| import { LegalCortexCaseUpdateCreated } from '../types/legalCortexEvents'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const mockEnvVars = { | |
| LAWMATICS_TOKEN: 'DUMMYTOKEN', | |
| @@ -197,7 +196,7 @@ describe('InteractionsService', () => { | |
| SupportRequestStatus.OPEN, | |
| ); | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId().toString(); | |
| const ticketActivityEvent: KafkaEventDto<TicketActivityDto> = { | |
| key: serviceId, | |
| @@ -224,7 +223,7 @@ describe('InteractionsService', () => { | |
| `( | |
| 'should add ticket interaction to lawmatics - $supportRequestStatus', | |
| async ({ supportRequestStatus, lawmaticsDisplayValue }) => { | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId().toString(); | |
| const lawmaticsId = '12345'; | |
| await configurationsService.create({ | |
| diff --git a/apps/lawmatics-ms/src/lawmatics-events-handlers/test/lawmatics-events-handlers.service.spec.ts b/apps/lawmatics-ms/src/lawmatics-events-handlers/test/lawmatics-events-handlers.service.spec.ts | |
| index 2ce074cfc..5dc41df26 100644 | |
| --- a/apps/lawmatics-ms/src/lawmatics-events-handlers/test/lawmatics-events-handlers.service.spec.ts | |
| +++ b/apps/lawmatics-ms/src/lawmatics-events-handlers/test/lawmatics-events-handlers.service.spec.ts | |
| @@ -20,7 +20,7 @@ import { ServicesClientModule, ServicesClientService } from '@vinny/services-cli | |
| import { KeyEventParentType, LegalTeamMemberRole, ServiceDto } from '@vinny/services-types'; | |
| import { TENANT_ID_HEADER } from '@vinny/tenancy'; | |
| import { UsersClientModule } from '@vinny/users-client'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { CasesModule } from '../../cases/cases.module'; | |
| import { ConfigurationModule } from '../../configurations/configurations.module'; | |
| @@ -78,7 +78,6 @@ import { | |
| import { DocumentCatalogClientModule } from '@vinny/catalog-client'; | |
| import { SchedulerClientModule } from '@vinny/scheduler-client'; | |
| import { calculateNotificationDateTime } from '../utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const SERVICES_TOPIC_NAME = 'services'; | |
| const CASES_TOPIC_NAME = 'cases'; | |
| @@ -217,8 +216,8 @@ describe('LawmaticsEventsHandlersService', () => { | |
| servicesMsNock.get(`/services/${MockService.internalId}`).reply(200, mockService); | |
| }); | |
| it('should emit a service update event for a matching matter update event but not emit a create event', async () => { | |
| - const serviceTypeId = objectStringId(); | |
| - const caseId = objectStringId(); | |
| + const serviceTypeId = Types.ObjectId().toString(); | |
| + const caseId = Types.ObjectId().toString(); | |
| await configurationModel.insertMany([ | |
| { ...MockCase, internalId: MockServiceData.caseId }, | |
| MockPracticeArea, | |
| @@ -1371,7 +1370,7 @@ describe('LawmaticsEventsHandlersService', () => { | |
| async ({ keyEventParentType, KeyEventParentMock, lawmaticsKeyEventParentType }) => { | |
| await configurationModel.insertMany([KeyEventParentMock, mockEventType]); | |
| - const mockInternalEventId = objectStringId(); | |
| + const mockInternalEventId = Types.ObjectId().toString(); | |
| servicesMsNock | |
| .post(`/${keyEventParentType}s/${KeyEventParentMock.internalId}/events/sync`) | |
| @@ -1404,7 +1403,7 @@ describe('LawmaticsEventsHandlersService', () => { | |
| }); | |
| const mockEvent: LawmaticsEventResponseData = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| type: 'event', | |
| attributes: { | |
| name: faker.name.findName(), | |
| @@ -1488,12 +1487,12 @@ describe('LawmaticsEventsHandlersService', () => { | |
| it('should emit event, but not sync event when event configuration already exists', async () => { | |
| const syncServiceEventSpy = jest.spyOn(servicesClientService, 'syncServiceEvent'); | |
| - const eventLawmaticsId = objectStringId(); | |
| + const eventLawmaticsId = Types.ObjectId().toString(); | |
| const mockKeyEventConfig = { | |
| lawmaticsId: eventLawmaticsId, | |
| type: ConfigurationType.EVENT, | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| }; | |
| await configurationModel.insertMany([MockService, mockEventType, mockKeyEventConfig]); | |
| @@ -1566,12 +1565,12 @@ describe('LawmaticsEventsHandlersService', () => { | |
| const syncServiceEventSpy = jest.spyOn(servicesClientService, 'syncServiceEvent'); | |
| - const mockEventLawmaticsId = objectStringId(); | |
| + const mockEventLawmaticsId = Types.ObjectId().toString(); | |
| const mockKeyEventConfig = { | |
| lawmaticsId: mockEventLawmaticsId, | |
| type: ConfigurationType.EVENT, | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| }; | |
| await configurationService.create(mockKeyEventConfig); | |
| @@ -1629,13 +1628,13 @@ describe('LawmaticsEventsHandlersService', () => { | |
| }); | |
| it('should emit an event updated event for a matching event updated event when event_type does not exists on db', async () => { | |
| - const mockEventLawmaticsId = objectStringId(); | |
| + const mockEventLawmaticsId = Types.ObjectId().toString(); | |
| const syncServiceEventSpy = jest.spyOn(servicesClientService, 'syncServiceEvent'); | |
| const mockKeyEventConfig = { | |
| lawmaticsId: mockEventLawmaticsId, | |
| type: ConfigurationType.EVENT, | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| }; | |
| await configurationModel.insertMany([mockEventType, mockKeyEventConfig]); | |
| @@ -1722,7 +1721,7 @@ describe('LawmaticsEventsHandlersService', () => { | |
| it('should throw not found exception when service lawmatics id does not exists on configurations collection', async () => { | |
| const mockParentEvent: LawmaticsEventResponseData = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| type: 'event', | |
| attributes: {}, | |
| relationships: { | |
| @@ -1737,7 +1736,7 @@ describe('LawmaticsEventsHandlersService', () => { | |
| await expect( | |
| lawmaticsEventsHandlersService.handleKeyEventEvent({ | |
| - key: objectStringId(), | |
| + key: Types.ObjectId().toString(), | |
| value: { | |
| eventId: 'mockUUID', | |
| type: KafkaEventType.CREATE, | |
| diff --git a/apps/lawmatics-ms/src/lawmatics-objects/dal/contact-objects.dal.ts b/apps/lawmatics-ms/src/lawmatics-objects/dal/contact-objects.dal.ts | |
| index cd3dafc2b..ccfc8c013 100644 | |
| --- a/apps/lawmatics-ms/src/lawmatics-objects/dal/contact-objects.dal.ts | |
| +++ b/apps/lawmatics-ms/src/lawmatics-objects/dal/contact-objects.dal.ts | |
| @@ -4,7 +4,6 @@ import { FilterQuery, Model } from 'mongoose'; | |
| import { LawmaticsContactResponseData } from '../../lawmatics-client/dtos'; | |
| import { ContactObjectResult, LawmaticsObjectInput } from '../dtos/interfaces'; | |
| import { ContactObject, ContactObjectDocument } from '../schemas/contact-objects.schema'; | |
| -import { materialize, materializeMany } from '@vinny/helpers'; | |
| @Injectable() | |
| export class ContactObjectsDal { | |
| @@ -15,7 +14,7 @@ export class ContactObjectsDal { | |
| async create( | |
| objectInput: LawmaticsObjectInput<LawmaticsContactResponseData>, | |
| ): Promise<ContactObjectDocument> { | |
| - return await materialize(async () => await this.contactObjectModel.create(objectInput)); | |
| + return this.contactObjectModel.create(objectInput); | |
| } | |
| async replaceByLawmaticsId({ | |
| @@ -28,17 +27,22 @@ export class ContactObjectsDal { | |
| lawmaticsUpdatedAt, | |
| data, | |
| }; | |
| - return await materialize( | |
| - async () => await this.contactObjectModel.findOneAndReplace({ lawmaticsId }, contactObject), | |
| - new Error(`can't find ContactObject ${lawmaticsId} - cannot replace`), | |
| - ); | |
| + const result = await this.contactObjectModel | |
| + .findOneAndReplace({ lawmaticsId }, contactObject) | |
| + .lean(); | |
| + | |
| + if (!result) { | |
| + throw new Error(`can't find ContactObject ${lawmaticsId} - cannot replace`); | |
| + } | |
| + | |
| + return result; | |
| } | |
| async findByLawmaticsId(lawmaticsId: string): Promise<ContactObjectResult | null> { | |
| - return await materialize(async () => await this.contactObjectModel.findOne({ lawmaticsId })); | |
| + return this.contactObjectModel.findOne({ lawmaticsId }).lean(); | |
| } | |
| async findAll(filter?: FilterQuery<ContactObjectDocument>): Promise<ContactObjectResult[]> { | |
| - return await materializeMany(async () => await this.contactObjectModel.find(filter || {})); | |
| + return this.contactObjectModel.find(filter || {}).lean(); | |
| } | |
| } | |
| diff --git a/apps/lawmatics-ms/src/lawmatics-objects/dal/event-objects.dal.ts b/apps/lawmatics-ms/src/lawmatics-objects/dal/event-objects.dal.ts | |
| index 07dde1fd8..327e43e08 100644 | |
| --- a/apps/lawmatics-ms/src/lawmatics-objects/dal/event-objects.dal.ts | |
| +++ b/apps/lawmatics-ms/src/lawmatics-objects/dal/event-objects.dal.ts | |
| @@ -2,9 +2,8 @@ import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { FilterQuery, Model } from 'mongoose'; | |
| import { LawmaticsEventResponseData } from '../../lawmatics-client/dtos'; | |
| -import { EventObjectResult, LawmaticsObjectInput } from '../dtos/interfaces'; | |
| +import { LawmaticsObjectInput, EventObjectResult } from '../dtos/interfaces'; | |
| import { EventObject, EventObjectDocument } from '../schemas/event-objects.schema'; | |
| -import { materialize, materializeMany } from '@vinny/helpers'; | |
| @Injectable() | |
| export class EventObjectsDal { | |
| @@ -28,17 +27,22 @@ export class EventObjectsDal { | |
| lawmaticsUpdatedAt, | |
| data, | |
| }; | |
| - return await materialize( | |
| - async () => await this.eventObjectModel.findOneAndReplace({ lawmaticsId }, eventObject), | |
| - new Error(`can't find eventObject ${lawmaticsId} - cannot replace`), | |
| - ); | |
| + const result = await this.eventObjectModel | |
| + .findOneAndReplace({ lawmaticsId }, eventObject) | |
| + .lean(); | |
| + | |
| + if (!result) { | |
| + throw new Error(`can't find eventObject ${lawmaticsId} - cannot replace`); | |
| + } | |
| + | |
| + return result; | |
| } | |
| async findByLawmaticsId(lawmaticsId: string): Promise<EventObjectResult | null> { | |
| - return await materialize(async () => await this.eventObjectModel.findOne({ lawmaticsId })); | |
| + return this.eventObjectModel.findOne({ lawmaticsId }).lean(); | |
| } | |
| async findAll(filter?: FilterQuery<EventObjectDocument>): Promise<EventObjectResult[]> { | |
| - return await materializeMany(async () => await this.eventObjectModel.find(filter || {})); | |
| + return this.eventObjectModel.find(filter || {}).lean(); | |
| } | |
| } | |
| diff --git a/apps/lawmatics-ms/src/practice-areas/test/practice-areas.controller.spec.ts b/apps/lawmatics-ms/src/practice-areas/test/practice-areas.controller.spec.ts | |
| index b7b23f684..c9f003b62 100644 | |
| --- a/apps/lawmatics-ms/src/practice-areas/test/practice-areas.controller.spec.ts | |
| +++ b/apps/lawmatics-ms/src/practice-areas/test/practice-areas.controller.spec.ts | |
| @@ -7,7 +7,7 @@ import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { TENANT_ID_HEADER } from '@vinny/tenancy'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import { ConfigurationModule } from '../../configurations/configurations.module'; | |
| @@ -18,7 +18,6 @@ import { MockConfigService, mockLawmaticsEnvVars } from '../../test/utils'; | |
| import { CreatePracticeAreaRequest } from '../dtos/practice-area.dto'; | |
| import { PracticeAreasService } from '../practice-areas.service'; | |
| import { PracticeAreasController } from '../practice-areas.controller'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Practice Area Controller', () => { | |
| let connection: Connection; | |
| @@ -78,7 +77,7 @@ describe('Practice Area Controller', () => { | |
| describe('create practice area', () => { | |
| it('should create new practice area', async () => { | |
| const createPracticeArea: CreatePracticeAreaRequest = { | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| displayName: 'Family', | |
| }; | |
| @@ -113,7 +112,7 @@ describe('Practice Area Controller', () => { | |
| }); | |
| it('should throw error when trying to create already mapped practice area', async () => { | |
| - const practiceAreaInternalId = objectStringId(); | |
| + const practiceAreaInternalId = Types.ObjectId().toString(); | |
| await configurationsService.create({ | |
| internalId: practiceAreaInternalId, | |
| lawmaticsId: '1234', | |
| @@ -132,7 +131,7 @@ describe('Practice Area Controller', () => { | |
| it('should create a new mapping configuration for an existing practice area in Lawmatics', async () => { | |
| const createPracticeArea: CreatePracticeAreaRequest = { | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| displayName: 'Family', | |
| }; | |
| diff --git a/apps/lawmatics-ms/src/services/test/service-notes.controller.spec.ts b/apps/lawmatics-ms/src/services/test/service-notes.controller.spec.ts | |
| index b2920f52d..1960b00b9 100644 | |
| --- a/apps/lawmatics-ms/src/services/test/service-notes.controller.spec.ts | |
| +++ b/apps/lawmatics-ms/src/services/test/service-notes.controller.spec.ts | |
| @@ -2,7 +2,7 @@ import { ContextIdFactory } from '@nestjs/core'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { | |
| @@ -14,7 +14,6 @@ import { CreateServiceNoteBody } from '../dtos/service-note.dto'; | |
| import { ServicesController } from '../services.controller'; | |
| import { MockService } from './utils'; | |
| import { ServicesModule } from '../services.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const mockEnvVars = { | |
| LAWMATICS_TOKEN: 'DUMMYTOKEN', | |
| @@ -67,7 +66,7 @@ describe('ServicesController', () => { | |
| describe('createServiceNote', () => { | |
| it('should create a note', async () => { | |
| - const [serviceNoteId, serviceId] = [objectStringId(), objectStringId()]; | |
| + const [serviceNoteId, serviceId] = [Types.ObjectId(), Types.ObjectId()]; | |
| const serviceNoteBody: CreateServiceNoteBody = { | |
| id: serviceNoteId.toString(), | |
| name: 'NAME', | |
| @@ -120,7 +119,7 @@ describe('ServicesController', () => { | |
| }); | |
| it('should throw an error when there is no service config', async () => { | |
| - const [serviceNoteId, serviceId] = [objectStringId(), objectStringId()]; | |
| + const [serviceNoteId, serviceId] = [Types.ObjectId(), Types.ObjectId()]; | |
| const serviceNoteBody: CreateServiceNoteBody = { | |
| id: serviceNoteId.toString(), | |
| name: 'NAME', | |
| diff --git a/apps/lawmatics-ms/src/services/test/services.service.spec.ts b/apps/lawmatics-ms/src/services/test/services.service.spec.ts | |
| index aa6bb84c7..1e6ed6c57 100644 | |
| --- a/apps/lawmatics-ms/src/services/test/services.service.spec.ts | |
| +++ b/apps/lawmatics-ms/src/services/test/services.service.spec.ts | |
| @@ -5,7 +5,7 @@ import { Test } from '@nestjs/testing'; | |
| import { ConfigurationType, ServiceData } from '@vinny/lawmatics-types'; | |
| import { LegalTeamMemberRole, ServiceStatus } from '@vinny/services-types'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { | |
| @@ -75,7 +75,6 @@ import { | |
| import * as utils from '../utils'; | |
| import { ServicesModule } from '../services.module'; | |
| import { LawmaticsUserClient } from '../../lawmatics-client/lawmatics-user-client.service'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| const mockEnvVars = { | |
| LAWMATICS_TOKEN: 'DUMMYTOKEN', | |
| @@ -216,7 +215,7 @@ describe('ServicesModule', () => { | |
| }, | |
| }); | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| MockPracticeArea, | |
| MockOpenStatus, | |
| @@ -246,16 +245,16 @@ describe('ServicesModule', () => { | |
| serviceTypeTitle: undefined, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| const responsibleAttorneyConf = await configurationModel.findOne({ | |
| - internalId: responsibleAttorneyId, | |
| + internalId: Types.ObjectId(responsibleAttorneyId), | |
| }); | |
| const caseManagerConf = await configurationModel.findOne({ | |
| - internalId: caseManagerId, | |
| + internalId: Types.ObjectId(caseManagerId), | |
| }); | |
| const paralegalConf = await configurationModel.findOne({ | |
| - internalId: paralegalId, | |
| + internalId: Types.ObjectId(paralegalId), | |
| }); | |
| getPracticeAreaRequest.done(); | |
| @@ -368,9 +367,9 @@ describe('ServicesModule', () => { | |
| }, | |
| }); | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| - { ...MockCase, internalId: MockServiceData.caseId }, | |
| + { ...MockCase, internalId: Types.ObjectId(MockServiceData.caseId) }, | |
| MockCaseManager, | |
| MockResponsibleAttorney, | |
| MockPracticeArea, | |
| @@ -404,7 +403,7 @@ describe('ServicesModule', () => { | |
| serviceTypeTitle: undefined, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| const custFieldsFromDB = await additionalFieldMapModel.findOne({ | |
| name: additionalFieldName, | |
| @@ -534,9 +533,9 @@ describe('ServicesModule', () => { | |
| }, | |
| }); | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| - { ...MockCase, internalId: mockServiceData.caseId }, | |
| + { ...MockCase, internalId: Types.ObjectId(mockServiceData.caseId) }, | |
| MockCaseManager, | |
| MockResponsibleAttorney, | |
| MockPracticeArea, | |
| @@ -569,7 +568,7 @@ describe('ServicesModule', () => { | |
| serviceTypeTitle: serviceData.serviceTypeTitle, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| const custFieldsFromDB = await additionalFieldMapModel.findOne({ | |
| name: additionalFieldName, | |
| @@ -703,9 +702,9 @@ describe('ServicesModule', () => { | |
| }, | |
| }); | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| - { ...MockCase, internalId: MockServiceData.caseId }, | |
| + { ...MockCase, internalId: Types.ObjectId(MockServiceData.caseId) }, | |
| MockCaseManager, | |
| MockResponsibleAttorney, | |
| MockPracticeArea, | |
| @@ -739,7 +738,7 @@ describe('ServicesModule', () => { | |
| serviceTypeTitle: undefined, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| const custFieldsFromDB = await additionalFieldMapModel.findOne({ | |
| name: additionalFieldName, | |
| @@ -786,7 +785,7 @@ describe('ServicesModule', () => { | |
| const additionalFieldName = 'coolness'; | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId(); | |
| const createMatterReq = nockBase | |
| .post('/prospects', { | |
| case_title: 'name', | |
| @@ -845,7 +844,7 @@ describe('ServicesModule', () => { | |
| }); | |
| await configurationModel.insertMany([ | |
| - { ...MockCase, internalId: MockServiceData.caseId }, | |
| + { ...MockCase, internalId: Types.ObjectId(MockServiceData.caseId) }, | |
| MockCaseManager, | |
| MockResponsibleAttorney, | |
| MockParalegal, | |
| @@ -903,7 +902,7 @@ describe('ServicesModule', () => { | |
| serviceTypeTitle: undefined, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| getPracticeAreaRequest.done(); | |
| @@ -937,7 +936,7 @@ describe('ServicesModule', () => { | |
| const additionalFieldName = 'coolness'; | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId(); | |
| const createMatterReq = nockBase | |
| .post('/prospects', { | |
| case_title: 'name', | |
| @@ -996,7 +995,7 @@ describe('ServicesModule', () => { | |
| }); | |
| await configurationModel.insertMany([ | |
| - { ...MockCase, internalId: MockServiceData.caseId }, | |
| + { ...MockCase, internalId: Types.ObjectId(MockServiceData.caseId) }, | |
| MockCaseManager, | |
| MockResponsibleAttorney, | |
| MockParalegal, | |
| @@ -1055,7 +1054,7 @@ describe('ServicesModule', () => { | |
| serviceTypeTitle: undefined, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| getPracticeAreaRequest.done(); | |
| @@ -1180,9 +1179,9 @@ describe('ServicesModule', () => { | |
| }, | |
| }); | |
| - const userId = objectId(objectStringId()); | |
| + const userId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| - { ...MockCase, internalId: MockServiceData.caseId }, | |
| + { ...MockCase, internalId: Types.ObjectId(MockServiceData.caseId) }, | |
| MockCaseManager, | |
| MockResponsibleAttorney, | |
| MockPracticeArea, | |
| @@ -1242,7 +1241,7 @@ describe('ServicesModule', () => { | |
| serviceTypeTitle: undefined, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| getPracticeAreaRequest.done(); | |
| @@ -1258,7 +1257,7 @@ describe('ServicesModule', () => { | |
| it('should create service without creating users', async () => { | |
| jest.spyOn(usersClient, 'getUserById'); | |
| jest.spyOn(lawmaticsStatusClient, 'getStatuses'); | |
| - const userId = objectId(objectStringId()); | |
| + const userId = Types.ObjectId(); | |
| const createMatterReq = nockBase | |
| .post('/prospects', { | |
| @@ -1322,7 +1321,7 @@ describe('ServicesModule', () => { | |
| }); | |
| await configurationModel.insertMany([ | |
| - { ...MockCase, internalId: MockServiceData.caseId }, | |
| + { ...MockCase, internalId: Types.ObjectId(MockServiceData.caseId) }, | |
| MockCaseManager, | |
| MockResponsibleAttorney, | |
| MockParalegal, | |
| @@ -1351,7 +1350,7 @@ describe('ServicesModule', () => { | |
| serviceTypeTitle: undefined, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| getPracticeAreaRequest.done(); | |
| createMatterReq.done(); | |
| @@ -1405,7 +1404,7 @@ describe('ServicesModule', () => { | |
| it('should not create service if case manager does not exist', async () => { | |
| usersClient.getUserById = jest.fn().mockReturnValue(undefined); | |
| - const userId = objectId(objectStringId()); | |
| + const userId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| { ...MockUserData, internalId: userId }, | |
| MockPracticeArea, | |
| @@ -1423,7 +1422,7 @@ describe('ServicesModule', () => { | |
| it('should not create service if responsible attorney does not exist', async () => { | |
| usersClient.getUserById = jest.fn().mockReturnValue(undefined); | |
| - const userId = objectId(objectStringId()); | |
| + const userId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| { ...MockCase, internalId: MockServiceData.caseId }, | |
| MockPracticeArea, | |
| @@ -1521,7 +1520,7 @@ describe('ServicesModule', () => { | |
| }); | |
| await configurationModel.insertMany([ | |
| - { ...MockCase, internalId: MockServiceData.caseId }, | |
| + { ...MockCase, internalId: Types.ObjectId(MockServiceData.caseId) }, | |
| MockCaseManager, | |
| MockResponsibleAttorney, | |
| MockParalegal, | |
| @@ -1548,12 +1547,12 @@ describe('ServicesModule', () => { | |
| await servicesController.createService({ | |
| ...MockServiceData, | |
| caseId: MockServiceData.caseId, | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId.toString(), | |
| serviceTypeTitle: undefined, | |
| }); | |
| const serviceFromDB = await configurationModel.findOne({ | |
| - internalId: MockServiceData.id, | |
| + internalId: Types.ObjectId(MockServiceData.id), | |
| }); | |
| const statusFromDB = await configurationModel.findOne({ | |
| @@ -1687,7 +1686,7 @@ describe('ServicesModule', () => { | |
| describe('getContactMatters', () => { | |
| it('should get matters by contact id', async () => { | |
| - const caseId = objectId(objectStringId()); | |
| + const caseId = Types.ObjectId(); | |
| await configurationModel.insertMany([ | |
| { ...MockCase, internalId: caseId }, | |
| MockPracticeArea, | |
| @@ -1893,7 +1892,7 @@ describe('ServicesModule', () => { | |
| } as any); | |
| const responsibleAttorneyConf = await configurationModel.findOne({ | |
| - internalId: responsibleAttorneyId, | |
| + internalId: Types.ObjectId(responsibleAttorneyId), | |
| }); | |
| updateMatterReq.done(); | |
| diff --git a/apps/lawmatics-ms/src/services/test/utils.ts b/apps/lawmatics-ms/src/services/test/utils.ts | |
| index fe5d2249b..7e696e5c5 100644 | |
| --- a/apps/lawmatics-ms/src/services/test/utils.ts | |
| +++ b/apps/lawmatics-ms/src/services/test/utils.ts | |
| @@ -1,20 +1,20 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { faker } from '@faker-js/faker'; | |
| import { ConfigurationType, Role, ServiceData } from '@vinny/lawmatics-types'; | |
| import { LegalTeamMemberRole, ServiceDto, ServiceStatus } from '@vinny/services-types'; | |
| import { LawmaticsUserResponseData } from '../../lawmatics-client/dtos/lawmatics-user.dto'; | |
| import { LawmaticsUserClient } from '../../lawmatics-client/lawmatics-user-client.service'; | |
| -export const responsibleAttorneyId = objectStringId(); | |
| -export const caseManagerId = objectStringId(); | |
| -export const practiceAreaId = objectStringId(); | |
| -export const paralegalId = objectStringId(); | |
| -export const serviceTypeId = objectStringId(); | |
| +export const responsibleAttorneyId = Types.ObjectId().toString(); | |
| +export const caseManagerId = Types.ObjectId().toString(); | |
| +export const practiceAreaId = Types.ObjectId().toString(); | |
| +export const paralegalId = Types.ObjectId().toString(); | |
| +export const serviceTypeId = Types.ObjectId().toString(); | |
| export const MockPipeline = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId(), | |
| lawmaticsId: '5432', | |
| - internalId: serviceTypeId, | |
| + internalId: Types.ObjectId(serviceTypeId), | |
| value: '14', | |
| firstStageId: '80', | |
| type: ConfigurationType.PIPELINE, | |
| @@ -22,14 +22,14 @@ export const MockPipeline = { | |
| export const MockServiceData: ServiceData = { | |
| serviceTypeTitle: undefined, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: 'name', | |
| description: 'description', | |
| practiceAreaId, | |
| opposingParty: faker.name.firstName(), | |
| serviceTypeId: serviceTypeId, | |
| - caseId: objectStringId(), | |
| - userId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| legalTeam: [ | |
| { | |
| @@ -48,24 +48,24 @@ export const MockServiceData: ServiceData = { | |
| }; | |
| export const MockService = { | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId(), | |
| lawmaticsId: '444', | |
| type: ConfigurationType.SERVICE, | |
| }; | |
| export const MockUser = { | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId(), | |
| lawmaticsId: '111', | |
| type: ConfigurationType.USER, | |
| }; | |
| export const mockService: ServiceDto = { | |
| id: MockService.internalId.toString(), | |
| - userId: objectStringId(), | |
| - caseId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| name: 'some name', | |
| legalTeam: [], | |
| location: { | |
| @@ -80,13 +80,13 @@ export const mockEventType = { | |
| }; | |
| export const MockNotExsitingService = { | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId(), | |
| lawmaticsId: '666', | |
| type: ConfigurationType.SERVICE, | |
| }; | |
| export const MockUserData = { | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId(), | |
| lawmaticsId: '111', | |
| type: ConfigurationType.USER, | |
| }; | |
| @@ -94,36 +94,36 @@ export const MockUserData = { | |
| export const MockPracticeArea = { | |
| value: 'FAMILY', | |
| lawmaticsId: '555', | |
| - internalId: practiceAreaId, | |
| + internalId: Types.ObjectId(practiceAreaId), | |
| type: ConfigurationType.PRACTICE_AREA, | |
| }; | |
| export const MockResponsibleAttorney = { | |
| - internalId: responsibleAttorneyId, | |
| + internalId: Types.ObjectId(responsibleAttorneyId), | |
| lawmaticsId: '222', | |
| type: ConfigurationType.USER, | |
| }; | |
| export const MockCaseManager = { | |
| - internalId: caseManagerId, | |
| + internalId: Types.ObjectId(caseManagerId), | |
| lawmaticsId: '333', | |
| type: ConfigurationType.USER, | |
| }; | |
| export const MockParalegal = { | |
| - internalId: paralegalId, | |
| + internalId: Types.ObjectId(paralegalId), | |
| lawmaticsId: '999', | |
| type: ConfigurationType.USER, | |
| }; | |
| export const MockCase = { | |
| lawmaticsId: '777', | |
| - internalId: MockServiceData.caseId, | |
| + internalId: Types.ObjectId(MockServiceData.caseId), | |
| type: ConfigurationType.CASE, | |
| }; | |
| export const MockOpenStatus = { | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId(), | |
| lawmaticsId: '123', | |
| type: ConfigurationType.STATUS, | |
| value: ServiceStatus.OPEN, | |
| @@ -131,7 +131,7 @@ export const MockOpenStatus = { | |
| export const MockCompletedStatus = { | |
| lawmaticsId: '12345', | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| type: ConfigurationType.STATUS, | |
| value: ServiceStatus.COMPLETED, | |
| }; | |
| diff --git a/apps/lawmatics-ms/src/tasks/tests/tasks.service.spec.ts b/apps/lawmatics-ms/src/tasks/tests/tasks.service.spec.ts | |
| index dc49e2d17..9259af7cf 100644 | |
| --- a/apps/lawmatics-ms/src/tasks/tests/tasks.service.spec.ts | |
| +++ b/apps/lawmatics-ms/src/tasks/tests/tasks.service.spec.ts | |
| @@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { Connection, Model } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { TasksService } from '../tasks.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { | |
| Configuration, | |
| @@ -159,7 +159,7 @@ describe('TasksService', () => { | |
| it('should throw error - matter configuration not found', async () => { | |
| const wrongPayloadFakeServiceId = { | |
| ...createTaskPayloadMock, | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }; | |
| await expect(tasksService.createTask(wrongPayloadFakeServiceId)).rejects.toThrowError( | |
| new InternalServerErrorException( | |
| @@ -171,7 +171,7 @@ describe('TasksService', () => { | |
| it('should throw error - user configuration not found', async () => { | |
| const wrongPayloadFakeUserId = { | |
| ...createTaskPayloadMock, | |
| - createdByUserId: objectStringId(), | |
| + createdByUserId: Types.ObjectId().toString(), | |
| }; | |
| await expect(tasksService.createTask(wrongPayloadFakeUserId)).rejects.toThrowError( | |
| new InternalServerErrorException( | |
| diff --git a/apps/lawmatics-ms/src/tasks/tests/utils.ts b/apps/lawmatics-ms/src/tasks/tests/utils.ts | |
| index d6e28f59e..6e26d7b7f 100644 | |
| --- a/apps/lawmatics-ms/src/tasks/tests/utils.ts | |
| +++ b/apps/lawmatics-ms/src/tasks/tests/utils.ts | |
| @@ -5,17 +5,17 @@ import { | |
| CreateTaskDataRequest, | |
| } from '@vinny/lawmatics-types'; | |
| import { ServiceStatus } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ScannedLawmaticsObjectType } from '../../diff-scanner/dtos/interfaces'; | |
| import { LawmaticsTasksResponseData } from '../../lawmatics-client/dtos'; | |
| import { LawmaticsObjectInput } from '../../lawmatics-objects/dtos/interfaces'; | |
| import { mockMatterObject } from '../../test/utils'; | |
| import { OPEN_TASKS_STATUSES } from '../consts'; | |
| -const createdByUserIdMock = objectStringId(); | |
| -const serviceIdMock = objectStringId(); | |
| +const createdByUserIdMock = Types.ObjectId().toString(); | |
| +const serviceIdMock = Types.ObjectId().toString(); | |
| -const assignToUserIdMock = objectStringId(); | |
| +const assignToUserIdMock = Types.ObjectId().toString(); | |
| export const fakeMarbleId = faker.database.mongodbObjectId(); | |
| export const lawmaticsTagId = faker.datatype.number().toString(); | |
| export const createTaskPayloadMock: CreateTaskDataRequest = { | |
| @@ -67,7 +67,7 @@ export const mockCustomer = { | |
| export const mockAttorney = { | |
| id: assignToUserIdMock, | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| email: '[email protected]', | |
| type: 'attorney', | |
| name: { | |
| diff --git a/apps/notifications-ms/src/devices/tests/devices.controller.integ.spec.ts b/apps/notifications-ms/src/devices/tests/devices.controller.integ.spec.ts | |
| index ad77b2356..187370d8c 100644 | |
| --- a/apps/notifications-ms/src/devices/tests/devices.controller.integ.spec.ts | |
| +++ b/apps/notifications-ms/src/devices/tests/devices.controller.integ.spec.ts | |
| @@ -2,7 +2,7 @@ import request from 'supertest'; | |
| import { HttpStatus, INestApplication, Logger } from '@nestjs/common'; | |
| import { ConfigService } from '@nestjs/config'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { getLogger, MockConfigService } from '@vinny/test-utils'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| @@ -50,7 +50,7 @@ describe('DevicesControllerIntegration', () => { | |
| }); | |
| describe('POST /devices', () => { | |
| - const mockUser = { id: objectStringId(), marbleId: 'mockMarbleId' }; | |
| + const mockUser = { id: Types.ObjectId().toString(), marbleId: 'mockMarbleId' }; | |
| const payload: RegisterDeviceRequest = { | |
| userId: mockUser.id, | |
| diff --git a/apps/notifications-ms/src/notifications/dal/schemas/notifications.schema.ts b/apps/notifications-ms/src/notifications/dal/schemas/notifications.schema.ts | |
| index 1bae6db8a..a11e06bcc 100644 | |
| --- a/apps/notifications-ms/src/notifications/dal/schemas/notifications.schema.ts | |
| +++ b/apps/notifications-ms/src/notifications/dal/schemas/notifications.schema.ts | |
| @@ -1,7 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { NotificationType, App } from '@vinny/notifications-types'; | |
| -import { Document, Types, Schema as MongooseSchema } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types, Schema as MongooseSchema } from 'mongoose'; | |
| const objectIdToStringGetter = (v: Types.ObjectId): string => v?.toString(); | |
| @@ -29,7 +28,7 @@ export class Notification { | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId, get: objectIdToStringGetter, index: true }) | |
| userId: string; | |
| @Prop({ required: true, type: String, enum: Object.values(App) }) | |
| diff --git a/apps/notifications-ms/src/notifications/tests/notifications.events-handler.controller.spec.ts b/apps/notifications-ms/src/notifications/tests/notifications.events-handler.controller.spec.ts | |
| index f4d165c20..ff26cc815 100644 | |
| --- a/apps/notifications-ms/src/notifications/tests/notifications.events-handler.controller.spec.ts | |
| +++ b/apps/notifications-ms/src/notifications/tests/notifications.events-handler.controller.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import nock from 'nock'; | |
| import { TestingModule } from '@nestjs/testing'; | |
| import { NotificationsEventHandlerController } from '../notifications.events-handler.controller'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { App } from '@vinny/notifications-types'; | |
| import { NO_USERS_ERROR_MESSAGE, USER_DOES_NOT_EXIST_ERROR_MESSAGE } from '../../exceptions/errors'; | |
| import { BadRequestException } from '@nestjs/common'; | |
| @@ -15,7 +15,6 @@ import { NotificationsDal } from '../dal/notifications.dal'; | |
| import { closeInMongodConnection } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { VinnyAnalyticsService } from '@vinny/vinny-analytics'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const usersMsNock = nock(ENV_VARS.USERS_MS_URL); | |
| const oneSignalNock = nock(ENV_VARS.ONE_SIGNAL_BASE_URL); | |
| @@ -50,9 +49,9 @@ describe('NotificationsEventHandlerController', () => { | |
| }); | |
| describe('handleNotificationEvent', () => { | |
| - const firstMockUser = { id: objectStringId(), marbleId: 'mockMarbleId1' }; | |
| - const secondMockUser = { id: objectStringId(), marbleId: 'mockMarbleId2' }; | |
| - const thirdMockUser = { id: objectStringId(), marbleId: 'mockMarbleId3' }; | |
| + const firstMockUser = { id: Types.ObjectId().toString(), marbleId: 'mockMarbleId1' }; | |
| + const secondMockUser = { id: Types.ObjectId().toString(), marbleId: 'mockMarbleId2' }; | |
| + const thirdMockUser = { id: Types.ObjectId().toString(), marbleId: 'mockMarbleId3' }; | |
| it('should send notification to one user', async () => { | |
| const sendEventSpy = jest.spyOn(analyticsService, 'trackEvent'); | |
| diff --git a/apps/scheduler-ms/src/cron/dal/cron-task/cron-task.schema.ts b/apps/scheduler-ms/src/cron/dal/cron-task/cron-task.schema.ts | |
| index ee61d8239..eb5f2627e 100644 | |
| --- a/apps/scheduler-ms/src/cron/dal/cron-task/cron-task.schema.ts | |
| +++ b/apps/scheduler-ms/src/cron/dal/cron-task/cron-task.schema.ts | |
| @@ -16,7 +16,7 @@ const CronRepeatOptionsSchema = SchemaFactory.createForClass(CronRepeatOptions); | |
| @Schema({ _id: false, id: false }) | |
| class CronTaskData { | |
| - @Prop({ required: true, enum: Object.values(AxiosMethodSubsetValues), type: String }) | |
| + @Prop({ required: true, enum: AxiosMethodSubsetValues, type: String }) | |
| method: Method; | |
| @Prop({ required: true }) | |
| diff --git a/apps/scheduler-ms/src/cron/dal/task/task.dal.ts b/apps/scheduler-ms/src/cron/dal/task/task.dal.ts | |
| index 29be0a96f..bb0885a2a 100644 | |
| --- a/apps/scheduler-ms/src/cron/dal/task/task.dal.ts | |
| +++ b/apps/scheduler-ms/src/cron/dal/task/task.dal.ts | |
| @@ -2,9 +2,8 @@ import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { TaskStatus } from '@vinny/scheduler-types'; | |
| import { TaskRetry } from '../../../types'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { Task, TaskDocument } from './task.schema'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class TaskDal { | |
| @@ -63,7 +62,7 @@ export class TaskDal { | |
| ): Promise<Task | null> { | |
| return ( | |
| await this.taskModel.findOneAndUpdate( | |
| - { _id: objectId(id) }, | |
| + { _id: Types.ObjectId(id) }, | |
| { | |
| ...(status && { status }), | |
| ...(retry && { $push: { retries: retry } }), | |
| diff --git a/apps/scheduler-ms/src/publisher/dal/delayed-task.dal.ts b/apps/scheduler-ms/src/publisher/dal/delayed-task.dal.ts | |
| index ecc6701a6..d24a5cc52 100644 | |
| --- a/apps/scheduler-ms/src/publisher/dal/delayed-task.dal.ts | |
| +++ b/apps/scheduler-ms/src/publisher/dal/delayed-task.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { DelayedTask, DelayedTaskDocument } from './delayed-task.schema'; | |
| import { | |
| DelayedTaskDto, | |
| @@ -9,7 +9,6 @@ import { | |
| TaskStatus, | |
| } from '@vinny/scheduler-types'; | |
| import { TaskRetry } from '../../types'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class DelayedTaskDal { | |
| @@ -44,7 +43,7 @@ export class DelayedTaskDal { | |
| ): Promise<DelayedTask | null> { | |
| return ( | |
| await this.delayedTaskModel.findOneAndUpdate( | |
| - { _id: objectId(id) }, | |
| + { _id: Types.ObjectId(id) }, | |
| { | |
| ...(status && { status }), | |
| ...(retry && { $push: { retries: retry } }), | |
| diff --git a/apps/scheduler-ms/src/publisher/dal/delayed-task.schema.ts b/apps/scheduler-ms/src/publisher/dal/delayed-task.schema.ts | |
| index 6fdb2624b..4ecb1861e 100644 | |
| --- a/apps/scheduler-ms/src/publisher/dal/delayed-task.schema.ts | |
| +++ b/apps/scheduler-ms/src/publisher/dal/delayed-task.schema.ts | |
| @@ -4,9 +4,9 @@ import { AxiosRequestHeaders, Method } from 'axios'; | |
| import { SchemaTypes, Types, Document } from 'mongoose'; | |
| import { TaskRetry, TaskRetrySchema } from '../../cron/dal/task/task.schema'; | |
| -@Schema({ _id: false, id: false }) | |
| +@Schema() | |
| class TaskData { | |
| - @Prop({ required: true, enum: Object.values(AxiosMethodSubsetValues), type: String }) | |
| + @Prop({ required: true, enum: AxiosMethodSubsetValues, type: String }) | |
| method: Method; | |
| @Prop({ required: true }) | |
| diff --git a/apps/scheduler-ms/src/publisher/publisher.service.ts b/apps/scheduler-ms/src/publisher/publisher.service.ts | |
| index bf35663e4..8184298e6 100644 | |
| --- a/apps/scheduler-ms/src/publisher/publisher.service.ts | |
| +++ b/apps/scheduler-ms/src/publisher/publisher.service.ts | |
| @@ -8,7 +8,7 @@ import { | |
| } from '@vinny/scheduler-types'; | |
| import { Queue } from 'bull'; | |
| import { InjectQueue } from '@nestjs/bull'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { | |
| DEFAULT_NUMBER_OF_RETRIES_TO_EXECUTE_TASK, | |
| BACKOFF_DELAY_DEFAULT_INITIAL_VALUE_IN_MS, | |
| @@ -43,7 +43,7 @@ export class PublisherService { | |
| throw new BadRequestException('given timeToExecute has elapsed'); | |
| } | |
| - const taskId = objectStringId(); | |
| + const taskId = Types.ObjectId().toString(); | |
| const requestData: DelayedRequestData = { | |
| requestData: { | |
| diff --git a/apps/scheduler-ms/src/publisher/test/publisher.controller.spec.ts b/apps/scheduler-ms/src/publisher/test/publisher.controller.spec.ts | |
| index 2fd084d10..114a13a30 100644 | |
| --- a/apps/scheduler-ms/src/publisher/test/publisher.controller.spec.ts | |
| +++ b/apps/scheduler-ms/src/publisher/test/publisher.controller.spec.ts | |
| @@ -23,7 +23,7 @@ import { | |
| updateDelayedTaskUpdatedAt, | |
| } from './utils'; | |
| import { getRedisMemoryServer, importCommons, MONGO_OBJECT_ID_REGEX } from '@vinny/test-utils'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { DelayedTaskDal } from '../dal/delayed-task.dal'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { DelayedTask, DelayedTaskDocument } from '../dal/delayed-task.schema'; | |
| @@ -31,7 +31,6 @@ import { closeInMongodConnection } from '@vinny/test-utils'; | |
| import { IDEMPOTENCY_KEY_HEADER } from '@vinny/idempotency'; | |
| import { Model } from 'mongoose'; | |
| import { PublisherModule } from '../publisher.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('Publisher Controller', () => { | |
| let controller: PublisherController; | |
| @@ -304,7 +303,7 @@ describe('Publisher Controller', () => { | |
| }); | |
| it('should throw not found exception when job does not exists', async () => { | |
| - const randomId = objectStringId(); | |
| + const randomId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .delete(`/schedule-webhook/${randomId}`) | |
| @@ -315,7 +314,7 @@ describe('Publisher Controller', () => { | |
| describe('find by id', () => { | |
| it('should find task by id', async () => { | |
| const timeToExecute = new Date(Date.now() + 10000); | |
| - const randomId = objectStringId(); | |
| + const randomId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .get(`/schedule-webhook/${randomId}`) | |
| diff --git a/apps/scheduler-ms/src/publisher/test/utils.ts b/apps/scheduler-ms/src/publisher/test/utils.ts | |
| index d4b2bc505..a6c910943 100644 | |
| --- a/apps/scheduler-ms/src/publisher/test/utils.ts | |
| +++ b/apps/scheduler-ms/src/publisher/test/utils.ts | |
| @@ -1,8 +1,7 @@ | |
| import { BackoffType, DelayedTaskRequestDto } from '@vinny/scheduler-types'; | |
| import { DelayedRequestData } from '../types'; | |
| import { DelayedTaskDocument } from '../dal/delayed-task.schema'; | |
| -import { Model } from 'mongoose'; | |
| -import { objectId } from '@vinny/helpers'; | |
| +import { Model, Types } from 'mongoose'; | |
| export const CreateDelayedTaskRequestDto = ( | |
| timeToExecute: Date, | |
| @@ -49,7 +48,7 @@ export const updateDelayedTaskUpdatedAt = async ({ | |
| updatedAt: Date; | |
| }) => { | |
| await model.findOneAndUpdate( | |
| - { _id: objectId(delayedTaskId) }, | |
| + { _id: Types.ObjectId(delayedTaskId) }, | |
| { $set: { updatedAt } }, | |
| { timestamps: false, upsert: true }, | |
| ); | |
| diff --git a/apps/services-ms/src/activities/test/activities.service.spec.ts b/apps/services-ms/src/activities/test/activities.service.spec.ts | |
| index 220225550..91cbcb563 100644 | |
| --- a/apps/services-ms/src/activities/test/activities.service.spec.ts | |
| +++ b/apps/services-ms/src/activities/test/activities.service.spec.ts | |
| @@ -1,5 +1,5 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { | |
| @@ -21,7 +21,6 @@ import { CreateTicketRequest, SupportRequestStatus } from '@vinny/users-types'; | |
| import { EmailSources } from '@vinny/communications-types'; | |
| import { ActivitiesModule } from '../activities.module'; | |
| import { DataAccessService } from '../../services/data-access.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const LAWMATICS_TICKETS_INTERACTION_TOPIC_NAME = 'lawmatics-tickets-activity'; | |
| @@ -190,7 +189,7 @@ describe('ActivitiesService', () => { | |
| TicketTypesToSyncLawmatics.CriticalDate, | |
| SupportRequestStatus.OPEN, | |
| ); | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const ticketEvent: KafkaEventDto<CreateTicketRequest> = { | |
| key: userId, | |
| @@ -217,22 +216,22 @@ describe('ActivitiesService', () => { | |
| TicketTypesToSyncLawmatics.CriticalDate, | |
| SupportRequestStatus.OPEN, | |
| ); | |
| - const userId = objectStringId(); | |
| + const userId = Types.ObjectId().toString(); | |
| const { id: serviceId1 } = await servicesDal.createService({ | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| userId, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| }); | |
| const { id: serviceId2 } = await servicesDal.createService({ | |
| - serviceId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| userId, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| }); | |
| diff --git a/apps/services-ms/src/administration/administration.service.ts b/apps/services-ms/src/administration/administration.service.ts | |
| index 384562f24..c54157d02 100644 | |
| --- a/apps/services-ms/src/administration/administration.service.ts | |
| +++ b/apps/services-ms/src/administration/administration.service.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { LawmaticsMsClient } from '../clients/lawmatics-ms-client/lawmatics-ms.client'; | |
| import { CreateLawmaticsPracticeAreaRequest } from '../clients/lawmatics-ms-client/dtos/lawmatics-practice-area.dto'; | |
| import { AdministrationDal } from './dal/administration.dal'; | |
| @@ -22,7 +22,7 @@ export class AdministrationService { | |
| async createPracticeArea(request: CreatePracticeAreaRequest): Promise<PracticeAreaDto> { | |
| this.logger.log('createPracticeArea - started', { request }); | |
| try { | |
| - const dalRequest = { ...request, id: objectStringId() }; | |
| + const dalRequest = { ...request, id: Types.ObjectId().toString() }; | |
| const createLawmaticsPracticeArea: CreateLawmaticsPracticeAreaRequest = { | |
| internalId: dalRequest.id, | |
| diff --git a/apps/services-ms/src/administration/dal/administration.dal.ts b/apps/services-ms/src/administration/dal/administration.dal.ts | |
| index 7142d3b53..206470b3c 100644 | |
| --- a/apps/services-ms/src/administration/dal/administration.dal.ts | |
| +++ b/apps/services-ms/src/administration/dal/administration.dal.ts | |
| @@ -1,9 +1,8 @@ | |
| import { Injectable, NotFoundException } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { CreatePracticeAreaRequest, FilterPracticeAreaRequestDto } from '@vinny/services-types'; | |
| import { PracticeArea, PracticeAreaDocument } from '../schemas/practice-areas.schema'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| const INVALID_OBJECT_ID_MESSAGE = | |
| 'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'; | |
| @@ -19,7 +18,7 @@ export class AdministrationDal { | |
| async createPracticeArea(request: CreatePracticeAreaDalRequest): Promise<PracticeArea> { | |
| return this.practiceAreasModel.create({ | |
| - _id: objectId(request.id ?? objectStringId()), | |
| + _id: (request.id && Types.ObjectId(request.id)) ?? Types.ObjectId(), | |
| key: request.key, | |
| displayName: request.displayName, | |
| }); | |
| @@ -27,7 +26,7 @@ export class AdministrationDal { | |
| async getPracticeAreaById(id: string): Promise<PracticeArea | null> { | |
| try { | |
| - const practiceArea = await this.practiceAreasModel.findOne({ _id: objectId(id) }); | |
| + const practiceArea = await this.practiceAreasModel.findOne({ _id: Types.ObjectId(id) }); | |
| return practiceArea; | |
| } catch (error) { | |
| if (error instanceof Error && error.message === INVALID_OBJECT_ID_MESSAGE) { | |
| @@ -41,7 +40,7 @@ export class AdministrationDal { | |
| const { ids, ...properties } = filter; | |
| return await this.practiceAreasModel.find({ | |
| ...properties, | |
| - ...(filter.ids && { _id: { $in: filter.ids.map((id) => objectId(id)) } }), | |
| + ...(filter.ids && { _id: { $in: filter.ids.map((id) => Types.ObjectId(id)) } }), | |
| }); | |
| } | |
| diff --git a/apps/services-ms/src/administration/dal/service-tags.dal.ts b/apps/services-ms/src/administration/dal/service-tags.dal.ts | |
| index 0b2f3a34a..fccfc8b3c 100644 | |
| --- a/apps/services-ms/src/administration/dal/service-tags.dal.ts | |
| +++ b/apps/services-ms/src/administration/dal/service-tags.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { ConflictException, Inject, Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { FilterQuery, Model } from 'mongoose'; | |
| +import { FilterQuery, Model, Types } from 'mongoose'; | |
| import { | |
| CreateServiceTagRequest, | |
| FilterServiceTagsDto, | |
| @@ -8,7 +8,6 @@ import { | |
| } from '@vinny/services-types'; | |
| import { ServiceTagDocument, ServiceTag } from '../schemas/service-tags.schema'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| -import { objectId } from '@vinny/helpers'; | |
| const DUPLICATE_KEY_ERROR_MSG_PREFIX = 'E11000 duplicate'; | |
| const INVALID_OBJECTID_ERROR_MSG = | |
| @@ -27,7 +26,7 @@ export class ServiceTagDal { | |
| return await this.serviceTagModel.create({ | |
| key: request.key, | |
| displayName: request.displayName, | |
| - practiceAreaId: objectId(request.practiceAreaId), | |
| + practiceAreaId: Types.ObjectId(request.practiceAreaId), | |
| }); | |
| } catch (error) { | |
| if (error instanceof Error && error.message.startsWith(DUPLICATE_KEY_ERROR_MSG_PREFIX)) { | |
| @@ -38,8 +37,7 @@ export class ServiceTagDal { | |
| } | |
| async findByKey(key: string): Promise<ServiceTag | null> { | |
| - const find = await this.serviceTagModel.findOne({ key }); | |
| - return find?.toObject() ?? null; | |
| + return await this.serviceTagModel.findOne({ key }).lean(); | |
| } | |
| async find(filter: FilterServiceTagsDto): Promise<ServiceTag[]> { | |
| @@ -52,7 +50,7 @@ export class ServiceTagDal { | |
| } | |
| if (practiceAreaIds) { | |
| - filterQuery.practiceAreaId = { $in: practiceAreaIds }; | |
| + filterQuery.practiceAreaId = { $in: practiceAreaIds.map((id) => Types.ObjectId(id)) }; | |
| } | |
| return await this.serviceTagModel.find(filterQuery); | |
| } catch (error) { | |
| @@ -65,16 +63,14 @@ export class ServiceTagDal { | |
| } | |
| async update(key: string, request: UpdateServiceTagRequest): Promise<ServiceTag | null> { | |
| - const update = await this.serviceTagModel | |
| - .findOneAndUpdate({ key }, { ...request }, { new: true }); | |
| - | |
| - return update?.toObject() ?? null; | |
| + return await this.serviceTagModel | |
| + .findOneAndUpdate({ key }, { ...request }, { new: true }) | |
| + .lean(); | |
| } | |
| async remove(key: string): Promise<ServiceTag | null> { | |
| - const removed = await this.serviceTagModel | |
| - .findOneAndUpdate({ key }, { removedAt: new Date() }, { new: true }); | |
| - | |
| - return removed?.toObject() ?? null; | |
| + return await this.serviceTagModel | |
| + .findOneAndUpdate({ key }, { removedAt: new Date() }, { new: true }) | |
| + .lean(); | |
| } | |
| } | |
| diff --git a/apps/services-ms/src/administration/schemas/service-tags.schema.ts b/apps/services-ms/src/administration/schemas/service-tags.schema.ts | |
| index a742f1c1a..ca67b0e69 100644 | |
| --- a/apps/services-ms/src/administration/schemas/service-tags.schema.ts | |
| +++ b/apps/services-ms/src/administration/schemas/service-tags.schema.ts | |
| @@ -1,8 +1,7 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, Types } from 'mongoose'; | |
| -@Schema({ timestamps: true, autoIndex: true, toObject: { getters: true } }) | |
| +@Schema({ timestamps: true, autoIndex: true }) | |
| export class ServiceTag { | |
| @Prop({ required: true, unique: true }) | |
| key: string; | |
| @@ -10,8 +9,8 @@ export class ServiceTag { | |
| @Prop({ required: true }) | |
| displayName: string; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| - practiceAreaId: string; | |
| + @Prop({ required: true, index: true }) | |
| + practiceAreaId: Types.ObjectId; | |
| @Prop({ required: false, type: Date, index: true }) | |
| removedAt?: Date | null; | |
| diff --git a/apps/services-ms/src/attorney-notes/dal/schemas/bpm-service-closure.schema.ts b/apps/services-ms/src/attorney-notes/dal/schemas/bpm-service-closure.schema.ts | |
| index 934bad2d8..76f0ab849 100644 | |
| --- a/apps/services-ms/src/attorney-notes/dal/schemas/bpm-service-closure.schema.ts | |
| +++ b/apps/services-ms/src/attorney-notes/dal/schemas/bpm-service-closure.schema.ts | |
| @@ -1,26 +1,25 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document } from 'mongoose'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| import { FilingOptions, ReasonOptions, ServiceRecommendationsOptions } from '@vinny/services-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| @Schema({ timestamps: true, id: true, toObject: { getters: true } }) | |
| export class BpmServiceClosure { | |
| @Prop({ required: true, unique: true }) | |
| taskId: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - serviceId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + serviceId: Types.ObjectId; | |
| @Prop({ required: true }) | |
| serviceOutcome: string; | |
| - @Prop({ required: true, enum: Object.values(FilingOptions), type: String }) | |
| + @Prop({ required: true, enum: FilingOptions, type: String }) | |
| filing: FilingOptions; | |
| - @Prop({ required: true, enum: Object.values(ServiceRecommendationsOptions), type: String }) | |
| + @Prop({ required: true, enum: ServiceRecommendationsOptions, type: String }) | |
| serviceRecommendations: ServiceRecommendationsOptions; | |
| - @Prop({ enum: Object.values(ReasonOptions), type: String }) | |
| + @Prop({ enum: ReasonOptions, type: String }) | |
| reason?: ReasonOptions; | |
| } | |
| diff --git a/apps/services-ms/src/attorney-notes/dal/schemas/intro-call.schema.ts b/apps/services-ms/src/attorney-notes/dal/schemas/intro-call.schema.ts | |
| index 0718586d8..db54c5e2a 100644 | |
| --- a/apps/services-ms/src/attorney-notes/dal/schemas/intro-call.schema.ts | |
| +++ b/apps/services-ms/src/attorney-notes/dal/schemas/intro-call.schema.ts | |
| @@ -1,14 +1,13 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, Types, SchemaTypes } from 'mongoose'; | |
| @Schema({ timestamps: true, id: true, toObject: { getters: true } }) | |
| export class IntroCall { | |
| @Prop({ required: true, unique: true }) | |
| taskId: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - serviceId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + serviceId: Types.ObjectId; | |
| @Prop({ required: true }) | |
| date: Date; | |
| diff --git a/apps/services-ms/src/case-status-updates/dal/case-status-updates.dal.ts b/apps/services-ms/src/case-status-updates/dal/case-status-updates.dal.ts | |
| index 50919a7f5..f5bfd48ef 100644 | |
| --- a/apps/services-ms/src/case-status-updates/dal/case-status-updates.dal.ts | |
| +++ b/apps/services-ms/src/case-status-updates/dal/case-status-updates.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { CaseStatusUpdate, CaseStatusUpdateDocument } from './schemas/case-status-updates.schema'; | |
| import { | |
| CaseStatusUpdateDto, | |
| @@ -9,7 +9,6 @@ import { | |
| ListRequestCaseStatusUpdatesDto, | |
| } from '@vinny/services-types'; | |
| import { SortOrder } from '@vinny/pagination'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class CaseStatusUpdatesDal { | |
| @@ -85,7 +84,7 @@ export class CaseStatusUpdatesDal { | |
| async findLastInformedForCaseIds(caseIds: string[]): Promise<Record<string, Date>> { | |
| const results = await this.caseStatusUpdateModel.aggregate([ | |
| - { $match: { caseId: { $in: caseIds.map((id) => objectId(id)) } } }, | |
| + { $match: { caseId: { $in: caseIds.map((id) => Types.ObjectId(id)) } } }, | |
| { $sort: { createdAt: -1 } }, | |
| { | |
| $group: { | |
| @@ -111,7 +110,7 @@ export class CaseStatusUpdatesDal { | |
| const snoozeThreshold = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000); | |
| const result = await this.caseStatusUpdateModel.aggregate([ | |
| - { $match: { caseId: { $in: caseIds.map((id) => objectId(id)) } } }, | |
| + { $match: { caseId: { $in: caseIds.map((id) => Types.ObjectId(id)) } } }, | |
| { $sort: { createdAt: -1 } }, | |
| { | |
| $group: { | |
| diff --git a/apps/services-ms/src/case-status-updates/dal/schemas/case-status-updates.schema.ts b/apps/services-ms/src/case-status-updates/dal/schemas/case-status-updates.schema.ts | |
| index 57e3f7a86..c33c98ab1 100644 | |
| --- a/apps/services-ms/src/case-status-updates/dal/schemas/case-status-updates.schema.ts | |
| +++ b/apps/services-ms/src/case-status-updates/dal/schemas/case-status-updates.schema.ts | |
| @@ -1,11 +1,11 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| import { | |
| CaseStatusUpdateSource, | |
| CaseStatusUpdateTypes, | |
| WaitingForEnum, | |
| } from '@vinny/services-types'; | |
| -import { Types } from 'mongoose'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ | |
| _id: true, | |
| @@ -17,32 +17,33 @@ export class CaseStatusUpdate { | |
| _id: Types.ObjectId; | |
| id: string; | |
| - @Prop({ enum: Object.values(CaseStatusUpdateSource), type: String, required: false }) | |
| + @Prop({ type: CaseStatusUpdateSource, isEnum: true }) | |
| source?: CaseStatusUpdateSource; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + set: (value: string) => Types.ObjectId(value), | |
| + index: true, | |
| + }) | |
| caseId: string; | |
| @Prop({ required: true }) | |
| content: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - createdBy: string; | |
| - | |
| @Prop({ | |
| required: true, | |
| - enum: Object.values(WaitingForEnum), | |
| - type: String, | |
| - default: WaitingForEnum.UNASSIGNED, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + set: (value: string) => Types.ObjectId(value), | |
| }) | |
| + createdBy: string; | |
| + | |
| + @Prop({ required: true, type: WaitingForEnum, default: WaitingForEnum.UNASSIGNED }) | |
| waitingFor: WaitingForEnum; | |
| - @Prop({ | |
| - required: true, | |
| - enum: Object.values(CaseStatusUpdateTypes), | |
| - type: String, | |
| - default: CaseStatusUpdateTypes.GENERAL, | |
| - }) | |
| + @Prop({ required: true, type: CaseStatusUpdateTypes, default: CaseStatusUpdateTypes.GENERAL }) | |
| type: CaseStatusUpdateTypes; | |
| @Prop({ type: Date, default: Date.now }) | |
| diff --git a/apps/services-ms/src/case-updates/dal/case-updates.dal.ts b/apps/services-ms/src/case-updates/dal/case-updates.dal.ts | |
| index 39643cf32..67bfca164 100644 | |
| --- a/apps/services-ms/src/case-updates/dal/case-updates.dal.ts | |
| +++ b/apps/services-ms/src/case-updates/dal/case-updates.dal.ts | |
| @@ -1,9 +1,8 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { FilterQuery, Model } from 'mongoose'; | |
| +import { FilterQuery, Model, Types } from 'mongoose'; | |
| import { CaseUpdate, CaseUpdateDocument } from './schemas/case-updates.schema'; | |
| import { CaseUpdateFilter, CreateCaseUpdateRequest, CaseUpdateDto } from '@vinny/services-types'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class CaseUpdatesDal { | |
| @@ -14,7 +13,7 @@ export class CaseUpdatesDal { | |
| filter: CaseUpdateFilter, | |
| ): FilterQuery<CaseUpdateDocument> { | |
| return { | |
| - caseId, | |
| + caseId: Types.ObjectId(caseId), | |
| ...(filter.sources && { source: { $in: filter.sources } }), | |
| }; | |
| } | |
| @@ -45,7 +44,7 @@ export class CaseUpdatesDal { | |
| const results = await this.caseUpdatesModel.aggregate([ | |
| { | |
| $match: { | |
| - caseId: { $in: caseIds.map((id) => objectId(id)) }, | |
| + caseId: { $in: caseIds.map((id) => Types.ObjectId(id)) }, | |
| $or: [ | |
| { title: 'You sent a case update to client' }, | |
| { title: 'A case update was sent to client' }, | |
| diff --git a/apps/services-ms/src/case-updates/dal/schemas/case-updates.schema.ts b/apps/services-ms/src/case-updates/dal/schemas/case-updates.schema.ts | |
| index 9a0d6396b..c1fd9c986 100644 | |
| --- a/apps/services-ms/src/case-updates/dal/schemas/case-updates.schema.ts | |
| +++ b/apps/services-ms/src/case-updates/dal/schemas/case-updates.schema.ts | |
| @@ -1,7 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { CaseUpdateSources } from '@vinny/services-types'; | |
| -import { Document, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ _id: false, id: false }) | |
| export class CaseUpdateSharingOptions { | |
| @@ -22,10 +21,10 @@ export class CaseUpdate { | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| - caseId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId, index: true }) | |
| + caseId: Types.ObjectId; | |
| - @Prop({ required: true, enum: Object.values(CaseUpdateSources), type: String }) | |
| + @Prop({ required: true, enum: CaseUpdateSources, type: String }) | |
| source: CaseUpdateSources; | |
| @Prop({ required: true }) | |
| @@ -37,8 +36,8 @@ export class CaseUpdate { | |
| @Prop({ type: CaseUpdateSharingOptions }) | |
| sharingOptions?: CaseUpdateSharingOptions; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - createdByUserId?: string; | |
| + @Prop({ type: SchemaTypes.ObjectId }) | |
| + createdByUserId?: Types.ObjectId; | |
| @Prop() | |
| createdByName?: string; | |
| diff --git a/apps/services-ms/src/cases/cases.service.ts b/apps/services-ms/src/cases/cases.service.ts | |
| index b0791cd73..2743c303b 100644 | |
| --- a/apps/services-ms/src/cases/cases.service.ts | |
| +++ b/apps/services-ms/src/cases/cases.service.ts | |
| @@ -30,7 +30,7 @@ import { | |
| } from '@vinny/services-types'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { Address, MemberRole, TeamType, UserType } from '@vinny/users-types'; | |
| -import { objectStringId, objectId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { AdministrationService } from '../administration/administration.service'; | |
| import { LawmaticsMsClient } from '../clients/lawmatics-ms-client/lawmatics-ms.client'; | |
| import { CasesDal } from './dal/cases.dal'; | |
| @@ -362,7 +362,7 @@ export class CasesService implements OnApplicationBootstrap { | |
| } = request; | |
| let returnedCaseResult: CaseDto | null = null; | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| const { user, practiceArea } = await this.validateUserAndPracticeArea(practiceAreaId, userId); | |
| const status = request?.status || CaseStatus.ACCEPTED; | |
| @@ -452,7 +452,7 @@ export class CasesService implements OnApplicationBootstrap { | |
| if (payload.submittedQuestionnaire) { | |
| await this.handleQuestionnaireSubmittedAndUpdate( | |
| currentCase.id, | |
| - currentCase.userId, | |
| + currentCase.userId.toString(), | |
| payload.submittedQuestionnaire, | |
| ); | |
| } | |
| @@ -466,8 +466,8 @@ export class CasesService implements OnApplicationBootstrap { | |
| returnedCaseResult = convertToCaseDto(updatedCaseDocument || currentCase, updatedCase); | |
| } else { | |
| const { user, practiceArea } = await this.validateUserAndPracticeArea( | |
| - currentCase?.practiceAreaId, | |
| - currentCase?.userId, | |
| + currentCase?.practiceAreaId.toString(), | |
| + currentCase?.userId.toString(), | |
| ); | |
| if (!practiceArea) { | |
| @@ -685,7 +685,7 @@ export class CasesService implements OnApplicationBootstrap { | |
| const theCase = await this.casesDal.getCaseById(caseId); | |
| hardDelete && theCase?.isExtendedByLawmatics && (await this.lawmaticsClient.deleteCase(caseId)); | |
| const result = hardDelete | |
| - ? await this.casesDal.delete({ _id: objectId(caseId) }) | |
| + ? await this.casesDal.delete({ _id: Types.ObjectId(caseId) }) | |
| : await this.casesDal.softDelete(caseId); | |
| if (!result) { | |
| @@ -744,7 +744,7 @@ export class CasesService implements OnApplicationBootstrap { | |
| throw new InternalServerErrorException(`failed to update case, id : ${theCase.id}`); | |
| } | |
| const practiceArea = await this.administrationService.getPracticeAreaById( | |
| - theCase.practiceAreaId, | |
| + theCase.practiceAreaId.toString(), | |
| ); | |
| const isDbServiceUpdatedInLast24Hours = caseServices.some( | |
| @@ -766,7 +766,7 @@ export class CasesService implements OnApplicationBootstrap { | |
| theCase: CaseDto | CaseContainer, | |
| caseServices: ServiceDto[], | |
| ): Promise<void> { | |
| - const { marbleId } = await this.usersClient.getUserById(theCase.userId); | |
| + const { marbleId } = await this.usersClient.getUserById(theCase.userId.toString()); | |
| const completedServiceTypeIds = caseServices | |
| ?.filter(({ status }) => status === ServiceStatus.COMPLETED) | |
| .map((service) => service.serviceTypeId); | |
| @@ -1162,7 +1162,7 @@ export class CasesService implements OnApplicationBootstrap { | |
| if (caseToClone?.status !== CaseStatus.REJECTED) { | |
| throw new BadRequestException('Case is not rejected'); | |
| } | |
| - if (caseToClone?.userId !== userId) { | |
| + if (caseToClone?.userId.toString() !== userId) { | |
| throw new UnauthorizedException('User is not authorized to clone this case'); | |
| } | |
| } | |
| diff --git a/apps/services-ms/src/cases/dal/cases.dal.ts b/apps/services-ms/src/cases/dal/cases.dal.ts | |
| index 40f837e40..60b4d6d38 100644 | |
| --- a/apps/services-ms/src/cases/dal/cases.dal.ts | |
| +++ b/apps/services-ms/src/cases/dal/cases.dal.ts | |
| @@ -12,7 +12,6 @@ import { CaseContainer as Case, CaseDocument, IntroCall } from '../schemas/cases | |
| import { pickBy, pick } from 'lodash'; | |
| import { FindCasesFilter } from './types'; | |
| import { SortOrder } from '@vinny/pagination'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class CasesDal { | |
| @@ -39,9 +38,9 @@ export class CasesDal { | |
| lssNotes, | |
| } = createCaseRequest; | |
| const caseInput = { | |
| - _id: objectId(caseId ?? objectStringId()), | |
| - userId: userId, | |
| - practiceAreaId: practiceAreaId, | |
| + _id: (caseId && Types.ObjectId(caseId)) ?? Types.ObjectId(), | |
| + userId: Types.ObjectId(userId), | |
| + practiceAreaId: Types.ObjectId(practiceAreaId), | |
| status: status && status, | |
| strategyReviewCallComplete: strategyReviewCallComplete && strategyReviewCallComplete, | |
| strategyReviewCallCompleteDate: | |
| @@ -53,7 +52,7 @@ export class CasesDal { | |
| additionalFields: additionalFields && additionalFields, | |
| lssNotes: lssNotes && lssNotes, | |
| subStatus: subStatus && subStatus, | |
| - } satisfies Partial<Case>; | |
| + }; | |
| const cleanedObject = this.cleanUndefined(caseInput); | |
| return this.caseModel.create(cleanedObject); | |
| } | |
| @@ -91,7 +90,7 @@ export class CasesDal { | |
| : undefined; | |
| const caseInput = { | |
| - _id: objectId(caseId ?? objectStringId()), | |
| + _id: (caseId && Types.ObjectId(caseId)) ?? Types.ObjectId(), | |
| ...filteredUpdateRequest, | |
| isExtendedByLawmatics: isExtendedByLawmatics && isExtendedByLawmatics, | |
| isCaseStarted, | |
| @@ -101,7 +100,7 @@ export class CasesDal { | |
| }; | |
| const cleanedObject = this.cleanUndefined(caseInput); | |
| - return this.caseModel.findOneAndUpdate({ _id: objectId(caseId) }, cleanedObject, { | |
| + return this.caseModel.findOneAndUpdate({ _id: Types.ObjectId(caseId) }, cleanedObject, { | |
| new: returnUpdatedObject, | |
| runValidators: true, | |
| }); | |
| @@ -122,7 +121,7 @@ export class CasesDal { | |
| } | |
| async getCaseById(id: string): Promise<Case | null> { | |
| - return this.caseModel.findOne({ _id: objectId(id) }); | |
| + return this.caseModel.findOne({ _id: Types.ObjectId(id) }); | |
| } | |
| private buildFilter(filter: FindCasesFilter): { | |
| @@ -166,9 +165,9 @@ export class CasesDal { | |
| // Prepare the filter query | |
| const query: FilterQuery<CaseDocument> = { | |
| - ...(filter.caseIds && { _id: { $in: filter.caseIds.map(objectId) } }), | |
| - ...(filter.userId && { userId: filter.userId }), | |
| - ...(filter.practiceAreaId && { practiceAreaId: filter.practiceAreaId }), | |
| + ...(filter.caseIds && { _id: { $in: filter.caseIds.map((id) => Types.ObjectId(id)) } }), | |
| + ...(filter.userId && { userId: Types.ObjectId(filter.userId) }), | |
| + ...(filter.practiceAreaId && { practiceAreaId: Types.ObjectId(filter.practiceAreaId) }), | |
| ...statusFilter, | |
| ...((filter.fromDate || filter.toDate) && dateFilter), | |
| ...(filter.opposingParty && { opposingParty: filter.opposingParty }), | |
| @@ -196,7 +195,7 @@ export class CasesDal { | |
| async removeLawmaticsCaseDataFromDb(id: string): Promise<Case | null> { | |
| return this.caseModel.findOneAndUpdate( | |
| - { _id: objectId(id) }, | |
| + { _id: Types.ObjectId(id) }, | |
| { | |
| $unset: { | |
| strategyReviewCallComplete: 1, | |
| @@ -215,7 +214,10 @@ export class CasesDal { | |
| } | |
| async softDelete(id: string): Promise<Case | null> { | |
| - return await this.caseModel.findOneAndUpdate({ _id: objectId(id) }, { removedAt: new Date() }); | |
| + return await this.caseModel.findOneAndUpdate( | |
| + { _id: Types.ObjectId(id) }, | |
| + { removedAt: new Date() }, | |
| + ); | |
| } | |
| private cleanUndefined(caseInput: { | |
| diff --git a/apps/services-ms/src/cases/schemas/cases.schema.ts b/apps/services-ms/src/cases/schemas/cases.schema.ts | |
| index 1c7afe4c1..6fe801536 100644 | |
| --- a/apps/services-ms/src/cases/schemas/cases.schema.ts | |
| +++ b/apps/services-ms/src/cases/schemas/cases.schema.ts | |
| @@ -3,7 +3,6 @@ import { CaseStatus, CaseSubStatus, CourtAppearance, Gender } from '@vinny/servi | |
| import { Document, SchemaTypes, Types } from 'mongoose'; | |
| import { transformBoolean } from '@vinny/transformers'; | |
| import { Transform } from 'class-transformer'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| @Schema({ _id: false }) | |
| export class LssNotes { | |
| @@ -59,26 +58,26 @@ export class IntroCall { | |
| unresponsiveClient?: boolean; | |
| } | |
| -@Schema({ timestamps: true, autoIndex: true, toObject: { getters: true } }) | |
| +@Schema({ timestamps: true, autoIndex: true }) | |
| export class CaseContainer { | |
| @Prop({ required: true }) | |
| _id: Types.ObjectId; | |
| id: string; | |
| - @Prop(objectIdPropHandler({ index: true })) | |
| - userId: string; | |
| + @Prop({ required: true, type: Types.ObjectId, index: true }) | |
| + userId: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - practiceAreaId: string; | |
| + @Prop({ required: true, type: Types.ObjectId }) | |
| + practiceAreaId: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ index: true })) | |
| - previousCaseId?: string; | |
| + @Prop({ type: Types.ObjectId, index: true }) | |
| + previousCaseId?: Types.ObjectId; | |
| - @Prop({ required: true, enum: Object.values(CaseStatus), type: String }) | |
| + @Prop({ required: true, enum: CaseStatus, type: String }) | |
| status: CaseStatus; | |
| - @Prop({ enum: Object.values(CaseSubStatus), type: String }) | |
| + @Prop({ enum: CaseSubStatus, type: String }) | |
| subStatus?: CaseSubStatus; | |
| @Prop({ type: Boolean }) | |
| diff --git a/apps/services-ms/src/cases/test/cases.service.spec.ts b/apps/services-ms/src/cases/test/cases.service.spec.ts | |
| index 6a5286384..6ed69aff7 100644 | |
| --- a/apps/services-ms/src/cases/test/cases.service.spec.ts | |
| +++ b/apps/services-ms/src/cases/test/cases.service.spec.ts | |
| @@ -10,6 +10,7 @@ import { generateCaseContainer, mockLssEvent } from './consts'; | |
| import { EventType } from '@vinny/events-types'; | |
| import { convertToCaseDto } from '../utils'; | |
| import { InternalServerErrorException, NotFoundException } from '@nestjs/common'; | |
| +import mongoose from 'mongoose'; | |
| import { ServiceModule } from '../../services/services.module'; | |
| const ENV_VARS: Record<string, string> = { | |
| @@ -83,7 +84,7 @@ describe('CasesService', () => { | |
| const newCase = generateCaseContainer(payload.userId, CaseStatus.PENDING, oldCase.id); | |
| const expectedCase = convertToCaseDto({ | |
| ...newCase, | |
| - previousCaseId: oldCase.id, | |
| + previousCaseId: new mongoose.Types.ObjectId(oldCase.id), | |
| }); | |
| jest.spyOn(casesDal, 'getCaseById').mockResolvedValueOnce(oldCase); | |
| @@ -98,7 +99,7 @@ describe('CasesService', () => { | |
| }); | |
| jest.spyOn(casesDal, 'updateCase').mockResolvedValueOnce({ | |
| ...newCase, | |
| - previousCaseId: oldCase.id, | |
| + previousCaseId: new mongoose.Types.ObjectId(oldCase.id), | |
| }); | |
| const updateEvent = eventsMsNock | |
| .patch(`/events/${mockLssEvent.id}`) | |
| diff --git a/apps/services-ms/src/cases/test/consts.ts b/apps/services-ms/src/cases/test/consts.ts | |
| index f9243e80e..da5ea942c 100644 | |
| --- a/apps/services-ms/src/cases/test/consts.ts | |
| +++ b/apps/services-ms/src/cases/test/consts.ts | |
| @@ -1,8 +1,8 @@ | |
| import faker from '@faker-js/faker'; | |
| import { EventType, LssEventDto, LssStatus } from '@vinny/events-types'; | |
| +import mongoose from 'mongoose'; | |
| import { CaseStatus } from '@vinny/services-types'; | |
| import { CaseContainer } from '../schemas/cases.schema'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| export const generateCaseContainer = ( | |
| userId: string, | |
| @@ -10,11 +10,11 @@ export const generateCaseContainer = ( | |
| previousCaseId?: string, | |
| ): CaseContainer => { | |
| return { | |
| - _id: objectId(objectStringId()), | |
| + _id: new mongoose.Types.ObjectId(), | |
| id: faker.database.mongodbObjectId().toString(), | |
| - practiceAreaId: objectStringId(), | |
| - userId: userId, | |
| - previousCaseId: previousCaseId, | |
| + practiceAreaId: new mongoose.Types.ObjectId(), | |
| + userId: new mongoose.Types.ObjectId(userId), | |
| + previousCaseId: previousCaseId ? new mongoose.Types.ObjectId(previousCaseId) : undefined, | |
| status: caseStatus, | |
| isExtendedByLawmatics: false, | |
| createdAt: new Date(), | |
| diff --git a/apps/services-ms/src/cases/test/utils.ts b/apps/services-ms/src/cases/test/utils.ts | |
| index 9207e87ca..33604bbfb 100644 | |
| --- a/apps/services-ms/src/cases/test/utils.ts | |
| +++ b/apps/services-ms/src/cases/test/utils.ts | |
| @@ -17,7 +17,7 @@ import { | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { AttorneyStatus, User } from '@vinny/users-types'; | |
| import { Role } from '@vinny/auth-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { TaskStatus } from '@vinny/scheduler-types'; | |
| import { NO_CONTACT_BUFFER } from '../consts'; | |
| import { DateTime } from 'luxon'; | |
| @@ -42,11 +42,11 @@ export const familyPracticeArea = { | |
| export const marbleId = 'M@RB13'; | |
| export const caseStartDate = new Date().toISOString(); | |
| -export const userId = objectStringId(); | |
| +export const userId = Types.ObjectId().toString(); | |
| export const generateMockAttorney = (practiceAreaId: string) => { | |
| return { | |
| - id: objectStringId(), | |
| - marbleId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + marbleId: Types.ObjectId().toString(), | |
| attorneyData: { | |
| practiceAreas: [ | |
| { | |
| @@ -60,14 +60,14 @@ export const generateMockAttorney = (practiceAreaId: string) => { | |
| export const getTestUser = (id?: string, marbleId?: string): User => { | |
| return { | |
| - id: id || objectStringId(), | |
| + id: id || Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: `myemail+${faker.datatype.uuid()}@themis-tech.io`, | |
| phone: faker.phone.phoneNumber('+972543######'), | |
| - marbleId: marbleId || objectStringId(), | |
| + marbleId: marbleId || Types.ObjectId().toString(), | |
| roles: [Role.CUSTOMER], | |
| }; | |
| }; | |
| @@ -168,9 +168,9 @@ export const getMockLssNotes = (): CreateLssNotesPayload => { | |
| }; | |
| export const CreateServiceResponseObjectMock = (status?: ServiceStatus): ServiceResponseObject => ({ | |
| - id: objectStringId(), | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| location: { | |
| state: 'some state', | |
| }, | |
| @@ -215,45 +215,45 @@ export const serviceType = { | |
| }; | |
| export const TestAttorney: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: `myemail+${faker.datatype.uuid()}@themis-tech.io`, | |
| phone: faker.phone.phoneNumber('+972543######'), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| export const TestAttorney2: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: `myemail+${faker.datatype.uuid()}@themis-tech.io`, | |
| phone: faker.phone.phoneNumber('+972543######'), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| export const TestUser: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: `myemail+${faker.datatype.uuid()}@themis-tech.io`, | |
| phone: faker.phone.phoneNumber('+972543######'), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.CUSTOMER], | |
| }; | |
| export const CaseConfiguration = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| lawmaticsId: faker.datatype.string(), | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId().toString(), | |
| value: faker.datatype.string(), | |
| firstStageId: null, | |
| type: ConfigurationType.CASE, | |
| @@ -263,10 +263,10 @@ const createdAtDate = new Date(); | |
| export const MockCaseServices = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId: CaseConfiguration.internalId, | |
| userId: TestAttorney.id, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| description: faker.datatype.string(), | |
| status: ServiceStatus.PENDING, | |
| @@ -282,10 +282,10 @@ export const MockCaseServices = [ | |
| export const MockCaseServices2 = [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId: CaseConfiguration.internalId, | |
| userId: userId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| description: faker.datatype.string(), | |
| status: ServiceStatus.PENDING, | |
| @@ -298,10 +298,10 @@ export const MockCaseServices2 = [ | |
| ], | |
| }, | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId: CaseConfiguration.internalId, | |
| userId: userId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| description: faker.datatype.string(), | |
| status: ServiceStatus.PENDING, | |
| @@ -317,9 +317,9 @@ export const MockCaseServices2 = [ | |
| export const getMockCase = (userId?: string, submittedQuestionnaire?: Date | undefined) => { | |
| return { | |
| - id: objectStringId(), | |
| - userId: userId || objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + userId: userId || Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| strategyReviewCallComplete: faker.datatype.boolean(), | |
| opposingParty: faker.datatype.string(), | |
| additionalFields: {}, | |
| @@ -344,18 +344,18 @@ export const getMockDelayedTask = ( | |
| }; | |
| }; | |
| export const MockDelayedTaskResponse = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| status: TaskStatus.SCHEDULED, | |
| }; | |
| // CaseNotificationService section | |
| -export const expectedAttorneyId = objectStringId(); | |
| +export const expectedAttorneyId = Types.ObjectId().toString(); | |
| -const mockCaseId = objectStringId(); | |
| +const mockCaseId = Types.ObjectId().toString(); | |
| export const mockClient = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'Ragner', | |
| last: 'Lutbrok', | |
| @@ -363,7 +363,7 @@ export const mockClient = { | |
| }; | |
| export const mockShouldSendPushCase = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId: 'user123', | |
| lastContactDate: new Date( | |
| DateTime.now() | |
| @@ -375,7 +375,7 @@ export const mockShouldSendPushCase = { | |
| }; | |
| export const mockShouldNotSendPushCase = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId: 'user123', | |
| lastContactDate: new Date( | |
| DateTime.now() | |
| @@ -437,8 +437,8 @@ export const mockCase: CaseDto = { | |
| createdAt: new Date(), | |
| }; | |
| -export const serviceTypeId = objectStringId(); | |
| -export const serviceTypeId_2 = objectStringId(); | |
| +export const serviceTypeId = Types.ObjectId().toString(); | |
| +export const serviceTypeId_2 = Types.ObjectId().toString(); | |
| export const mockServiceCatalogResponse: ServiceType = { | |
| modifierId: 'E2E-GENERATED-9de5aa15-1dcf-4312-a77b-4ac46255563a', | |
| @@ -522,13 +522,13 @@ export const DAY_TIME_IN_MILLISECONDS = 24 * 60 * 60 * 1000; | |
| export const getServicesByCaseId = (caseId: string): ServiceDto[] => [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId, | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| name: faker.lorem.words(), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| { | |
| userId: faker.database.mongodbObjectId(), | |
| @@ -541,13 +541,13 @@ export const getServicesByCaseId = (caseId: string): ServiceDto[] => [ | |
| updatedAt: faker.date.past(), | |
| }, | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| caseId, | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| name: faker.lorem.words(), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| legalTeam: [ | |
| { | |
| userId: faker.database.mongodbObjectId(), | |
| @@ -561,8 +561,8 @@ export const getServicesByCaseId = (caseId: string): ServiceDto[] => [ | |
| }, | |
| ]; | |
| -const attorneyId1 = objectStringId(); | |
| -const attorneyId2 = objectStringId(); | |
| +const attorneyId1 = Types.ObjectId().toString(); | |
| +const attorneyId2 = Types.ObjectId().toString(); | |
| export const introCallsMock = { | |
| [attorneyId1]: { | |
| unresponsiveClient: true, | |
| diff --git a/apps/services-ms/src/cases/utils.ts b/apps/services-ms/src/cases/utils.ts | |
| index 102dff51e..6da82e63c 100644 | |
| --- a/apps/services-ms/src/cases/utils.ts | |
| +++ b/apps/services-ms/src/cases/utils.ts | |
| @@ -80,10 +80,10 @@ export const convertToCaseDto = ( | |
| return { | |
| introCalls: caseResult.introCalls, | |
| id: caseResult.id.toString(), | |
| - practiceAreaId: caseResult.practiceAreaId, | |
| + practiceAreaId: caseResult.practiceAreaId.toString(), | |
| createdAt: caseFromLawmatics?.createdAt || caseResult.createdAt, | |
| - userId: caseResult.userId, | |
| - previousCaseId: caseResult.previousCaseId, | |
| + userId: caseResult.userId.toString(), | |
| + previousCaseId: caseResult.previousCaseId?.toString(), | |
| status: caseResult.status, | |
| submittedQuestionnaire: caseResult.submittedQuestionnaire, | |
| lastActivityDate: | |
| diff --git a/apps/services-ms/src/controllers/cases.controller.ts b/apps/services-ms/src/controllers/cases.controller.ts | |
| index 55a47497c..6c40b969f 100644 | |
| --- a/apps/services-ms/src/controllers/cases.controller.ts | |
| +++ b/apps/services-ms/src/controllers/cases.controller.ts | |
| @@ -41,6 +41,7 @@ import { | |
| UpdateEventRequest, | |
| } from '@vinny/services-types'; | |
| import { getLoggingInterceptor } from '@vinny/logger'; | |
| +import { Types } from 'mongoose'; | |
| import { EventsService } from '../events/events.service'; | |
| import { LegalCortexService } from '../legal-cortex/legal-cortex.service'; | |
| import { IDEMPOTENCY_KEY_HEADER, IdempotencyInterceptor } from '@vinny/idempotency'; | |
| @@ -62,7 +63,6 @@ import { CaseNotificationsService } from '../cases/case-notifications.service'; | |
| import { DelegateDto } from '@vinny/delegate-types'; | |
| import { CaseStatusUpdatesService } from '../case-status-updates/case-status-updates.service'; | |
| import { ServiceCatalogClientService } from '@vinny/catalog-client'; | |
| -import { isObjectId } from '@vinny/helpers'; | |
| @Controller('/cases') | |
| @ApiTags('services') | |
| @@ -215,7 +215,7 @@ export class CasesController { | |
| @Param('id') caseId: string, | |
| @Body() payload: CreateCaseNoteRequest, | |
| ): Promise<CaseNoteDto> { | |
| - if (!isObjectId(caseId)) { | |
| + if (!Types.ObjectId.isValid(caseId)) { | |
| throw new BadRequestException(`CaseId must be mongo ObjectId: ${caseId}`); | |
| } | |
| return this.caseNotesService.createCaseNote({ caseId, ...payload }); | |
| @@ -400,7 +400,7 @@ export class CasesController { | |
| @Param('id') caseId: string, | |
| @Query() filter?: GetCaseEventsFilterDto, | |
| ): Promise<EventResponse[]> { | |
| - if (!isObjectId(caseId)) { | |
| + if (!Types.ObjectId.isValid(caseId)) { | |
| throw new BadRequestException(`CaseId must be mongo ObjectId: ${caseId}`); | |
| } | |
| return this.eventsService.getCaseEvents(caseId, filter); | |
| @@ -425,7 +425,7 @@ export class CasesController { | |
| @Param('id') caseId: string, | |
| @Body() payload: CreateCaseStatusUpdateDto, | |
| ): Promise<CaseStatusUpdateDto> { | |
| - if (!isObjectId(caseId)) { | |
| + if (!Types.ObjectId.isValid(caseId)) { | |
| throw new BadRequestException(`CaseId must be mongo ObjectId: ${caseId}`); | |
| } | |
| return await this.caseStatusUpdatesService.create(caseId, payload); | |
| @@ -441,7 +441,7 @@ export class CasesController { | |
| @Param('id') caseId: string, | |
| @Body() payload: CreateCaseStatusUpdateDto[], | |
| ): Promise<CaseStatusUpdateDto[]> { | |
| - if (!isObjectId(caseId)) { | |
| + if (!Types.ObjectId.isValid(caseId)) { | |
| throw new BadRequestException(`CaseId must be mongo ObjectId: ${caseId}`); | |
| } | |
| return await this.caseStatusUpdatesService.createManyOfCase(caseId, payload); | |
| diff --git a/apps/services-ms/src/controllers/tests/administration.controller.spec.ts b/apps/services-ms/src/controllers/tests/administration.controller.spec.ts | |
| index 496e86e8a..fc4070fa7 100644 | |
| --- a/apps/services-ms/src/controllers/tests/administration.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/administration.controller.spec.ts | |
| @@ -2,7 +2,7 @@ import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { InternalServerErrorException, NotFoundException } from '@nestjs/common'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { LawmaticsMsClient } from '../../clients/lawmatics-ms-client/lawmatics-ms.client'; | |
| import { CreatePracticeAreaRequest } from '@vinny/services-types'; | |
| import { | |
| @@ -15,7 +15,6 @@ import { getLawmaticsMsClient } from '../../services/test/mock-generator'; | |
| import { ControllersModule } from '../controllers.module'; | |
| import { IdempotencyService } from '@vinny/idempotency'; | |
| import { MockIdempotencyService } from '@vinny/idempotency-test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('AdministrationController', () => { | |
| let administrationController: AdministrationController; | |
| @@ -122,7 +121,9 @@ describe('AdministrationController', () => { | |
| }); | |
| it("should return null when practice area doesn't exist", async () => { | |
| - const practiceArea = await administrationController.getPracticeAreaById(objectStringId()); | |
| + const practiceArea = await administrationController.getPracticeAreaById( | |
| + Types.ObjectId().toString(), | |
| + ); | |
| expect(practiceArea).toBeNull(); | |
| }); | |
| }); | |
| diff --git a/apps/services-ms/src/controllers/tests/case-notes.controller.spec.ts b/apps/services-ms/src/controllers/tests/case-notes.controller.spec.ts | |
| index 5df7f71aa..5a5bdd7be 100644 | |
| --- a/apps/services-ms/src/controllers/tests/case-notes.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/case-notes.controller.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { CreateCaseNoteRequest } from '@vinny/services-types'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { CasesDal } from '../../cases/dal/cases.dal'; | |
| import { CasesController } from '../cases.controller'; | |
| @@ -10,7 +10,6 @@ import { Test } from '@nestjs/testing'; | |
| import { IdempotencyService } from '@vinny/idempotency'; | |
| import { MockIdempotencyService } from '@vinny/idempotency-test-utils'; | |
| import { ControllersModule } from '../controllers.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('CasesController', () => { | |
| let casesController: CasesController, connection: Connection, casesDal: CasesDal; | |
| @@ -42,7 +41,7 @@ describe('CasesController', () => { | |
| describe('createCaseNote', () => { | |
| it('should create a service note', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| const payload: CreateCaseNoteRequest = { | |
| name: 'NAME', | |
| body: 'DESC', | |
| @@ -64,7 +63,7 @@ describe('CasesController', () => { | |
| }); | |
| it('should fail to create an note on lawmatics ms', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| const payload: CreateCaseNoteRequest = { | |
| name: 'NAME', | |
| body: 'BODY', | |
| diff --git a/apps/services-ms/src/controllers/tests/cases.controller.spec.ts b/apps/services-ms/src/controllers/tests/cases.controller.spec.ts | |
| index 05f706b05..17edd9dba 100644 | |
| --- a/apps/services-ms/src/controllers/tests/cases.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/cases.controller.spec.ts | |
| @@ -14,7 +14,7 @@ import { CaseDto, CreateCaseRequest, Gender, CaseStatus } from '@vinny/services- | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { User } from '@vinny/users-types'; | |
| import _ from 'lodash'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { | |
| PracticeArea, | |
| @@ -57,7 +57,6 @@ import { mockEnvVars } from './utils'; | |
| import request from 'supertest'; | |
| import { FeedbackType } from '@vinny/legal-cortex-types'; | |
| import { serviceTypeCatalog } from './consts'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| const lawmaticsMsNock = nock(mockEnvVars.LAWMATICS_MS_URL); | |
| const servicesCatalogMsNock = nock(mockEnvVars.CATALOG_MS_URL); | |
| @@ -136,7 +135,7 @@ describe('cases controller', () => { | |
| it('should successfully create PENDING case', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request: CreateCaseRequest = { | |
| @@ -172,7 +171,7 @@ describe('cases controller', () => { | |
| it('should successfully create ACCEPTED case', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request = { | |
| @@ -201,7 +200,7 @@ describe('cases controller', () => { | |
| ), | |
| ) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...request, | |
| }); | |
| @@ -220,7 +219,7 @@ describe('cases controller', () => { | |
| it('should successfully create case with additional fields and status ACCEPTED', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request = { | |
| @@ -249,7 +248,7 @@ describe('cases controller', () => { | |
| ), | |
| ) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...request, | |
| }); | |
| @@ -263,7 +262,7 @@ describe('cases controller', () => { | |
| it('should successfully create case with lssNotes and status ACCEPTED', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request = { | |
| practiceAreaId: practiceArea.id, | |
| @@ -322,7 +321,7 @@ describe('cases controller', () => { | |
| it('should successfully create case with lssNotes from db and after status updated to ACCEPTED', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const requestLssNotes = getMockLssNotes(); | |
| const request = { | |
| @@ -398,7 +397,7 @@ describe('cases controller', () => { | |
| it('should successfully create case with partial lssNotes', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request = { | |
| practiceAreaId: practiceArea.id, | |
| @@ -434,7 +433,7 @@ describe('cases controller', () => { | |
| ), | |
| ) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...createdCaseFromLawmaticsResponse, | |
| }); | |
| @@ -459,8 +458,8 @@ describe('cases controller', () => { | |
| it('should fail to create case - no practice area', async () => { | |
| const request = { | |
| createdAt: new Date(), | |
| - practiceAreaId: objectStringId(), | |
| - userId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| status: CaseStatus.PENDING, | |
| }; | |
| @@ -472,12 +471,12 @@ describe('cases controller', () => { | |
| describe('update case by id', () => { | |
| it('should successfully update case with intro calls', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const paralegalId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const paralegalId = Types.ObjectId().toString(); | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...familyPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createRequest: CreateCaseRequest = { | |
| @@ -497,7 +496,7 @@ describe('cases controller', () => { | |
| const caseId = createdCase.id; | |
| const { id: serviceTypeId } = await serviceTypesDal.createServiceType({ | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| name: 'some name', | |
| }); | |
| @@ -591,12 +590,12 @@ describe('cases controller', () => { | |
| }); | |
| }); | |
| it('should not emit event when introCalls is empty', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const paralegalId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const paralegalId = Types.ObjectId().toString(); | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...familyPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createRequest: CreateCaseRequest = { | |
| @@ -616,7 +615,7 @@ describe('cases controller', () => { | |
| const caseId = createdCase.id; | |
| const { id: serviceTypeId } = await serviceTypesDal.createServiceType({ | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| name: 'some name', | |
| }); | |
| @@ -655,7 +654,7 @@ describe('cases controller', () => { | |
| it('PATCH: :id/introCall-migration', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...familyPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createRequest: CreateCaseRequest = { | |
| @@ -690,12 +689,12 @@ describe('cases controller', () => { | |
| }); | |
| it('should successfully update case with status ACCEPTED and additional fields and assign sub status completed', async () => { | |
| - const attorneyId = objectStringId(); | |
| - const paralegalId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const paralegalId = Types.ObjectId().toString(); | |
| const emitSpy = jest.spyOn(kafkaEventsService, 'emitEvent'); | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...familyPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createRequest: CreateCaseRequest = { | |
| @@ -762,7 +761,7 @@ describe('cases controller', () => { | |
| ), | |
| ) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...createRequest, | |
| additionalFields: { okay: 'boomer', illness: 'case of the mondays' }, | |
| }); | |
| @@ -845,7 +844,7 @@ describe('cases controller', () => { | |
| const emitSpy = jest.spyOn(kafkaEventsService, 'emitEvent'); | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| ...(practiceAreaKey && { key: practiceAreaKey }), | |
| }); | |
| @@ -866,7 +865,7 @@ describe('cases controller', () => { | |
| const caseId = createdCase.id; | |
| const { id: serviceTypeId } = await serviceTypesDal.createServiceType({ | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| name: 'some name', | |
| }); | |
| @@ -921,7 +920,7 @@ describe('cases controller', () => { | |
| ), | |
| ) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...createRequest, | |
| additionalFields: { okay: 'boomer', illness: 'case of the mondays' }, | |
| }); | |
| @@ -939,7 +938,7 @@ describe('cases controller', () => { | |
| it('should successfully update case with status ACCEPTED lssNotes', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createRequest: CreateCaseRequest = { | |
| @@ -982,7 +981,7 @@ describe('cases controller', () => { | |
| ), | |
| ) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...createRequest, | |
| lssNotes: updateRequest.lssNotes, | |
| }); | |
| @@ -1022,7 +1021,7 @@ describe('cases controller', () => { | |
| const spyOnCreateLawmaticsCase = jest.spyOn(lawmaticsMsClient, 'createCase'); | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createRequest = { | |
| @@ -1060,7 +1059,7 @@ describe('cases controller', () => { | |
| it('should not update practiceAreaId and userId', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createRequest = { | |
| @@ -1073,7 +1072,7 @@ describe('cases controller', () => { | |
| const postCasesReq = lawmaticsMsNock | |
| .post(`/cases`, _.matches(getCreateCaseRequest({ user: testUser }))) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...createRequest, | |
| }); | |
| @@ -1087,7 +1086,7 @@ describe('cases controller', () => { | |
| ); | |
| const familyPractice = await practiceAreaModel.create({ | |
| ...familyPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const otherTestUser = getTestUser(); | |
| @@ -1124,7 +1123,7 @@ describe('cases controller', () => { | |
| it('should get services by case id', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const serviceResponseObject1 = CreateServiceResponseObjectMock(); | |
| const serviceResponseObject2 = CreateServiceResponseObjectMock(); | |
| @@ -1149,8 +1148,8 @@ describe('cases controller', () => { | |
| .reply(200, lawmaticsMsResponse); | |
| const dbService1 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| @@ -1158,8 +1157,8 @@ describe('cases controller', () => { | |
| }); | |
| const dbService2 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| @@ -1182,7 +1181,7 @@ describe('cases controller', () => { | |
| it('should get services by case id for pending case', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createCaseDal: CreateCaseRequest = { | |
| @@ -1196,21 +1195,21 @@ describe('cases controller', () => { | |
| const getCaseServicesReq = lawmaticsMsNock.get(`/cases/${caseId}/services`).reply(200); | |
| const dbService1 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: true, | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }); | |
| const dbService2 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: true, | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }); | |
| const result = await casesController.getCaseServices(caseId, {}); | |
| @@ -1226,7 +1225,7 @@ describe('cases controller', () => { | |
| it('should filter out services returned from lawmatics who do not exists in our db', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createCaseDal: CreateCaseRequest = { | |
| @@ -1257,8 +1256,8 @@ describe('cases controller', () => { | |
| const dbService1 = await servicesDal.createService({ | |
| serviceId: serviceResponseObject1.id?.toString(), | |
| caseId, | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| }); | |
| @@ -1266,8 +1265,8 @@ describe('cases controller', () => { | |
| const dbService2 = await servicesDal.createService({ | |
| serviceId: serviceResponseObject2.id?.toString(), | |
| caseId, | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| }); | |
| @@ -1288,7 +1287,7 @@ describe('cases controller', () => { | |
| it('should return only services with status :open, canceled, disengaged or completed', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createCaseDal: CreateCaseRequest = { | |
| @@ -1310,8 +1309,8 @@ describe('cases controller', () => { | |
| .reply(200, lawmaticsMsResponse); | |
| const dbService1 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| @@ -1319,12 +1318,12 @@ describe('cases controller', () => { | |
| }); | |
| await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: false, | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }); | |
| const result = await casesController.getCaseServices(caseId, { | |
| @@ -1342,7 +1341,7 @@ describe('cases controller', () => { | |
| it('should return only services with status : pending', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createCaseDal: CreateCaseRequest = { | |
| @@ -1364,8 +1363,8 @@ describe('cases controller', () => { | |
| .reply(200, lawmaticsMsResponse); | |
| await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| @@ -1373,12 +1372,12 @@ describe('cases controller', () => { | |
| }); | |
| const dbService2 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: false, | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }); | |
| const result = await casesController.getCaseServices(caseId, { | |
| @@ -1396,7 +1395,7 @@ describe('cases controller', () => { | |
| it('should return only services with status : pending, completed', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const createCaseDal: CreateCaseRequest = { | |
| @@ -1418,8 +1417,8 @@ describe('cases controller', () => { | |
| .reply(200, lawmaticsMsResponse); | |
| const dbService1 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.COMPLETED, | |
| isExtendedByLawmatics: true, | |
| @@ -1427,12 +1426,12 @@ describe('cases controller', () => { | |
| }); | |
| const dbService2 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: false, | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }); | |
| const result = await casesController.getCaseServices(caseId, { | |
| @@ -1455,7 +1454,7 @@ describe('cases controller', () => { | |
| it.skip('should get services with ai content by case id', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const serviceResponseObject1 = CreateServiceResponseObjectMock(); | |
| const serviceResponseObject2 = CreateServiceResponseObjectMock(); | |
| @@ -1478,7 +1477,7 @@ describe('cases controller', () => { | |
| .reply(200, mockServiceCatalogResponse_2); | |
| const dbService1 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| serviceTypeId: serviceTypeId, | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| @@ -1487,7 +1486,7 @@ describe('cases controller', () => { | |
| }); | |
| const dbService2 = await servicesDal.createService({ | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| serviceTypeId: serviceTypeId_2, | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| @@ -1525,7 +1524,7 @@ describe('cases controller', () => { | |
| it('should successfully get case by id', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request = { | |
| practiceAreaId: practiceArea.id, | |
| @@ -1541,7 +1540,7 @@ describe('cases controller', () => { | |
| const postCasesReq = lawmaticsMsNock | |
| .post(`/cases`, _.matches(getCreateCaseRequest({ user: testUser }))) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...request, | |
| }); | |
| const createdCase = await casesController.createCase(request); | |
| @@ -1563,7 +1562,7 @@ describe('cases controller', () => { | |
| it('should successfully get case by id with lss notes and additional fields', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const today = new Date(); | |
| const request = { | |
| @@ -1600,7 +1599,7 @@ describe('cases controller', () => { | |
| ), | |
| ) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...lawmaticsCaseResponse, | |
| }); | |
| const createdCase = await casesController.createCase(request); | |
| @@ -1639,7 +1638,7 @@ describe('cases controller', () => { | |
| }); | |
| it('should fail to get case by id', async () => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| await expect(casesController.getCaseById(caseId)).rejects.toThrow(NotFoundException); | |
| }); | |
| }); | |
| @@ -1650,12 +1649,12 @@ describe('cases controller', () => { | |
| const testPractice = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const familyPractice = await practiceAreaModel.create({ | |
| ...familyPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const firstCase = { | |
| @@ -1691,17 +1690,17 @@ describe('cases controller', () => { | |
| const postCasesReq = lawmaticsMsNock | |
| .post(`/cases`, _.matches(getCreateCaseRequest({ user: testUser }))) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...firstCase, | |
| }) | |
| .post(`/cases`, _.matches(getCreateCaseRequest({ user: testUser }))) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...secondCase, | |
| }) | |
| .post(`/cases`, _.matches(getCreateCaseRequest({ user: otherTestUser }))) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...thirdCase, | |
| }); | |
| @@ -1723,7 +1722,7 @@ describe('cases controller', () => { | |
| it('should successfuly delete case', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request = { | |
| practiceAreaId: practiceArea.id, | |
| @@ -1737,7 +1736,7 @@ describe('cases controller', () => { | |
| const postCasesReq = lawmaticsMsNock | |
| .post(`/cases`, _.matches(getCreateCaseRequest({ user: testUser }))) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...request, | |
| }); | |
| const createdCase = await casesController.createCase(request); | |
| @@ -1758,7 +1757,7 @@ describe('cases controller', () => { | |
| it('should soft delete by updating removedAt', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request = { | |
| practiceAreaId: practiceArea.id, | |
| @@ -1771,7 +1770,7 @@ describe('cases controller', () => { | |
| const postCasesReq = lawmaticsMsNock | |
| .post(`/cases`, _.matches(getCreateCaseRequest({ user: testUser }))) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...request, | |
| }); | |
| @@ -1796,7 +1795,7 @@ describe('cases controller', () => { | |
| it('should soft delete but not call lawmatics client', async () => { | |
| const practiceArea = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| const request = { | |
| practiceAreaId: practiceArea.id, | |
| @@ -1810,7 +1809,7 @@ describe('cases controller', () => { | |
| const postCasesReq = lawmaticsMsNock | |
| .post(`/cases`, _.matches(getCreateCaseRequest({ user: testUser }))) | |
| .reply(201, { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...request, | |
| }); | |
| @@ -1834,7 +1833,7 @@ describe('cases controller', () => { | |
| beforeEach(async () => { | |
| familyPractice = await practiceAreaModel.create({ | |
| ...familyPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| responsibleAtt = generateMockAttorney(familyPractice._id); | |
| getAttorneysReq = usersMsNock.get(`/attorneys`).query(true).reply(200, [responsibleAtt]); | |
| diff --git a/apps/services-ms/src/controllers/tests/consts.ts b/apps/services-ms/src/controllers/tests/consts.ts | |
| index a6e5f2987..0902a2282 100644 | |
| --- a/apps/services-ms/src/controllers/tests/consts.ts | |
| +++ b/apps/services-ms/src/controllers/tests/consts.ts | |
| @@ -1,6 +1,6 @@ | |
| import { KafkaEventDto, KafkaEventType } from '@vinny/kafka-client'; | |
| import { v4 as uuid } from 'uuid'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { User } from '@vinny/users-types'; | |
| import { ServiceDto } from '../../services/dtos/service.dto'; | |
| import { | |
| @@ -16,7 +16,6 @@ import faker from '@faker-js/faker'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { BrazeDestinationType, BrazeNotification } from '@vinny/communications-client'; | |
| import { ServiceDocument } from '../../services/schemas/services.schema'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| export const SERVICE_COMPLETED_DATE = new Date('2021-02-01T13:29:31.499Z'); | |
| @@ -36,7 +35,7 @@ export const generateServiceEvent = ({ | |
| previousResponsibleAttorneyId?: string; | |
| }): KafkaEventDto<Partial<ServiceDto>> => { | |
| return { | |
| - key: objectStringId(), | |
| + key: Types.ObjectId().toString(), | |
| value: { | |
| eventId: uuid(), | |
| type: eventType, | |
| @@ -114,24 +113,24 @@ export const generateServiceClosureEvent = ({ | |
| }; | |
| export const mockUser: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'first', | |
| last: 'last', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [], | |
| }; | |
| export const mockAttorney: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| @@ -173,44 +172,44 @@ export const updateServiceUpdatedAt = async ({ | |
| ); | |
| }; | |
| -export const caseId = objectStringId(); | |
| +export const caseId = Types.ObjectId().toString(); | |
| export const pendingServiceOfCasePayload = { | |
| - serviceTypeId: objectStringId(), | |
| - userId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: false, | |
| }; | |
| export const pendingServiceOfOtherCasePayload = { | |
| - serviceTypeId: objectStringId(), | |
| - userId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: false, | |
| }; | |
| export const openServiceOfCasePayload = { | |
| - serviceTypeId: objectStringId(), | |
| - userId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| }; | |
| export const anotherPendingServiceOfCasePayload = { | |
| - serviceTypeId: objectStringId(), | |
| - userId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: false, | |
| }; | |
| export const caseEvent = { | |
| - key: objectStringId(), | |
| + key: Types.ObjectId().toString(), | |
| value: { | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| type: KafkaEventType.UPDATE, | |
| time: new Date().toISOString(), | |
| data: { | |
| diff --git a/apps/services-ms/src/controllers/tests/event.controller.spec.ts b/apps/services-ms/src/controllers/tests/event.controller.spec.ts | |
| index 8f8ad9514..a25b8a08f 100644 | |
| --- a/apps/services-ms/src/controllers/tests/event.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/event.controller.spec.ts | |
| @@ -6,7 +6,7 @@ import { IdempotencyService } from '@vinny/idempotency'; | |
| import { MockIdempotencyService } from '@vinny/idempotency-test-utils'; | |
| import { CaseStatus, CreateEventRequest, EventResponse } from '@vinny/services-types'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ServicesDal } from '../../services/dal/services.dal'; | |
| import { | |
| @@ -26,7 +26,6 @@ import { | |
| import { ServicesController } from '../services.controller'; | |
| import { CasesController } from '../cases.controller'; | |
| import { ControllersModule } from '../controllers.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('EventsController', () => { | |
| let lawmaticsMsNock: nock.Scope; | |
| @@ -179,12 +178,12 @@ describe('EventsController', () => { | |
| describe('sync event', () => { | |
| it('should sync service event from lawmatics to db', async () => { | |
| - const result = await servicesController.syncServiceEvent(objectStringId()); | |
| + const result = await servicesController.syncServiceEvent(Types.ObjectId().toString()); | |
| expect(result.id).toBeTruthy(); | |
| }); | |
| it('should sync case event from lawmatics to db', async () => { | |
| - const result = await casesController.syncCaseEvent(objectStringId()); | |
| + const result = await casesController.syncCaseEvent(Types.ObjectId().toString()); | |
| expect(result.id).toBeTruthy(); | |
| }); | |
| }); | |
| @@ -318,7 +317,7 @@ describe('EventsController', () => { | |
| }); | |
| describe('getCaseEvents', () => { | |
| - const parentId = objectStringId(); | |
| + const parentId = Types.ObjectId().toString(); | |
| beforeEach(async () => { | |
| await casesDal.createCase(generateCreateCaseRequest(), false, parentId); | |
| }); | |
| @@ -362,7 +361,7 @@ describe('EventsController', () => { | |
| ${CaseStatus.PENDING} | |
| ${CaseStatus.REJECTED} | |
| `('should not get list of case events when case is $', async ({ status }) => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| await casesDal.createCase(generateCreateCaseRequest(status), false, caseId); | |
| const getCaseEventsResponse: EventResponse[] = []; | |
| const result = await casesController.getCaseEvents(caseId); | |
| diff --git a/apps/services-ms/src/controllers/tests/events-handler.controller.spec.ts b/apps/services-ms/src/controllers/tests/events-handler.controller.spec.ts | |
| index 1c799f28b..7d2a2062c 100644 | |
| --- a/apps/services-ms/src/controllers/tests/events-handler.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/events-handler.controller.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ServicesDal } from '../../services/dal/services.dal'; | |
| import { | |
| @@ -66,8 +66,6 @@ import { RepeatCriteria } from '../../cases/consts'; | |
| import { CaseStatusUpdate } from '../../case-status-updates/dal/schemas/case-status-updates.schema'; | |
| import _ from 'lodash'; | |
| import { ServiceCatalogClientService } from '@vinny/catalog-client'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| -import { ServiceType } from '../../service-types/schemas/service-types.schema'; | |
| const lawmaticsMsNock = nock(mockEnvVars.LAWMATICS_MS_URL); | |
| const servicesCatalogMsNock = nock(mockEnvVars.CATALOG_MS_URL); | |
| @@ -136,10 +134,10 @@ describe('EventHandlerController', () => { | |
| describe('ServiceEventsHandlerController', () => { | |
| describe('handleServiceEvent', () => { | |
| - const caseId = objectStringId(); | |
| - const userId = objectStringId(); | |
| - const attorneyId = objectStringId(); | |
| - const paralegalId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| + const userId = Types.ObjectId().toString(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const paralegalId = Types.ObjectId().toString(); | |
| it.each` | |
| currentServiceStatus | otherSyncServiceStatuses | isPendingService | expectedCaseSubStatus | isCompletedDate | |
| @@ -163,7 +161,7 @@ describe('EventHandlerController', () => { | |
| isCompletedDate, | |
| }) => { | |
| let getServiceTypesFromCatalogNock; | |
| - const practiceAreaId = objectStringId(); | |
| + const practiceAreaId = Types.ObjectId().toString(); | |
| await administrationDal.createPracticeArea({ | |
| ...familyPracticeArea, | |
| id: practiceAreaId, | |
| @@ -332,8 +330,8 @@ describe('EventHandlerController', () => { | |
| ); | |
| describe('new case notification', () => { | |
| - const attorneyId = objectStringId(); | |
| - const previousAttorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| + const previousAttorneyId = Types.ObjectId().toString(); | |
| beforeEach(async () => { | |
| const casesService = module.get(CasesService); | |
| @@ -421,7 +419,7 @@ describe('EventHandlerController', () => { | |
| const name = faker.lorem.word(); | |
| const { id: serviceTypeId } = await serviceTypesService.createServiceType({ | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| name, | |
| }); | |
| @@ -434,11 +432,11 @@ describe('EventHandlerController', () => { | |
| ...(isCompletedDate && { completedDate: SERVICE_COMPLETED_DATE }), | |
| legalTeam: [ | |
| { | |
| - userId: attorneyId || objectStringId(), | |
| + userId: attorneyId || Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY, | |
| }, | |
| { | |
| - userId: paralegalId || objectStringId(), | |
| + userId: paralegalId || Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.PARALEGAL, | |
| }, | |
| ], | |
| @@ -454,8 +452,8 @@ describe('EventHandlerController', () => { | |
| await casesDal.createCase( | |
| { | |
| status: CaseStatus.PENDING, | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| }, | |
| false, | |
| caseId, | |
| @@ -483,11 +481,11 @@ describe('EventHandlerController', () => { | |
| }); | |
| describe('handleCreateAttorneyRepeatEmail', () => { | |
| - let familyPractice: PracticeArea, testPractice: PracticeArea; | |
| - let firstCaseId: string, firstCase: Partial<Case>; | |
| - let secondCaseId: string, secondCase: Partial<Case>; | |
| - let thirdCaseId: string, thirdCase: Partial<Case>; | |
| - let serviceType1: Partial<ServiceType>, serviceType2: Partial<ServiceType>; | |
| + let familyPractice, testPractice; | |
| + let firstCaseId, firstCase; | |
| + let secondCaseId, secondCase; | |
| + let thirdCaseId, thirdCase; | |
| + let serviceType1, serviceType2; | |
| let responsibleAtt; | |
| let getAttorneyCasesReq: nock.Scope, | |
| @@ -503,17 +501,17 @@ describe('EventHandlerController', () => { | |
| beforeEach(async () => { | |
| testPractice = await practiceAreaModel.create({ | |
| ...testPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| familyPractice = await practiceAreaModel.create({ | |
| ...familyPracticeArea, | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| }); | |
| - firstCaseId = objectStringId(); | |
| + firstCaseId = Types.ObjectId(); | |
| firstCase = { | |
| - _id: objectId(firstCaseId), | |
| + _id: firstCaseId, | |
| practiceAreaId: testPractice.id, | |
| userId: userCase1.id, | |
| createdAt: new Date(), | |
| @@ -521,15 +519,15 @@ describe('EventHandlerController', () => { | |
| isExtendedByLawmatics: true, | |
| caseStartDate: new Date(), | |
| subStatus: CaseSubStatus.OPEN, | |
| - } satisfies Partial<Case>; | |
| + }; | |
| const closedWonDateXWeeksAgo = new Date(); | |
| closedWonDateXWeeksAgo.setDate( | |
| closedWonDateXWeeksAgo.getDate() - (serviceCategory.weeksSinceCW * 7 + 2), | |
| ); | |
| - secondCaseId = objectStringId(); | |
| + secondCaseId = Types.ObjectId(); | |
| secondCase = { | |
| - _id: objectId(secondCaseId), | |
| + _id: secondCaseId, | |
| practiceAreaId: familyPractice.id, | |
| userId: userCase2.id, | |
| createdAt: new Date(), | |
| @@ -537,13 +535,13 @@ describe('EventHandlerController', () => { | |
| isExtendedByLawmatics: true, | |
| caseStartDate: closedWonDateXWeeksAgo, | |
| subStatus: CaseSubStatus.OPEN, | |
| - } satisfies Partial<Case>; | |
| + }; | |
| - thirdCaseId = objectStringId(); | |
| + thirdCaseId = Types.ObjectId(); | |
| const closedWonDate6WeeksAgo = new Date(); | |
| closedWonDate6WeeksAgo.setDate(closedWonDate6WeeksAgo.getDate() - (6 * 7 + 2)); | |
| thirdCase = { | |
| - _id: objectId(thirdCaseId), | |
| + _id: thirdCaseId, | |
| practiceAreaId: familyPractice.id, | |
| userId: userCase3.id, | |
| createdAt: new Date(), | |
| @@ -551,7 +549,7 @@ describe('EventHandlerController', () => { | |
| isExtendedByLawmatics: true, | |
| caseStartDate: closedWonDate6WeeksAgo, | |
| subStatus: CaseSubStatus.OPEN, | |
| - } satisfies Partial<Case>; | |
| + }; | |
| await caseModel.insertMany([firstCase, secondCase, thirdCase]); | |
| @@ -566,7 +564,7 @@ describe('EventHandlerController', () => { | |
| category: serviceCategory.categoryName, | |
| }); | |
| - responsibleAtt = generateMockAttorney(familyPractice._id.toString()); | |
| + responsibleAtt = generateMockAttorney(familyPractice._id); | |
| await servicesDal.createService({ | |
| userId: userCase1.id, | |
| @@ -697,14 +695,8 @@ describe('EventHandlerController', () => { | |
| ); | |
| }); | |
| it('should send repeat email about cases which are not canceled or completed', async () => { | |
| - await casesDal.updateCase({ | |
| - caseId: secondCaseId, | |
| - subStatus: CaseSubStatus.CANCELED, | |
| - }); | |
| - await casesDal.updateCase({ | |
| - caseId: thirdCaseId, | |
| - subStatus: CaseSubStatus.COMPLETED, | |
| - }); | |
| + await casesDal.updateCase({ caseId: secondCaseId, subStatus: CaseSubStatus.CANCELED }); | |
| + await casesDal.updateCase({ caseId: thirdCaseId, subStatus: CaseSubStatus.COMPLETED }); | |
| const emitSpy = jest.spyOn(kafkaEventsService, 'emitEvent'); | |
| eventHandlerController.handleCreateAttorneyRepeatEmail({ | |
| @@ -750,12 +742,12 @@ describe('EventHandlerController', () => { | |
| }); | |
| describe('handleActivityLogEvent', () => { | |
| - const mockCaseId = objectStringId(); | |
| + const mockCaseId = Types.ObjectId(); | |
| const getMockedEvent = (override?: { | |
| type?: KafkaEventType; | |
| relatedDataCreatedAt?: Date; | |
| }): KafkaEventDto<CreateActivityLogDto> => ({ | |
| - key: mockCaseId, | |
| + key: mockCaseId.toString(), | |
| value: { | |
| eventId: 'mockEventId', | |
| type: override?.type || KafkaEventType.CREATE, | |
| @@ -763,7 +755,7 @@ describe('EventHandlerController', () => { | |
| data: { | |
| relatedDataCreatedAt: override?.relatedDataCreatedAt || new Date(), | |
| additionalData: { | |
| - caseId: mockCaseId, | |
| + caseId: mockCaseId.toString(), | |
| }, | |
| type: ActivityLogType.COMMUNICATION_POINT, | |
| }, | |
| @@ -777,7 +769,7 @@ describe('EventHandlerController', () => { | |
| await eventHandlerController.handleActivityLogEvent(mockEvent); | |
| expect(updateCaseDalSpy).toHaveBeenCalledWith({ | |
| - caseId: mockCaseId, | |
| + caseId: mockCaseId.toString(), | |
| lastActivityDate: mockEvent.value.data.relatedDataCreatedAt, | |
| }); | |
| }); | |
| @@ -795,13 +787,13 @@ describe('EventHandlerController', () => { | |
| describe('should update lastActivityDate only if the activity event is newer', () => { | |
| let updateCaseDalSpy: jest.SpyInstance; | |
| const mockCase = { | |
| - _id: objectId(mockCaseId), | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + _id: mockCaseId, | |
| + userId: Types.ObjectId(), | |
| + practiceAreaId: Types.ObjectId(), | |
| status: CaseStatus.ACCEPTED, | |
| isExtendedByLawmatics: true, | |
| lastActivityDate: new Date(), | |
| - } satisfies Partial<Case>; | |
| + }; | |
| beforeEach(async () => { | |
| updateCaseDalSpy = jest.spyOn(casesDal, 'updateCase'); | |
| diff --git a/apps/services-ms/src/controllers/tests/repeats.controller.spec.ts b/apps/services-ms/src/controllers/tests/repeats.controller.spec.ts | |
| index 81992df09..6cc627693 100644 | |
| --- a/apps/services-ms/src/controllers/tests/repeats.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/repeats.controller.spec.ts | |
| @@ -3,7 +3,7 @@ import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { RepeatsService } from '../../repeats/repeats.service'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { HttpStatus, INestApplication, ValidationPipe } from '@nestjs/common'; | |
| import { | |
| MockRepeatRequest, | |
| @@ -31,7 +31,6 @@ import { | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { DataAccessService } from '../../services/data-access.service'; | |
| import { ControllersModule } from '../controllers.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('repeats controller', () => { | |
| let repeatsService: RepeatsService; | |
| @@ -128,7 +127,7 @@ describe('repeats controller', () => { | |
| .post(`/repeats/support-request`) | |
| .send({ | |
| userId: MockCase.userId, | |
| - repeatId: objectStringId(), | |
| + repeatId: Types.ObjectId(), | |
| message: 'a message', | |
| supportRequestType: 'PAYMENT', | |
| }) | |
| diff --git a/apps/services-ms/src/controllers/tests/service-closures-handler.controller.spec.ts b/apps/services-ms/src/controllers/tests/service-closures-handler.controller.spec.ts | |
| index 31367638c..a33f659e8 100644 | |
| --- a/apps/services-ms/src/controllers/tests/service-closures-handler.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/service-closures-handler.controller.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { KafkaEventType, KafkaProducerService } from '@vinny/kafka-client'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| @@ -20,7 +20,6 @@ import { ControllersModule } from '../controllers.module'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| import { mockEnvVars } from './utils'; | |
| import { ServiceEventsHandlerController } from '../events-handler.controller'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const usersMsNock = nock(mockEnvVars.USERS_MS_URL); | |
| const communicationsMsNock = nock(mockEnvVars.COMMUNICATIONS_MS_URL); | |
| @@ -70,16 +69,16 @@ describe('ServiceClosuresHandlerController', () => { | |
| `( | |
| 'should send disengagement process braze notification to client and attorney when $message', | |
| async ({ eventType, status }) => { | |
| - const caseId = objectStringId(); | |
| + const caseId = Types.ObjectId().toString(); | |
| const { id: serviceId } = await servicesDal.createService({ | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| userId: mockUser.id, | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: false, | |
| legalTeam: [ | |
| - { userId: objectStringId(), role: LegalTeamMemberRole.PARALEGAL }, | |
| + { userId: Types.ObjectId().toString(), role: LegalTeamMemberRole.PARALEGAL }, | |
| { userId: mockAttorney.id, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| ], | |
| }); | |
| @@ -128,8 +127,8 @@ describe('ServiceClosuresHandlerController', () => { | |
| eventType: KafkaEventType.UPDATE, | |
| status: ServiceClosureStatus.PENDING_WITHDRAWAL, | |
| previousStatus: ServiceClosureStatus.PENDING_WITHDRAWAL, | |
| - caseId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }); | |
| await eventHandlerController.handleServiceClosureEvent(serviceClosureEvent); | |
| @@ -145,8 +144,8 @@ describe('ServiceClosuresHandlerController', () => { | |
| const serviceClosureEvent = generateServiceClosureEvent({ | |
| eventType: KafkaEventType.DELETE, | |
| status: ServiceClosureStatus.PENDING_WITHDRAWAL, | |
| - caseId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }); | |
| await eventHandlerController.handleServiceClosureEvent(serviceClosureEvent); | |
| diff --git a/apps/services-ms/src/controllers/tests/service-notes.controller.spec.ts b/apps/services-ms/src/controllers/tests/service-notes.controller.spec.ts | |
| index 6e10d8903..de5d88fa8 100644 | |
| --- a/apps/services-ms/src/controllers/tests/service-notes.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/service-notes.controller.spec.ts | |
| @@ -5,14 +5,13 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { IdempotencyService } from '@vinny/idempotency'; | |
| import { MockIdempotencyService } from '@vinny/idempotency-test-utils'; | |
| import { UsersClientService } from '@vinny/users-client'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { ServicesController } from '../services.controller'; | |
| import { mockEnvVars } from '../../cases/test/testing-module'; | |
| import { ControllersModule } from '../controllers.module'; | |
| import { ServicesDal } from '../../services/dal/services.dal'; | |
| import { CreateServiceNoteRequest } from '../../services/dtos/service-note.dto'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('ServicesController', () => { | |
| let servicesController: ServicesController, | |
| @@ -49,7 +48,7 @@ describe('ServicesController', () => { | |
| describe('createServiceNote', () => { | |
| it('should create a service note', async () => { | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId().toString(); | |
| const payload: CreateServiceNoteRequest = { | |
| name: 'NAME', | |
| body: 'DESC', | |
| @@ -75,7 +74,7 @@ describe('ServicesController', () => { | |
| }); | |
| it('should fail to create an note on lawmatics ms', async () => { | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId().toString(); | |
| const payload: CreateServiceNoteRequest = { | |
| name: 'NAME', | |
| body: 'BODY', | |
| diff --git a/apps/services-ms/src/controllers/tests/service-tags.controller.spec.ts b/apps/services-ms/src/controllers/tests/service-tags.controller.spec.ts | |
| index 9c78b76a6..a7543b093 100644 | |
| --- a/apps/services-ms/src/controllers/tests/service-tags.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/service-tags.controller.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { CreateServiceTagRequest } from '@vinny/services-types'; | |
| import { ServiceTagsController } from '../service-tags.controller'; | |
| import { PracticeArea } from '@vinny/users-types'; | |
| @@ -11,7 +11,6 @@ import { ControllersModule } from '../controllers.module'; | |
| import { PracticeAreaDocument } from '../../administration/schemas/practice-areas.schema'; | |
| import { AdministrationService } from '../../administration/administration.service'; | |
| import { ServiceTag, ServiceTagDocument } from '../../administration/schemas/service-tags.schema'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| describe('ServiceTagsController', () => { | |
| let serviceTagsController: ServiceTagsController; | |
| @@ -72,7 +71,7 @@ describe('ServiceTagsController', () => { | |
| expect(createdServiceTag).toEqual( | |
| expect.objectContaining({ | |
| ...serviceTagRequest, | |
| - practiceAreaId: mockPracticeAreaId, | |
| + practiceAreaId: Types.ObjectId(mockPracticeAreaId), | |
| }), | |
| ); | |
| }); | |
| @@ -89,7 +88,7 @@ describe('ServiceTagsController', () => { | |
| await serviceTagsController.createServiceTag(serviceTagRequest); | |
| const invalidServiceTagRequest = { | |
| ...serviceTagRequest, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId.toString(), | |
| }; | |
| await expect( | |
| serviceTagsController.createServiceTag(invalidServiceTagRequest), | |
| @@ -120,7 +119,7 @@ describe('ServiceTagsController', () => { | |
| expect(updatedServiceTag).toEqual( | |
| expect.objectContaining({ | |
| ...serviceTagRequest, | |
| - practiceAreaId: mockPracticeAreaId, | |
| + practiceAreaId: Types.ObjectId(mockPracticeAreaId), | |
| displayName: 'updated mock service tag name', | |
| }), | |
| ); | |
| @@ -146,7 +145,7 @@ describe('ServiceTagsController', () => { | |
| expect(resultServiceTag).toEqual( | |
| expect.objectContaining({ | |
| ...serviceTagRequest, | |
| - practiceAreaId: mockPracticeAreaId, | |
| + practiceAreaId: Types.ObjectId(mockPracticeAreaId), | |
| }), | |
| ); | |
| }); | |
| @@ -223,7 +222,7 @@ describe('ServiceTagsController', () => { | |
| expect(deletedServiceTag).toEqual( | |
| expect.objectContaining({ | |
| ...serviceTagRequest, | |
| - practiceAreaId: mockPracticeAreaId, | |
| + practiceAreaId: Types.ObjectId(mockPracticeAreaId), | |
| }), | |
| ); | |
| }); | |
| @@ -247,7 +246,7 @@ describe('ServiceTagsController', () => { | |
| expect(tags.serviceTags).not.toContainEqual( | |
| expect.objectContaining({ | |
| ...serviceTagRequest, | |
| - practiceAreaId: objectId(mockPracticeAreaId), | |
| + practiceAreaId: Types.ObjectId(mockPracticeAreaId), | |
| }), | |
| ); | |
| }); | |
| diff --git a/apps/services-ms/src/controllers/tests/service-types.controller.spec.ts b/apps/services-ms/src/controllers/tests/service-types.controller.spec.ts | |
| index 709f0afde..17c9debab 100644 | |
| --- a/apps/services-ms/src/controllers/tests/service-types.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/service-types.controller.spec.ts | |
| @@ -2,7 +2,7 @@ import faker from '@faker-js/faker'; | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { | |
| CreateServiceTypeRequest, | |
| ReplaceServiceTypeRequest, | |
| @@ -11,7 +11,6 @@ import { | |
| import { ServiceTypesController } from '../service-types.controller'; | |
| import { ControllersModule } from '../controllers.module'; | |
| import { mockEnvVars } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| function createServiceTypeRequest( | |
| options: Partial<CreateServiceTypeRequest> = {}, | |
| @@ -30,7 +29,7 @@ function createServiceTypeRequest( | |
| name: `service test ${num}`, | |
| ...(description && { description: `service description ${num}` }), | |
| ...(category && { category: `service category ${num}` }), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| descriptionForClient: faker.lorem.sentence(), | |
| whatIsIncluded: ` | |
| - ${faker.lorem.words()} | |
| @@ -151,7 +150,7 @@ describe('ServiceTypeController', () => { | |
| }); | |
| it("should return null when service doesn't exists", async () => { | |
| - const getServiceType = await serviceTypesController.getById(objectStringId()); | |
| + const getServiceType = await serviceTypesController.getById(Types.ObjectId().toString()); | |
| expect(getServiceType).toBeNull(); | |
| }); | |
| @@ -310,7 +309,7 @@ describe('ServiceTypeController', () => { | |
| }); | |
| it("should throw not found exception when service type doesn't exist", async () => { | |
| - const nonExistingId = objectStringId(); | |
| + const nonExistingId = Types.ObjectId().toString(); | |
| await expect( | |
| serviceTypesController.updateServiceType(nonExistingId, { | |
| name: 'yana', | |
| @@ -327,7 +326,7 @@ describe('ServiceTypeController', () => { | |
| name: 'replace service type name', | |
| description: 'replace service type name', | |
| category: 'replace service type category', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| stateIds: [{ id: '2' }], | |
| }; | |
| @@ -345,7 +344,7 @@ describe('ServiceTypeController', () => { | |
| }); | |
| it("should throw not found exception when service type doesn't exist", async () => { | |
| - const nonExistingId = objectStringId(); | |
| + const nonExistingId = Types.ObjectId().toString(); | |
| await expect( | |
| serviceTypesController.replaceServiceType(nonExistingId, createServiceTypeRequest()), | |
| ).rejects.toThrowError(`Service type with id:${nonExistingId} doesn't exist`); | |
| diff --git a/apps/services-ms/src/controllers/tests/services.controller.spec.ts b/apps/services-ms/src/controllers/tests/services.controller.spec.ts | |
| index 7fa5e68e0..5d747b487 100644 | |
| --- a/apps/services-ms/src/controllers/tests/services.controller.spec.ts | |
| +++ b/apps/services-ms/src/controllers/tests/services.controller.spec.ts | |
| @@ -25,7 +25,7 @@ import { | |
| import { UsersClientService } from '@vinny/users-client'; | |
| import { UserDto } from '@vinny/users-types'; | |
| import _, { omit } from 'lodash'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import request from 'supertest'; | |
| import { v4 as uuidv4 } from 'uuid'; | |
| @@ -74,7 +74,6 @@ import { ControllersModule } from '../controllers.module'; | |
| import { mockEnvVars } from './utils'; | |
| import { upsertServiceType } from '../../services/test/mock-generator'; | |
| import { ServiceProgressService } from '../../services/service-progress/service-progress.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('ServicesController', () => { | |
| let lawmaticsMsNock: nock.Scope, calendarsMsNock: nock.Scope; | |
| @@ -223,7 +222,7 @@ describe('ServicesController', () => { | |
| ])('should create service in lawmatics and db %s', async (_, location) => { | |
| const emitSpy = jest.spyOn(kafkaEventsService, 'emitEvent'); | |
| const caseCreated = await createCustomerWithCase(); | |
| - const practiceAreaId = caseCreated.practiceAreaId; | |
| + const practiceAreaId = caseCreated.practiceAreaId.toString(); | |
| const createServiceRequest = createServiceRequestMock({ | |
| practiceAreaId, | |
| @@ -483,7 +482,7 @@ describe('ServicesController', () => { | |
| }); | |
| const updatedCreateServiceRequest = { | |
| ...createServiceRequest, | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| }; | |
| await expect( | |
| @@ -1344,7 +1343,7 @@ describe('ServicesController', () => { | |
| caseId, | |
| status: ServiceStatus.PENDING, | |
| isExtendedByLawmatics: false, | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }); | |
| await servicesDal.createService({ | |
| @@ -1443,7 +1442,7 @@ describe('ServicesController', () => { | |
| it('get services by filter', async () => { | |
| const { id: service1Id } = await servicesDal.createService({ | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| userId, | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| @@ -1451,16 +1450,16 @@ describe('ServicesController', () => { | |
| }); | |
| const { id: service2Id } = await servicesDal.createService({ | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| userId, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| }); | |
| const { id: service3Id } = await servicesDal.createService({ | |
| serviceTypeId, | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| @@ -1525,12 +1524,12 @@ describe('ServicesController', () => { | |
| expect(results[0].id).toEqual(service1Id); | |
| }); | |
| it('get services by multiple users', async () => { | |
| - const userId1 = objectStringId(); | |
| - const userId2 = objectStringId(); | |
| - const userId3 = objectStringId(); | |
| + const userId1 = Types.ObjectId().toString(); | |
| + const userId2 = Types.ObjectId().toString(); | |
| + const userId3 = Types.ObjectId().toString(); | |
| const { id: service1Id } = await servicesDal.createService({ | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| userId: userId1, | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| @@ -1538,9 +1537,9 @@ describe('ServicesController', () => { | |
| }); | |
| const { id: service2Id } = await servicesDal.createService({ | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| userId: userId2, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| isExtendedByLawmatics: true, | |
| }); | |
| @@ -1712,7 +1711,7 @@ describe('ServicesController', () => { | |
| ...payload1, | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 80.5, | |
| }, | |
| ], | |
| @@ -1760,13 +1759,13 @@ describe('ServicesController', () => { | |
| const payload1 = { | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| updatedAt: new Date(), | |
| updatedBy: faker.database.mongodbObjectId(), | |
| }, | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 100, | |
| updatedAt: new Date(), | |
| updatedBy: faker.database.mongodbObjectId(), | |
| @@ -1780,7 +1779,7 @@ describe('ServicesController', () => { | |
| status: ServiceClosureStatus.PENDING_WITHDRAWAL, | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| updatedAt: new Date(), | |
| updatedBy: faker.database.mongodbObjectId(), | |
| }, | |
| @@ -1870,7 +1869,7 @@ describe('ServicesController', () => { | |
| it('should throw a bad request exception when isWithdrawalBundle value is not boolean', async () => { | |
| await request(app.getHttpServer()) | |
| - .patch(`/services/${objectStringId()}/service-closure`) | |
| + .patch(`/services/${Types.ObjectId().toString()}/service-closure`) | |
| .send({ isWithdrawalBundle: 4 }) | |
| .expect(HttpStatus.BAD_REQUEST); | |
| }); | |
| @@ -1963,7 +1962,7 @@ describe('ServicesController', () => { | |
| }); | |
| it('should throw not found exception when service closure does not exist', async () => { | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId().toString(); | |
| await request(app.getHttpServer()) | |
| .delete(`/services/${serviceId}/service-closure`) | |
| .expect(HttpStatus.NOT_FOUND); | |
| diff --git a/apps/services-ms/src/controllers/tests/utils.ts b/apps/services-ms/src/controllers/tests/utils.ts | |
| index 0960abc86..a7c21c76e 100644 | |
| --- a/apps/services-ms/src/controllers/tests/utils.ts | |
| +++ b/apps/services-ms/src/controllers/tests/utils.ts | |
| @@ -20,7 +20,7 @@ import { ControllersModule } from '../controllers.module'; | |
| import { DynamicModule } from '@nestjs/common'; | |
| import { getLawmaticsMsClient } from '../../services/test/mock-generator'; | |
| import { KafkaEventDto, KafkaEventType } from '@vinny/kafka-client'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { Role } from '@vinny/auth-types'; | |
| export const mockEnvVars = { | |
| @@ -117,23 +117,23 @@ export const MockRepeatKafkaPayload: KafkaEventDto<RepeatKafkaPayloadDto> = { | |
| value: { | |
| data: { | |
| id: faker.datatype.string(), | |
| - caseId: objectStringId(), | |
| - attorneyId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| + attorneyId: Types.ObjectId().toString(), | |
| submittedBy: { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| type: Role.ATTORNEY, | |
| }, | |
| services: { | |
| additionalServices: [ | |
| { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| - practiceAreaId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [], | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| location: { state: faker.datatype.string() }, | |
| }, | |
| ], | |
| @@ -144,10 +144,10 @@ export const MockRepeatKafkaPayload: KafkaEventDto<RepeatKafkaPayloadDto> = { | |
| }, | |
| events: [], | |
| flowType: 'Touch' as const, | |
| - documentTypeIds: [objectStringId()], | |
| - userId: objectStringId(), | |
| + documentTypeIds: [Types.ObjectId().toString()], | |
| + userId: Types.ObjectId().toString(), | |
| }, | |
| - eventId: objectStringId(), | |
| + eventId: Types.ObjectId().toString(), | |
| type: KafkaEventType.CREATE, | |
| time: faker.datatype.string(), | |
| }, | |
| diff --git a/apps/services-ms/src/events/dal/event.dal.ts b/apps/services-ms/src/events/dal/event.dal.ts | |
| index 33566bcdc..f3d33bb44 100644 | |
| --- a/apps/services-ms/src/events/dal/event.dal.ts | |
| +++ b/apps/services-ms/src/events/dal/event.dal.ts | |
| @@ -1,9 +1,8 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { KeyEventParentType } from '@vinny/services-types'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { Event, EventDocument } from '../schemas/event.schema'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class EventDal { | |
| @@ -18,8 +17,8 @@ export class EventDal { | |
| eventId?: string, | |
| ): Promise<Event> { | |
| return this.eventsModel.create({ | |
| - _id: eventId ?? objectStringId(), | |
| - parentId: parentId, | |
| + _id: eventId ?? Types.ObjectId(), | |
| + parentId: Types.ObjectId(parentId), | |
| objectType: parentType, | |
| }); | |
| } | |
| diff --git a/apps/services-ms/src/events/events.service.ts b/apps/services-ms/src/events/events.service.ts | |
| index f1fe4b603..1d319d2d3 100644 | |
| --- a/apps/services-ms/src/events/events.service.ts | |
| +++ b/apps/services-ms/src/events/events.service.ts | |
| @@ -10,7 +10,7 @@ import { | |
| SyncEventResponse, | |
| UpdateEventRequest, | |
| } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { LawmaticsMsClient } from '../clients/lawmatics-ms-client/lawmatics-ms.client'; | |
| import { EventDal } from './dal/event.dal'; | |
| import { convertToEventDTO } from './utils'; | |
| @@ -29,7 +29,7 @@ export class EventsService { | |
| parentId: string, | |
| parentType: KeyEventParentType, | |
| ): Promise<EventResponse> { | |
| - const eventId = objectStringId(); | |
| + const eventId = Types.ObjectId().toString(); | |
| const { users } = await this.lawmaticsClient.createEvent( | |
| payload, | |
| parentId, | |
| diff --git a/apps/services-ms/src/events/key-events-handler/test/utils.ts b/apps/services-ms/src/events/key-events-handler/test/utils.ts | |
| index 85db15dc4..7241b09e3 100644 | |
| --- a/apps/services-ms/src/events/key-events-handler/test/utils.ts | |
| +++ b/apps/services-ms/src/events/key-events-handler/test/utils.ts | |
| @@ -4,7 +4,7 @@ import { Test } from '@nestjs/testing'; | |
| import { KeyEventResponseObject } from '@vinny/lawmatics-types'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| import { EventDto, KeyEventParentType } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { KeyEventHandlerModule } from '../key-events-handler.module'; | |
| export const ENV_VARS = { | |
| @@ -29,7 +29,7 @@ export const createEventsHandlerTestModule = () => { | |
| }; | |
| export const mockCustomer = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'John', | |
| last: 'Snow', | |
| @@ -37,8 +37,8 @@ export const mockCustomer = { | |
| }; | |
| export const mockEvent: EventDto = { | |
| - id: objectStringId(), | |
| - parentId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + parentId: Types.ObjectId().toString(), | |
| name: 'test', | |
| description: 'test', | |
| eventType: 'COURT_DATE', | |
| @@ -49,8 +49,8 @@ export const mockEvent: EventDto = { | |
| }; | |
| export const mockEventValidData: Partial<KeyEventResponseObject> = { | |
| - id: objectStringId(), | |
| - parentId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + parentId: Types.ObjectId().toString(), | |
| name: 'test', | |
| description: 'test', | |
| eventType: 'COURT_DATE', | |
| diff --git a/apps/services-ms/src/events/schemas/event.schema.ts b/apps/services-ms/src/events/schemas/event.schema.ts | |
| index 5f99ee3da..f6eb47d47 100644 | |
| --- a/apps/services-ms/src/events/schemas/event.schema.ts | |
| +++ b/apps/services-ms/src/events/schemas/event.schema.ts | |
| @@ -1,7 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { KeyEventParentType } from '@vinny/services-types'; | |
| -import { Document, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, Types, SchemaTypes } from 'mongoose'; | |
| @Schema({ timestamps: true, toObject: { getters: true } }) | |
| export class Event { | |
| @@ -10,12 +9,12 @@ export class Event { | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler()) | |
| - parentId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + parentId: Types.ObjectId; | |
| - @Prop({ enum: Object.values(KeyEventParentType), type: String, required: true }) | |
| + @Prop({ enum: KeyEventParentType, type: String, required: true }) | |
| objectType: KeyEventParentType; | |
| } | |
| -export type EventDocument = Event & Document<Event, unknown, Event>; | |
| +export type EventDocument = Event & Document; | |
| export const EventSchema = SchemaFactory.createForClass(Event); | |
| diff --git a/apps/services-ms/src/events/test/events.service.spec.ts b/apps/services-ms/src/events/test/events.service.spec.ts | |
| index d7d0f1196..5433c5429 100644 | |
| --- a/apps/services-ms/src/events/test/events.service.spec.ts | |
| +++ b/apps/services-ms/src/events/test/events.service.spec.ts | |
| @@ -1,7 +1,7 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { EventDal } from '../dal/event.dal'; | |
| import { EventsService } from '../events.service'; | |
| import { Event, EventDocument } from '../schemas/event.schema'; | |
| @@ -10,7 +10,6 @@ import { convertEventResponseToDto, mockEventFromLawmatics } from './utils'; | |
| import { EventDto, KeyEventParentType } from '@vinny/services-types'; | |
| import { NotFoundException } from '@nestjs/common'; | |
| import { EventModule } from '../events.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| LAWMATICS_MS_URL: 'https://lawmati.cs', | |
| @@ -55,7 +54,7 @@ describe('EventsService', () => { | |
| describe('success', () => { | |
| it('should return event by id', async () => { | |
| const eventCreated = await eventModel.create({ | |
| - parentId: objectStringId(), | |
| + parentId: new Types.ObjectId(), | |
| objectType: KeyEventParentType.CASE, | |
| }); | |
| const expectedEvent: EventDto = convertEventResponseToDto( | |
| @@ -72,7 +71,7 @@ describe('EventsService', () => { | |
| describe('fail', () => { | |
| it('should throw not found error, fake id', async () => { | |
| - const fakeId = objectStringId(); | |
| + const fakeId = Types.ObjectId().toString(); | |
| lawmaticsMsNock.get(`/events/${fakeId}`).reply(200, undefined); | |
| const getEventByIdMock = jest.spyOn(eventDal, 'getEventById'); | |
| getEventByIdMock.mockResolvedValueOnce(null); | |
| diff --git a/apps/services-ms/src/events/test/utils.ts b/apps/services-ms/src/events/test/utils.ts | |
| index d76a87eb2..020b578ab 100644 | |
| --- a/apps/services-ms/src/events/test/utils.ts | |
| +++ b/apps/services-ms/src/events/test/utils.ts | |
| @@ -11,13 +11,13 @@ import { | |
| ServiceStatus, | |
| UpdateEventRequest, | |
| } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ConfigurationType } from '@vinny/lawmatics-types'; | |
| import { Event } from '../schemas/event.schema'; | |
| import { DateTime } from 'luxon'; | |
| const TODAY = new Date(); | |
| -export const parentId = objectStringId(); | |
| +export const parentId = Types.ObjectId().toString(); | |
| export const createEventPayload: CreateEventRequest = { | |
| name: 'NAME', | |
| description: 'DESC', | |
| @@ -65,17 +65,17 @@ export const convertEventResponseToDto = ( | |
| }; | |
| export const mockServiceBase = { | |
| - internalId: objectStringId(), | |
| + internalId: Types.ObjectId(), | |
| lawmaticsId: faker.datatype.string(5), | |
| type: ConfigurationType.SERVICE, | |
| }; | |
| export const mockService = { | |
| - userId: objectStringId(), | |
| - caseId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| isExtendedByLawmatics: true, | |
| name: faker.datatype.string(), | |
| legalTeam: [], | |
| @@ -85,9 +85,9 @@ export const mockService = { | |
| }; | |
| export const generateCreateCaseRequest = (status = CaseStatus.ACCEPTED): CreateCaseRequest => ({ | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| status, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| }); | |
| export const mockCreateEventRequest: CreateEventRequest = { | |
| @@ -101,11 +101,11 @@ export const mockCreateEventRequest: CreateEventRequest = { | |
| }; | |
| export const mockEventFromLawmatics: EventResponse = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| eventType: 'HEARING', | |
| name: faker.datatype.string(), | |
| description: faker.datatype.string(), | |
| - parentId: objectStringId(), | |
| + parentId: Types.ObjectId().toString(), | |
| startDate: faker.date.future().toISOString(), | |
| endDate: faker.date.future().toISOString(), | |
| timezone: 'America/Chicago', | |
| @@ -114,8 +114,8 @@ export const mockEventFromLawmatics: EventResponse = { | |
| }; | |
| export const mockEventFromDb: EventDto = { | |
| - id: objectStringId(), | |
| - parentId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + parentId: Types.ObjectId().toString(), | |
| eventType: 'HEARING', | |
| name: faker.datatype.string(), | |
| parentType: KeyEventParentType.SERVICE, | |
| @@ -126,12 +126,12 @@ export const mockEventFromDb: EventDto = { | |
| location: faker.datatype.string(), | |
| }; | |
| -export const mockAttorney = { id: objectStringId() }; | |
| +export const mockAttorney = { id: Types.ObjectId().toString() }; | |
| export const mockClientName = 'John Snow'; | |
| export const mockServiceWithResponsibleAttorney = { | |
| - id: objectStringId(), | |
| - caseId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| legalTeam: [{ userId: mockAttorney.id, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }], | |
| }; | |
| diff --git a/apps/services-ms/src/locations/schemas/county.schema.ts b/apps/services-ms/src/locations/schemas/county.schema.ts | |
| index 6bfaf6d87..3c5c7533e 100644 | |
| --- a/apps/services-ms/src/locations/schemas/county.schema.ts | |
| +++ b/apps/services-ms/src/locations/schemas/county.schema.ts | |
| @@ -1,12 +1,9 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Types } from 'mongoose'; | |
| +import { Document } from 'mongoose'; | |
| // Manually populated from https://simplemaps.com/data/us-counties | |
| -@Schema({ _id: true, id: true, timestamps: false, autoIndex: true }) | |
| +@Schema({ timestamps: false, autoIndex: true }) | |
| export class County { | |
| - _id: Types.ObjectId; | |
| - id: string; | |
| - | |
| @Prop({ required: true, index: true }) | |
| name: string; | |
| @@ -41,5 +38,5 @@ export class County { | |
| isEnabled: boolean; | |
| } | |
| -export type CountyDocument = County; | |
| +export type CountyDocument = County & Document; | |
| export const CountySchema = SchemaFactory.createForClass(County); | |
| diff --git a/apps/services-ms/src/locations/test/utils.ts b/apps/services-ms/src/locations/test/utils.ts | |
| index ae8864ecb..d008a1b5b 100644 | |
| --- a/apps/services-ms/src/locations/test/utils.ts | |
| +++ b/apps/services-ms/src/locations/test/utils.ts | |
| @@ -2,7 +2,7 @@ import faker from '@faker-js/faker'; | |
| import { DocumentDefinition } from 'mongoose'; | |
| import { CountyDocument } from '../schemas/county.schema'; | |
| -export const generateCounty = (): Omit<DocumentDefinition<CountyDocument>, '_id' | 'id'> => { | |
| +export const generateCounty = (): DocumentDefinition<CountyDocument> => { | |
| const name = faker.address.county(); | |
| const osName = `${faker.address.county()} County`; | |
| const stateName = faker.address.state(); | |
| diff --git a/apps/services-ms/src/repeat-reminders/dal/repeat-reminder.dal.ts b/apps/services-ms/src/repeat-reminders/dal/repeat-reminder.dal.ts | |
| index 4d73e52fb..18a0ed8da 100644 | |
| --- a/apps/services-ms/src/repeat-reminders/dal/repeat-reminder.dal.ts | |
| +++ b/apps/services-ms/src/repeat-reminders/dal/repeat-reminder.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { FilterQuery, Model } from 'mongoose'; | |
| +import { FilterQuery, Model, Types } from 'mongoose'; | |
| import { RepeatReminder, RepeatReminderDocument } from './schemas/repeat-reminder.schema'; | |
| import { | |
| CreateRepeatReminderDto, | |
| @@ -37,9 +37,9 @@ export class RepeatRemindersDal { | |
| private constructFindQuery(filter: FilterRepeatReminderDto) { | |
| const repeatReminderQuery: FilterQuery<RepeatReminderDocument> = { | |
| - attorneyId: filter.attorneyId, | |
| + attorneyId: Types.ObjectId(filter.attorneyId), | |
| ...(filter.caseId && { | |
| - caseId: filter.caseId, | |
| + caseId: Types.ObjectId(filter.caseId), | |
| }), | |
| }; | |
| diff --git a/apps/services-ms/src/repeat-reminders/dal/schemas/repeat-reminder.schema.ts b/apps/services-ms/src/repeat-reminders/dal/schemas/repeat-reminder.schema.ts | |
| index 7d6e1ef6d..c9b300df6 100644 | |
| --- a/apps/services-ms/src/repeat-reminders/dal/schemas/repeat-reminder.schema.ts | |
| +++ b/apps/services-ms/src/repeat-reminders/dal/schemas/repeat-reminder.schema.ts | |
| @@ -1,7 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { ReasonType } from '@vinny/services-types'; | |
| -import { Document, Types } from 'mongoose'; | |
| -import { objectIdPropHandler, objectIdsPropHandler } from '@vinny/helpers'; | |
| +import { Document, Types, SchemaTypes } from 'mongoose'; | |
| @Schema({ timestamps: true, id: true, toObject: { getters: true } }) | |
| export class RepeatReminder { | |
| @@ -13,17 +12,17 @@ export class RepeatReminder { | |
| @Prop({ required: true }) | |
| reminderId: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - caseId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + caseId: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - attorneyId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + attorneyId: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - customerId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + customerId: Types.ObjectId; | |
| - @Prop(objectIdsPropHandler) | |
| - additionalServiceTypeIds?: string[]; | |
| + @Prop({ type: [SchemaTypes.ObjectId] }) | |
| + additionalServiceTypeIds?: Types.ObjectId[]; | |
| @Prop({ | |
| required: true, | |
| diff --git a/apps/services-ms/src/repeat-reminders/tests/repeat-reminders.controller.spec.ts b/apps/services-ms/src/repeat-reminders/tests/repeat-reminders.controller.spec.ts | |
| index b04e322c2..03dbc6134 100644 | |
| --- a/apps/services-ms/src/repeat-reminders/tests/repeat-reminders.controller.spec.ts | |
| +++ b/apps/services-ms/src/repeat-reminders/tests/repeat-reminders.controller.spec.ts | |
| @@ -4,7 +4,7 @@ import request from 'supertest'; | |
| import { importCommons } from '@vinny/test-utils'; | |
| import { RepeatRemindersModule } from '../repeat-reminders.module'; | |
| import { RepeatRemindersService } from '../repeat-reminders.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { validRepeatRemindersDocument } from './utils'; | |
| describe('RepeatRemindersController', () => { | |
| @@ -44,7 +44,7 @@ describe('RepeatRemindersController', () => { | |
| const mockReminders = [ | |
| { | |
| ...validRepeatRemindersDocument[0], | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: new Date().toISOString(), | |
| updatedAt: new Date().toISOString(), | |
| }, | |
| diff --git a/apps/services-ms/src/repeat-reminders/tests/utils.ts b/apps/services-ms/src/repeat-reminders/tests/utils.ts | |
| index b36de05d7..e4b9897a4 100644 | |
| --- a/apps/services-ms/src/repeat-reminders/tests/utils.ts | |
| +++ b/apps/services-ms/src/repeat-reminders/tests/utils.ts | |
| @@ -1,21 +1,21 @@ | |
| import { ReasonType } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| -export const mockAttorneyId = objectStringId(); | |
| +export const mockAttorneyId = Types.ObjectId().toString(); | |
| export const validRepeatRemindersDocument = [ | |
| { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| reminderId: '1', | |
| - customerId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| attorneyId: mockAttorneyId, | |
| reason: ReasonType.LIKELY_TO_REPEAT_SERVICE, | |
| - additionalServiceTypeIds: [objectStringId(), objectStringId()], | |
| + additionalServiceTypeIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| reminderId: '2', | |
| - customerId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| attorneyId: mockAttorneyId, | |
| reason: ReasonType.REQUIRED_REPEATS_SERVICE_CLOSURE, | |
| additionalServiceTypeIds: [], | |
| @@ -26,9 +26,9 @@ export const invalidRepeatRemindersDocument = [ | |
| { | |
| caseId: '1', // invalid caseId | |
| reminderId: '1', | |
| - customerId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| attorneyId: mockAttorneyId, | |
| reason: ReasonType.LIKELY_TO_REPEAT_SERVICE, | |
| - additionalServiceTypeIds: [objectStringId(), objectStringId()], | |
| + additionalServiceTypeIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ]; | |
| diff --git a/apps/services-ms/src/repeats/dal/repeat.dal.ts b/apps/services-ms/src/repeats/dal/repeat.dal.ts | |
| index 2ce32abf4..0ae79fa58 100644 | |
| --- a/apps/services-ms/src/repeats/dal/repeat.dal.ts | |
| +++ b/apps/services-ms/src/repeats/dal/repeat.dal.ts | |
| @@ -6,10 +6,10 @@ import { | |
| RepeatData, | |
| UpdateRepeatRequest, | |
| } from '@vinny/services-types'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { GetRepeatsFilterDto } from '../dtos/repeat.dto'; | |
| import { Repeat, RepeatDocument } from '../schemas/repeats.schema'; | |
| -import { objectId, schemaToDto } from '@vinny/helpers'; | |
| +import { schemaToDto } from '@vinny/helpers'; | |
| @Injectable() | |
| export class RepeatDal { | |
| @@ -24,7 +24,7 @@ export class RepeatDal { | |
| } | |
| async getRepeatById(id: string): Promise<RepeatData | null> { | |
| - const repeatFromDb = await this.repeatModel.findOne({ _id: objectId(id) }); | |
| + const repeatFromDb = await this.repeatModel.findOne({ _id: Types.ObjectId(id) }); | |
| if (!repeatFromDb) { | |
| return null; | |
| } | |
| diff --git a/apps/services-ms/src/repeats/schemas/repeats.schema.ts b/apps/services-ms/src/repeats/schemas/repeats.schema.ts | |
| index b7a642076..d4a04c783 100644 | |
| --- a/apps/services-ms/src/repeats/schemas/repeats.schema.ts | |
| +++ b/apps/services-ms/src/repeats/schemas/repeats.schema.ts | |
| @@ -1,8 +1,8 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { RepeatStatus } from '@vinny/services-types'; | |
| -import { Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| +import { objectIdToStringGetter } from './schema.utils'; | |
| @Schema({ _id: false }) | |
| export class AddendumServiceRequest { | |
| @@ -30,7 +30,7 @@ export class SubmittedBy { | |
| @Prop({ type: String, require: true }) | |
| id: string; | |
| - @Prop({ enum: Object.values(Role), type: String, require: false }) | |
| + @Prop({ type: Role }) | |
| type?: Role; | |
| } | |
| @@ -65,16 +65,24 @@ export class Repeat { | |
| id: string; | |
| createdAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| caseId: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| attorneyId: string; | |
| @Prop({ type: SubmittedBy }) | |
| submittedBy: SubmittedBy; | |
| - @Prop({ enum: Object.values(RepeatStatus), require: true, type: String }) | |
| + @Prop({ type: String, enum: RepeatStatus, require: true }) | |
| status: RepeatStatus; | |
| // Todo - change sreason to enum | |
| diff --git a/apps/services-ms/src/repeats/schemas/schema.utils.ts b/apps/services-ms/src/repeats/schemas/schema.utils.ts | |
| new file mode 100644 | |
| index 000000000..9ea72e736 | |
| --- /dev/null | |
| +++ b/apps/services-ms/src/repeats/schemas/schema.utils.ts | |
| @@ -0,0 +1,3 @@ | |
| +import { Types } from 'mongoose'; | |
| + | |
| +export const objectIdToStringGetter = (v: Types.ObjectId): string => v?.toString(); | |
| diff --git a/apps/services-ms/src/repeats/test/repeats.service.spec.ts b/apps/services-ms/src/repeats/test/repeats.service.spec.ts | |
| index 99f7f067e..319cb9508 100644 | |
| --- a/apps/services-ms/src/repeats/test/repeats.service.spec.ts | |
| +++ b/apps/services-ms/src/repeats/test/repeats.service.spec.ts | |
| @@ -3,7 +3,7 @@ import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { RepeatsService } from '../repeats.service'; | |
| import { KafkaProducerModule, KafkaProducerService, KafkaTopics } from '@vinny/kafka-client'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { RepeatsModule } from '../repeats.module'; | |
| import { INestApplication, ValidationPipe } from '@nestjs/common'; | |
| import { | |
| @@ -43,7 +43,6 @@ import { TaskStatus } from '@vinny/scheduler-types'; | |
| import { PaymentsService } from '@vinny/payments'; | |
| import { ActivityLogType } from '@vinny/activity-logs-types'; | |
| import { DataAccessService } from '../../services/data-access.service'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const mockEnv = { | |
| ...mockEnvVars, | |
| @@ -476,7 +475,7 @@ describe('repeats service', () => { | |
| it('should throw error when repeat doesnt exist', async () => { | |
| await expect( | |
| - repeatsService.updateRepeat(objectStringId(), { status: RepeatStatus.APPROVED }), | |
| + repeatsService.updateRepeat(Types.ObjectId().toString(), { status: RepeatStatus.APPROVED }), | |
| ).rejects.toThrowError(`repeat not found`); | |
| }); | |
| }); | |
| @@ -484,7 +483,7 @@ describe('repeats service', () => { | |
| describe('updateRepeatServices', () => { | |
| it('should add service to additional services on repeat', async () => { | |
| const createdRepeat = await repeatsService.createRepeat(MockRepeatRequest); | |
| - const newServiceId = objectStringId(); | |
| + const newServiceId = Types.ObjectId().toString(); | |
| const result = await repeatsService.updateRepeatServices({ | |
| repeatId: createdRepeat.id, | |
| serviceId: newServiceId, | |
| diff --git a/apps/services-ms/src/repeats/test/utils.ts b/apps/services-ms/src/repeats/test/utils.ts | |
| index a4e58f3c2..329040aa6 100644 | |
| --- a/apps/services-ms/src/repeats/test/utils.ts | |
| +++ b/apps/services-ms/src/repeats/test/utils.ts | |
| @@ -11,22 +11,22 @@ import { | |
| } from '@vinny/services-types'; | |
| import { AttorneyStatus, User } from '@vinny/users-types'; | |
| import { omit } from 'lodash'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { mockEnvVars } from '../../cases/test/testing-module'; | |
| -export const testCaseId = objectStringId(); | |
| -export const servicesTypeId = objectStringId(); | |
| -export const testAttorneyId = objectStringId(); | |
| -export const additionalServiceId = objectStringId(); | |
| -export const testRepeatId = objectStringId(); | |
| +export const testCaseId = Types.ObjectId().toString(); | |
| +export const servicesTypeId = Types.ObjectId().toString(); | |
| +export const testAttorneyId = Types.ObjectId().toString(); | |
| +export const additionalServiceId = Types.ObjectId().toString(); | |
| +export const testRepeatId = Types.ObjectId().toString(); | |
| export const MockAttorney = { | |
| id: testAttorneyId, | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| attorneyData: { | |
| practiceAreas: [ | |
| { | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| }, | |
| ], | |
| status: AttorneyStatus.ACTIVE, | |
| @@ -36,7 +36,7 @@ export const MockAttorney = { | |
| export const createMockEventResponse = ( | |
| startDate = new Date(new Date().setDate(new Date().getDate() + 14)).toISOString(), | |
| ): EventResponse => ({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| parentId: testCaseId, | |
| users: [faker.datatype.string()], | |
| name: faker.datatype.string(), | |
| @@ -104,13 +104,13 @@ export const MockRepeatRemoveRequest = { | |
| export const MockRepeatRequest2 = { | |
| ...MockRepeatRequest, | |
| - caseId: objectStringId(), | |
| + caseId: Types.ObjectId().toString(), | |
| }; | |
| export const MockCase = { | |
| id: testCaseId, | |
| - userId: objectStringId(), | |
| - practiceAreaId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| strategyReviewCallComplete: faker.datatype.boolean(), | |
| opposingParty: faker.datatype.string(), | |
| additionalFields: {}, | |
| @@ -118,16 +118,16 @@ export const MockCase = { | |
| }; | |
| export const MockServiceType = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: faker.datatype.string(), | |
| description: faker.datatype.string(), | |
| practiceAreaId: MockCase.practiceAreaId, | |
| - stateIds: [{ id: objectStringId() }], | |
| + stateIds: [{ id: Types.ObjectId().toString() }], | |
| isAddendumOnly: false, | |
| }; | |
| -export const paralegalId = objectStringId(); | |
| -export const paralegalId_2 = objectStringId(); | |
| +export const paralegalId = Types.ObjectId().toString(); | |
| +export const paralegalId_2 = Types.ObjectId().toString(); | |
| export const paralegalUser: User = { | |
| id: paralegalId, | |
| name: { | |
| @@ -136,7 +136,7 @@ export const paralegalUser: User = { | |
| }, | |
| email: faker.internet.email(), | |
| emailAlias: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [], | |
| phone: faker.phone.phoneNumber(), | |
| }; | |
| @@ -149,22 +149,22 @@ export const paralegalUser_2: User = { | |
| }, | |
| email: faker.internet.email(), | |
| emailAlias: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [], | |
| }; | |
| export const mockService = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId: MockCase.userId, | |
| - name: objectStringId(), | |
| - description: objectStringId(), | |
| + name: Types.ObjectId().toString(), | |
| + description: Types.ObjectId().toString(), | |
| caseId: MockCase.id, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| - stage: objectStringId(), | |
| + stage: Types.ObjectId().toString(), | |
| location: { | |
| - state: objectStringId(), | |
| - county: objectStringId(), | |
| + state: Types.ObjectId().toString(), | |
| + county: Types.ObjectId().toString(), | |
| }, | |
| legalTeam: [ | |
| { userId: MockRepeatRequest.attorneyId, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| @@ -172,18 +172,18 @@ export const mockService = { | |
| }; | |
| export const mockOlderServiceWithParalegal = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId: MockCase.userId, | |
| - name: objectStringId(), | |
| - description: objectStringId(), | |
| + name: Types.ObjectId().toString(), | |
| + description: Types.ObjectId().toString(), | |
| caseId: MockCase.id, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| - stage: objectStringId(), | |
| + stage: Types.ObjectId().toString(), | |
| createdAt: new Date('2023-07-10T14:37:13.238Z'), | |
| location: { | |
| - state: objectStringId(), | |
| - county: objectStringId(), | |
| + state: Types.ObjectId().toString(), | |
| + county: Types.ObjectId().toString(), | |
| }, | |
| legalTeam: [ | |
| { userId: MockRepeatRequest.attorneyId, role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY }, | |
| @@ -192,17 +192,17 @@ export const mockOlderServiceWithParalegal = { | |
| }; | |
| export const mockServiceWithParalegal = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| userId: MockCase.userId, | |
| - name: objectStringId(), | |
| - description: objectStringId(), | |
| + name: Types.ObjectId().toString(), | |
| + description: Types.ObjectId().toString(), | |
| caseId: MockCase.id, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| - stage: objectStringId(), | |
| + stage: Types.ObjectId().toString(), | |
| location: { | |
| - state: objectStringId(), | |
| - county: objectStringId(), | |
| + state: Types.ObjectId().toString(), | |
| + county: Types.ObjectId().toString(), | |
| }, | |
| createdAt: new Date(), | |
| legalTeam: [ | |
| @@ -243,7 +243,7 @@ export const MockRepeatResponse = { | |
| }; | |
| export const CaseConfiguration = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| lawmaticsId: faker.datatype.string(), | |
| internalId: MockCase.id, | |
| value: faker.datatype.string(), | |
| @@ -258,7 +258,7 @@ export const MockUser: User = { | |
| last: 'last', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [], | |
| }; | |
| diff --git a/apps/services-ms/src/service-types/dal/service-types.dal.ts b/apps/services-ms/src/service-types/dal/service-types.dal.ts | |
| index e57d4f8d0..f393010dd 100644 | |
| --- a/apps/services-ms/src/service-types/dal/service-types.dal.ts | |
| +++ b/apps/services-ms/src/service-types/dal/service-types.dal.ts | |
| @@ -6,9 +6,8 @@ import { | |
| ReplaceServiceTypeRequest, | |
| UpdateServiceTypeRequest, | |
| } from '@vinny/services-types'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { ServiceType, ServiceTypeDocument } from '../schemas/service-types.schema'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class ServiceTypesDal { | |
| @@ -19,7 +18,7 @@ export class ServiceTypesDal { | |
| async getServiceTypeById(id: string): Promise<ServiceTypeDocument | null> { | |
| return this.serviceTypesModel.findOne({ | |
| - _id: objectId(id), | |
| + _id: Types.ObjectId(id), | |
| }); | |
| } | |
| @@ -53,7 +52,7 @@ export class ServiceTypesDal { | |
| request: UpdateServiceTypeRequest, | |
| ): Promise<ServiceTypeDocument | null> { | |
| return this.serviceTypesModel.findOneAndUpdate( | |
| - { _id: objectId(id) }, | |
| + { _id: Types.ObjectId(id) }, | |
| { | |
| ...request, | |
| }, | |
| @@ -66,7 +65,7 @@ export class ServiceTypesDal { | |
| request: ReplaceServiceTypeRequest, | |
| ): Promise<ServiceTypeDocument | null> { | |
| return this.serviceTypesModel.findOneAndReplace( | |
| - { _id: objectId(id) }, | |
| + { _id: Types.ObjectId(id) }, | |
| { | |
| ...request, | |
| }, | |
| diff --git a/apps/services-ms/src/service-types/schemas/service-types.schema.ts b/apps/services-ms/src/service-types/schemas/service-types.schema.ts | |
| index 440a0731e..4dace05f2 100644 | |
| --- a/apps/services-ms/src/service-types/schemas/service-types.schema.ts | |
| +++ b/apps/services-ms/src/service-types/schemas/service-types.schema.ts | |
| @@ -1,6 +1,5 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ _id: false, versionKey: false }) | |
| class StepForClient { | |
| @@ -25,7 +24,7 @@ class StateIds { | |
| } | |
| const StateIdsSchema = SchemaFactory.createForClass(StateIds); | |
| -@Schema({ timestamps: true, toObject: { getters: true } }) | |
| +@Schema({ timestamps: true }) | |
| export class ServiceType { | |
| id: string; | |
| createdAt: Date; | |
| @@ -43,8 +42,8 @@ export class ServiceType { | |
| @Prop() | |
| category?: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - practiceAreaId: string; | |
| + @Prop({ type: SchemaTypes.ObjectId, required: true }) | |
| + practiceAreaId: Types.ObjectId; | |
| @Prop() | |
| descriptionForClient?: string; | |
| diff --git a/apps/services-ms/src/services/dal/service-note.dal.ts b/apps/services-ms/src/services/dal/service-note.dal.ts | |
| index 6ffdf5c1c..167d77c6a 100644 | |
| --- a/apps/services-ms/src/services/dal/service-note.dal.ts | |
| +++ b/apps/services-ms/src/services/dal/service-note.dal.ts | |
| @@ -1,9 +1,8 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { CreateServiceNotePayload } from '../dtos/service-note.dto'; | |
| import { ServiceNote, ServiceNoteDocument } from '../schemas/service-note.schema'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class ServiceNoteDal { | |
| @@ -15,8 +14,8 @@ export class ServiceNoteDal { | |
| async createServiceNote(noteId: string, payload: CreateServiceNotePayload): Promise<ServiceNote> { | |
| const { serviceId } = payload; | |
| return this.serviceNoteModel.create({ | |
| - _id: objectId(noteId), | |
| - serviceId: objectId(serviceId), | |
| + _id: Types.ObjectId(noteId), | |
| + serviceId: Types.ObjectId(serviceId), | |
| }); | |
| } | |
| } | |
| diff --git a/apps/services-ms/src/services/dal/services.dal.ts b/apps/services-ms/src/services/dal/services.dal.ts | |
| index 403b2f18e..8ecb04e85 100644 | |
| --- a/apps/services-ms/src/services/dal/services.dal.ts | |
| +++ b/apps/services-ms/src/services/dal/services.dal.ts | |
| @@ -10,14 +10,13 @@ import { | |
| } from '@vinny/services-types'; | |
| import { omitBy, isUndefined } from 'lodash'; | |
| import { GetServicesMetadataFilterDto } from '@vinny/services-types'; | |
| -import { FilterQuery, LeanDocument, Model } from 'mongoose'; | |
| +import { LeanDocument, Model, Types } from 'mongoose'; | |
| import { ServiceLean, Service, ServiceDocument, ServiceProgress } from '../schemas/services.schema'; | |
| import { CreateServiceDalData } from './types'; | |
| import { FnLogger } from '@vinny/logger'; | |
| import _ from 'lodash'; | |
| import { ServiceMilestoneItem } from '@vinny/catalog-types'; | |
| import { convertToServiceMetadataDto } from '../utils'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class ServicesDal { | |
| @@ -28,10 +27,10 @@ export class ServicesDal { | |
| async createService(serviceData: CreateServiceDalData): Promise<ServiceLean> { | |
| const service = { | |
| - _id: objectId(serviceData?.serviceId ?? objectStringId()), | |
| - userId: serviceData?.userId, | |
| - caseId: serviceData?.caseId, | |
| - serviceTypeId: serviceData?.serviceTypeId, | |
| + _id: serviceData?.serviceId ?? Types.ObjectId(), | |
| + userId: Types.ObjectId(serviceData?.userId), | |
| + caseId: Types.ObjectId(serviceData?.caseId), | |
| + serviceTypeId: Types.ObjectId(serviceData?.serviceTypeId), | |
| isExtendedByLawmatics: serviceData?.isExtendedByLawmatics, | |
| status: serviceData.status, | |
| name: serviceData?.name, | |
| @@ -42,7 +41,7 @@ export class ServicesDal { | |
| completedDate: serviceData?.completedDate, | |
| practiceAreaAdditionalFields: serviceData?.practiceAreaAdditionalFields, | |
| bundleId: serviceData.bundleId, | |
| - } satisfies Partial<Service>; | |
| + }; | |
| const cleanObject = omitBy(service, isUndefined); | |
| const createdService = (await this.servicesModel.create(cleanObject)).toObject(); | |
| @@ -179,7 +178,7 @@ export class ServicesDal { | |
| return this.convertDocumentToService(serviceDoc); | |
| } | |
| - private buildFilterQuery(filter: GetServicesMetadataFilterDto): FilterQuery<ServiceDocument> { | |
| + private buildFilterQuery(filter: GetServicesMetadataFilterDto) { | |
| const { | |
| userId, | |
| userIds, | |
| @@ -196,19 +195,21 @@ export class ServicesDal { | |
| return { | |
| ...restOfFilter, | |
| ...((userIds || userId) && { | |
| - userId: Array.isArray(userIds) ? { $in: userIds } : userId, | |
| + userId: Array.isArray(userIds) | |
| + ? { $in: userIds.map((id) => Types.ObjectId(id)) } | |
| + : Types.ObjectId(userId), | |
| }), | |
| ...(statuses && { | |
| status: { | |
| $in: statuses, | |
| }, | |
| }), | |
| - ...(caseId && { caseId: caseId }), | |
| - ...(serviceTypeId && { serviceTypeId: serviceTypeId }), | |
| + ...(caseId && { caseId: Types.ObjectId(caseId) }), | |
| + ...(serviceTypeId && { serviceTypeId: Types.ObjectId(serviceTypeId) }), | |
| ...(responsibleAttorneyIds && { | |
| legalTeam: { | |
| $elemMatch: { | |
| - userId: { $in: responsibleAttorneyIds }, | |
| + userId: { $in: responsibleAttorneyIds.map((id) => Types.ObjectId(id)) }, | |
| role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY, | |
| }, | |
| }, | |
| @@ -234,7 +235,7 @@ export class ServicesDal { | |
| async findByIds(ids: string[]): Promise<ServiceLean[]> { | |
| const serviceDocs = await this.servicesModel.find({ | |
| - _id: { $in: ids }, | |
| + _id: { $in: ids.map((id) => Types.ObjectId(id)) }, | |
| }); | |
| return serviceDocs.map((serviceDoc) => this.convertDocumentToService(serviceDoc.toObject())); | |
| } | |
| @@ -243,8 +244,8 @@ export class ServicesDal { | |
| const { practiceAreaId, ids } = filter; | |
| const query = { | |
| - ...(practiceAreaId && { practiceAreaId: practiceAreaId }), | |
| - ...(ids && { _id: { $in: ids } }), | |
| + ...(practiceAreaId && { practiceAreaId: Types.ObjectId(practiceAreaId).toString() }), | |
| + ...(ids && { _id: { $in: ids.map((id) => Types.ObjectId(id)) } }), | |
| }; | |
| const serviceDocs = await this.servicesModel.find(query); | |
| @@ -252,7 +253,7 @@ export class ServicesDal { | |
| } | |
| private convertDocumentToService(service: LeanDocument<ServiceDocument>): ServiceLean { | |
| - if (service?.removedAt) return _.omit(service, 'removedAt') as ServiceLean; | |
| + if (service?.removedAt) return _.omit(service, 'removedAt'); | |
| return service as ServiceLean; | |
| } | |
| } | |
| diff --git a/apps/services-ms/src/services/dal/test/service-closure.dal.spec.ts b/apps/services-ms/src/services/dal/test/service-closure.dal.spec.ts | |
| index 4aa0d32e6..a9eaa109c 100644 | |
| --- a/apps/services-ms/src/services/dal/test/service-closure.dal.spec.ts | |
| +++ b/apps/services-ms/src/services/dal/test/service-closure.dal.spec.ts | |
| @@ -1,12 +1,11 @@ | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { ServiceClosureStatus } from '@vinny/services-types'; | |
| import { ServiceClosuresDal } from '../service-closure.dal'; | |
| import { closeInMongodConnection, defaultMongooseTestModule } from '@vinny/test-utils'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| import { ServiceModule } from '../../services.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('ServiceClosuresDal', () => { | |
| let serviceClosuresDal: ServiceClosuresDal; | |
| @@ -38,12 +37,12 @@ describe('ServiceClosuresDal', () => { | |
| let otherServiceId: string; | |
| beforeEach(async () => { | |
| - serviceId = objectStringId(); | |
| - otherServiceId = objectStringId(); | |
| + serviceId = Types.ObjectId().toString(); | |
| + otherServiceId = Types.ObjectId().toString(); | |
| await expect( | |
| serviceClosuresDal.create({ | |
| - serviceId: objectStringId(), | |
| + serviceId: Types.ObjectId().toString(), | |
| }), | |
| ).resolves.not.toThrow(); | |
| diff --git a/apps/services-ms/src/services/schemas/service-closure.schema.ts b/apps/services-ms/src/services/schemas/service-closure.schema.ts | |
| index edd0ea128..ff08bee65 100644 | |
| --- a/apps/services-ms/src/services/schemas/service-closure.schema.ts | |
| +++ b/apps/services-ms/src/services/schemas/service-closure.schema.ts | |
| @@ -1,11 +1,11 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler, objectIdsPropHandler } from '@vinny/helpers'; | |
| +import { objectIdToStringGetter, objectIdsToStringsGetter } from '@vinny/helpers'; | |
| import { | |
| NoticeOfWithdrawal, | |
| ServiceClosureStatus, | |
| ServiceWithdrawalInitiator, | |
| } from '@vinny/services-types'; | |
| -import { Types } from 'mongoose'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ _id: false, id: false }) | |
| class AttorneyCaseReview { | |
| @@ -29,13 +29,13 @@ const AttorneyCaseReviewSchema = SchemaFactory.createForClass(AttorneyCaseReview | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| class MilestoneProgressItem { | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId, get: objectIdToStringGetter }) | |
| serviceMilestoneId: string; | |
| @Prop() | |
| milestonePercentCompleted?: number; | |
| - @Prop(objectIdsPropHandler({ default: undefined })) | |
| + @Prop({ type: [SchemaTypes.ObjectId], default: undefined, get: objectIdsToStringsGetter }) | |
| documentIds?: string[]; | |
| } | |
| @@ -45,7 +45,11 @@ const MilestoneProgressItemSchema = SchemaFactory.createForClass(MilestoneProgre | |
| export class ServiceClosure { | |
| _id: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| serviceId: string; | |
| @Prop() | |
| diff --git a/apps/services-ms/src/services/schemas/service-note.schema.ts b/apps/services-ms/src/services/schemas/service-note.schema.ts | |
| index 65fd07322..129288707 100644 | |
| --- a/apps/services-ms/src/services/schemas/service-note.schema.ts | |
| +++ b/apps/services-ms/src/services/schemas/service-note.schema.ts | |
| @@ -1,16 +1,15 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, Types, SchemaTypes } from 'mongoose'; | |
| -@Schema({ timestamps: true, toObject: { getters: true } }) | |
| +@Schema({ timestamps: true }) | |
| export class ServiceNote { | |
| _id: Types.ObjectId; | |
| id: string; | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - serviceId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + serviceId: Types.ObjectId; | |
| } | |
| export type ServiceNoteDocument = ServiceNote & Document; | |
| diff --git a/apps/services-ms/src/services/schemas/services.schema.ts b/apps/services-ms/src/services/schemas/services.schema.ts | |
| index cf6d9401c..5e1f72d86 100644 | |
| --- a/apps/services-ms/src/services/schemas/services.schema.ts | |
| +++ b/apps/services-ms/src/services/schemas/services.schema.ts | |
| @@ -3,7 +3,7 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { OmitType } from '@nestjs/swagger'; | |
| import { LocationObject } from '@vinny/lawmatics-types'; | |
| import { LegalTeamMemberRole, ServiceStatus } from '@vinny/services-types'; | |
| -import { objectIdPropHandler, objectIdsPropHandler } from '@vinny/helpers'; | |
| +import { objectIdsToStringsGetter, objectIdToStringGetter } from '@vinny/helpers'; | |
| import { calculatePercentCompletedOfService } from '@vinny/services-utils'; | |
| import { ServiceMilestoneItem } from '@vinny/catalog-types'; | |
| @@ -12,14 +12,14 @@ export class LegalTeamMember { | |
| @Prop({ type: String }) | |
| userId: string; | |
| - @Prop({ enum: Object.values(LegalTeamMemberRole), type: String }) | |
| + @Prop({ enum: LegalTeamMemberRole, type: String }) | |
| role: LegalTeamMemberRole; | |
| } | |
| export const LegalTeamMemberSchema = SchemaFactory.createForClass(LegalTeamMember); | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class MilestoneProgress { | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId, get: objectIdToStringGetter }) | |
| serviceMilestoneId: string; | |
| @Prop({ type: Number }) | |
| @@ -28,12 +28,13 @@ export class MilestoneProgress { | |
| @Prop({ type: Date, required: true }) | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ type: SchemaTypes.ObjectId, get: objectIdToStringGetter, required: true }) | |
| updatedBy: string; | |
| - @Prop(objectIdsPropHandler()) | |
| + @Prop({ type: [SchemaTypes.ObjectId], get: objectIdsToStringsGetter }) | |
| documentIds?: string[]; | |
| } | |
| + | |
| const MilestoneDataSchema = SchemaFactory.createForClass(MilestoneProgress); | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| @@ -45,13 +46,7 @@ export class ServiceProgress { | |
| type: SchemaTypes.Map, | |
| of: MilestoneDataSchema, | |
| default: {}, | |
| - get: (v: Map<string, MilestoneProgress & Document>) => { | |
| - const ret: Record<string, MilestoneProgress> = {}; | |
| - for (const [key, value] of v.entries()) { | |
| - ret[key] = value.toObject(); | |
| - } | |
| - return ret; | |
| - }, | |
| + get: (v: Map<string, MilestoneProgress>) => Object.fromEntries(v.entries()), | |
| }) | |
| milestones: Record<string, MilestoneProgress>; | |
| } | |
| @@ -65,16 +60,16 @@ export class Service { | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - userId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + userId: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - serviceTypeId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + serviceTypeId: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - caseId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + caseId: Types.ObjectId; | |
| - @Prop({ required: false, enum: Object.values(ServiceStatus), type: String }) | |
| + @Prop({ required: false, enum: ServiceStatus, type: String }) | |
| status?: ServiceStatus; | |
| @Prop({ required: true, type: Boolean }) | |
| @@ -113,9 +108,9 @@ export class Service { | |
| @Prop({ | |
| type: ServiceProgressSchema, | |
| }) | |
| - progress?: ServiceProgressDocument; | |
| + progress?: ServiceProgress; | |
| } | |
| -export type ServiceProgressDocument = ServiceProgress & Document; | |
| + | |
| export type ServiceDocument = Service & Document; | |
| export const ServiceSchema = SchemaFactory.createForClass(Service); | |
| diff --git a/apps/services-ms/src/services/service-notes.service.ts b/apps/services-ms/src/services/service-notes.service.ts | |
| index 891023cff..af8ba1bab 100644 | |
| --- a/apps/services-ms/src/services/service-notes.service.ts | |
| +++ b/apps/services-ms/src/services/service-notes.service.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Inject, Injectable } from '@nestjs/common'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { LawmaticsMsClient } from '../clients/lawmatics-ms-client/lawmatics-ms.client'; | |
| import { ServiceNoteDal } from './dal/service-note.dal'; | |
| import { CreateServiceNotePayload, ServiceNoteDto } from './dtos/service-note.dto'; | |
| @@ -18,7 +18,7 @@ export class ServiceNotesService { | |
| }); | |
| try { | |
| - const serviceNoteId = objectStringId(); | |
| + const serviceNoteId = Types.ObjectId().toString(); | |
| await this.lawmaticsMsClient.createServiceNote({ | |
| ...payload, | |
| diff --git a/apps/services-ms/src/services/services.service.ts b/apps/services-ms/src/services/services.service.ts | |
| index d53abdb81..37aa5fca1 100644 | |
| --- a/apps/services-ms/src/services/services.service.ts | |
| +++ b/apps/services-ms/src/services/services.service.ts | |
| @@ -30,7 +30,7 @@ import { | |
| UpdateServiceRequest, | |
| } from '@vinny/services-types'; | |
| import _ from 'lodash'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { v4 as uuid } from 'uuid'; | |
| import { AdministrationService } from '../administration/administration.service'; | |
| import { CasesService } from '../cases/cases.service'; | |
| @@ -85,7 +85,7 @@ export class ServicesService { | |
| await this.validateCreateService(caseForService, payload, serviceType); | |
| const { status } = payload; | |
| - const serviceId = objectStringId(); | |
| + const serviceId = Types.ObjectId().toString(); | |
| const isExodusAttorney = getIsExodusAttorney(this.configService); | |
| if (!SYNCED_LAWMATICS_STATUSES.includes(status)) { | |
| diff --git a/apps/services-ms/src/services/test/mock-generator.ts b/apps/services-ms/src/services/test/mock-generator.ts | |
| index f593a43cd..b652dc5e1 100644 | |
| --- a/apps/services-ms/src/services/test/mock-generator.ts | |
| +++ b/apps/services-ms/src/services/test/mock-generator.ts | |
| @@ -11,7 +11,7 @@ import { | |
| CreateCaseNotePayload, | |
| CaseNoteDto, | |
| } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { LawmaticsMsClient } from '../../clients/lawmatics-ms-client/lawmatics-ms.client'; | |
| import { | |
| CreateLawmaticsPracticeAreaRequest, | |
| @@ -35,7 +35,7 @@ export const upsertServiceType = async ({ | |
| name: serviceName ?? faker.name.findName(), | |
| description: serviceDescription ?? faker.lorem.words(10), | |
| category: faker.lorem.word(), | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| stateIds: [{ id: '1' }], | |
| }); | |
| }; | |
| @@ -43,15 +43,15 @@ export const upsertServiceType = async ({ | |
| const createLegalTeamMock = (): LegalTeamMember[] => { | |
| return [ | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.CASE_MANAGER, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.RESPONSIBLE_ATTORNEY, | |
| }, | |
| { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: LegalTeamMemberRole.PARALEGAL, | |
| }, | |
| ]; | |
| @@ -72,13 +72,13 @@ export const getCreateLawmaticsServiceMock = ({ | |
| practiceAreaId?: string; | |
| }): ServiceData => { | |
| return { | |
| - id: id ?? objectStringId(), | |
| + id: id ?? Types.ObjectId().toString(), | |
| name: name ?? faker.name.findName(), | |
| legalTeam: legalTeam ?? createLegalTeamMock(), | |
| - practiceAreaId: practiceAreaId ?? objectStringId(), | |
| - userId: userId ?? objectStringId(), | |
| - caseId: caseId ?? objectStringId(), | |
| - serviceTypeId: serviceTypeId ?? objectStringId(), | |
| + practiceAreaId: practiceAreaId ?? Types.ObjectId().toString(), | |
| + userId: userId ?? Types.ObjectId().toString(), | |
| + caseId: caseId ?? Types.ObjectId().toString(), | |
| + serviceTypeId: serviceTypeId ?? Types.ObjectId().toString(), | |
| status: ServiceStatus.COMPLETED, | |
| location: location ?? { | |
| state: faker.address.state(), | |
| diff --git a/apps/services-ms/src/services/test/utils.ts b/apps/services-ms/src/services/test/utils.ts | |
| index 0f50724c5..7e60546fc 100644 | |
| --- a/apps/services-ms/src/services/test/utils.ts | |
| +++ b/apps/services-ms/src/services/test/utils.ts | |
| @@ -14,7 +14,7 @@ import { | |
| ServiceWithdrawalInitiator, | |
| } from '@vinny/services-types'; | |
| import { UserDto } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ServiceModule } from '../services.module'; | |
| import { ServiceResponseObject } from '@vinny/lawmatics-types'; | |
| import faker from '@faker-js/faker'; | |
| @@ -35,14 +35,14 @@ export const getServicesTestingModule = async ( | |
| }; | |
| export const user: UserDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'Yana', | |
| last: 'Banana', | |
| }, | |
| email: '[email protected]', | |
| phone: '+9725465766', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const updateInput = { | |
| @@ -132,15 +132,15 @@ export function createPendingServiceRequestMock( | |
| }; | |
| } | |
| -export const caseId = objectStringId(); | |
| -export const userId = objectStringId(); | |
| -export const attorneyId = objectStringId(); | |
| -export const paralegalId = objectStringId(); | |
| -export const serviceId = objectStringId(); | |
| -export const secondServiceId = objectStringId(); | |
| -export const serviceTypeId = objectStringId(); | |
| -export const bundleId = objectStringId(); | |
| -export const oldBundleId = objectStringId(); | |
| +export const caseId = Types.ObjectId().toString(); | |
| +export const userId = Types.ObjectId().toString(); | |
| +export const attorneyId = Types.ObjectId().toString(); | |
| +export const paralegalId = Types.ObjectId().toString(); | |
| +export const serviceId = Types.ObjectId().toString(); | |
| +export const secondServiceId = Types.ObjectId().toString(); | |
| +export const serviceTypeId = Types.ObjectId().toString(); | |
| +export const bundleId = Types.ObjectId().toString(); | |
| +export const oldBundleId = Types.ObjectId().toString(); | |
| export function createServiceRequestMock(options: { | |
| practiceAreaId: string; | |
| @@ -158,7 +158,7 @@ export function createServiceRequestMock(options: { | |
| }, | |
| status: status || ServiceStatus.OPEN, | |
| legalTeam, | |
| - serviceTypeId: serviceTypeId || objectStringId(), | |
| + serviceTypeId: serviceTypeId || Types.ObjectId().toString(), | |
| userId: user.id, | |
| caseId, | |
| practiceAreaId, | |
| @@ -168,7 +168,7 @@ export function createServiceRequestMock(options: { | |
| export function openServiceCreateRequestMock(serviceId?: string): CreateServiceDalData { | |
| return { | |
| serviceId: serviceId, | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| userId, | |
| caseId, | |
| status: ServiceStatus.OPEN, | |
| @@ -201,7 +201,7 @@ export function createServiceResponseMock(id: string): ServiceResponseObject { | |
| export function eventsMockResponse(parentId: string): EventResponse { | |
| return { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| parentId, | |
| name: faker.datatype.string(), | |
| eventType: EventType.EVENT, | |
| @@ -244,26 +244,26 @@ export const emptyLegalTeamAtPosition0 = 'legalTeam.0.userId should not be empty | |
| export const emptyLegalTeamAtPosition1 = 'legalTeam.1.userId should not be empty'; | |
| export const openServiceDto1: ServiceDto = { | |
| - id: objectStringId(), | |
| - caseId: objectStringId(), | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| }; | |
| export const openServiceDto2: ServiceDto = { | |
| - id: objectStringId(), | |
| - caseId: objectStringId(), | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.OPEN, | |
| }; | |
| export const pendingServiceDto: ServiceDto = { | |
| - id: objectStringId(), | |
| - caseId: objectStringId(), | |
| - userId: objectStringId(), | |
| - serviceTypeId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| + userId: Types.ObjectId().toString(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| status: ServiceStatus.PENDING, | |
| }; | |
| @@ -292,14 +292,18 @@ export const serviceClosureDto3: ServiceClosureDto = { | |
| percentCompleted: 85, | |
| milestonesProgressList: [ | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 70, | |
| - documentIds: [objectStringId(), objectStringId(), objectStringId()], | |
| + documentIds: [ | |
| + Types.ObjectId().toString(), | |
| + Types.ObjectId().toString(), | |
| + Types.ObjectId().toString(), | |
| + ], | |
| updatedAt: new Date(), | |
| updatedBy: user.id, | |
| }, | |
| { | |
| - serviceMilestoneId: objectStringId(), | |
| + serviceMilestoneId: Types.ObjectId().toString(), | |
| milestonePercentCompleted: 100, | |
| updatedAt: new Date(), | |
| updatedBy: user.id, | |
| diff --git a/apps/services-ms/src/tasks/dal/schemas/tasks.schema.ts b/apps/services-ms/src/tasks/dal/schemas/tasks.schema.ts | |
| index 390651478..08f7719ac 100644 | |
| --- a/apps/services-ms/src/tasks/dal/schemas/tasks.schema.ts | |
| +++ b/apps/services-ms/src/tasks/dal/schemas/tasks.schema.ts | |
| @@ -1,6 +1,5 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, Types, SchemaTypes } from 'mongoose'; | |
| @Schema({ timestamps: true, id: true, toObject: { getters: true } }) | |
| export class Task { | |
| @@ -9,11 +8,11 @@ export class Task { | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - createdByUserId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + createdByUserId: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - serviceId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + serviceId: Types.ObjectId; | |
| @Prop({ required: true, type: String }) | |
| taskName: string; | |
| diff --git a/apps/services-ms/src/tasks/dal/tasks.dal.ts b/apps/services-ms/src/tasks/dal/tasks.dal.ts | |
| index 16d887232..8b4334091 100644 | |
| --- a/apps/services-ms/src/tasks/dal/tasks.dal.ts | |
| +++ b/apps/services-ms/src/tasks/dal/tasks.dal.ts | |
| @@ -1,7 +1,7 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { CreateTaskDto, FilterTasksDto } from '@vinny/services-types'; | |
| -import { FilterQuery, Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { Task, TaskDocument } from './schemas/tasks.schema'; | |
| @Injectable() | |
| @@ -20,13 +20,13 @@ export class TasksDal { | |
| return (await this.tasksModel.find(query)).map((task) => task.toObject()); | |
| } | |
| - private constructFindQuery(filter: FilterTasksDto): FilterQuery<TaskDocument> { | |
| + private constructFindQuery(filter: FilterTasksDto) { | |
| const tasksQuery = { | |
| ...(filter.createdByUserId && { | |
| - createdByUserId: filter.createdByUserId, | |
| + createdByUserId: Types.ObjectId(filter.createdByUserId), | |
| }), | |
| ...(filter.servicesIds && { | |
| - serviceId: { $in: filter.servicesIds }, | |
| + serviceId: { $in: filter.servicesIds.map((id) => Types.ObjectId(id)) }, | |
| }), | |
| }; | |
| return tasksQuery; | |
| diff --git a/apps/services-ms/src/tasks/test/tasks.service.spec.ts b/apps/services-ms/src/tasks/test/tasks.service.spec.ts | |
| index 19cf09a1e..5319b1642 100644 | |
| --- a/apps/services-ms/src/tasks/test/tasks.service.spec.ts | |
| +++ b/apps/services-ms/src/tasks/test/tasks.service.spec.ts | |
| @@ -4,12 +4,11 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { TasksDal } from '../dal/tasks.dal'; | |
| import { Task, TaskDocument } from '../dal/schemas/tasks.schema'; | |
| import { TasksService } from '../tasks.service'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import nock from 'nock'; | |
| import { createTaskMock, createTaskMockResponse } from './utils'; | |
| import { CreateTaskDto } from '@vinny/services-types'; | |
| import { TaskModule } from '../tasks.module'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const ENV_VARS: Record<string, string> = { | |
| LAWMATICS_MS_URL: 'http://lawmatics.ms', | |
| @@ -61,8 +60,8 @@ describe('TasksService', () => { | |
| id: createdTask.id, | |
| taskName: createTaskMock.taskName, | |
| dueDate: createTaskMock?.dueDate, | |
| - createdByUserId: createTaskMock.createdByUserId, | |
| - serviceId: createTaskMock.serviceId, | |
| + createdByUserId: Types.ObjectId(createTaskMock.createdByUserId), | |
| + serviceId: Types.ObjectId(createTaskMock.serviceId), | |
| description: createTaskMock.description, | |
| createdAt: expect.any(Date), | |
| updatedAt: expect.any(Date), | |
| @@ -96,7 +95,7 @@ describe('TasksService', () => { | |
| describe('findAll', () => { | |
| describe('success', () => { | |
| it('should return all tasks related to createdByUserId', async () => { | |
| - const commonCreatedByUserId = objectStringId(); | |
| + const commonCreatedByUserId = Types.ObjectId().toString(); | |
| const createTaskReq1 = { ...createTaskMock, createdByUserId: commonCreatedByUserId }; | |
| const createTaskReq2 = { ...createTaskMock, createdByUserId: commonCreatedByUserId }; | |
| const createdTask1 = await TaskModel.create(createTaskReq1); | |
| @@ -112,7 +111,7 @@ describe('TasksService', () => { | |
| }); | |
| it('should return all tasks related to serviceId', async () => { | |
| - const commonServiceId = objectStringId(); | |
| + const commonServiceId = Types.ObjectId().toString(); | |
| const createTaskReq1 = { ...createTaskMock, serviceId: commonServiceId }; | |
| const createTaskReq2 = { ...createTaskMock, serviceId: commonServiceId }; | |
| const createdTask1 = await TaskModel.create(createTaskReq1); | |
| @@ -128,7 +127,7 @@ describe('TasksService', () => { | |
| }); | |
| it('should return empty array, not found on this filter', async () => { | |
| - const createByUserIdFilter = objectStringId(); | |
| + const createByUserIdFilter = Types.ObjectId().toString(); | |
| const createdTask1 = await TaskModel.create(createTaskMock); | |
| const filter = { createdByUserId: createByUserIdFilter }; | |
| diff --git a/apps/services-ms/src/tasks/test/utils.ts b/apps/services-ms/src/tasks/test/utils.ts | |
| index 9a42c1a7b..b9e076e57 100644 | |
| --- a/apps/services-ms/src/tasks/test/utils.ts | |
| +++ b/apps/services-ms/src/tasks/test/utils.ts | |
| @@ -1,14 +1,14 @@ | |
| import { CreateTaskDataResponse } from '@vinny/lawmatics-types'; | |
| import { CreateTaskDto } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const createTaskMock: CreateTaskDto = { | |
| - createdByUserId: objectStringId(), | |
| - serviceId: objectStringId(), | |
| + createdByUserId: Types.ObjectId().toString(), | |
| + serviceId: Types.ObjectId().toString(), | |
| taskName: 'test', | |
| description: 'test', | |
| dueDate: new Date(), | |
| - assignTo: [objectStringId()], | |
| + assignTo: [Types.ObjectId().toString()], | |
| }; | |
| export const createTaskMockResponse: CreateTaskDataResponse = { | |
| diff --git a/apps/stats-ms/src/attorneys-review/dal/attorney-review.dal.ts b/apps/stats-ms/src/attorneys-review/dal/attorney-review.dal.ts | |
| index 04bd45e38..b50e7e7fd 100644 | |
| --- a/apps/stats-ms/src/attorneys-review/dal/attorney-review.dal.ts | |
| +++ b/apps/stats-ms/src/attorneys-review/dal/attorney-review.dal.ts | |
| @@ -1,5 +1,5 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { AttorneyReview, AttorneyReviewDocument } from './schema/attorney-review.schema'; | |
| import { | |
| @@ -8,7 +8,6 @@ import { | |
| UpdateAttorneyReviewDto, | |
| } from '@vinny/stats-types'; | |
| import { SortOrder } from '@vinny/pagination'; | |
| -import { objectId } from '@vinny/helpers'; | |
| @Injectable() | |
| export class AttorneyReviewDal { | |
| @@ -62,8 +61,8 @@ export class AttorneyReviewDal { | |
| private async buildFindQuery(filter: FilterAttorneyReviewDto) { | |
| const query = { | |
| - ...(filter.attorneyId && { attorneyId: filter.attorneyId }), | |
| - ...(filter.customerId && { customerId: filter.customerId }), | |
| + ...(filter.attorneyId && { attorneyId: Types.ObjectId(filter.attorneyId) }), | |
| + ...(filter.customerId && { customerId: Types.ObjectId(filter.customerId) }), | |
| ...(filter.scores && { score: { $in: filter.scores } }), | |
| ...(filter.isHide !== undefined && { isHide: filter.isHide }), | |
| ...(filter.minReviewDate && { reviewDate: { $gte: filter.minReviewDate } }), | |
| @@ -92,7 +91,7 @@ export class AttorneyReviewDal { | |
| async getAverageScoreByAttorneyId(attorneyId: string): Promise<number> { | |
| const result = await this.attorneyReviewModel.aggregate([ | |
| - { $match: { attorneyId: objectId(attorneyId), removedAt: null } }, | |
| + { $match: { attorneyId: new Types.ObjectId(attorneyId), removedAt: null } }, | |
| { | |
| $group: { | |
| _id: null, | |
| diff --git a/apps/stats-ms/src/attorneys-review/dal/schema/attorney-review.schema.ts b/apps/stats-ms/src/attorneys-review/dal/schema/attorney-review.schema.ts | |
| index 5b56fd036..77d1cce98 100644 | |
| --- a/apps/stats-ms/src/attorneys-review/dal/schema/attorney-review.schema.ts | |
| +++ b/apps/stats-ms/src/attorneys-review/dal/schema/attorney-review.schema.ts | |
| @@ -1,7 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { Exclude } from 'class-transformer'; | |
| -import { Document, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ timestamps: true, autoIndex: true, toObject: { getters: true } }) | |
| export class AttorneyReview { | |
| @@ -9,11 +8,11 @@ export class AttorneyReview { | |
| id: string; | |
| createdAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| - attorneyId: string; | |
| + @Prop({ required: true, index: true, type: SchemaTypes.ObjectId }) | |
| + attorneyId: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - customerId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + customerId: Types.ObjectId; | |
| @Prop({ required: true }) | |
| score: number; | |
| diff --git a/apps/stats-ms/src/attorneys-review/test/attorney-review.service.spec.ts b/apps/stats-ms/src/attorneys-review/test/attorney-review.service.spec.ts | |
| index b3793c482..e1d3b7bc0 100644 | |
| --- a/apps/stats-ms/src/attorneys-review/test/attorney-review.service.spec.ts | |
| +++ b/apps/stats-ms/src/attorneys-review/test/attorney-review.service.spec.ts | |
| @@ -24,10 +24,9 @@ import { | |
| CreateAttorneyReviewDto, | |
| FilterAttorneyReviewDto, | |
| } from '@vinny/stats-types'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { InternalServerErrorException, NotFoundException } from '@nestjs/common'; | |
| import { SortOrder } from '@vinny/pagination'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('AttorneysReviewService', () => { | |
| let attorneysReviewService: AttorneysReviewService; | |
| @@ -79,12 +78,12 @@ describe('AttorneysReviewService', () => { | |
| const expectedReview = { | |
| ...createAttorneyReviewDto, | |
| id: createdAttorneyReview.id, | |
| - attorneyId: createAttorneyReviewDto.attorneyId, | |
| - customerId: createAttorneyReviewDto.customerId, | |
| + attorneyId: Types.ObjectId(createAttorneyReviewDto.attorneyId), | |
| + customerId: Types.ObjectId(createAttorneyReviewDto.customerId), | |
| createdAt: expect.any(Date), | |
| updatedAt: expect.any(Date), | |
| removedAt: null, | |
| - } satisfies Partial<AttorneyReview>; | |
| + }; | |
| expect(createdAttorneyReview).toEqual(expect.objectContaining(expectedReview)); | |
| }); | |
| @@ -118,12 +117,12 @@ describe('AttorneysReviewService', () => { | |
| const expectedReview = { | |
| ...updateAttorneyReviewData, | |
| id: createdAttorneyReview.id, | |
| - attorneyId: createAttorneyReviewDto.attorneyId, | |
| - customerId: createAttorneyReviewDto.customerId, | |
| + attorneyId: Types.ObjectId(createAttorneyReviewDto.attorneyId), | |
| + customerId: Types.ObjectId(createAttorneyReviewDto.customerId), | |
| createdAt: expect.any(Date), | |
| updatedAt: expect.any(Date), | |
| removedAt: null, | |
| - } satisfies Partial<AttorneyReview>; | |
| + }; | |
| expect(updatedAttorneyReview).toEqual(expect.objectContaining(expectedReview)); | |
| }); | |
| @@ -131,7 +130,7 @@ describe('AttorneysReviewService', () => { | |
| describe('fail', () => { | |
| it('Should not update attorney review when review id not found', async () => { | |
| - const fakeAttorneyId = objectStringId(); | |
| + const fakeAttorneyId = Types.ObjectId().toString(); | |
| await attorneyReviewModel.create(createAttorneyReviewDto); | |
| await expect( | |
| attorneysReviewService.update(fakeAttorneyId, attorneyReviewDto), | |
| @@ -152,7 +151,7 @@ describe('AttorneysReviewService', () => { | |
| describe('fail', () => { | |
| it('Should throw not found error, fake id', async () => { | |
| await attorneyReviewModel.create(createAttorneyReviewDto); | |
| - const fakeId = objectStringId(); | |
| + const fakeId = Types.ObjectId().toString(); | |
| await expect(attorneysReviewService.findById(fakeId)).rejects.toThrowError( | |
| NotFoundException, | |
| ); | |
| diff --git a/apps/stats-ms/src/attorneys-review/test/utils.ts b/apps/stats-ms/src/attorneys-review/test/utils.ts | |
| index 87484e0d2..683e21cd4 100644 | |
| --- a/apps/stats-ms/src/attorneys-review/test/utils.ts | |
| +++ b/apps/stats-ms/src/attorneys-review/test/utils.ts | |
| @@ -6,7 +6,7 @@ import { | |
| CreateAttorneyReviewDto, | |
| CreateAttorneyReviewRequestDto, | |
| } from '@vinny/stats-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { AttorneyReview, AttorneyReviewSchema } from '../dal/schema/attorney-review.schema'; | |
| import { ConfigModule, ConfigService } from '@nestjs/config'; | |
| import { rootMongooseTestModule } from '@vinny/test-utils'; | |
| @@ -18,7 +18,7 @@ import { MockConfigService } from '@vinny/test-utils'; | |
| import { AttorneysReviewController } from '../attorney-review.controller'; | |
| import faker from '@faker-js/faker'; | |
| -export const mockAttorneyId = objectStringId(); | |
| +export const mockAttorneyId = Types.ObjectId().toString(); | |
| export const generateMockCreateAttorneyReviewDto = ( | |
| reviewDate?: Date, | |
| @@ -28,7 +28,7 @@ export const generateMockCreateAttorneyReviewDto = ( | |
| ): CreateAttorneyReviewDto => { | |
| const attorneyReview: CreateAttorneyReviewDto = { | |
| attorneyId: mockAttorneyId, | |
| - customerId: objectStringId(), | |
| + customerId: Types.ObjectId().toString(), | |
| score: score || 5, | |
| reviewDate: reviewDate || new Date(), | |
| comment: 'test', | |
| @@ -45,7 +45,7 @@ export const generateMockAttorneyReviewDto = ( | |
| const { isRemoved, isHide, ...rest } = createAttorneyReviewReq; | |
| const attorneyReview: AttorneyReviewDto = { | |
| ...rest, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| isHide: isHide ? isHide : false, | |
| removedAt: isRemoved ? new Date() : null, | |
| createdAt: faker.date.past(), | |
| diff --git a/apps/stats-ms/src/attorneys-stats/dal/attorneys-stats.dal.ts b/apps/stats-ms/src/attorneys-stats/dal/attorneys-stats.dal.ts | |
| index 99459063b..e7a590c3c 100644 | |
| --- a/apps/stats-ms/src/attorneys-stats/dal/attorneys-stats.dal.ts | |
| +++ b/apps/stats-ms/src/attorneys-stats/dal/attorneys-stats.dal.ts | |
| @@ -1,7 +1,7 @@ | |
| import { Injectable, OnApplicationBootstrap } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| import { FlareLogger, FnLogger } from '@vinny/logger'; | |
| -import { FilterQuery, isValidObjectId, Model } from 'mongoose'; | |
| +import { FilterQuery, isValidObjectId, Model, Types } from 'mongoose'; | |
| import { | |
| AttorneyStatsMirror, | |
| AttorneyStatsMirrorDocument, | |
| @@ -88,14 +88,14 @@ export class AttorneyStatsDal implements OnApplicationBootstrap { | |
| async findByMarbleId(marbleId: string): Promise<AttorneyStatsEntity | null> { | |
| const model = await this.getActiveModel(); | |
| - const response = await model.findOne({ marbleId: marbleId }); | |
| + const response = await model.findOne({ marbleId: Types.ObjectId(marbleId) }); | |
| return response && this.documentToEntity(response); | |
| } | |
| async getBackupRecordByMarbleId(marbleId: string): Promise<AttorneyStatsEntity | null> { | |
| const model = await this.getBackupModel(); | |
| - const response = await model.findOne({ marbleId: marbleId }); | |
| + const response = await model.findOne({ marbleId: Types.ObjectId(marbleId) }); | |
| return response && this.documentToEntity(response); | |
| } | |
| diff --git a/apps/stats-ms/src/attorneys-stats/dal/schemas/attorney-stats-mirror.schema.ts b/apps/stats-ms/src/attorneys-stats/dal/schemas/attorney-stats-mirror.schema.ts | |
| index 4639de9db..0b3be3034 100644 | |
| --- a/apps/stats-ms/src/attorneys-stats/dal/schemas/attorney-stats-mirror.schema.ts | |
| +++ b/apps/stats-ms/src/attorneys-stats/dal/schemas/attorney-stats-mirror.schema.ts | |
| @@ -1,16 +1,15 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { Months } from '@vinny/stats-types'; | |
| -import { Document, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| -@Schema({ timestamps: true, autoIndex: true, toObject: { getters: true } }) | |
| +@Schema({ timestamps: true, autoIndex: true }) | |
| export class AttorneyStatsMirror { | |
| _id: Types.ObjectId; | |
| id: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - marbleId: string; | |
| + @Prop({ type: SchemaTypes.ObjectId, required: true }) | |
| + marbleId: Types.ObjectId; | |
| @Prop({ required: true }) | |
| activeClients: number; | |
| diff --git a/apps/stats-ms/src/attorneys-stats/dal/schemas/attorney-stats.schema.ts b/apps/stats-ms/src/attorneys-stats/dal/schemas/attorney-stats.schema.ts | |
| index 4a56fd5aa..1067781cd 100644 | |
| --- a/apps/stats-ms/src/attorneys-stats/dal/schemas/attorney-stats.schema.ts | |
| +++ b/apps/stats-ms/src/attorneys-stats/dal/schemas/attorney-stats.schema.ts | |
| @@ -1,16 +1,15 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { Months } from '@vinny/stats-types'; | |
| -import { Document, Types } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| -@Schema({ timestamps: true, autoIndex: true, toObject: { getters: true } }) | |
| +@Schema({ timestamps: true, autoIndex: true }) | |
| export class AttorneyStats { | |
| _id: Types.ObjectId; | |
| id: string; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - marbleId: string; | |
| + @Prop({ type: SchemaTypes.ObjectId, required: true }) | |
| + marbleId: Types.ObjectId; | |
| @Prop({ required: true }) | |
| activeClients: number; | |
| diff --git a/apps/stats-ms/src/attorneys-stats/test/utils.ts b/apps/stats-ms/src/attorneys-stats/test/utils.ts | |
| index 6fb31c7c3..be5cb4d75 100644 | |
| --- a/apps/stats-ms/src/attorneys-stats/test/utils.ts | |
| +++ b/apps/stats-ms/src/attorneys-stats/test/utils.ts | |
| @@ -1,5 +1,5 @@ | |
| import { S3CreatedPayload, VinnyS3Module, VinnyS3Service } from '@vinny/vinny-s3'; | |
| -import { objectStringId, objectId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { getLogger, rootMongooseTestModule } from '@vinny/test-utils'; | |
| @@ -137,9 +137,10 @@ export const getS3Payload = (validation: string): S3CreatedPayload => { | |
| } | |
| }; | |
| -export const attorneyMarbleId1 = '62c1abbdd508cd06f58b26fa'; | |
| +export const attorneyMarbleId1 = Types.ObjectId('62c1abbdd508cd06f58b26fa'); | |
| + | |
| +export const attorneyMarbleId2 = Types.ObjectId('62c1abbfd508cd78818b26fd'); | |
| -export const attorneyMarbleId2 = '62c1abbfd508cd78818b26fd'; | |
| //DB results | |
| export const attorneyStatsEntity = { | |
| @@ -198,7 +199,7 @@ export const attorneyStatsEntity2 = { | |
| }; | |
| export const ConfigData = { | |
| - _id: objectId(objectStringId()), | |
| + _id: Types.ObjectId(), | |
| attorneyStats: true, | |
| AttorneyStatsMirror: false, | |
| }; | |
| diff --git a/apps/stats-ms/src/feedback/dal/feedback-dto-converter.ts b/apps/stats-ms/src/feedback/dal/feedback-dto-converter.ts | |
| index 5ec6fc093..684a5f92d 100644 | |
| --- a/apps/stats-ms/src/feedback/dal/feedback-dto-converter.ts | |
| +++ b/apps/stats-ms/src/feedback/dal/feedback-dto-converter.ts | |
| @@ -1,6 +1,8 @@ | |
| import { UserFeedback } from './schemas/feedback.schema'; | |
| import { FeedbackDto } from '@vinny/stats-types'; | |
| +import { Types } from 'mongoose'; | |
| + | |
| //TODO:: Create tests | |
| export class FeedbackDtoConverter { | |
| static fromDto(dto: FeedbackDto): UserFeedback { | |
| @@ -16,9 +18,9 @@ export class FeedbackDtoConverter { | |
| userComment: answer.userComment, | |
| })), | |
| })); | |
| - feedback.relatedEntityId = dto.relatedEntityId; | |
| + feedback.relatedEntityId = Types.ObjectId(dto.relatedEntityId); | |
| feedback.relatedEntityType = dto.relatedEntityType; | |
| - feedback.userId = dto.userId; | |
| + feedback.userId = Types.ObjectId(dto.userId); | |
| return feedback; | |
| } | |
| } | |
| diff --git a/apps/stats-ms/src/feedback/dal/schemas/feedback.schema.ts b/apps/stats-ms/src/feedback/dal/schemas/feedback.schema.ts | |
| index 21fc8b6de..8da85abc6 100644 | |
| --- a/apps/stats-ms/src/feedback/dal/schemas/feedback.schema.ts | |
| +++ b/apps/stats-ms/src/feedback/dal/schemas/feedback.schema.ts | |
| @@ -1,7 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Types } from 'mongoose'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| import { UserFeedbackRelatedEntityType } from '@vinny/stats-types'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class FeedbackAnswer { | |
| @@ -41,18 +40,14 @@ export const FeedbackQuestionResponseSchema = | |
| export class UserFeedback { | |
| id: Types.ObjectId; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - relatedEntityId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + relatedEntityId: Types.ObjectId; | |
| - @Prop({ | |
| - required: true, | |
| - type: String, | |
| - enum: Object.values(UserFeedbackRelatedEntityType), | |
| - }) | |
| + @Prop({ required: true, type: UserFeedbackRelatedEntityType }) | |
| relatedEntityType: UserFeedbackRelatedEntityType; | |
| - @Prop(objectIdPropHandler()) | |
| - userId: string; | |
| + @Prop({ type: SchemaTypes.ObjectId }) | |
| + userId: Types.ObjectId; | |
| @Prop({ required: false, type: Number, enum: [1, 2, 3, 4, 5] }) | |
| rating?: 1 | 2 | 3 | 4 | 5; | |
| diff --git a/apps/users-ms/src/attorneys/attorney-practice-areas.controller.spec.ts b/apps/users-ms/src/attorneys/attorney-practice-areas.controller.spec.ts | |
| index ed39e0963..4c38e6b26 100644 | |
| --- a/apps/users-ms/src/attorneys/attorney-practice-areas.controller.spec.ts | |
| +++ b/apps/users-ms/src/attorneys/attorney-practice-areas.controller.spec.ts | |
| @@ -1,5 +1,4 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { KafkaEventType, KafkaProducerService } from '@vinny/kafka-client'; | |
| @@ -9,7 +8,7 @@ import { | |
| ServiceExpertise, | |
| ServicePreference, | |
| } from '@vinny/users-types'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { | |
| createAttorneyDTOWithDefaultsFactory, | |
| createPracticeAreaDTO, | |
| @@ -132,9 +131,9 @@ describe('AttorneyPracticeAreasController', () => { | |
| it('should fail when attorney doesnt exist', async () => { | |
| const practiceAreaDto = createPracticeAreaDTO(); | |
| - await expect(controller.create(objectStringId(), practiceAreaDto)).rejects.toThrowError( | |
| - 'attorney not found', | |
| - ); | |
| + await expect( | |
| + controller.create(new Types.ObjectId().toString(), practiceAreaDto), | |
| + ).rejects.toThrowError('attorney not found'); | |
| verifyEventNotEmitted(KafkaEventType.CREATE); | |
| }); | |
| @@ -264,15 +263,15 @@ describe('AttorneyPracticeAreasController', () => { | |
| it('should fail when this practice area does not exist', async () => { | |
| const attorneyDto = createAttorneyDTOWithDefaultsFactory(); | |
| const attorney = await usersService.create(attorneyDto); | |
| - await expect(controller.findById(attorney.id, objectStringId())).rejects.toThrowError( | |
| - 'practice area not found', | |
| - ); | |
| + await expect( | |
| + controller.findById(attorney.id, new Types.ObjectId().toString()), | |
| + ).rejects.toThrowError('practice area not found'); | |
| }); | |
| it('should fail when attorney does not exist', async () => { | |
| - await expect(controller.findById(objectStringId(), objectStringId())).rejects.toThrowError( | |
| - 'attorney not found', | |
| - ); | |
| + await expect( | |
| + controller.findById(new Types.ObjectId().toString(), new Types.ObjectId().toString()), | |
| + ).rejects.toThrowError('attorney not found'); | |
| }); | |
| }); | |
| diff --git a/apps/users-ms/src/attorneys/tests/attorneys.controller.spec.ts b/apps/users-ms/src/attorneys/tests/attorneys.controller.spec.ts | |
| index 6e554825d..dd02cba9e 100644 | |
| --- a/apps/users-ms/src/attorneys/tests/attorneys.controller.spec.ts | |
| +++ b/apps/users-ms/src/attorneys/tests/attorneys.controller.spec.ts | |
| @@ -1,6 +1,5 @@ | |
| import { faker } from '@faker-js/faker'; | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { Role } from '@vinny/auth-types'; | |
| @@ -18,7 +17,7 @@ import { | |
| UpdateAttorneyRequestDto, | |
| } from '@vinny/users-types'; | |
| import _ from 'lodash'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { | |
| attorney1Dto, | |
| attorney2Dto, | |
| @@ -178,7 +177,7 @@ describe('AttorneysController', () => { | |
| it('should create attorney with isActive & practiceAreasIds attorney data - for backwards compatibility', async () => { | |
| const attorney = attorneyFactory({ | |
| isActive: true, | |
| - practiceAreasIds: [objectStringId()], | |
| + practiceAreasIds: [Types.ObjectId().toString()], | |
| }); | |
| const newAttorney = await controller.create(attorney); | |
| const [foundAttorney] = await controller.find({ marbleId: newAttorney?.marbleId }); | |
| @@ -195,7 +194,7 @@ describe('AttorneysController', () => { | |
| attorneyData: { ...attorney2Dto.attorneyData, practiceAreasIds: ['yana'] }, | |
| }), | |
| ).rejects.toThrowError( | |
| - 'User validation failed: attorneyData.practiceAreasIds: Cast to Array failed for value "[ \'yana\' ]" (type Array) at path "practiceAreasIds", attorneyData: Validation failed: practiceAreasIds: Cast to Array failed for value "[ \'yana\' ]" (type Array) at path "practiceAreasIds"', | |
| + 'User validation failed: attorneyData.practiceAreasIds.0: Cast to [ObjectId] failed for value "["yana"]" (type string) at path "practiceAreasIds.0", attorneyData: Validation failed: practiceAreasIds.0: Cast to [ObjectId] failed for value "["yana"]" (type string) at path "practiceAreasIds.0"', | |
| ); | |
| }); | |
| @@ -304,13 +303,13 @@ describe('AttorneysController', () => { | |
| ]; | |
| attorneys[0].phone = faker.phone.phoneNumber(); | |
| attorneys[0].email = faker.internet.email(); | |
| - attorneys[0].marbleId = objectStringId(); | |
| + attorneys[0].marbleId = Types.ObjectId().toString(); | |
| attorneys[1].phone = faker.phone.phoneNumber(); | |
| attorneys[1].email = faker.internet.email(); | |
| - attorneys[1].marbleId = objectStringId(); | |
| + attorneys[1].marbleId = Types.ObjectId().toString(); | |
| attorneys[2].phone = faker.phone.phoneNumber(); | |
| attorneys[2].email = faker.internet.email(); | |
| - attorneys[2].marbleId = objectStringId(); | |
| + attorneys[2].marbleId = Types.ObjectId().toString(); | |
| const foundAttorneysBeforeCreated = await controller.find({}); | |
| expect(foundAttorneysBeforeCreated).toEqual([]); | |
| await controller.create(attorneys[0]); | |
| @@ -332,13 +331,13 @@ describe('AttorneysController', () => { | |
| ]; | |
| attorneys[0].phone = faker.phone.phoneNumber(); | |
| attorneys[0].email = faker.internet.email(); | |
| - attorneys[0].marbleId = objectStringId(); | |
| + attorneys[0].marbleId = Types.ObjectId().toString(); | |
| attorneys[1].phone = faker.phone.phoneNumber(); | |
| attorneys[1].email = faker.internet.email(); | |
| - attorneys[1].marbleId = objectStringId(); | |
| + attorneys[1].marbleId = Types.ObjectId().toString(); | |
| attorneys[2].phone = faker.phone.phoneNumber(); | |
| attorneys[2].email = faker.internet.email(); | |
| - attorneys[2].marbleId = objectStringId(); | |
| + attorneys[2].marbleId = Types.ObjectId().toString(); | |
| await controller.create(attorneys[0]); | |
| await controller.create(attorneys[1]); | |
| @@ -359,13 +358,13 @@ describe('AttorneysController', () => { | |
| ]; | |
| attorneys[0].phone = faker.phone.phoneNumber(); | |
| attorneys[0].email = faker.internet.email(); | |
| - attorneys[0].marbleId = objectStringId(); | |
| + attorneys[0].marbleId = Types.ObjectId().toString(); | |
| attorneys[1].phone = faker.phone.phoneNumber(); | |
| attorneys[1].email = faker.internet.email(); | |
| - attorneys[1].marbleId = objectStringId(); | |
| + attorneys[1].marbleId = Types.ObjectId().toString(); | |
| attorneys[2].phone = faker.phone.phoneNumber(); | |
| attorneys[2].email = faker.internet.email(); | |
| - attorneys[2].marbleId = objectStringId(); | |
| + attorneys[2].marbleId = Types.ObjectId().toString(); | |
| await controller.create(attorneys[0]); | |
| await controller.create(attorneys[1]); | |
| @@ -386,13 +385,13 @@ describe('AttorneysController', () => { | |
| ]; | |
| attorneys[0].phone = faker.phone.phoneNumber(); | |
| attorneys[0].email = faker.internet.email(); | |
| - attorneys[0].marbleId = objectStringId(); | |
| + attorneys[0].marbleId = Types.ObjectId().toString(); | |
| attorneys[1].phone = faker.phone.phoneNumber(); | |
| attorneys[1].email = faker.internet.email(); | |
| - attorneys[1].marbleId = objectStringId(); | |
| + attorneys[1].marbleId = Types.ObjectId().toString(); | |
| attorneys[2].phone = faker.phone.phoneNumber(); | |
| attorneys[2].email = faker.internet.email(); | |
| - attorneys[2].marbleId = objectStringId(); | |
| + attorneys[2].marbleId = Types.ObjectId().toString(); | |
| await controller.create(attorneys[0]); | |
| await controller.create(attorneys[1]); | |
| @@ -452,7 +451,7 @@ describe('AttorneysController', () => { | |
| }); | |
| describe('Attorney practice area filter', () => { | |
| - const practiceAreaId = objectStringId(); | |
| + const practiceAreaId = Types.ObjectId().toString(); | |
| const stateId = 'CA'; | |
| const fips = '13445'; | |
| @@ -599,7 +598,9 @@ describe('AttorneysController', () => { | |
| it('should not find a non existing attorney by id', async () => { | |
| const attorneyDto = generateCreateAttorneyRequestWithRequiredDataFields(); | |
| await controller.create(attorneyDto); | |
| - await expect(controller.findById(objectStringId())).rejects.toThrowError(`user not found`); | |
| + await expect(controller.findById(Types.ObjectId().toString())).rejects.toThrowError( | |
| + `user not found`, | |
| + ); | |
| }); | |
| }); | |
| diff --git a/apps/users-ms/src/attorneys/tests/utils.ts b/apps/users-ms/src/attorneys/tests/utils.ts | |
| index 759f67be3..b92e66922 100644 | |
| --- a/apps/users-ms/src/attorneys/tests/utils.ts | |
| +++ b/apps/users-ms/src/attorneys/tests/utils.ts | |
| @@ -1,6 +1,6 @@ | |
| import faker from '@faker-js/faker'; | |
| import { AttorneyType } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export interface CreateAttorneyProps { | |
| attorneyType?: AttorneyType; | |
| @@ -20,7 +20,7 @@ export const createAttorneyDto = (props?: CreateAttorneyProps) => ({ | |
| city: faker.address.city(), | |
| country: faker.address.country(), | |
| }, | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| attorneyData: { | |
| attorneyType: props?.attorneyType ?? AttorneyType.LEGAL_PARTNER, | |
| }, | |
| diff --git a/apps/users-ms/src/change-log/user-change-log.service.spec.ts b/apps/users-ms/src/change-log/user-change-log.service.spec.ts | |
| index 9d73e992c..776782913 100644 | |
| --- a/apps/users-ms/src/change-log/user-change-log.service.spec.ts | |
| +++ b/apps/users-ms/src/change-log/user-change-log.service.spec.ts | |
| @@ -1,11 +1,10 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { UserChangeLogService } from './user-change-log.service'; | |
| import { v4 as uuid } from 'uuid'; | |
| import { AttorneyStatus } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| import { | |
| CreateUserEvent, | |
| UpdateUserEvent, | |
| @@ -39,7 +38,7 @@ describe('UserChangeLogService', () => { | |
| }); | |
| describe('log user changes', () => { | |
| - const USER_ID: string = objectStringId(); | |
| + const USER_ID: string = Types.ObjectId().toString(); | |
| it('should return empty list on no changes found', async () => { | |
| const actual = await service.getChangesOfUserById(USER_ID); | |
| diff --git a/apps/users-ms/src/customers/tests/utils.ts b/apps/users-ms/src/customers/tests/utils.ts | |
| index 040bf437b..293f687c6 100644 | |
| --- a/apps/users-ms/src/customers/tests/utils.ts | |
| +++ b/apps/users-ms/src/customers/tests/utils.ts | |
| @@ -1,7 +1,7 @@ | |
| import { faker } from '@faker-js/faker'; | |
| import { EventResponse } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { CreateCustomerRequestDto, User } from '@vinny/users-types'; | |
| import { KafkaEventType } from '@vinny/kafka-client'; | |
| import { BrazeDestinationType, BrazeNotification } from '@vinny/communications-client'; | |
| @@ -23,8 +23,8 @@ export const eventIn2WeeksPayload: EventResponse = { | |
| description: faker.lorem.words(), | |
| eventType: 'COURT_DATE', | |
| startDate: dateIn2Weeks.toISOString(), | |
| - id: objectStringId(), | |
| - parentId: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| + parentId: Types.ObjectId().toString(), | |
| users: [], | |
| }; | |
| @@ -194,7 +194,7 @@ export const freezeDataFrozenStatus = { | |
| isFrozen: true, | |
| reason: faker.lorem.words(), | |
| frozenAt: faker.date.past(), | |
| - initiatedBy: objectStringId(), | |
| + initiatedBy: Types.ObjectId().toString(), | |
| }, | |
| }, | |
| }; | |
| @@ -205,7 +205,7 @@ export const freezeDataWithdrawalNotification = { | |
| isFrozen: true, | |
| reason: faker.lorem.words(), | |
| frozenAt: faker.date.past(), | |
| - initiatedBy: objectStringId(), | |
| + initiatedBy: Types.ObjectId().toString(), | |
| isNotifiedOfDisengagement: true, | |
| }, | |
| }, | |
| diff --git a/apps/users-ms/src/external-staff/test/external-staff.controller.spec.ts b/apps/users-ms/src/external-staff/test/external-staff.controller.spec.ts | |
| index 99e3a66be..e94d4c783 100644 | |
| --- a/apps/users-ms/src/external-staff/test/external-staff.controller.spec.ts | |
| +++ b/apps/users-ms/src/external-staff/test/external-staff.controller.spec.ts | |
| @@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import nock from 'nock'; | |
| import { INestApplication, ValidationPipe } from '@nestjs/common'; | |
| import '@vinny/test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { KafkaEventType, KafkaProducerService, KafkaTopics } from '@vinny/kafka-client'; | |
| import { importCommons } from '@vinny/test-utils'; | |
| import { CreateUserRequestDto, MemberRole, MemberStatus, TeamType } from '@vinny/users-types'; | |
| @@ -24,7 +24,7 @@ describe('External staff controller', () => { | |
| const fname = faker.name.firstName(); | |
| const lname = faker.name.lastName(); | |
| - const marbleId = objectStringId(); | |
| + const marbleId = Types.ObjectId().toString(); | |
| beforeEach(async () => { | |
| module = await Test.createTestingModule({ | |
| @@ -45,10 +45,10 @@ describe('External staff controller', () => { | |
| jest | |
| .spyOn(usersService, 'findById') | |
| .mockResolvedValueOnce({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { first: fname, last: lname }, | |
| } as any) | |
| - .mockResolvedValueOnce({ id: objectStringId(), marbleId } as any); | |
| + .mockResolvedValueOnce({ id: Types.ObjectId().toString(), marbleId } as any); | |
| }); | |
| afterEach(async () => { | |
| @@ -70,13 +70,13 @@ describe('External staff controller', () => { | |
| describe('POST /external-staff/add', () => { | |
| beforeEach(() => { | |
| jest.spyOn(usersService, 'findById').mockResolvedValue({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { first: fname, last: lname }, | |
| } as any); | |
| }); | |
| it('should add external staff to the attorney team', async () => { | |
| - const actorUserId = objectStringId(); | |
| - const externalStaffId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| + const externalStaffId = Types.ObjectId().toString(); | |
| const attorneyTeam = { | |
| type: TeamType.LEGAL_TEAM, | |
| members: [{ userId: actorUserId, role: MemberRole.ENGAGEMENT_MANAGER }], | |
| @@ -124,7 +124,7 @@ describe('External staff controller', () => { | |
| describe('POST /external-staff', () => { | |
| it('should create external staff and add him/her to the attorney team', async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const createUserRequest: CreateUserRequestDto = { | |
| name: { first: 'John', last: 'Doe' }, | |
| email: faker.internet.email(), | |
| @@ -132,7 +132,7 @@ describe('External staff controller', () => { | |
| }; | |
| const attorneyTeam = { | |
| type: TeamType.LEGAL_TEAM, | |
| - members: [{ userId: objectStringId(), role: MemberRole.ENGAGEMENT_MANAGER }], | |
| + members: [{ userId: Types.ObjectId().toString(), role: MemberRole.ENGAGEMENT_MANAGER }], | |
| }; | |
| const team = await teamsService.create(attorneyTeam, actorUserId); | |
| @@ -181,7 +181,7 @@ describe('External staff controller', () => { | |
| }); | |
| it('shoult throw an error if the attorney does not have a legal team', async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const createUserRequest: CreateUserRequestDto = { | |
| name: { first: 'John', last: 'Doe' }, | |
| email: faker.internet.email(), | |
| diff --git a/apps/users-ms/src/funnel-legal-plan/dal/schemas/funnel-legal-plan.schema.ts b/apps/users-ms/src/funnel-legal-plan/dal/schemas/funnel-legal-plan.schema.ts | |
| index efee78d80..6ca8a9e02 100644 | |
| --- a/apps/users-ms/src/funnel-legal-plan/dal/schemas/funnel-legal-plan.schema.ts | |
| +++ b/apps/users-ms/src/funnel-legal-plan/dal/schemas/funnel-legal-plan.schema.ts | |
| @@ -56,8 +56,8 @@ export class FunnelLegalPlan { | |
| @Prop({ | |
| required: true, | |
| - enum: Object.values(FunnelLegalPlanStatus), | |
| - type: String, | |
| + enum: FunnelLegalPlanStatus, | |
| + type: FunnelLegalPlanStatus, | |
| default: FunnelLegalPlanStatus.PROCESSING, | |
| }) | |
| status: FunnelLegalPlanStatus; | |
| diff --git a/apps/users-ms/src/login/test/utils.ts b/apps/users-ms/src/login/test/utils.ts | |
| index 83fd8a1b6..8c4746b56 100644 | |
| --- a/apps/users-ms/src/login/test/utils.ts | |
| +++ b/apps/users-ms/src/login/test/utils.ts | |
| @@ -1,13 +1,13 @@ | |
| import faker from '@faker-js/faker'; | |
| import { ConfigService } from '@nestjs/config'; | |
| import { User } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const mockUser: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| diff --git a/apps/users-ms/src/register-invitation/dal/schemas/register-invitation.schema.ts b/apps/users-ms/src/register-invitation/dal/schemas/register-invitation.schema.ts | |
| index ca60a63ee..dcb9de517 100644 | |
| --- a/apps/users-ms/src/register-invitation/dal/schemas/register-invitation.schema.ts | |
| +++ b/apps/users-ms/src/register-invitation/dal/schemas/register-invitation.schema.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| -import { Types } from 'mongoose'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ id: true, timestamps: true, toObject: { getters: true }, autoIndex: true }) | |
| export class RegisterInvitation { | |
| @@ -9,7 +9,11 @@ export class RegisterInvitation { | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + }) | |
| inviterId: string; | |
| @Prop({ required: true }) | |
| diff --git a/apps/users-ms/src/register-invitation/tests/register-invitations.service.spec.ts b/apps/users-ms/src/register-invitation/tests/register-invitations.service.spec.ts | |
| index 0e3b2e778..24b345900 100644 | |
| --- a/apps/users-ms/src/register-invitation/tests/register-invitations.service.spec.ts | |
| +++ b/apps/users-ms/src/register-invitation/tests/register-invitations.service.spec.ts | |
| @@ -11,7 +11,7 @@ import { | |
| } from '@vinny/users-types'; | |
| import { RegisterInvitationsModule } from '../register-invitations.module'; | |
| import { importCommons } from '@vinny/test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| import { generateRegisterInvitation, mailGunServiceMock } from './utils'; | |
| import { RegisterInvitation } from '../dal/schemas/register-invitation.schema'; | |
| @@ -53,7 +53,7 @@ describe('RegisterInvitationService', () => { | |
| }); | |
| const createRegisterInvitationDto: CreateRegisterInvitationDto = { | |
| - inviterId: objectStringId(), | |
| + inviterId: Types.ObjectId().toString(), | |
| email: faker.internet.email(), | |
| }; | |
| @@ -124,7 +124,7 @@ describe('RegisterInvitationService', () => { | |
| describe('findById', () => { | |
| describe('success', () => { | |
| it('should return the invitation for a valid id', async () => { | |
| - const id = objectStringId(); | |
| + const id = Types.ObjectId().toString(); | |
| const expectedRegisterInvitationDoc = generateRegisterInvitation( | |
| createRegisterInvitationDto, | |
| ); | |
| @@ -140,7 +140,7 @@ describe('RegisterInvitationService', () => { | |
| describe('fail', () => { | |
| it('should throw a NotFoundException if no invitation is found for the id', async () => { | |
| - const id = objectStringId(); | |
| + const id = Types.ObjectId().toString(); | |
| dal.findById.mockResolvedValueOnce(null); | |
| await expect(service.findById(id)).rejects.toThrow(NotFoundException); | |
| @@ -172,7 +172,7 @@ describe('RegisterInvitationService', () => { | |
| describe('fail', () => { | |
| it('should throw an error if update fails', async () => { | |
| - const invitationId = objectStringId(); | |
| + const invitationId = Types.ObjectId().toString(); | |
| const expiredRegisterInvitationDoc = generateRegisterInvitation( | |
| createRegisterInvitationDto, | |
| @@ -187,7 +187,7 @@ describe('RegisterInvitationService', () => { | |
| }); | |
| it('should throw an error if register invite is not valid', async () => { | |
| - const invitationId = objectStringId(); | |
| + const invitationId = Types.ObjectId().toString(); | |
| const expiredRegisterInvitationDoc = generateRegisterInvitation({ | |
| ...createRegisterInvitationDto, | |
| expirationDate: new Date(Date.now() - 1000), | |
| diff --git a/apps/users-ms/src/register-invitation/tests/utils.ts b/apps/users-ms/src/register-invitation/tests/utils.ts | |
| index 95951cde8..bb98e3e0c 100644 | |
| --- a/apps/users-ms/src/register-invitation/tests/utils.ts | |
| +++ b/apps/users-ms/src/register-invitation/tests/utils.ts | |
| @@ -1,13 +1,13 @@ | |
| import faker from '@faker-js/faker'; | |
| import { CreateRegisterInvitationDto } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const generateRegisterInvitation = ( | |
| createRegisterInvitationDto: CreateRegisterInvitationDto, | |
| ) => { | |
| return { | |
| ...createRegisterInvitationDto, | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| isUsed: false, | |
| token: faker.random.alphaNumeric(10), | |
| createdAt: new Date(), | |
| diff --git a/apps/users-ms/src/teams/dal/schemas/teams.schema.ts b/apps/users-ms/src/teams/dal/schemas/teams.schema.ts | |
| index ad8de99fb..c7d6f0d8f 100644 | |
| --- a/apps/users-ms/src/teams/dal/schemas/teams.schema.ts | |
| +++ b/apps/users-ms/src/teams/dal/schemas/teams.schema.ts | |
| @@ -1,11 +1,11 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| import { MemberRole, MemberStatus, TeamType } from '@vinny/users-types'; | |
| -import { Types } from 'mongoose'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| class Member { | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId, get: objectIdToStringGetter }) | |
| userId: string; | |
| @Prop({ type: String, enum: Object.values(MemberRole) }) | |
| diff --git a/apps/users-ms/src/teams/dal/tests/teams.dal.spec.ts b/apps/users-ms/src/teams/dal/tests/teams.dal.spec.ts | |
| index 4ba5b752a..19e8105c1 100644 | |
| --- a/apps/users-ms/src/teams/dal/tests/teams.dal.spec.ts | |
| +++ b/apps/users-ms/src/teams/dal/tests/teams.dal.spec.ts | |
| @@ -8,7 +8,7 @@ import { CreateTeamDto, MemberRole, TeamType } from '@vinny/users-types'; | |
| import { Team, TeamSchema } from '../schemas/teams.schema'; | |
| import { omit } from 'lodash'; | |
| import { defaultAttorneyMember, generateCreateTeamDto } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| describe('TeamsDalService', () => { | |
| let teamsDal: TeamsDalService; | |
| @@ -84,7 +84,7 @@ describe('TeamsDalService', () => { | |
| describe('fail', () => { | |
| it('should failed to update team, Id does not exist', async () => { | |
| - const fakeAttorneyId = objectStringId(); | |
| + const fakeAttorneyId = Types.ObjectId().toString(); | |
| const teamUpdated = await teamsDal.updateByUserIdTypeAndRole( | |
| TeamType.LEGAL_TEAM, | |
| fakeAttorneyId, | |
| @@ -147,7 +147,7 @@ describe('TeamsDalService', () => { | |
| describe('fail', () => { | |
| it('should return empty list, fakeId', async () => { | |
| - const fakeAttorneyId = objectStringId(); | |
| + const fakeAttorneyId = Types.ObjectId().toString(); | |
| const teams = await teamsDal.findByFilter({ | |
| userId: fakeAttorneyId, | |
| type: TeamType.LEGAL_TEAM, | |
| diff --git a/apps/users-ms/src/teams/dal/tests/utils.ts b/apps/users-ms/src/teams/dal/tests/utils.ts | |
| index 18c860411..514eb781d 100644 | |
| --- a/apps/users-ms/src/teams/dal/tests/utils.ts | |
| +++ b/apps/users-ms/src/teams/dal/tests/utils.ts | |
| @@ -1,26 +1,26 @@ | |
| import { CreateTeamDto, Member, MemberRole, MemberStatus, TeamType } from '@vinny/users-types'; | |
| import { sample } from 'lodash'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export const defaultAttorneyMember: Member = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.ATTORNEY, | |
| }; | |
| export const managingAttorneyMember = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.MANAGING_ATTORNEY, | |
| }; | |
| export const generateMember = (): Member => ({ | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: sample(Object.keys(MemberRole)) as MemberRole, | |
| joinedAt: new Date(), | |
| status: sample(Object.keys(MemberStatus)) as MemberStatus, | |
| }); | |
| export const externalStaffMember: Member = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| role: MemberRole.EXTERNAL_STAFF, | |
| joinedAt: new Date(2025, 0, 1), | |
| status: MemberStatus.ACTIVE, | |
| diff --git a/apps/users-ms/src/teams/tests/teams.service.spec.ts b/apps/users-ms/src/teams/tests/teams.service.spec.ts | |
| index 2c6e943de..f3c276b2b 100644 | |
| --- a/apps/users-ms/src/teams/tests/teams.service.spec.ts | |
| +++ b/apps/users-ms/src/teams/tests/teams.service.spec.ts | |
| @@ -4,7 +4,7 @@ import { Test, TestingModule } from '@nestjs/testing'; | |
| import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { getSplitService, SplitService } from '@marbletech/split'; | |
| import { CreateTeamDto, MemberRole, TeamDto, TeamType } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { Team, TeamSchema } from '../dal/schemas/teams.schema'; | |
| import { TeamsDalService } from '../dal/teams.dal'; | |
| import { TeamsService } from '../teams.service'; | |
| @@ -24,7 +24,7 @@ describe('TeamsService', () => { | |
| let findByIdTeamsDalMock: any; | |
| let findByUserIdAndTypeTeamsDalMock: any; | |
| const createTeamDto: CreateTeamDto = generateCreateTeamDto(); | |
| - const teamDto: TeamDto = { id: objectStringId(), ...generateCreateTeamDto() }; | |
| + const teamDto: TeamDto = { id: Types.ObjectId.toString(), ...generateCreateTeamDto() }; | |
| beforeAll(async () => { | |
| const module: TestingModule = await Test.createTestingModule({ | |
| @@ -122,7 +122,7 @@ describe('TeamsService', () => { | |
| describe('findById', () => { | |
| describe('success', () => { | |
| it('should return team by id', async () => { | |
| - const teamId = objectStringId(); | |
| + const teamId = Types.ObjectId.toString(); | |
| findByIdTeamsDalMock.mockResolvedValueOnce(teamDto); | |
| const team = await teamsService.findById(teamId); | |
| expect(team).toEqual(teamDto); | |
| @@ -131,7 +131,7 @@ describe('TeamsService', () => { | |
| describe('fail', () => { | |
| it('should throw not found error, fake id', async () => { | |
| - const fakeId = objectStringId(); | |
| + const fakeId = Types.ObjectId().toString(); | |
| findByIdTeamsDalMock.mockResolvedValueOnce(null); | |
| await expect(teamsService.findById(fakeId)).rejects.toThrowError(NotFoundException); | |
| }); | |
| @@ -151,7 +151,7 @@ describe('TeamsService', () => { | |
| }); | |
| it('should return empty array with wrong attorney id', async () => { | |
| - const fakeAttorneyId = objectStringId(); | |
| + const fakeAttorneyId = Types.ObjectId.toString(); | |
| findByUserIdAndTypeTeamsDalMock.mockResolvedValueOnce([]); | |
| const teams = await teamsDal.findByFilter({ | |
| userId: fakeAttorneyId, | |
| @@ -165,7 +165,7 @@ describe('TeamsService', () => { | |
| describe('add team member', () => { | |
| it('should add team member', async () => { | |
| - const attorneyId = objectStringId(); | |
| + const attorneyId = Types.ObjectId().toString(); | |
| const createdTeam = await teamsService.create( | |
| { members: [managingAttorneyMember], type: TeamType.LEGAL_TEAM }, | |
| attorneyId, | |
| diff --git a/apps/users-ms/src/tickets/tests/tickets.controller.spec.ts b/apps/users-ms/src/tickets/tests/tickets.controller.spec.ts | |
| index 86f146070..22b630279 100644 | |
| --- a/apps/users-ms/src/tickets/tests/tickets.controller.spec.ts | |
| +++ b/apps/users-ms/src/tickets/tests/tickets.controller.spec.ts | |
| @@ -6,7 +6,7 @@ import { TicketTypesToSyncLawmatics } from '@vinny/lawmatics-types'; | |
| import { FlareLogger } from '@vinny/logger'; | |
| import { CreateTicketRequest, SupportRequestStatus } from '@vinny/users-types'; | |
| import { generateTicketDataMock } from '@vinny/users-test-utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { TicketsController } from '../tickets.controller'; | |
| import { TicketsService } from '../tickets.service'; | |
| import { LegalCortexClientModule } from '@vinny/legal-cortex-client'; | |
| @@ -47,7 +47,7 @@ describe('tickets controller', () => { | |
| ); | |
| const createTicketRequest: CreateTicketRequest = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| ticketData, | |
| }; | |
| @@ -68,7 +68,7 @@ describe('tickets controller', () => { | |
| it('should not emit a ticket created event when ticket Type is not item of TicketTypesToSyncLawmatics', async () => { | |
| const ticketData = generateTicketDataMock('General', SupportRequestStatus.OPEN); | |
| const createTicketRequest: CreateTicketRequest = { | |
| - userId: objectStringId(), | |
| + userId: Types.ObjectId().toString(), | |
| ticketData, | |
| }; | |
| diff --git a/apps/users-ms/src/users/dal/funnel.dal.ts b/apps/users-ms/src/users/dal/funnel.dal.ts | |
| index 5445baca7..2e43f7391 100644 | |
| --- a/apps/users-ms/src/users/dal/funnel.dal.ts | |
| +++ b/apps/users-ms/src/users/dal/funnel.dal.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Injectable } from '@nestjs/common'; | |
| import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { Funnel, FunnelDocument } from './schemas/user.schema'; | |
| import { FunnelDto } from '@vinny/users-types'; | |
| import { hashString, schemaToDto } from '@vinny/helpers'; | |
| @@ -13,11 +13,15 @@ export class FunnelDALService { | |
| return hashString(str, { algorithm: 'MD5' }).toLowerCase().substring(0, 24); | |
| } | |
| public async createOrUpdate(funnel: FunnelDto): Promise<FunnelDto> { | |
| - const document = await this.funnelModel.findByIdAndUpdate(this.toId(funnel.id), funnel, { | |
| - new: true, | |
| - upsert: true, | |
| - lean: true, | |
| - }); | |
| + const document = await this.funnelModel.findByIdAndUpdate( | |
| + Types.ObjectId(this.toId(funnel.id)), | |
| + funnel, | |
| + { | |
| + new: true, | |
| + upsert: true, | |
| + lean: true, | |
| + }, | |
| + ); | |
| return schemaToDto(FunnelDto, document); | |
| } | |
| } | |
| diff --git a/apps/users-ms/src/users/dal/practiceArea.dal.ts b/apps/users-ms/src/users/dal/practiceArea.dal.ts | |
| index 122cb18d0..3be67f134 100644 | |
| --- a/apps/users-ms/src/users/dal/practiceArea.dal.ts | |
| +++ b/apps/users-ms/src/users/dal/practiceArea.dal.ts | |
| @@ -7,7 +7,7 @@ import { | |
| UpdateAttorneyPracticeAreaRequestDto, | |
| User, | |
| } from '@vinny/users-types'; | |
| -import { Model } from 'mongoose'; | |
| +import { Model, Types } from 'mongoose'; | |
| import { UserDocument } from './schemas/user.schema'; | |
| import { FlareLogger, FnLogger } from '@vinny/logger'; | |
| import { flatten } from 'flat'; | |
| @@ -38,7 +38,7 @@ export class PracticeAreaDalService { | |
| throw Error('attorney has a practice area with the same id'); | |
| } | |
| - const update = { ...createPracticeAreaDto, practiceAreaId: practiceAreaId }; | |
| + const update = { ...createPracticeAreaDto, practiceAreaId: Types.ObjectId(practiceAreaId) }; | |
| const userDocument = await this.userModel | |
| .findOneAndUpdate( | |
| diff --git a/apps/users-ms/src/users/dal/query-builder.ts b/apps/users-ms/src/users/dal/query-builder.ts | |
| index a804acd62..80fe17477 100644 | |
| --- a/apps/users-ms/src/users/dal/query-builder.ts | |
| +++ b/apps/users-ms/src/users/dal/query-builder.ts | |
| @@ -1,10 +1,9 @@ | |
| import { FilterUserDto, Identity } from '@vinny/users-types'; | |
| -import { FilterQuery } from 'mongoose'; | |
| +import { FilterQuery, Types } from 'mongoose'; | |
| import { UserDocument } from './schemas/user.schema'; | |
| import _ from 'lodash'; | |
| import { flatten } from 'flat'; | |
| import { MongoQueryRecord, Pagination, SingleFieldSort, SortOrder } from '@vinny/pagination'; | |
| -import { objectId } from '@vinny/helpers'; | |
| type IdentityFilter = Record<string, MongoQueryRecord>; | |
| @@ -60,7 +59,7 @@ export function constructAggregationPipeline({ | |
| } | |
| if (ids && ids.length > 0) { | |
| - matchStage.$match._id = { $in: ids.map((id) => objectId(id)) }; | |
| + matchStage.$match._id = { $in: ids.map((id) => Types.ObjectId(id)) }; | |
| } | |
| if (marbleIds && marbleIds.length > 0) { | |
| @@ -314,7 +313,7 @@ function constructAttorneyPipeline( | |
| $elemMatch: cleanupQueryObject({ | |
| ...restOfPracticeArea, | |
| ...(practiceAreaId && { | |
| - practiceAreaId: objectId(practiceAreaId), | |
| + practiceAreaId: Types.ObjectId(practiceAreaId), | |
| }), | |
| ...((stateId || fips) && { | |
| diff --git a/apps/users-ms/src/users/dal/schemas/attorney-data.schema.ts b/apps/users-ms/src/users/dal/schemas/attorney-data.schema.ts | |
| index 736301b81..97550b968 100644 | |
| --- a/apps/users-ms/src/users/dal/schemas/attorney-data.schema.ts | |
| +++ b/apps/users-ms/src/users/dal/schemas/attorney-data.schema.ts | |
| @@ -17,8 +17,8 @@ import { | |
| ReligiousBackground, | |
| ServiceAttitude, | |
| } from '@vinny/users-types'; | |
| +import { SchemaTypes, Types } from 'mongoose'; | |
| import { Address, AddressSchema } from './utils.schema'; | |
| -import { objectIdPropHandler, objectIdsPropHandler } from '@vinny/helpers'; | |
| @Schema({ _id: false }) | |
| class ServicePreference { | |
| @@ -63,7 +63,7 @@ class Email { | |
| @Prop({ required: true }) | |
| address: string; | |
| - @Prop({ required: true, enum: Object.values(EmailType), type: String }) | |
| + @Prop({ required: true, enum: EmailType, type: String }) | |
| type: EmailType; | |
| } | |
| @@ -74,7 +74,7 @@ class Phone { | |
| @Prop({ required: true }) | |
| number: string; | |
| - @Prop({ required: true, enum: Object.values(PhoneType), type: String }) | |
| + @Prop({ required: true, enum: PhoneType, type: String }) | |
| type: PhoneType; | |
| } | |
| @@ -85,7 +85,7 @@ class Link { | |
| @Prop({ required: true }) | |
| url: string; | |
| - @Prop({ required: true, enum: Object.values(LinkType), type: String }) | |
| + @Prop({ required: true, enum: LinkType, type: String }) | |
| type: LinkType; | |
| } | |
| @@ -96,7 +96,7 @@ class DaySchedule { | |
| @Prop({ required: true }) | |
| meetingTypeId: string; | |
| - @Prop({ required: true, enum: Object.values(Days), type: String }) | |
| + @Prop({ required: true, enum: Days, type: String }) | |
| day: Days; | |
| @Prop({ required: true }) | |
| @@ -164,7 +164,7 @@ export class ServiceExpertise { | |
| @Prop({ | |
| type: String, | |
| - enum: Object.values(ServiceAttitude), | |
| + enum: ServiceAttitude, | |
| default: ServiceAttitude.NO_PREFRENCE, | |
| required: true, | |
| }) | |
| @@ -173,13 +173,13 @@ export class ServiceExpertise { | |
| const ServiceExpertiseSchema = SchemaFactory.createForClass(ServiceExpertise); | |
| -@Schema({ _id: false, toObject: { getters: true } }) | |
| +@Schema({ _id: false }) | |
| export class PracticeArea { | |
| performsLSSAggregated: boolean; | |
| handlesCasesAggregated: boolean; | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| - practiceAreaId: string; | |
| + @Prop({ required: true, type: SchemaTypes.ObjectId }) | |
| + practiceAreaId: Types.ObjectId; | |
| @Prop({ type: [ServicePreferenceSchema], default: [] }) | |
| servicePreferences: ServicePreference[]; | |
| @@ -239,8 +239,8 @@ const WorkingDaysSchema = SchemaFactory.createForClass(WorkingDays); | |
| @Schema({ _id: false }) | |
| export class AttorneyData { | |
| //deprecated: used for Workato workflows | |
| - @Prop(objectIdsPropHandler()) | |
| - practiceAreasIds?: string[]; | |
| + @Prop({ type: [SchemaTypes.ObjectId] }) | |
| + practiceAreasIds?: Types.ObjectId[]; | |
| //deprecated: used for Workato workflows | |
| @Prop() | |
| @@ -261,7 +261,7 @@ export class AttorneyData { | |
| @Prop({ type: String, enum: AttorneyStatus }) | |
| status?: AttorneyStatus; | |
| - @Prop({ type: String, enum: Object.values(AttorneySubStatus), nullable: true }) | |
| + @Prop({ type: String, enum: AttorneySubStatus, nullable: true }) | |
| subStatus?: AttorneySubStatus | null; | |
| @Prop({ type: [EducationSchema], default: [] }) | |
| diff --git a/apps/users-ms/src/users/dal/schemas/user.schema.ts b/apps/users-ms/src/users/dal/schemas/user.schema.ts | |
| index 05981c497..91078cd9c 100644 | |
| --- a/apps/users-ms/src/users/dal/schemas/user.schema.ts | |
| +++ b/apps/users-ms/src/users/dal/schemas/user.schema.ts | |
| @@ -38,7 +38,7 @@ class FreezeData { | |
| isNotifiedOfDisengagement?: boolean; | |
| } | |
| -@Schema({ _id: false, id: false }) | |
| +@Schema() | |
| class CustomerState { | |
| @Prop() | |
| firstEmailSent?: boolean; | |
| @@ -58,7 +58,7 @@ class CustomerState { | |
| @Prop() | |
| visitedMyMarbleWeb?: boolean; | |
| - @Prop({ type: String, enum: Object.values(RepeatFlowType) }) | |
| + @Prop({ type: [{ type: String, enum: RepeatFlowType }] }) | |
| repeatFlowType?: RepeatFlowType; | |
| @Prop({ type: FreezeData }) | |
| @@ -81,7 +81,7 @@ class IntegrationInfo { | |
| const IntegrationInfoSchema = SchemaFactory.createForClass(IntegrationInfo); | |
| -@Schema({ _id: false, minimize: false, strict: false }) | |
| +@Schema({ _id: false }) | |
| class CustomerData { | |
| @Prop() | |
| customerState?: CustomerState; | |
| @@ -99,7 +99,7 @@ class CustomerData { | |
| const CustomerDataSchema = SchemaFactory.createForClass(CustomerData); | |
| const ProviderSchema = SchemaFactory.createForClass(Provider); | |
| -@Schema({ _id: true, id: true, timestamps: true, minimize: false }) | |
| +@Schema({ _id: true, id: true, timestamps: true }) | |
| export class User { | |
| _id: Types.ObjectId; | |
| id: string; | |
| diff --git a/apps/users-ms/src/users/dal/users.dal.spec.ts b/apps/users-ms/src/users/dal/users.dal.spec.ts | |
| index c64a1bc75..d495b9478 100644 | |
| --- a/apps/users-ms/src/users/dal/users.dal.spec.ts | |
| +++ b/apps/users-ms/src/users/dal/users.dal.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, getLogger, rootMongooseTestModule } from '@vinny/test-utils'; | |
| import { getConnectionToken, MongooseModule } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { ConfigModule } from '@nestjs/config'; | |
| import { MockClientKafka } from '@vinny/test-utils'; | |
| @@ -14,7 +14,6 @@ import { PracticeAreaDalService } from './practiceArea.dal'; | |
| import { KafkaProducerModule } from '@vinny/kafka-client'; | |
| import { FunnelLegalPlanDALService } from '../../funnel-legal-plan/dal/funnelLegalPlan.dal'; | |
| import { FunnelLegalPlanSchema } from '../../funnel-legal-plan/dal/schemas/funnel-legal-plan.schema'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const getUser = ( | |
| attorneyLevelPerformsLSS: boolean | undefined, | |
| @@ -31,7 +30,7 @@ const getUser = ( | |
| last: faker.name.lastName(), | |
| }, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.ATTORNEY], | |
| attorneyData: { | |
| performsLSS: attorneyLevelPerformsLSS, | |
| @@ -40,7 +39,7 @@ const getUser = ( | |
| { | |
| performsLSS: practiceAreaLevelPerformsLSS, | |
| handlesCases: practiceAreaLevelHandlesCases, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| servicePreferences: [], | |
| locations: [], | |
| }, | |
| @@ -52,7 +51,7 @@ const getUser = ( | |
| attorneyData.attorneyData.practiceAreas.push({ | |
| performsLSS: secondPerformsLSS, | |
| handlesCases: secondHandlesCases, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| servicePreferences: [], | |
| locations: [], | |
| }); | |
| @@ -429,7 +428,7 @@ describe('UsersDalService', () => { | |
| const user = { | |
| name, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| attorneyData: expect.any(Object), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| @@ -465,7 +464,7 @@ describe('UsersDalService', () => { | |
| const user = { | |
| name, | |
| email: faker.internet.email(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| attorneyData: expect.any(Object), | |
| roles: [Role.ATTORNEY], | |
| }; | |
| diff --git a/apps/users-ms/src/users/dal/users.dal.ts b/apps/users-ms/src/users/dal/users.dal.ts | |
| index 47f9a9fc9..ebddaa225 100644 | |
| --- a/apps/users-ms/src/users/dal/users.dal.ts | |
| +++ b/apps/users-ms/src/users/dal/users.dal.ts | |
| @@ -4,7 +4,7 @@ import { FlareLogger, FnLogger } from '@vinny/logger'; | |
| import { CreateUserDto, Identity, ListUsersDto, UpdateUserDto, User } from '@vinny/users-types'; | |
| import { flatten } from 'flat'; | |
| import _ from 'lodash'; | |
| -import { LeanDocument, Model } from 'mongoose'; | |
| +import { LeanDocument, Model, Types } from 'mongoose'; | |
| import { UserDocument } from './schemas/user.schema'; | |
| import { Role } from '@vinny/auth-types'; | |
| import { userDocumentToUser, userDTOToUserDocument } from './converters'; | |
| @@ -56,9 +56,9 @@ export class UsersDALService { | |
| try { | |
| const userDocument = await this.userModel.create(userDTOToUserDocument(createUserDto, true)); | |
| - const user = await this.userModel.findById(userDocument.id); | |
| + const user = await this.userModel.findById(userDocument.id).lean(); | |
| - return this.mapUserDocumentToUser(user?.toObject()); | |
| + return this.mapUserDocumentToUser(user!); | |
| } catch (error) { | |
| this.logger.error('users DAL - create user failed', { createUserDto, error }); | |
| if (error instanceof Error && error.message.startsWith(DUPLICATE_KEY_ERROR_MSG_PREFIX)) { | |
| @@ -90,12 +90,13 @@ export class UsersDALService { | |
| { | |
| new: true, | |
| }, | |
| - ); | |
| + ) | |
| + .lean(); | |
| if (!userDocument) { | |
| return null; | |
| } | |
| - const user = await this.mapUserDocumentToUser(userDocument.toObject()); | |
| + const user = await this.mapUserDocumentToUser(userDocument); | |
| this.logger.log('users DAL - update user completed'); | |
| return user; | |
| } catch (error) { | |
| @@ -151,12 +152,13 @@ export class UsersDALService { | |
| const identityFilter = identity && createIdentityFilter(identity); | |
| const user = await this.userModel | |
| - .findOne(_.omitBy({ ...identityFilter, _id: id }, _.isUndefined)); | |
| + .findOne(_.omitBy({ ...identityFilter, _id: id }, _.isUndefined)) | |
| + .lean(); | |
| if (!user) { | |
| return null; | |
| } | |
| - return user && this.mapUserDocumentToUser(user.toObject()); | |
| + return user && this.mapUserDocumentToUser(user); | |
| } | |
| @FnLogger() | |
| @@ -165,19 +167,20 @@ export class UsersDALService { | |
| const user = await this.userModel | |
| .findOne({ | |
| $or: [{ email: emailRegex }, { emailAlias: emailRegex }], | |
| - }); | |
| + }) | |
| + .lean(); | |
| if (!user) { | |
| return null; | |
| } | |
| - return this.mapUserDocumentToUser(user.toObject()); | |
| + return this.mapUserDocumentToUser(user); | |
| } | |
| async findByEmailOrPhone(email: string, phone?: string): Promise<User[]> { | |
| const emailRegex = caseInsensitiveRegex(email); | |
| const filterArray = phone ? [{ email: emailRegex }, { phone }] : [{ email: emailRegex }]; | |
| - const users = await this.userModel.find({ $or: filterArray }); | |
| - const mappedUserPromises = users.map((user) => this.mapUserDocumentToUser(user.toObject())); | |
| + const users = await this.userModel.find({ $or: filterArray }).lean(); | |
| + const mappedUserPromises = users.map((user) => this.mapUserDocumentToUser(user)); | |
| return Promise.all(mappedUserPromises); | |
| } | |
| @@ -195,15 +198,15 @@ export class UsersDALService { | |
| } | |
| async delete(id: string): Promise<null | User> { | |
| - const user = await this.userModel.findOneAndDelete({ _id: id }); | |
| - return user && this.mapUserDocumentToUser(user.toObject()); | |
| + const user = await this.userModel.findOneAndDelete({ _id: id }).lean(); | |
| + return user && this.mapUserDocumentToUser(user); | |
| } | |
| // temporary method for migration | |
| async updateEmailAlias(userId: string, emailAlias: string): Promise<User | null> { | |
| const updatedUserDoc = await this.userModel.findOneAndUpdate( | |
| { | |
| - _id: userId, | |
| + _id: Types.ObjectId(userId), | |
| }, | |
| { | |
| $set: { emailAlias }, | |
| diff --git a/apps/users-ms/src/users/tests/users.controller.spec.ts b/apps/users-ms/src/users/tests/users.controller.spec.ts | |
| index c5f416238..215e4f86a 100644 | |
| --- a/apps/users-ms/src/users/tests/users.controller.spec.ts | |
| +++ b/apps/users-ms/src/users/tests/users.controller.spec.ts | |
| @@ -1,6 +1,6 @@ | |
| import { closeInMongodConnection, importCommons } from '@vinny/test-utils'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { UsersController } from '../users.controller'; | |
| import { UsersService } from '../users.service'; | |
| @@ -18,7 +18,6 @@ import { UsersModule } from '../users.module'; | |
| import faker from '@faker-js/faker'; | |
| import { Response } from 'express'; | |
| import { MarbleOsModule } from '@vinny/marble-os'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| const mockResponse = { | |
| json: jest.fn(() => mockResponse), | |
| @@ -65,7 +64,7 @@ describe('UsersController', () => { | |
| describe('create', () => { | |
| it('should call create in users service', async () => { | |
| const createSpy = jest.spyOn(service, 'create'); | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await controller.create(user2Dto, actorUserId); | |
| @@ -76,7 +75,7 @@ describe('UsersController', () => { | |
| it('should call create in users service with user without phone', async () => { | |
| const createSpy = jest.spyOn(service, 'create'); | |
| const { phone: _, ...userWithoutPhone } = user2Dto; | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await controller.create(userWithoutPhone, actorUserId); | |
| @@ -111,7 +110,7 @@ describe('UsersController', () => { | |
| describe('upsert', () => { | |
| it('should call createOrUpdate in users service', async () => { | |
| const createSpy = jest.spyOn(service, 'createOrUpdate'); | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await controller.upsert(mockResponse, user2Dto, actorUserId); | |
| @@ -122,7 +121,7 @@ describe('UsersController', () => { | |
| it('should call createOrUpdate in users service with user without phone', async () => { | |
| const createSpy = jest.spyOn(service, 'createOrUpdate'); | |
| const { phone: _, ...userWithoutPhone } = user2Dto; | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await controller.upsert(mockResponse, userWithoutPhone, actorUserId); | |
| @@ -133,7 +132,7 @@ describe('UsersController', () => { | |
| it('should update existing user based on various params', async () => { | |
| const create1Spy = jest.spyOn(service as any, 'createUserInternal'); | |
| const update1Spy = jest.spyOn(service as any, 'updateUserInternal'); | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await controller.upsert(mockResponse, user2Dto, actorUserId); | |
| expect(create1Spy).toBeCalledWith(user2Dto, actorUserId); | |
| const { phone: _, ...userWithoutPhone } = user2Dto; | |
| @@ -174,7 +173,7 @@ describe('UsersController', () => { | |
| const updateSpy = jest.spyOn(service, 'update'); | |
| const user = await controller.create(user1Dto); | |
| const newName = { first: 'test', middle: '', last: '123' }; | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await controller.update( | |
| user.id, | |
| @@ -196,7 +195,7 @@ describe('UsersController', () => { | |
| const updateSpy = jest.spyOn(service, 'update'); | |
| const user = await controller.create(user1Dto); | |
| const newEmail = '[email protected]'; | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await controller.update( | |
| user.id, | |
| @@ -217,7 +216,7 @@ describe('UsersController', () => { | |
| const updateSpy = jest.spyOn(service, 'update'); | |
| const user = await controller.create(user1Dto); | |
| const newPhone = '+972548213490'; | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await controller.update( | |
| user.id, | |
| @@ -237,7 +236,7 @@ describe('UsersController', () => { | |
| it('should return user without customer and attorney data', async () => { | |
| jest.spyOn(service, 'update').mockImplementation(async () => customerAndAttorneyUserMock); | |
| const newName = { first: 'test', middle: '', last: '123' }; | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const updatedUser = await controller.update( | |
| '1', | |
| @@ -252,7 +251,7 @@ describe('UsersController', () => { | |
| describe('delete', () => { | |
| it('should delete a user successfully', async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const user = await controller.create(user2Dto); | |
| emitSpy.mockReset(); | |
| diff --git a/apps/users-ms/src/users/tests/users.integ.spec.ts b/apps/users-ms/src/users/tests/users.integ.spec.ts | |
| index 72471fb53..fc39b8e33 100644 | |
| --- a/apps/users-ms/src/users/tests/users.integ.spec.ts | |
| +++ b/apps/users-ms/src/users/tests/users.integ.spec.ts | |
| @@ -4,12 +4,11 @@ import { INestApplication } from '@nestjs/common'; | |
| import { getConnectionToken } from '@nestjs/mongoose'; | |
| import { Test, TestingModule } from '@nestjs/testing'; | |
| import { KafkaEventType, KafkaProducerService, KafkaTopics } from '@vinny/kafka-client'; | |
| -import { Connection } from 'mongoose'; | |
| +import { Connection, Types } from 'mongoose'; | |
| import request from 'supertest'; | |
| import { UsersModule } from '../users.module'; | |
| import { user1Dto, user2Dto } from './utils'; | |
| import { MarbleOsModule } from '@vinny/marble-os'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| describe('UsersIntegration', () => { | |
| let app: INestApplication; | |
| @@ -43,7 +42,7 @@ describe('UsersIntegration', () => { | |
| describe('happy flows', () => { | |
| describe('create', () => { | |
| it('should create a user', async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const { body: createdUser } = await request(httpServer) | |
| .post('/users') | |
| @@ -66,7 +65,7 @@ describe('UsersIntegration', () => { | |
| describe('update', () => { | |
| it('should update user', async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| const { body: createdUser } = await request(httpServer) | |
| .post('/users') | |
| @@ -111,7 +110,7 @@ describe('UsersIntegration', () => { | |
| }; | |
| beforeEach(async () => { | |
| - const actorUserId = objectStringId(); | |
| + const actorUserId = Types.ObjectId().toString(); | |
| await request(httpServer) | |
| .post('/users') | |
| diff --git a/apps/users-ms/src/users/tests/users.service.spec.ts b/apps/users-ms/src/users/tests/users.service.spec.ts | |
| index 3883fae01..37e53c612 100644 | |
| --- a/apps/users-ms/src/users/tests/users.service.spec.ts | |
| +++ b/apps/users-ms/src/users/tests/users.service.spec.ts | |
| @@ -1,5 +1,5 @@ | |
| import { closeInMongodConnection } from '@vinny/test-utils'; | |
| -import { Connection, Model } from 'mongoose'; | |
| +import { Connection, Model, Types } from 'mongoose'; | |
| import { getConnectionToken, getModelToken } from '@nestjs/mongoose'; | |
| import { | |
| AttorneyPauseReason, | |
| @@ -10,7 +10,6 @@ import { | |
| User, | |
| } from '@vinny/users-types'; | |
| import { UserDocument } from '../dal/schemas/user.schema'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| import { | |
| attorney0Dto, | |
| attorney1Dto, | |
| @@ -129,7 +128,7 @@ describe('UsersService', () => { | |
| }); | |
| it("should create customer that doesn't exist", async () => { | |
| - const customerWithMarbleIdDto = { ...customer2Dto, marbleId: objectStringId() }; | |
| + const customerWithMarbleIdDto = { ...customer2Dto, marbleId: Types.ObjectId().toString() }; | |
| const createdCustomer = await verifyUserCreation(customerWithMarbleIdDto); | |
| expect(createdCustomer.emailAlias).toBeTruthy(); | |
| @@ -183,7 +182,7 @@ describe('UsersService', () => { | |
| describe('create attorney', () => { | |
| it("should create attorney that don't exist", async () => { | |
| - const attorneyWithMarbleIdDto = { marbleId: objectStringId(), ...attorney2Dto }; | |
| + const attorneyWithMarbleIdDto = { marbleId: Types.ObjectId().toString(), ...attorney2Dto }; | |
| const createdAttorney = await verifyUserCreation(attorneyWithMarbleIdDto); | |
| expect(createdAttorney.emailAlias).toBeTruthy(); | |
| expect( | |
| @@ -416,7 +415,7 @@ describe('UsersService', () => { | |
| }); | |
| it("should return error if user doesn't exist", async () => { | |
| - await expect(service.findById(objectStringId())).rejects.toThrowError( | |
| + await expect(service.findById(Types.ObjectId().toString())).rejects.toThrowError( | |
| new NotFoundException('user not found'), | |
| ); | |
| }); | |
| @@ -723,7 +722,7 @@ describe('UsersService', () => { | |
| }); | |
| it('should throw ConflictException when user does not exists', async () => { | |
| - const randomId = objectStringId(); | |
| + const randomId = Types.ObjectId().toString(); | |
| await expect( | |
| service.update({ id: randomId, updateUserDto: { email: '[email protected]' } }), | |
| ).rejects.toThrowError(new ConflictException('User not found')); | |
| diff --git a/apps/users-ms/src/users/tests/utils.ts b/apps/users-ms/src/users/tests/utils.ts | |
| index 9a9c2dfc7..b35895079 100644 | |
| --- a/apps/users-ms/src/users/tests/utils.ts | |
| +++ b/apps/users-ms/src/users/tests/utils.ts | |
| @@ -40,7 +40,7 @@ import { | |
| } from '@vinny/users-types'; | |
| import Ajv from 'ajv'; | |
| import addFormats from 'ajv-formats'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { generateCreateTeamDto } from '../../teams/dal/tests/utils'; | |
| import { UsersModule } from '../users.module'; | |
| import { normalizeName } from '../utils/email-alias.utils'; | |
| @@ -75,7 +75,7 @@ export const userMock = { | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const userWithoutFirstName = { | |
| @@ -86,7 +86,7 @@ export const userWithoutFirstName = { | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const userWithoutMiddleName = { | |
| @@ -97,7 +97,7 @@ export const userWithoutMiddleName = { | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const userWithoutLastName = { | |
| @@ -108,7 +108,7 @@ export const userWithoutLastName = { | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const mockUser = { | |
| @@ -119,7 +119,7 @@ export const mockUser = { | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| }; | |
| export const userWithMarbleIdDto = { | |
| @@ -130,7 +130,7 @@ export const userWithMarbleIdDto = { | |
| }, | |
| email: faker.internet.email(), | |
| phone: faker.phone.phoneNumber(), | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| address: { | |
| street: faker.address.streetName(), | |
| city: faker.address.city(), | |
| @@ -292,7 +292,7 @@ export const updatedCustomerDto = { | |
| }; | |
| export const userEntityMockWithId = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| marbleId: '1', | |
| email: '[email protected]', | |
| name: { | |
| @@ -373,7 +373,7 @@ export const createLawFirm = (overrides?: Partial<LawFirm>) => ({ | |
| export const createLegalTeam = (overrides?: Partial<TeamDto>): TeamDto => | |
| ({ | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| ...generateCreateTeamDto(), | |
| ...overrides, | |
| }) as TeamDto; | |
| @@ -382,7 +382,7 @@ export const createBarDetails = (overrides?: Partial<BarDetails>) => { | |
| return { barNumber: faker.datatype.number().toString(), ...overrides }; | |
| }; | |
| -export const createPracticeAreaId = () => objectStringId(); | |
| +export const createPracticeAreaId = () => new Types.ObjectId().toString(); | |
| export const createPracticeAreaEntity = (overrides?: Partial<PracticeArea>): PracticeArea => ({ | |
| practiceAreaId: overrides?.practiceAreaId ?? createPracticeAreaId(), | |
| diff --git a/apps/users-ms/src/users/users.service.ts b/apps/users-ms/src/users/users.service.ts | |
| index bc52b2e8d..57d6babfb 100644 | |
| --- a/apps/users-ms/src/users/users.service.ts | |
| +++ b/apps/users-ms/src/users/users.service.ts | |
| @@ -29,7 +29,7 @@ import { | |
| User, | |
| UserType, | |
| } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { v4 as uuid } from 'uuid'; | |
| import { getDiffData } from '@vinny/diff-util'; | |
| import { ConfigService } from '@nestjs/config'; | |
| @@ -365,10 +365,10 @@ export class UsersService { | |
| ...(e.Status__c && { status: e.Status__c }), | |
| ...(e.Assigned__c && { sfAssignedAttorneyId: e.Assigned__c }), | |
| }, | |
| - id: existing?.id ?? objectStringId(), | |
| + id: existing?.id ?? new Types.ObjectId().toString(), | |
| ...(e.case && { | |
| case: { | |
| - id: existing?.case?.id ?? objectStringId(), | |
| + id: existing?.case?.id ?? new Types.ObjectId().toString(), | |
| sfId: e.Id, | |
| ...(e.case.LastModifiedDate && { lastUpdated: new Date(e.LastModifiedDate) }), | |
| ...(e.case.Name && { name: e.case.Name }), | |
| @@ -462,7 +462,7 @@ export class UsersService { | |
| actorUserId?: string, | |
| ): Promise<User> { | |
| const localCreateUserDto = { ...createUserDto }; | |
| - localCreateUserDto.marbleId ??= objectStringId(); | |
| + localCreateUserDto.marbleId ??= new Types.ObjectId().toString(); | |
| const createdUser = await this.userDAL.create( | |
| await this.handleSpecificFields(localCreateUserDto), | |
| ); | |
| diff --git a/apps/visitors-ms/src/application-forms/dal/schemas/application-form.schema.ts b/apps/visitors-ms/src/application-forms/dal/schemas/application-form.schema.ts | |
| index 7cb841a8e..7d636304e 100644 | |
| --- a/apps/visitors-ms/src/application-forms/dal/schemas/application-form.schema.ts | |
| +++ b/apps/visitors-ms/src/application-forms/dal/schemas/application-form.schema.ts | |
| @@ -1,5 +1,5 @@ | |
| import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { objectIdToStringGetter } from '@vinny/helpers'; | |
| import { ApplicationFormStatus, ApplicationFormType } from '@vinny/visitors-types'; | |
| import { Document, SchemaTypes, Types } from 'mongoose'; | |
| @@ -12,20 +12,25 @@ export class ApplicationForm { | |
| createdAt: Date; | |
| updatedAt: Date; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: objectIdToStringGetter, | |
| + index: true, | |
| + }) | |
| userId: string; | |
| @Prop({ | |
| required: true, | |
| type: String, | |
| - enum: Object.values(ApplicationFormType), | |
| + enum: ApplicationFormType, | |
| }) | |
| type: ApplicationFormType; | |
| @Prop({ | |
| required: true, | |
| type: String, | |
| - enum: Object.values(ApplicationFormStatus), | |
| + enum: ApplicationFormStatus, | |
| default: ApplicationFormStatus.PENDING, | |
| }) | |
| status: ApplicationFormStatus; | |
| diff --git a/apps/visitors-ms/src/referrals/dal/schemas/referral.schema.ts b/apps/visitors-ms/src/referrals/dal/schemas/referral.schema.ts | |
| index 2f7d3b342..f055912a7 100644 | |
| --- a/apps/visitors-ms/src/referrals/dal/schemas/referral.schema.ts | |
| +++ b/apps/visitors-ms/src/referrals/dal/schemas/referral.schema.ts | |
| @@ -7,8 +7,7 @@ import { | |
| ReferralStatus, | |
| ReferralType, | |
| } from '@vinny/visitors-types'; | |
| -import { Document } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| +import { Document, SchemaTypes, Types } from 'mongoose'; | |
| @Schema({ _id: false }) | |
| export class AdditionalInfo { | |
| @@ -69,7 +68,12 @@ export class CaseDetails { | |
| @Schema({ _id: false, id: false, toObject: { getters: true } }) | |
| export class RecommendedService { | |
| - @Prop(objectIdPropHandler({ required: true })) | |
| + @Prop({ | |
| + required: true, | |
| + type: SchemaTypes.ObjectId, | |
| + get: (v: Types.ObjectId) => v?.toString(), | |
| + set: (v: string) => Types.ObjectId(v), | |
| + }) | |
| serviceTypeId: string; | |
| @Prop({ required: false }) | |
| diff --git a/apps/visitors-ms/src/referrals/test/utils.ts b/apps/visitors-ms/src/referrals/test/utils.ts | |
| index e0663511d..3e43e67e4 100644 | |
| --- a/apps/visitors-ms/src/referrals/test/utils.ts | |
| +++ b/apps/visitors-ms/src/referrals/test/utils.ts | |
| @@ -19,7 +19,7 @@ import { | |
| ReferralType, | |
| } from '@vinny/visitors-types'; | |
| import { plainToInstance } from 'class-transformer'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { ReferralsModule } from '../referrals.module'; | |
| export const ENV_VARS: Record<string, string> = { | |
| @@ -36,7 +36,7 @@ export const createReferralsTestModule = (): Promise<TestingModule> => { | |
| }; | |
| export const mockPracticeArea: PracticeAreaDto = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| key: 'TEST_KEY', | |
| displayName: 'Test Display Name', | |
| }; | |
| @@ -66,7 +66,7 @@ export const generateCreateReferralDto = (submitterUserId?: string): CreateRefer | |
| }, | |
| caseDetails: { | |
| practiceAreaId: mockPracticeArea.id, | |
| - courtCaseId: objectStringId(), | |
| + courtCaseId: Types.ObjectId().toString(), | |
| expertises: ['test'], | |
| opposingPartyName: { | |
| first: faker.name.firstName(), | |
| @@ -86,7 +86,7 @@ export const generateCreateReferralDto = (submitterUserId?: string): CreateRefer | |
| }, | |
| recommendedServices: [ | |
| { | |
| - serviceTypeId: objectStringId(), | |
| + serviceTypeId: Types.ObjectId().toString(), | |
| details: faker.lorem.sentence(), | |
| }, | |
| ], | |
| @@ -106,7 +106,7 @@ export const generateCreateReferralDto = (submitterUserId?: string): CreateRefer | |
| export const createReferralDtoObj = (req: CreateReferralDto): ReferralDto => { | |
| const now = new Date(); | |
| return { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| createdAt: now, | |
| updatedAt: now, | |
| type: req.type, | |
| diff --git a/apps/visitors-ms/src/visitors/tests/visitors.utils.ts b/apps/visitors-ms/src/visitors/tests/visitors.utils.ts | |
| index 7b1d7997b..6e0c46f62 100644 | |
| --- a/apps/visitors-ms/src/visitors/tests/visitors.utils.ts | |
| +++ b/apps/visitors-ms/src/visitors/tests/visitors.utils.ts | |
| @@ -1,4 +1,4 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import faker from '@faker-js/faker'; | |
| import { CreateVisitorRequestDto } from '@vinny/visitors-types'; | |
| @@ -8,7 +8,7 @@ export const ENV_VARS = { | |
| }; | |
| export const mockNewVisitor: CreateVisitorRequestDto = { | |
| - anonymousId: objectStringId(), | |
| + anonymousId: Types.ObjectId().toString(), | |
| name: { | |
| first: faker.name.firstName(), | |
| last: faker.name.lastName(), | |
| @@ -21,4 +21,4 @@ export const mockNewVisitor: CreateVisitorRequestDto = { | |
| }, | |
| }; | |
| -export const mockVisitorId = objectStringId(); | |
| +export const mockVisitorId = Types.ObjectId().toString(); | |
| diff --git a/e2e/e2e-tests/test/attorneys-graphql/lss/lss-events.spec.ts b/e2e/e2e-tests/test/attorneys-graphql/lss/lss-events.spec.ts | |
| index cdb7acf09..6636f17c3 100644 | |
| --- a/e2e/e2e-tests/test/attorneys-graphql/lss/lss-events.spec.ts | |
| +++ b/e2e/e2e-tests/test/attorneys-graphql/lss/lss-events.spec.ts | |
| @@ -9,7 +9,7 @@ import { generateHeadersWithIdempotency } from '@vinny/idempotency-test-utils'; | |
| import { PracticeAreaDto } from '@vinny/services-types'; | |
| import { User } from '@vinny/users-types'; | |
| import { plainToInstance } from 'class-transformer'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { createTestPracticeAreaIfDoesntExist } from '../../services.utils'; | |
| import { BaseUrl, createUser, generateCreateUserRequest } from '../../user.utils'; | |
| import { apiClient, attorneysGraphApiClient } from '../../utils'; | |
| @@ -141,7 +141,7 @@ describe('lss-event', () => { | |
| customerId: lssCustomer.id, | |
| practiceAreaId: practiceArea.id, | |
| }); | |
| - const idempotencyKey = objectStringId(); | |
| + const idempotencyKey = Types.ObjectId().toString(); | |
| const headers = generateHeadersWithIdempotency({ [IDEMPOTENCY_KEY_HEADER]: idempotencyKey }); | |
| const lssEvent1 = await sendCreateLssEventRequest(apiClient, createDto, headers); | |
| @@ -156,11 +156,11 @@ describe('lss-event', () => { | |
| customerId: lssCustomer.id, | |
| practiceAreaId: practiceArea.id, | |
| }); | |
| - const idempotencyKey = objectStringId(); | |
| + const idempotencyKey = Types.ObjectId().toString(); | |
| const headers = generateHeadersWithIdempotency({ [IDEMPOTENCY_KEY_HEADER]: idempotencyKey }); | |
| const lssEvent1 = await sendCreateLssEventRequest(apiClient, createDto, headers); | |
| - const NewIdempotencyKey = objectStringId(); | |
| + const NewIdempotencyKey = Types.ObjectId().toString(); | |
| const newHeaders = { | |
| ...headers, | |
| [IDEMPOTENCY_KEY_HEADER]: NewIdempotencyKey, | |
| diff --git a/e2e/e2e-tests/test/attorneys/attorneys.spec.ts b/e2e/e2e-tests/test/attorneys/attorneys.spec.ts | |
| index e4564a178..0372d5634 100644 | |
| --- a/e2e/e2e-tests/test/attorneys/attorneys.spec.ts | |
| +++ b/e2e/e2e-tests/test/attorneys/attorneys.spec.ts | |
| @@ -15,7 +15,7 @@ import { | |
| User, | |
| } from '@vinny/users-types'; | |
| import { plainToInstance } from 'class-transformer'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { apiClient } from '../utils'; | |
| import { | |
| attorneyDataDefaults, | |
| @@ -134,9 +134,12 @@ describe('Attorneys', () => { | |
| it('should not find non existing attorney by id', async () => { | |
| const createAttorneyRequest = generateCreateAttorneyOverrideRequest(); | |
| await createAttorneyAndVerify(createAttorneyRequest); | |
| - const { data: res, status } = await apiClient.get(`/attorneys/${new objectStringId()}`, { | |
| - validateStatus: null, | |
| - }); | |
| + const { data: res, status } = await apiClient.get( | |
| + `/attorneys/${new Types.ObjectId().toString()}`, | |
| + { | |
| + validateStatus: null, | |
| + }, | |
| + ); | |
| expect(res.message).toEqual('user not found'); | |
| expect(status).toEqual(404); | |
| diff --git a/e2e/e2e-tests/test/catalog/utils.ts b/e2e/e2e-tests/test/catalog/utils.ts | |
| index cd3e71a8c..63296c736 100644 | |
| --- a/e2e/e2e-tests/test/catalog/utils.ts | |
| +++ b/e2e/e2e-tests/test/catalog/utils.ts | |
| @@ -4,7 +4,7 @@ import { AxiosInstance } from 'axios'; | |
| import { apiClient } from '../utils'; | |
| import { HttpStatus } from '@nestjs/common'; | |
| import { v4 as uuid } from 'uuid'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| export async function createDocumentType(apiClient: AxiosInstance): Promise<DocumentTypeDto> { | |
| const MockDocumentTypePayload = { | |
| @@ -53,7 +53,7 @@ export async function generateRandomCatalogServiceTypeRequest(): Promise<CreateS | |
| purpose: 'purpose', | |
| }, | |
| isAddendumProduct: false, | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| firm: 'Marble', | |
| category: `E2E-GENERATED-${uuid()}`, | |
| isRequiresAdditionalExpenseForClient: false, | |
| diff --git a/e2e/e2e-tests/test/documents/documents.spec.ts b/e2e/e2e-tests/test/documents/documents.spec.ts | |
| index 05174d3ec..5c4c6df8e 100644 | |
| --- a/e2e/e2e-tests/test/documents/documents.spec.ts | |
| +++ b/e2e/e2e-tests/test/documents/documents.spec.ts | |
| @@ -13,7 +13,7 @@ import { | |
| } from './documents.utils'; | |
| import { createUserAndCase } from '../cases/cases.utils'; | |
| import { apiClient } from '../utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import axios from 'axios'; | |
| import * as fs from 'fs'; | |
| import * as path from 'path'; | |
| @@ -57,7 +57,7 @@ describe('documents', () => { | |
| }); | |
| it('should return empty documents list when filter by random case id', async () => { | |
| - const params = { caseId: objectStringId() }; | |
| + const params = { caseId: Types.ObjectId().toString() }; | |
| const { data: foundDocuments, status } = await apiClient.get('documents', { params }); | |
| expect(status).toEqual(200); | |
| expect(foundDocuments).toEqual([]); | |
| @@ -79,8 +79,8 @@ describe('documents', () => { | |
| 'documents/upload', | |
| { | |
| ...baseDocumentUploadRequest1, | |
| - uploaderMarbleId: objectStringId(), | |
| - caseId: objectStringId(), | |
| + uploaderMarbleId: Types.ObjectId().toString(), | |
| + caseId: Types.ObjectId().toString(), | |
| documentTypeId: documentType.id, | |
| }, | |
| { validateStatus: null }, | |
| @@ -90,7 +90,7 @@ describe('documents', () => { | |
| }); | |
| it('should fail on getDocumentDownloadUrl when case does not exists', async () => { | |
| - const documentId = objectStringId(); | |
| + const documentId = Types.ObjectId().toString(); | |
| const { status } = await apiClient.get(`documents/download/${documentId}`, { | |
| validateStatus: null, | |
| }); | |
| @@ -99,7 +99,7 @@ describe('documents', () => { | |
| }); | |
| it('should fail to update if document does not exists', async () => { | |
| - const id = objectStringId(); | |
| + const id = Types.ObjectId().toString(); | |
| const { status } = await apiClient.patch(`/documents/${id}`, updateDocumentDtoMock, { | |
| validateStatus: null, | |
| }); | |
| diff --git a/e2e/e2e-tests/test/events/lss/lss-events.spec.ts b/e2e/e2e-tests/test/events/lss/lss-events.spec.ts | |
| index 87d0dd768..83076d80b 100644 | |
| --- a/e2e/e2e-tests/test/events/lss/lss-events.spec.ts | |
| +++ b/e2e/e2e-tests/test/events/lss/lss-events.spec.ts | |
| @@ -14,7 +14,7 @@ import { generateHeadersWithIdempotency } from '@vinny/idempotency-test-utils'; | |
| import { LssEventDto, LssStatus, LssStatusForUpdate } from '@vinny/events-types'; | |
| import { PracticeAreaDto } from '@vinny/services-types'; | |
| import { User } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { createTestPracticeAreaIfDoesntExist } from '../../services.utils'; | |
| import { BaseUrl, createUser, generateCreateUserRequest } from '../../user.utils'; | |
| import { apiClient } from '../../utils'; | |
| @@ -41,7 +41,7 @@ describe('lss-event', () => { | |
| lssCustomer = customer; | |
| practiceArea = await createTestPracticeAreaIfDoesntExist(); | |
| - caseId = objectStringId(); | |
| + caseId = Types.ObjectId().toString(); | |
| }); | |
| describe('flows', () => { | |
| @@ -68,7 +68,7 @@ describe('lss-event', () => { | |
| }); | |
| describe('update', () => { | |
| it('lss event fields', async () => { | |
| - const newCaseId = objectStringId(); | |
| + const newCaseId = Types.ObjectId().toString(); | |
| const updateDto = generateUpdateLssEventDto({ caseId: newCaseId }); | |
| const updatedEvent = await sendUpdateLssEventRequest(apiClient, lssEvent.id, updateDto); | |
| @@ -199,7 +199,7 @@ describe('lss-event', () => { | |
| const createDto = generateCreateLssEventDto(); | |
| const headers = generateHeadersWithIdempotency(); | |
| const lssEvent1 = await sendCreateLssEventRequest(apiClient, createDto, headers); | |
| - const idempotencyKey = objectStringId(); | |
| + const idempotencyKey = Types.ObjectId().toString(); | |
| const newHeaders = { | |
| ...headers, | |
| [IDEMPOTENCY_KEY_HEADER]: idempotencyKey, | |
| diff --git a/e2e/e2e-tests/test/graphql/documents/documents.spec.ts b/e2e/e2e-tests/test/graphql/documents/documents.spec.ts | |
| index 105330b85..02b3a17a1 100644 | |
| --- a/e2e/e2e-tests/test/graphql/documents/documents.spec.ts | |
| +++ b/e2e/e2e-tests/test/graphql/documents/documents.spec.ts | |
| @@ -11,7 +11,7 @@ import { | |
| removeCustomerVisibilityMutation, | |
| newFileName, | |
| } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { TokenTypes } from '@vinny/auth-types'; | |
| import { createDocumentType } from '../../catalog/utils'; | |
| @@ -67,7 +67,7 @@ describe('graphql', () => { | |
| }, 10000); | |
| it('should get success = false on renameDocument request if document does not exists', async () => { | |
| - const id = objectStringId(); | |
| + const id = Types.ObjectId().toString(); | |
| const { data, status } = await graphApiClient({ | |
| data: { | |
| query: renameDocumentMutation, | |
| @@ -82,7 +82,7 @@ describe('graphql', () => { | |
| }); | |
| it('should get success = false on removeDocumentCustomerVisibility request if document does not exists', async () => { | |
| - const id = objectStringId(); | |
| + const id = Types.ObjectId().toString(); | |
| const { data, status } = await graphApiClient({ | |
| data: { | |
| query: removeCustomerVisibilityMutation, | |
| diff --git a/e2e/e2e-tests/test/service-tags/service-tags.spec.ts b/e2e/e2e-tests/test/service-tags/service-tags.spec.ts | |
| index f7af27960..09525c6f5 100644 | |
| --- a/e2e/e2e-tests/test/service-tags/service-tags.spec.ts | |
| +++ b/e2e/e2e-tests/test/service-tags/service-tags.spec.ts | |
| @@ -1,5 +1,5 @@ | |
| import faker from '@faker-js/faker'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { createTestPracticeAreaIfDoesntExist } from '../services.utils'; | |
| import { apiClient } from '../utils'; | |
| @@ -51,7 +51,7 @@ describe('Service Tags', () => { | |
| const createServiceTagRequest = { | |
| key: `bad-key`, | |
| displayName: 'mock tag', | |
| - practiceAreaId: objectStringId(), | |
| + practiceAreaId: Types.ObjectId().toString(), | |
| }; | |
| const { data, status } = await apiClient.post(`${BASE_PATH}`, createServiceTagRequest, { | |
| validateStatus: null, | |
| diff --git a/e2e/e2e-tests/test/user.utils.ts b/e2e/e2e-tests/test/user.utils.ts | |
| index 140714eec..f7e5a8966 100644 | |
| --- a/e2e/e2e-tests/test/user.utils.ts | |
| +++ b/e2e/e2e-tests/test/user.utils.ts | |
| @@ -29,7 +29,7 @@ import { | |
| ServiceAttitude, | |
| UpdateAttorneyPracticeAreaRequestDto, | |
| } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| const API_URL = process.env.API_URL ?? 'http://localhost:8080'; | |
| const API_TOKEN = process.env.API_TOKEN ?? '264c1762-ff4c-464d-8bb2-ba34ba5ea654'; | |
| @@ -357,7 +357,7 @@ export async function createAuthorizedAttorney(): Promise<any> { | |
| return attorney; | |
| } | |
| -export const getValidIdString = () => new objectStringId(); | |
| +export const getValidIdString = () => new Types.ObjectId().toString(); | |
| export const attorneyDataWithAllFields = (practiceAreaIds: [string, string]): AttorneyData => ({ | |
| practiceAreasIds: practiceAreaIds, | |
| diff --git a/e2e/e2e-tests/test/users.spec.ts b/e2e/e2e-tests/test/users.spec.ts | |
| index f5a5e6292..4687bdfbe 100644 | |
| --- a/e2e/e2e-tests/test/users.spec.ts | |
| +++ b/e2e/e2e-tests/test/users.spec.ts | |
| @@ -2,7 +2,7 @@ import { normalizeUsPhoneNumberForTests } from '@vinny/transformers'; | |
| import { createUser, findUser, generateCreateUserRequest, getUser, updateUser } from './user.utils'; | |
| import { faker } from '@faker-js/faker'; | |
| import { apiClient } from './utils'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { addUserIdToCleanupList } from '@vinny/users-test-utils'; | |
| describe('Users', () => { | |
| @@ -228,7 +228,7 @@ describe('Users', () => { | |
| }); | |
| it('should fail to update a user if user does not exists', async () => { | |
| - const randomId = objectStringId(); | |
| + const randomId = Types.ObjectId().toString(); | |
| const { status } = await updateUser({ | |
| id: randomId, | |
| updateUserRequest: { email: '[email protected]' }, | |
| @@ -240,7 +240,7 @@ describe('Users', () => { | |
| describe('findById', () => { | |
| it('should fail to find user by id when user does not exists', async () => { | |
| - const { status: findStatus } = await getUser(objectStringId(), undefined, true); | |
| + const { status: findStatus } = await getUser(Types.ObjectId().toString(), undefined, true); | |
| expect(findStatus).toEqual(404); | |
| }); | |
| }); | |
| diff --git a/libs/auth-client/src/lib/test/utils.ts b/libs/auth-client/src/lib/test/utils.ts | |
| index 16a67bdaf..6df618f1e 100644 | |
| --- a/libs/auth-client/src/lib/test/utils.ts | |
| +++ b/libs/auth-client/src/lib/test/utils.ts | |
| @@ -1,6 +1,6 @@ | |
| import { Role, PermissionsAndConfig, ALLOWED_PERMISSIONS_AND_CONFIG } from '@vinny/auth-types'; | |
| import { User } from '@vinny/users-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { createMock } from '@golevelup/ts-jest'; | |
| import { ExecutionContext } from '@nestjs/common'; | |
| import { Reflector } from '@nestjs/core'; | |
| @@ -13,21 +13,21 @@ import { FlareLogger, FlareLoggerMock } from '@vinny/logger'; | |
| import { SplitModule } from '@marbletech/split'; | |
| export const user: User = { | |
| - id: objectStringId(), | |
| + id: Types.ObjectId().toString(), | |
| name: { | |
| first: 'test', | |
| last: 'user', | |
| }, | |
| email: '[email protected]', | |
| - marbleId: objectStringId(), | |
| + marbleId: Types.ObjectId().toString(), | |
| roles: [Role.CUSTOMER], | |
| }; | |
| export const VERIFICATION_CODE = '123456'; | |
| -export const mockUserId = objectStringId(); | |
| -export const mockUserMarbleId = objectStringId(); | |
| -export const mockImpersonateId = objectStringId(); | |
| +export const mockUserId = Types.ObjectId().toString(); | |
| +export const mockUserMarbleId = Types.ObjectId().toString(); | |
| +export const mockImpersonateId = Types.ObjectId().toString(); | |
| export const mockToken = | |
| 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJ3lbWFpbCI6ImRldnVzZXJAdGhlbWlzLXRlY2guaW8iLCJuYW1lIjp7ImZpcnN0IjoiRGV2IiwibGFzdCI6IlVzZXIifSwibWFyYmxlSWQiOiI2MjQ5NzVjNGM0N2VlZmI1NGNhYzU5OGQiLCJpZCI6IjYwZTU0ZjQxYzU0ZDY2MmY3ODJhZmI4YiIsInR5cGUiOiJjdXN0b21lciIsInNlc3Npb25JZCI6IjRhOGRkNzhlLTZkNjEtNGQ4MS04MmI3LTc3OTRlNmY2YWI2NSIsInNlc3Npb25UeXBlIjoiVE9LRU4iLCJpYXQiOjE2NTkyODE5MTMsImV4cCI6MTY2MDQ5MTUxM30.vihkMDZ0CeShC2C7hpdYt5mzSsfPo76UN9Z23dc20bkN5ezu-q3hNTPtytCTGrGVJI12qufDpTDgfFseuip_AA'; | |
| export const AuthorizationMock = `Bearer ${mockToken}`; | |
| diff --git a/libs/helpers/src/lib/schema/index.ts b/libs/helpers/src/lib/schema/index.ts | |
| index 995948307..76157569f 100644 | |
| --- a/libs/helpers/src/lib/schema/index.ts | |
| +++ b/libs/helpers/src/lib/schema/index.ts | |
| @@ -1,61 +1,6 @@ | |
| -import { Document, ObjectId, SchemaTypeOptions, SchemaTypes, Types } from 'mongoose'; | |
| -import { PropOptions } from '@nestjs/mongoose'; | |
| -import { safe, succeeded } from '@vinny/infra'; | |
| +import { Types } from 'mongoose'; | |
| -export const objectIdToStringGetter = (v: Types.ObjectId): string => v?.toHexString(); | |
| +export const objectIdToStringGetter = (v: Types.ObjectId): string => v?.toString(); | |
| export const objectIdsToStringsGetter = (objectIds: Types.ObjectId[]): string[] => { | |
| return objectIds?.map(objectIdToStringGetter); | |
| }; | |
| - | |
| -export function enumPropHandler<T extends Record<string, string>>( | |
| - obj: T, | |
| - opts?: SchemaTypeOptions<ObjectId>, | |
| -): PropOptions { | |
| - return { | |
| - ...opts, | |
| - type: String, | |
| - enum: Object.values(obj), | |
| - }; | |
| -} | |
| - | |
| -export function objectIdPropHandler(opts?: SchemaTypeOptions<ObjectId>): PropOptions { | |
| - return { | |
| - ...opts, | |
| - type: SchemaTypes.ObjectId, | |
| - get: objectIdToStringGetter, | |
| - set: (v: string): Types.ObjectId | undefined => (v ? objectId(v) : undefined), | |
| - }; | |
| -} | |
| - | |
| -export function objectIdsPropHandler(opts?: SchemaTypeOptions<ObjectId[]>): PropOptions { | |
| - return { | |
| - ...opts, | |
| - type: [SchemaTypes.ObjectId], | |
| - get: objectIdsToStringsGetter, | |
| - set: (v: string[]): Types.ObjectId[] => v.filter((a) => a).map((a) => objectId(a)), | |
| - }; | |
| -} | |
| - | |
| -export const objectStringId: (objectId?: Types.ObjectId) => string = (objectId?: Types.ObjectId) => | |
| - (objectId ?? Types.ObjectId()).toHexString(); | |
| - | |
| -export const objectId: (str: string) => Types.ObjectId = (str: string) => Types.ObjectId(str); | |
| -export const isObjectId: (str: string) => boolean = (str: string) => | |
| - succeeded(safe(() => objectId(str))); | |
| - | |
| -export async function materialize<T extends Document>( | |
| - mongooseCall: () => Promise<T | null>, | |
| - throwOnNull?: Error, | |
| -): Promise<T | null> { | |
| - const result = await mongooseCall(); | |
| - if (result) return result.toObject({ virtuals: true }) as T; | |
| - if (throwOnNull) throw throwOnNull; | |
| - return null; | |
| -} | |
| - | |
| -export async function materializeMany<T extends Document>( | |
| - mongooseCall: () => Promise<T[] | undefined>, | |
| -): Promise<T[]> { | |
| - const result = await mongooseCall(); | |
| - return !result ? [] : result.map((a) => a.toObject({ virtuals: true }) as T); | |
| -} | |
| diff --git a/libs/infra/src/lib/safe.ts b/libs/infra/src/lib/safe.ts | |
| index 2bc6b5f6e..603fe3d11 100644 | |
| --- a/libs/infra/src/lib/safe.ts | |
| +++ b/libs/infra/src/lib/safe.ts | |
| @@ -2,14 +2,6 @@ export declare type SuccessResult<TObj> = [undefined, TObj]; | |
| export declare type FailureResult<TErr> = [TErr]; | |
| export declare type Result<T> = SuccessResult<T> | FailureResult<Error>; | |
| -export function succeeded<TRet>(res: Result<TRet>): boolean { | |
| - return !res[0]; | |
| -} | |
| - | |
| -export function failed<TRet>(res: Result<TRet>): boolean { | |
| - return !succeeded(res); | |
| -} | |
| - | |
| export function Success<TRet>(obj: TRet): SuccessResult<TRet> { | |
| return [undefined, obj]; | |
| } | |
| diff --git a/libs/marble-os/src/marble-os.schema.ts b/libs/marble-os/src/marble-os.schema.ts | |
| index c33824101..3bee67739 100644 | |
| --- a/libs/marble-os/src/marble-os.schema.ts | |
| +++ b/libs/marble-os/src/marble-os.schema.ts | |
| @@ -2,7 +2,7 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| import { Document, Types } from 'mongoose'; | |
| import { isQualifiedInternalEmail } from '@vinny/infra'; | |
| -@Schema({ _id: false, id: false }) | |
| +@Schema() | |
| class Name { | |
| @Prop({ required: true }) | |
| first: string; | |
| diff --git a/libs/playground/README.md b/libs/playground/README.md | |
| deleted file mode 100644 | |
| index b87f1eb08..000000000 | |
| --- a/libs/playground/README.md | |
| +++ /dev/null | |
| @@ -1,7 +0,0 @@ | |
| -# activity-log-client | |
| - | |
| -This library was generated with [Nx](https://nx.dev). | |
| - | |
| -## Running unit tests | |
| - | |
| -Run `nx test activity-log-client` to execute the unit tests via [Jest](https://jestjs.io). | |
| diff --git a/libs/playground/package.json b/libs/playground/package.json | |
| deleted file mode 100644 | |
| index ad7043b09..000000000 | |
| --- a/libs/playground/package.json | |
| +++ /dev/null | |
| @@ -1,21 +0,0 @@ | |
| -{ | |
| - "name": "@vinny/playground", | |
| - "private": "true", | |
| - "version": "1.0.0", | |
| - "license": "ISC", | |
| - "main": "./src/index.ts", | |
| - "scripts": { | |
| - "lint": "eslint -f mo --cache --cache-location ./.cache/.eslintcache .", | |
| - "format": "prettier --align-object-properties=none --cache-location ./.cache/.prettier --list-different \"./src/**/*.ts\"", | |
| - "test": "jest --passWithNoTests --logHeapUsage" | |
| - }, | |
| - "jest": { | |
| - "preset": "../../.build/.base/jest.preset.cjs" | |
| - }, | |
| - "devDependencies": { | |
| - "@vinny/activity-logs-types": "1.0.0", | |
| - "@vinny/http-client-wrapper": "1.0.0", | |
| - "@vinny/kafka-client": "1.0.0", | |
| - "@vinny/logger": "1.0.0" | |
| - } | |
| -} | |
| diff --git a/libs/playground/src/index.ts b/libs/playground/src/index.ts | |
| deleted file mode 100644 | |
| index d6de5df64..000000000 | |
| --- a/libs/playground/src/index.ts | |
| +++ /dev/null | |
| @@ -1,2 +0,0 @@ | |
| -export * from './lib/client/playground.module'; | |
| -export * from './lib/client/playground.service'; | |
| diff --git a/libs/playground/src/lib/client/playground.module.ts b/libs/playground/src/lib/client/playground.module.ts | |
| deleted file mode 100644 | |
| index fa6197f89..000000000 | |
| --- a/libs/playground/src/lib/client/playground.module.ts | |
| +++ /dev/null | |
| @@ -1,18 +0,0 @@ | |
| -import { Module } from '@nestjs/common'; | |
| -import { PlaygroundService } from './playground.service'; | |
| -import { MongooseModule } from '@nestjs/mongoose'; | |
| -import { Playground, PlaygroundSchema } from './playground.schema'; | |
| - | |
| -@Module({ | |
| - imports: [ | |
| - MongooseModule.forFeature([ | |
| - { | |
| - name: Playground.name, | |
| - schema: PlaygroundSchema, | |
| - }, | |
| - ]), | |
| - ], | |
| - providers: [PlaygroundService], | |
| - exports: [PlaygroundService], | |
| -}) | |
| -export class PlaygroundModule {} | |
| diff --git a/libs/playground/src/lib/client/playground.schema.ts b/libs/playground/src/lib/client/playground.schema.ts | |
| deleted file mode 100644 | |
| index 574cd9b91..000000000 | |
| --- a/libs/playground/src/lib/client/playground.schema.ts | |
| +++ /dev/null | |
| @@ -1,74 +0,0 @@ | |
| -import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | |
| -import { Document, EnforceDocument, SchemaTypes } from 'mongoose'; | |
| -import { objectIdPropHandler } from '@vinny/helpers'; | |
| - | |
| -export enum SomeEnum { | |
| - VALUE1 = 'VALUE1', | |
| - VALUE2 = 'VALUE2', | |
| -} | |
| - | |
| -@Schema({ | |
| - _id: false, | |
| - id: false, | |
| - toObject: { getters: true }, | |
| - toJSON: { getters: true }, | |
| - minimize: false, | |
| -}) | |
| -export class NestedObjectForMap { | |
| - @Prop({ type: String }) | |
| - stringProp?: string; | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| - objectIdProp: string; | |
| - | |
| - @Prop({ type: String, enum: Object.values(SomeEnum), default: SomeEnum.VALUE1 }) | |
| - someEnumProp?: SomeEnum; | |
| -} | |
| - | |
| -const NestedObjectForMapSchema = SchemaFactory.createForClass(NestedObjectForMap); | |
| - | |
| -@Schema({ | |
| - _id: true, | |
| - id: true, | |
| - toObject: { getters: true }, | |
| - toJSON: { getters: true }, | |
| - timestamps: true, | |
| - minimize: false, | |
| -}) | |
| -export class Playground { | |
| - id?: string; | |
| - | |
| - @Prop({ | |
| - index: true, | |
| - type: SchemaTypes.Map, | |
| - of: NestedObjectForMapSchema, | |
| - default: new Map(), | |
| - get(value: Map<string, NestedObjectForMap & Document>) { | |
| - const newObject: Record<string, NestedObjectForMap> = {}; | |
| - for (const [key, val] of value) { | |
| - if (val) newObject[key] = val?.toObject(); | |
| - } | |
| - return newObject; | |
| - }, | |
| - }) | |
| - mapProperty: Record<string, NestedObjectForMap>; | |
| - | |
| - @Prop({ | |
| - type: NestedObjectForMapSchema, | |
| - required: false, | |
| - }) | |
| - standaloneNestedObjectProperty?: NestedObjectForMap; | |
| - @Prop({ | |
| - type: [NestedObjectForMapSchema], | |
| - required: false, | |
| - }) | |
| - arrayOfNestedObjectProperty?: NestedObjectForMap[]; | |
| - | |
| - @Prop(objectIdPropHandler({ required: true, index: true })) | |
| - objectRootIdProp: string; | |
| - | |
| - @Prop({ type: String, enum: Object.values(SomeEnum) }) | |
| - someEnumProp?: SomeEnum; | |
| -} | |
| -export const PlaygroundSchema = SchemaFactory.createForClass(Playground); | |
| -export declare type PlaygroundDocument = Playground & | |
| - Document<Playground, never, EnforceDocument<Playground, Document<Playground, never, Playground>>>; | |
| diff --git a/libs/playground/src/lib/client/playground.service.ts b/libs/playground/src/lib/client/playground.service.ts | |
| deleted file mode 100644 | |
| index a710f59d7..000000000 | |
| --- a/libs/playground/src/lib/client/playground.service.ts | |
| +++ /dev/null | |
| @@ -1,12 +0,0 @@ | |
| -import { Injectable } from '@nestjs/common'; | |
| -import { InjectModel } from '@nestjs/mongoose'; | |
| -import { Model } from 'mongoose'; | |
| -import { PlaygroundDocument, Playground } from './playground.schema'; | |
| -@Injectable() | |
| -export class PlaygroundService { | |
| - constructor(@InjectModel(Playground.name) private userModel: Model<PlaygroundDocument>) {} | |
| - | |
| - public get model(): Model<PlaygroundDocument> { | |
| - return this.userModel; | |
| - } | |
| -} | |
| diff --git a/libs/playground/src/test/playground.spec.ts b/libs/playground/src/test/playground.spec.ts | |
| deleted file mode 100644 | |
| index 54eb0a110..000000000 | |
| --- a/libs/playground/src/test/playground.spec.ts | |
| +++ /dev/null | |
| @@ -1,143 +0,0 @@ | |
| -import { createTestingModule, importCommons } from '@vinny/test-utils'; | |
| -import { PlaygroundModule } from '../lib/client/playground.module'; | |
| -import { Model } from 'mongoose'; | |
| -import { Playground, PlaygroundDocument, SomeEnum } from '../lib/client/playground.schema'; | |
| -import { objectId, objectStringId } from '@vinny/helpers'; | |
| -import { omit } from 'lodash'; | |
| -import { getModelToken } from '@nestjs/mongoose'; | |
| - | |
| -describe('playground', () => { | |
| - let model: Model<PlaygroundDocument>; | |
| - beforeEach(async () => { | |
| - const module = await createTestingModule({ | |
| - imports: [PlaygroundModule, ...importCommons()], | |
| - }) | |
| - .overrideCommons() | |
| - .compile(); | |
| - model = await module.resolve(getModelToken(Playground.name)); | |
| - }); | |
| - it('should work', async () => { | |
| - const a = { | |
| - objectRootIdProp: objectStringId(), | |
| - standaloneNestedObjectProperty: { | |
| - objectIdProp: objectStringId(), | |
| - stringProp: 'stringProp', | |
| - someEnumProp: SomeEnum.VALUE1, | |
| - }, | |
| - arrayOfNestedObjectProperty: [ | |
| - { | |
| - objectIdProp: objectStringId(), | |
| - stringProp: 'stringProp', | |
| - someEnumProp: SomeEnum.VALUE1, | |
| - }, | |
| - { | |
| - objectIdProp: objectStringId(), | |
| - stringProp: 'stringProp', | |
| - someEnumProp: SomeEnum.VALUE2, | |
| - }, | |
| - ], | |
| - mapProperty: { | |
| - aa: { | |
| - objectIdProp: objectStringId(), | |
| - stringProp: 'stringProp', | |
| - someEnumProp: SomeEnum.VALUE1, | |
| - }, | |
| - }, | |
| - } satisfies Playground; | |
| - const res = await model.create<Playground>(a); | |
| - expect(res).toBeDefined(); | |
| - expect(res.toObject()).toEqual(expect.objectContaining(omit(a, '_id'))); | |
| - const res2 = await model.findById(res.id); | |
| - expect(res2.toObject()).toEqual(expect.objectContaining(omit(a, '_id'))); | |
| - const res3 = await model.find({ | |
| - objectRootIdProp: a.objectRootIdProp, | |
| - }); | |
| - expect(res3[0].toObject()) | |
| - .toEqual(expect.objectContaining(omit(a, '_id'))); | |
| - | |
| - const nested = objectStringId(); | |
| - const res4 = await model | |
| - .findOneAndUpdate( | |
| - { | |
| - objectRootIdProp: a.objectRootIdProp, | |
| - }, | |
| - { | |
| - $set: { | |
| - mapProperty: { | |
| - aa: { | |
| - objectIdProp: nested, | |
| - }, | |
| - }, | |
| - }, | |
| - }, | |
| - { | |
| - new: true, | |
| - returnDocument: 'after', | |
| - }, | |
| - ); | |
| - expect(res4.toObject()).toEqual( | |
| - expect.objectContaining( | |
| - omit( | |
| - { | |
| - ...a, | |
| - mapProperty: expect.objectContaining({ | |
| - aa: expect.objectContaining({ | |
| - objectIdProp: nested, | |
| - }), | |
| - }), | |
| - }, | |
| - '_id', | |
| - ), | |
| - ), | |
| - ); | |
| - const res5 = await model | |
| - .aggregate([ | |
| - { | |
| - $match: { | |
| - objectRootIdProp: objectId(a.objectRootIdProp), | |
| - }, | |
| - }, | |
| - { | |
| - $set: { | |
| - mapProperty: { | |
| - bb: { | |
| - objectIdProp: objectId(nested), | |
| - }, | |
| - }, | |
| - }, | |
| - }, | |
| - { | |
| - $project: { | |
| - mapProperty: 1, | |
| - }, | |
| - }, | |
| - ]).option({ | |
| - rawResult: true, | |
| - nested: true, | |
| - }); | |
| - const findNested = await model.findOne({ | |
| - //arrayOfNestedObjectProperty:{ $elemMatch:{objectIdProp:a.arrayOfNestedObjectProperty[0].objectIdProp}}, | |
| - 'mapProperty.aa.objectIdProp': nested, | |
| - //'mapProperty.aa.objectIdProp': a.mapProperty.aa.objectIdProp, | |
| - }); | |
| - | |
| - expect(findNested.toObject()).toEqual( | |
| - expect.objectContaining( | |
| - omit( | |
| - { | |
| - ...a, | |
| - mapProperty: expect.objectContaining({ | |
| - aa: expect.objectContaining({ | |
| - objectIdProp: nested, | |
| - }), | |
| - }), | |
| - }, | |
| - '_id', | |
| - ), | |
| - ), | |
| - ); | |
| - const newId = objectStringId(); | |
| - const oo = await model.create({ ...a, _id: newId }); | |
| - expect(oo).toMatchObject(expect.objectContaining({ _id: objectId(newId), id: newId })); | |
| - }); | |
| -}); | |
| diff --git a/libs/playground/tsconfig.build.json b/libs/playground/tsconfig.build.json | |
| deleted file mode 100644 | |
| index 3711a9e6a..000000000 | |
| --- a/libs/playground/tsconfig.build.json | |
| +++ /dev/null | |
| @@ -1,22 +0,0 @@ | |
| -{ | |
| - "extends": "../../.build/.base/tsconfig.base.json", | |
| - "compilerOptions": { | |
| - "outDir": "./dist/cjs", | |
| - "composite": true, | |
| - "declaration": true, | |
| - "declarationMap": true, | |
| - "declarationDir": "./dist/cjs", | |
| - "types": [ | |
| - "node", | |
| - "@nestjs/common" | |
| - ] | |
| - }, | |
| - "include": ["**/src/*.ts","**/src/**/*.ts","types.d.ts"], | |
| - "exclude": ["**/*.js", "jest.config.ts", "**/dist/**", "**/*.spec.ts", "**/*.test.ts", "**/test/","**/test/*.ts","**/test*/**/*.ts", "**/tests-index.ts"], | |
| - "references": [ | |
| - {"path": "../logger/tsconfig.build.json"}, | |
| - {"path": "../http-client-wrapper/tsconfig.build.json"}, | |
| - {"path": "../activity-logs-types/tsconfig.build.json"}, | |
| - {"path": "../kafka-client/tsconfig.build.json"} | |
| - ] | |
| -} | |
| diff --git a/libs/playground/tsconfig.json b/libs/playground/tsconfig.json | |
| deleted file mode 100644 | |
| index 31c3529ec..000000000 | |
| --- a/libs/playground/tsconfig.json | |
| +++ /dev/null | |
| @@ -1,9 +0,0 @@ | |
| -{ | |
| - "extends": "../../.build/.base/tsconfig.base.json", | |
| - "files": [], | |
| - "include": [], | |
| - "references": [ | |
| - {"path": "./tsconfig.spec.json"}, | |
| - {"path": "./tsconfig.build.json"} | |
| - ] | |
| -} | |
| diff --git a/libs/playground/tsconfig.spec.json b/libs/playground/tsconfig.spec.json | |
| deleted file mode 100644 | |
| index 50e9db421..000000000 | |
| --- a/libs/playground/tsconfig.spec.json | |
| +++ /dev/null | |
| @@ -1,22 +0,0 @@ | |
| -{ | |
| - "extends": "../../.build/.base/tsconfig.base.json", | |
| - "compilerOptions": { | |
| - "outDir": "./dist/tests", | |
| - "types": ["jest", "node"], | |
| - "strictFunctionTypes": false, | |
| - "noImplicitAny": false, | |
| - "module": "preserve", | |
| - "moduleResolution": "bundler" | |
| - }, | |
| - "include": [ | |
| - "jest.config.ts", | |
| - "src/tests-index.ts", | |
| - "src/test-module.ts", | |
| - "**/*.test.ts", | |
| - "**/*.spec.ts", | |
| - "**/*.d.ts", | |
| - "**/test*/**/*.ts", | |
| - "**/test/**/*.ts", | |
| - "../../types/*.d.ts" | |
| - ] | |
| -} | |
| diff --git a/libs/services-types/src/lib/administration/service-tags.dto.ts b/libs/services-types/src/lib/administration/service-tags.dto.ts | |
| index 455847a71..813f79cce 100644 | |
| --- a/libs/services-types/src/lib/administration/service-tags.dto.ts | |
| +++ b/libs/services-types/src/lib/administration/service-tags.dto.ts | |
| @@ -1,4 +1,5 @@ | |
| import { IsArray, IsNotEmpty, IsOptional } from 'class-validator'; | |
| +import { Types } from 'mongoose'; | |
| export class CreateServiceTagRequest { | |
| @IsNotEmpty() | |
| @@ -23,7 +24,7 @@ export class ServiceTagListDto { | |
| export class ServiceTagDto { | |
| key: string; | |
| displayName: string; | |
| - practiceAreaId: string; | |
| + practiceAreaId: Types.ObjectId; | |
| } | |
| export class FilterServiceTagsDto { | |
| diff --git a/libs/services-utils/src/lib/service-percent-completed-calculation/test/consts.ts b/libs/services-utils/src/lib/service-percent-completed-calculation/test/consts.ts | |
| index 334780395..1773f02dd 100644 | |
| --- a/libs/services-utils/src/lib/service-percent-completed-calculation/test/consts.ts | |
| +++ b/libs/services-utils/src/lib/service-percent-completed-calculation/test/consts.ts | |
| @@ -1,14 +1,14 @@ | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| -export const serviceMilestoneId1 = objectStringId(); | |
| -export const serviceMilestoneId2 = objectStringId(); | |
| -export const serviceMilestoneId3 = objectStringId(); | |
| -export const serviceMilestoneId4 = objectStringId(); | |
| -export const serviceMilestoneId5 = objectStringId(); | |
| +export const serviceMilestoneId1 = Types.ObjectId().toString(); | |
| +export const serviceMilestoneId2 = Types.ObjectId().toString(); | |
| +export const serviceMilestoneId3 = Types.ObjectId().toString(); | |
| +export const serviceMilestoneId4 = Types.ObjectId().toString(); | |
| +export const serviceMilestoneId5 = Types.ObjectId().toString(); | |
| -export const documentId1 = objectStringId(); | |
| -export const documentId2 = objectStringId(); | |
| -export const documentId3 = objectStringId(); | |
| +export const documentId1 = Types.ObjectId().toString(); | |
| +export const documentId2 = Types.ObjectId().toString(); | |
| +export const documentId3 = Types.ObjectId().toString(); | |
| export const serviceMilestonesList1 = [ | |
| { serviceMilestoneId: serviceMilestoneId1, portion: 20, isProofRequired: true }, | |
| @@ -42,12 +42,12 @@ export const milestonesProgressList1 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 25, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ]; | |
| @@ -60,12 +60,12 @@ export const milestonesProgressList3 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 75, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 45 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 35 }, | |
| @@ -76,12 +76,12 @@ export const milestonesProgressList4 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 0, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 35 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 35 }, | |
| @@ -92,12 +92,12 @@ export const milestonesProgressList5 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 25, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 35, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 15 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 45 }, | |
| @@ -108,12 +108,12 @@ export const milestonesProgressList6 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 35, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 65, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 85 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 45 }, | |
| @@ -124,12 +124,12 @@ export const milestonesProgressList7 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 26, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 97, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 82 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 42 }, | |
| @@ -140,12 +140,12 @@ export const milestonesProgressList8 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 36, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 93, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 84 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 48 }, | |
| @@ -156,12 +156,12 @@ export const milestonesProgressList9 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 13, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 84 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 57 }, | |
| @@ -172,12 +172,12 @@ export const milestonesProgressList10 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 82, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 98 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 57 }, | |
| @@ -188,12 +188,12 @@ export const milestonesProgressList11 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 7, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 18 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 89 }, | |
| @@ -204,12 +204,12 @@ export const milestonesProgressList12 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 7, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 18 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 89 }, | |
| @@ -220,12 +220,12 @@ export const milestonesProgressList13 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: null, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 83, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 18 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 89 }, | |
| @@ -236,12 +236,12 @@ export const milestonesProgressList14 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId2, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 100, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId4, milestonePercentCompleted: 100 }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 100 }, | |
| @@ -252,7 +252,7 @@ export const milestonesProgressList15 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 50, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 100 }, | |
| ]; | |
| @@ -262,7 +262,7 @@ export const milestonesProgressList16 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 50, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 100 }, | |
| ]; | |
| @@ -272,7 +272,7 @@ export const milestonesProgressList17 = [ | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| milestonePercentCompleted: 50, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| ]; | |
| @@ -280,7 +280,7 @@ export const milestonesProgressList18 = [ | |
| { serviceMilestoneId: serviceMilestoneId1 }, | |
| { | |
| serviceMilestoneId: serviceMilestoneId3, | |
| - documentIds: [objectStringId(), objectStringId()], | |
| + documentIds: [Types.ObjectId().toString(), Types.ObjectId().toString()], | |
| }, | |
| { serviceMilestoneId: serviceMilestoneId5, milestonePercentCompleted: 100 }, | |
| ]; | |
| diff --git a/libs/services-utils/src/lib/service-percent-completed-calculation/test/percent-completed-calculation-of-service.spec.ts b/libs/services-utils/src/lib/service-percent-completed-calculation/test/percent-completed-calculation-of-service.spec.ts | |
| index d9e39a2fc..4b6009667 100644 | |
| --- a/libs/services-utils/src/lib/service-percent-completed-calculation/test/percent-completed-calculation-of-service.spec.ts | |
| +++ b/libs/services-utils/src/lib/service-percent-completed-calculation/test/percent-completed-calculation-of-service.spec.ts | |
| @@ -1,5 +1,5 @@ | |
| import { MilestoneProgressDto } from '@vinny/services-types'; | |
| -import { objectStringId } from '@vinny/helpers'; | |
| +import { Types } from 'mongoose'; | |
| import { calculatePercentCompletedOfService } from '../service-percent-completed-calculation'; | |
| import { | |
| milestonesProgressList1, | |
| @@ -49,7 +49,7 @@ describe('calculatePercentCompletedOfService', () => { | |
| const result = calculatePercentCompletedOfService( | |
| milestonesProgressL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment