Skip to content

Commit e1efac4

Browse files
authored
deps: upgrade nest + packages (#990)
1 parent 0cf041f commit e1efac4

File tree

8 files changed

+1428
-1434
lines changed

8 files changed

+1428
-1434
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@
3232
"@nestjs/axios": "^4.0.1",
3333
"@nestjs/common": "^11.1.9",
3434
"@nestjs/config": "^4.0.1",
35-
"@nestjs/core": "^10.4.15",
36-
"@nestjs/platform-express": "^10.4.12",
37-
"@nestjs/swagger": "^7.4.0",
35+
"@nestjs/core": "^11.1.9",
36+
"@nestjs/platform-express": "^11.1.9",
37+
"@nestjs/swagger": "^11.2.3",
3838
"@nestjs/terminus": "^11.0.0",
3939
"@nestjs/throttler": "^6.5.0",
4040
"@nestjs/typeorm": "^11.0.0",
4141
"@storyblok/js": "^4.4.3",
4242
"axios": "^1.13.2",
4343
"class-transformer": "^0.5.1",
4444
"class-validator": "^0.14.3",
45-
"crisp-api": "^9.10.0",
45+
"crisp-api": "^10.1.0",
4646
"date-fns": "^4.1.0",
47-
"dotenv": "^17.2.3",
4847
"dompurify": "^3.3.1",
48+
"dotenv": "^17.2.3",
4949
"firebase": "^12.7.0",
5050
"firebase-admin": "^13.6.0",
5151
"jsdom": "^27.3.0",
5252
"lodash": "^4.17.21",
5353
"nestjs-cls": "^6.1.0",
54-
"newrelic": "^12.21.0",
54+
"newrelic": "^13.8.1",
5555
"pg": "^8.16.3",
5656
"pg-connection-string": "^2.7.0",
5757
"reflect-metadata": "^0.2.1",
@@ -67,20 +67,20 @@
6767
"@golevelup/ts-jest": "^0.7.0",
6868
"@nestjs/cli": "^11.0.14",
6969
"@nestjs/schematics": "^11.0.9",
70-
"@nestjs/testing": "^10.4.15",
70+
"@nestjs/testing": "^11.1.9",
7171
"@types/date-fns": "^2.6.0",
7272
"@types/dompurify": "^3.2.0",
7373
"@types/express": "^5.0.6",
74-
"@types/jest": "^29.5.13",
74+
"@types/jest": "^30.0.0",
7575
"@types/jsdom": "^27.0.0",
7676
"@types/lodash": "^4.17.21",
77-
"@types/node": "^22.15.29",
77+
"@types/node": "^25.0.3",
7878
"@types/supertest": "^6.0.2",
7979
"@types/validator": "^13.15.10",
8080
"eslint": "^9.39.2",
8181
"eslint-config-prettier": "^10.1.8",
8282
"eslint-plugin-prettier": "^5.5.4",
83-
"jest": "^29.7.0",
83+
"jest": "^30.2.0",
8484
"prettier": "^3.7.4",
8585
"supertest": "^7.1.4",
8686
"ts-jest": "^29.4.6",

src/app.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ import { WebhooksModule } from './webhooks/webhooks.module';
4646
middleware: {
4747
mount: true,
4848
generateId: true,
49-
idGenerator: (req: Request) => req.headers['X-Request-Id'] ?? uuidv4(),
49+
idGenerator: (req: Request) => {
50+
const requestId = req.headers['x-request-id'];
51+
return (Array.isArray(requestId) ? requestId[0] : requestId) ?? uuidv4();
52+
},
5053
},
5154
}),
5255
LoggerModule,

src/crisp/crisp.interface.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ export interface NewCrispProfileBaseResponse {
6060
data: CrispProfileBaseResponse;
6161
}
6262

63+
// Response type from crisp-api getPeopleData - matches PeopleData type
6364
export interface CrispProfileDataResponse {
64-
error: boolean;
65-
reason: string;
66-
data: { data: CrispProfileCustomFields };
65+
data?: CrispProfileCustomFields;
6766
}
67+
68+
// Type for updatePeopleData params - crisp-api expects flat Record, not nested object
69+
export type CrispPeopleDataUpdateParams = Record<string, string | number | boolean>;

src/crisp/crisp.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ describe('CrispService', () => {
230230
expect(mockWebsite.updatePeopleData).toHaveBeenCalledWith(
231231
crispWebsiteId,
232232
233-
{ data: customFields },
233+
customFields,
234234
);
235235
expect(response).toEqual(expectedResponse);
236236
});

src/crisp/crisp.service.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { EventLoggerService } from 'src/event-logger/event-logger.service';
44
import { crispPluginId, crispPluginKey, crispWebsiteId } from 'src/utils/constants';
55
import { isCypressTestEmail } from 'src/utils/utils';
66
import {
7+
CrispPeopleDataUpdateParams,
78
CrispProfileBase,
89
CrispProfileBaseResponse,
910
CrispProfileCustomFields,
@@ -21,6 +22,19 @@ export class CrispService {
2122
CrispClient.authenticateTier('plugin', crispPluginId, crispPluginKey);
2223
}
2324

25+
// Convert CrispProfileCustomFields to the format crisp-api expects (primitive values only)
26+
private toCrispDataParams(
27+
peopleData: CrispProfileCustomFields,
28+
): CrispPeopleDataUpdateParams {
29+
const data: CrispPeopleDataUpdateParams = {};
30+
for (const [key, value] of Object.entries(peopleData)) {
31+
if (value !== undefined && value !== null) {
32+
data[key] = value;
33+
}
34+
}
35+
return data;
36+
}
37+
2438
private isProfileNotFoundError(error: unknown): boolean {
2539
// Based on Crisp API docs, error format is: { reason: 'error', message: 'not_found', code: 404 }
2640
const errorObj = error as Record<string, unknown>;
@@ -143,19 +157,21 @@ export class CrispService {
143157
return null;
144158
}
145159

160+
const params = this.toCrispDataParams(peopleData);
161+
146162
try {
147-
const crispPeopleData = CrispClient.website.updatePeopleData(crispWebsiteId, email, {
148-
data: peopleData,
149-
});
163+
const crispPeopleData = CrispClient.website.updatePeopleData(
164+
crispWebsiteId,
165+
email,
166+
params,
167+
);
150168
return crispPeopleData;
151169
} catch (error) {
152170
// Only handle profile not found errors (404, not_found, or profile-related errors)
153171
if (this.isProfileNotFoundError(error)) {
154172
try {
155173
await this.createCrispProfile({ email });
156-
return await CrispClient.website.updatePeopleData(crispWebsiteId, email, {
157-
data: peopleData,
158-
});
174+
return await CrispClient.website.updatePeopleData(crispWebsiteId, email, params);
159175
} catch {
160176
throw new Error(`Update crisp profile API call failed: ${error}`);
161177
}

src/user/dtos/admin-update-user.dto.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ export class AdminUpdateUserDto {
2828

2929
@IsOptional()
3030
@IsDate()
31-
@ApiProperty({ type: 'date' })
31+
@ApiProperty({ type: Date })
3232
lastActiveAt: Date;
3333

3434
@SecureInput('email', { required: false, maxLength: 255 })
35-
@ApiProperty({ type: 'email' })
35+
@ApiProperty({ type: String, format: 'email' })
3636
email: string;
3737

3838
@IsOptional()
3939
@IsBoolean({})
40-
@ApiProperty({ type: 'boolean' })
40+
@ApiProperty({ type: Boolean })
4141
isSuperAdmin: boolean;
4242
}

src/user/dtos/update-user.dto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ export class UpdateUserDto {
2828

2929
@IsOptional()
3030
@IsDate()
31-
@ApiProperty({ type: 'date' })
31+
@ApiProperty({ type: Date })
3232
lastActiveAt: Date;
3333

3434
@SecureInput('email', { required: false, maxLength: 255 })
35-
@ApiProperty({ type: 'email' })
35+
@ApiProperty({ type: String, format: 'email' })
3636
email: string;
3737
}

0 commit comments

Comments
 (0)