tychat-contracts 1.0.123 → 1.0.125

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -110,6 +110,21 @@ describe('ConversationContactFiltersQueryConstraint', () => {
110
110
  expect(errors).toHaveLength(0);
111
111
  expect(dto.filters).toBeUndefined();
112
112
  });
113
+ it('should accept sortBy and sortOrder query params', async () => {
114
+ const dto = simulateValidationPipe({
115
+ page: '1',
116
+ limit: '20',
117
+ sortBy: 'startedAt',
118
+ sortOrder: 'desc',
119
+ });
120
+ const errors = await (0, class_validator_1.validate)(dto, {
121
+ whitelist: true,
122
+ forbidNonWhitelisted: true,
123
+ });
124
+ expect(errors).toHaveLength(0);
125
+ expect(dto.sortBy).toBe('startedAt');
126
+ expect(dto.sortOrder).toBe('DESC');
127
+ });
113
128
  it('should accept empty string filters', async () => {
114
129
  const dto = simulateValidationPipe({ filters: '' });
115
130
  const errors = await (0, class_validator_1.validate)(dto, {
@@ -4,6 +4,8 @@ export declare const TOPIC_FOLLOWUP_CONFIG_UPDATED = "FOLLOWUP_CONFIG_UPDATED";
4
4
  export declare const TOPIC_APPOINTMENT_CHANGED = "APPOINTMENT_CHANGED";
5
5
  /** Kafka request-reply: list follow-up logs (paginated, filters). */
6
6
  export declare const TOPIC_FOLLOWUP_LOG_LIST = "followup.log.list";
7
+ /** Kafka request-reply: latest follow-up log by patient IDs. */
8
+ export declare const TOPIC_FOLLOWUP_LOG_LATEST_BY_PATIENT_IDS = "followup.log.latestByPatientIds";
7
9
  export declare class FollowupConversationEventPayload {
8
10
  tenant: string;
9
11
  patientId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"followup-events.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/followup-events.dto.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AACjD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACv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,gCAAgC;IAK3C,MAAM,EAAE,MAAM,CAAC;IAMf,SAAS,EAAE,MAAM,CAAC;IAIlB,WAAW,EAAE,MAAM,CAAC;IAIpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAMhB,WAAW,EAAE,IAAI,GAAG,OAAO,GAAG,SAAS,CAAC;IAKxC,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,iCAAiC;IAK5C,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,CAAC,EAAE,MAAM,CAAC;IAMhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAIhC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,8BAA8B;IAKzC,MAAM,EAAE,MAAM,CAAC;IAIf,aAAa,EAAE,MAAM,CAAC;IAMtB,SAAS,EAAE,MAAM,CAAC;IAMlB,MAAM,EAAE,MAAM,CAAC;IAMf,cAAc,CAAC,EAAE,MAAM,CAAC;IAKxB,IAAI,CAAC,EAAE,MAAM,CAAC;IAKd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAIlB,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AppointmentChangedEventPayload = exports.FollowupConfigUpdatedEventPayload = exports.FollowupConversationEventPayload = exports.TOPIC_FOLLOWUP_LOG_LIST = exports.TOPIC_APPOINTMENT_CHANGED = exports.TOPIC_FOLLOWUP_CONFIG_UPDATED = exports.TOPIC_MESSAGE_RECEIVED = exports.TOPIC_MESSAGE_SENT = void 0;
12
+ exports.AppointmentChangedEventPayload = exports.FollowupConfigUpdatedEventPayload = exports.FollowupConversationEventPayload = exports.TOPIC_FOLLOWUP_LOG_LATEST_BY_PATIENT_IDS = exports.TOPIC_FOLLOWUP_LOG_LIST = exports.TOPIC_APPOINTMENT_CHANGED = exports.TOPIC_FOLLOWUP_CONFIG_UPDATED = exports.TOPIC_MESSAGE_RECEIVED = exports.TOPIC_MESSAGE_SENT = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  exports.TOPIC_MESSAGE_SENT = 'MESSAGE_SENT';
@@ -18,6 +18,8 @@ exports.TOPIC_FOLLOWUP_CONFIG_UPDATED = 'FOLLOWUP_CONFIG_UPDATED';
18
18
  exports.TOPIC_APPOINTMENT_CHANGED = 'APPOINTMENT_CHANGED';
19
19
  /** Kafka request-reply: list follow-up logs (paginated, filters). */
20
20
  exports.TOPIC_FOLLOWUP_LOG_LIST = 'followup.log.list';
21
+ /** Kafka request-reply: latest follow-up log by patient IDs. */
22
+ exports.TOPIC_FOLLOWUP_LOG_LATEST_BY_PATIENT_IDS = 'followup.log.latestByPatientIds';
21
23
  class FollowupConversationEventPayload {
22
24
  tenant;
23
25
  patientId;
@@ -8,6 +8,8 @@ export type ConversationContactListFilterKeyDto = (typeof CONVERSATION_CONTACT_L
8
8
  export declare class ListConversationContactsQueryDto {
9
9
  page?: number;
10
10
  limit?: number;
11
+ sortBy?: 'startedAt' | 'unreadCount';
12
+ sortOrder?: 'ASC' | 'DESC';
11
13
  filters?: ParsedFilterDto[];
12
14
  }
13
15
  //# sourceMappingURL=list-conversation-contacts-query.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list-conversation-contacts-query.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/list-conversation-contacts-query.dto.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,qCAAqC,0JAWxC,CAAC;AACX,MAAM,MAAM,mCAAmC,GAC7C,CAAC,OAAO,qCAAqC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,qBAAa,gCAAgC;IAU3C,IAAI,CAAC,EAAE,MAAM,CAAC;IAad,KAAK,CAAC,EAAE,MAAM,CAAC;IAWf,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B"}
1
+ {"version":3,"file":"list-conversation-contacts-query.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/list-conversation-contacts-query.dto.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,qCAAqC,0JAWxC,CAAC;AACX,MAAM,MAAM,mCAAmC,GAC7C,CAAC,OAAO,qCAAqC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,qBAAa,gCAAgC;IAU3C,IAAI,CAAC,EAAE,MAAM,CAAC;IAad,KAAK,CAAC,EAAE,MAAM,CAAC;IAUf,MAAM,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC;IAWrC,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAW3B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B"}
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ListConversationContactsQueryDto = exports.CONVERSATION_CONTACT_LIST_FILTER_KEYS = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
+ const class_transformer_1 = require("class-transformer");
14
15
  const class_validator_1 = require("class-validator");
15
16
  /**
16
17
  * Allowed conversation session entity columns for filtering (camelCase API keys).
@@ -31,6 +32,8 @@ exports.CONVERSATION_CONTACT_LIST_FILTER_KEYS = [
31
32
  class ListConversationContactsQueryDto {
32
33
  page;
33
34
  limit;
35
+ sortBy;
36
+ sortOrder;
34
37
  filters;
35
38
  }
36
39
  exports.ListConversationContactsQueryDto = ListConversationContactsQueryDto;
@@ -60,6 +63,26 @@ __decorate([
60
63
  (0, class_validator_1.Max)(100),
61
64
  __metadata("design:type", Number)
62
65
  ], ListConversationContactsQueryDto.prototype, "limit", void 0);
66
+ __decorate([
67
+ (0, swagger_1.ApiPropertyOptional)({
68
+ description: 'Campo de ordenação: `startedAt` (padrão na API) ou `unreadCount`.',
69
+ enum: ['startedAt', 'unreadCount'],
70
+ }),
71
+ (0, class_validator_1.IsOptional)(),
72
+ (0, class_transformer_1.Transform)(({ value }) => (typeof value === 'string' ? value.trim() : value)),
73
+ (0, class_validator_1.IsIn)(['startedAt', 'unreadCount']),
74
+ __metadata("design:type", String)
75
+ ], ListConversationContactsQueryDto.prototype, "sortBy", void 0);
76
+ __decorate([
77
+ (0, swagger_1.ApiPropertyOptional)({
78
+ description: 'Direção: `ASC` ou `DESC` (case-insensitive na query string).',
79
+ enum: ['ASC', 'DESC'],
80
+ }),
81
+ (0, class_validator_1.IsOptional)(),
82
+ (0, class_transformer_1.Transform)(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value),
83
+ (0, class_validator_1.IsIn)(['ASC', 'DESC']),
84
+ __metadata("design:type", String)
85
+ ], ListConversationContactsQueryDto.prototype, "sortOrder", void 0);
63
86
  __decorate([
64
87
  (0, swagger_1.ApiPropertyOptional)({
65
88
  description: 'JSON string with an array of filter objects `{ key, op, value }`. ' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tychat-contracts",
3
- "version": "1.0.123",
3
+ "version": "1.0.125",
4
4
  "description": "DTOs compartilhados com class-validator (API e microserviços)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -120,6 +120,22 @@ describe('ConversationContactFiltersQueryConstraint', () => {
120
120
  expect(dto.filters).toBeUndefined();
121
121
  });
122
122
 
123
+ it('should accept sortBy and sortOrder query params', async () => {
124
+ const dto = simulateValidationPipe({
125
+ page: '1',
126
+ limit: '20',
127
+ sortBy: 'startedAt',
128
+ sortOrder: 'desc',
129
+ });
130
+ const errors = await validate(dto, {
131
+ whitelist: true,
132
+ forbidNonWhitelisted: true,
133
+ });
134
+ expect(errors).toHaveLength(0);
135
+ expect(dto.sortBy).toBe('startedAt');
136
+ expect(dto.sortOrder).toBe('DESC');
137
+ });
138
+
123
139
  it('should accept empty string filters', async () => {
124
140
  const dto = simulateValidationPipe({ filters: '' });
125
141
  const errors = await validate(dto, {
@@ -8,6 +8,9 @@ export const TOPIC_APPOINTMENT_CHANGED = 'APPOINTMENT_CHANGED';
8
8
 
9
9
  /** Kafka request-reply: list follow-up logs (paginated, filters). */
10
10
  export const TOPIC_FOLLOWUP_LOG_LIST = 'followup.log.list';
11
+ /** Kafka request-reply: latest follow-up log by patient IDs. */
12
+ export const TOPIC_FOLLOWUP_LOG_LATEST_BY_PATIENT_IDS =
13
+ 'followup.log.latestByPatientIds';
11
14
 
12
15
  export class FollowupConversationEventPayload {
13
16
  @ApiProperty({ example: 'homolog' })
@@ -1,5 +1,6 @@
1
1
  import { ApiPropertyOptional } from '@nestjs/swagger';
2
- import { IsInt, IsOptional, Max, Min } from 'class-validator';
2
+ import { Transform } from 'class-transformer';
3
+ import { IsIn, IsInt, IsOptional, Max, Min } from 'class-validator';
3
4
  import type { ParsedFilterDto } from '../filters/parsed-filter.dto';
4
5
 
5
6
  /**
@@ -46,6 +47,27 @@ export class ListConversationContactsQueryDto {
46
47
  @Max(100)
47
48
  limit?: number;
48
49
 
50
+ @ApiPropertyOptional({
51
+ description:
52
+ 'Campo de ordenação: `startedAt` (padrão na API) ou `unreadCount`.',
53
+ enum: ['startedAt', 'unreadCount'],
54
+ })
55
+ @IsOptional()
56
+ @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
57
+ @IsIn(['startedAt', 'unreadCount'])
58
+ sortBy?: 'startedAt' | 'unreadCount';
59
+
60
+ @ApiPropertyOptional({
61
+ description: 'Direção: `ASC` ou `DESC` (case-insensitive na query string).',
62
+ enum: ['ASC', 'DESC'],
63
+ })
64
+ @IsOptional()
65
+ @Transform(({ value }) =>
66
+ typeof value === 'string' ? value.trim().toUpperCase() : value,
67
+ )
68
+ @IsIn(['ASC', 'DESC'])
69
+ sortOrder?: 'ASC' | 'DESC';
70
+
49
71
  @ApiPropertyOptional({
50
72
  description:
51
73
  'JSON string with an array of filter objects `{ key, op, value }`. ' +