tychat-contracts 1.0.124 → 1.0.126

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.
Files changed (23) hide show
  1. package/dist/conversations/conversation-contact-filters-query.validator.spec.js +15 -0
  2. package/dist/conversations/list-conversation-contacts-query.dto.d.ts +2 -0
  3. package/dist/conversations/list-conversation-contacts-query.dto.d.ts.map +1 -1
  4. package/dist/conversations/list-conversation-contacts-query.dto.js +23 -0
  5. package/dist/notifications/index.d.ts +1 -0
  6. package/dist/notifications/index.d.ts.map +1 -1
  7. package/dist/notifications/index.js +3 -1
  8. package/dist/notifications/list-notifications-query.dto.d.ts +2 -1
  9. package/dist/notifications/list-notifications-query.dto.d.ts.map +1 -1
  10. package/dist/notifications/list-notifications-query.dto.js +2 -1
  11. package/dist/notifications/notifications-find-all-kafka.dto.d.ts +11 -0
  12. package/dist/notifications/notifications-find-all-kafka.dto.d.ts.map +1 -0
  13. package/dist/notifications/notifications-find-all-kafka.dto.js +47 -0
  14. package/dist/notifications/update-notification-viewed.dto.d.ts +1 -0
  15. package/dist/notifications/update-notification-viewed.dto.d.ts.map +1 -1
  16. package/dist/notifications/update-notification-viewed.dto.js +5 -0
  17. package/package.json +1 -1
  18. package/src/conversations/conversation-contact-filters-query.validator.spec.ts +16 -0
  19. package/src/conversations/list-conversation-contacts-query.dto.ts +23 -1
  20. package/src/notifications/index.ts +1 -0
  21. package/src/notifications/list-notifications-query.dto.ts +2 -1
  22. package/src/notifications/notifications-find-all-kafka.dto.ts +34 -0
  23. package/src/notifications/update-notification-viewed.dto.ts +3 -0
@@ -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, {
@@ -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 }`. ' +
@@ -3,6 +3,7 @@ export { TOPIC_NOTIFICATIONS_FIND_ALL, TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN,
3
3
  export { AdminBroadcastPushDto } from './admin-broadcast-push.dto';
4
4
  export { RegisterPushTokenDto, NotificationsRegisterPushTokenKafkaDto, } from './register-push-token.dto';
5
5
  export { ListNotificationsQueryDto, NOTIFICATION_PROVIDER_FILTERS, NOTIFICATION_STATUS_FILTERS, type NotificationProviderFilterDto, type NotificationStatusFilterDto, } from './list-notifications-query.dto';
6
+ export { NotificationsFindAllKafkaDto } from './notifications-find-all-kafka.dto';
6
7
  export { NotificationListItemDto } from './notification-list-item.dto';
7
8
  export { UpdateNotificationViewedDto, NotificationsUpdateViewedKafkaDto, } from './update-notification-viewed.dto';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EACnC,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,4BAA4B,EAC5B,uCAAuC,EACvC,iCAAiC,EACjC,wCAAwC,GACzC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,sCAAsC,GACvC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,EAC3B,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,GAClC,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EACnC,8CAA8C,GAC/C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,4BAA4B,EAC5B,uCAAuC,EACvC,iCAAiC,EACjC,wCAAwC,GACzC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,sCAAsC,GACvC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,EAC3B,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,GAClC,MAAM,kCAAkC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotificationsUpdateViewedKafkaDto = exports.UpdateNotificationViewedDto = exports.NotificationListItemDto = exports.NOTIFICATION_STATUS_FILTERS = exports.NOTIFICATION_PROVIDER_FILTERS = exports.ListNotificationsQueryDto = exports.NotificationsRegisterPushTokenKafkaDto = exports.RegisterPushTokenDto = exports.AdminBroadcastPushDto = exports.EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH = exports.TOPIC_NOTIFICATIONS_UPDATE_VIEWED = exports.TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN = exports.TOPIC_NOTIFICATIONS_FIND_ALL = exports.NotificationPasswordResetRequestedEventPayload = exports.NotificationUserCreatedEventPayload = void 0;
3
+ exports.NotificationsUpdateViewedKafkaDto = exports.UpdateNotificationViewedDto = exports.NotificationListItemDto = exports.NotificationsFindAllKafkaDto = exports.NOTIFICATION_STATUS_FILTERS = exports.NOTIFICATION_PROVIDER_FILTERS = exports.ListNotificationsQueryDto = exports.NotificationsRegisterPushTokenKafkaDto = exports.RegisterPushTokenDto = exports.AdminBroadcastPushDto = exports.EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH = exports.TOPIC_NOTIFICATIONS_UPDATE_VIEWED = exports.TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN = exports.TOPIC_NOTIFICATIONS_FIND_ALL = exports.NotificationPasswordResetRequestedEventPayload = exports.NotificationUserCreatedEventPayload = void 0;
4
4
  var notifications_kafka_payloads_1 = require("./notifications-kafka.payloads");
5
5
  Object.defineProperty(exports, "NotificationUserCreatedEventPayload", { enumerable: true, get: function () { return notifications_kafka_payloads_1.NotificationUserCreatedEventPayload; } });
6
6
  Object.defineProperty(exports, "NotificationPasswordResetRequestedEventPayload", { enumerable: true, get: function () { return notifications_kafka_payloads_1.NotificationPasswordResetRequestedEventPayload; } });
@@ -18,6 +18,8 @@ var list_notifications_query_dto_1 = require("./list-notifications-query.dto");
18
18
  Object.defineProperty(exports, "ListNotificationsQueryDto", { enumerable: true, get: function () { return list_notifications_query_dto_1.ListNotificationsQueryDto; } });
19
19
  Object.defineProperty(exports, "NOTIFICATION_PROVIDER_FILTERS", { enumerable: true, get: function () { return list_notifications_query_dto_1.NOTIFICATION_PROVIDER_FILTERS; } });
20
20
  Object.defineProperty(exports, "NOTIFICATION_STATUS_FILTERS", { enumerable: true, get: function () { return list_notifications_query_dto_1.NOTIFICATION_STATUS_FILTERS; } });
21
+ var notifications_find_all_kafka_dto_1 = require("./notifications-find-all-kafka.dto");
22
+ Object.defineProperty(exports, "NotificationsFindAllKafkaDto", { enumerable: true, get: function () { return notifications_find_all_kafka_dto_1.NotificationsFindAllKafkaDto; } });
21
23
  var notification_list_item_dto_1 = require("./notification-list-item.dto");
22
24
  Object.defineProperty(exports, "NotificationListItemDto", { enumerable: true, get: function () { return notification_list_item_dto_1.NotificationListItemDto; } });
23
25
  var update_notification_viewed_dto_1 = require("./update-notification-viewed.dto");
@@ -3,7 +3,8 @@ export type NotificationProviderFilterDto = (typeof NOTIFICATION_PROVIDER_FILTER
3
3
  export declare const NOTIFICATION_STATUS_FILTERS: readonly ["pending", "sent", "failed"];
4
4
  export type NotificationStatusFilterDto = (typeof NOTIFICATION_STATUS_FILTERS)[number];
5
5
  /**
6
- * Query HTTP + payload Kafka para listar notificações do tenant.
6
+ * Query HTTP + filhos de `payload` no Kafka `notifications.findAll`.
7
+ * A lista é sempre filtrada pelo `userId` enviado no envelope Kafka (JWT na API).
7
8
  */
8
9
  export declare class ListNotificationsQueryDto {
9
10
  page?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"list-notifications-query.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/list-notifications-query.dto.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,+CAKhC,CAAC;AACX,MAAM,MAAM,6BAA6B,GACvC,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,eAAO,MAAM,2BAA2B,wCAI9B,CAAC;AACX,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C;;GAEG;AACH,qBAAa,yBAAyB;IAMpC,IAAI,CAAC,EAAE,MAAM,CAAC;IAQd,KAAK,CAAC,EAAE,MAAM,CAAC;IAQf,QAAQ,CAAC,EAAE,6BAA6B,CAAC;IAQzC,MAAM,CAAC,EAAE,2BAA2B,CAAC;IASrC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
1
+ {"version":3,"file":"list-notifications-query.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/list-notifications-query.dto.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,+CAKhC,CAAC;AACX,MAAM,MAAM,6BAA6B,GACvC,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,eAAO,MAAM,2BAA2B,wCAI9B,CAAC;AACX,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C;;;GAGG;AACH,qBAAa,yBAAyB;IAMpC,IAAI,CAAC,EAAE,MAAM,CAAC;IAQd,KAAK,CAAC,EAAE,MAAM,CAAC;IAQf,QAAQ,CAAC,EAAE,6BAA6B,CAAC;IAQzC,MAAM,CAAC,EAAE,2BAA2B,CAAC;IASrC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
@@ -25,7 +25,8 @@ exports.NOTIFICATION_STATUS_FILTERS = [
25
25
  'failed',
26
26
  ];
27
27
  /**
28
- * Query HTTP + payload Kafka para listar notificações do tenant.
28
+ * Query HTTP + filhos de `payload` no Kafka `notifications.findAll`.
29
+ * A lista é sempre filtrada pelo `userId` enviado no envelope Kafka (JWT na API).
29
30
  */
30
31
  class ListNotificationsQueryDto {
31
32
  page;
@@ -0,0 +1,11 @@
1
+ import { ListNotificationsQueryDto } from './list-notifications-query.dto';
2
+ /**
3
+ * Payload Kafka `notifications.findAll`.
4
+ * O `userId` deve ser o sub do JWT — só esse utilizador vê as suas notificações.
5
+ */
6
+ export declare class NotificationsFindAllKafkaDto {
7
+ tenant: string;
8
+ userId: string;
9
+ payload?: ListNotificationsQueryDto;
10
+ }
11
+ //# sourceMappingURL=notifications-find-all-kafka.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications-find-all-kafka.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/notifications-find-all-kafka.dto.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;GAGG;AACH,qBAAa,4BAA4B;IAIvC,MAAM,EAAE,MAAM,CAAC;IAOf,MAAM,EAAE,MAAM,CAAC;IAMf,OAAO,CAAC,EAAE,yBAAyB,CAAC;CACrC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.NotificationsFindAllKafkaDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const class_validator_1 = require("class-validator");
16
+ const list_notifications_query_dto_1 = require("./list-notifications-query.dto");
17
+ /**
18
+ * Payload Kafka `notifications.findAll`.
19
+ * O `userId` deve ser o sub do JWT — só esse utilizador vê as suas notificações.
20
+ */
21
+ class NotificationsFindAllKafkaDto {
22
+ tenant;
23
+ userId;
24
+ payload;
25
+ }
26
+ exports.NotificationsFindAllKafkaDto = NotificationsFindAllKafkaDto;
27
+ __decorate([
28
+ (0, swagger_1.ApiProperty)({ example: 'default' }),
29
+ (0, class_validator_1.IsString)(),
30
+ (0, class_validator_1.IsNotEmpty)(),
31
+ __metadata("design:type", String)
32
+ ], NotificationsFindAllKafkaDto.prototype, "tenant", void 0);
33
+ __decorate([
34
+ (0, swagger_1.ApiProperty)({
35
+ description: 'ID do utilizador (ex.: JWT sub). Lista apenas linhas com este user_id.',
36
+ format: 'uuid',
37
+ }),
38
+ (0, class_validator_1.IsUUID)('4'),
39
+ __metadata("design:type", String)
40
+ ], NotificationsFindAllKafkaDto.prototype, "userId", void 0);
41
+ __decorate([
42
+ (0, swagger_1.ApiPropertyOptional)({ type: list_notifications_query_dto_1.ListNotificationsQueryDto }),
43
+ (0, class_validator_1.IsOptional)(),
44
+ (0, class_validator_1.ValidateNested)(),
45
+ (0, class_transformer_1.Type)(() => list_notifications_query_dto_1.ListNotificationsQueryDto),
46
+ __metadata("design:type", list_notifications_query_dto_1.ListNotificationsQueryDto)
47
+ ], NotificationsFindAllKafkaDto.prototype, "payload", void 0);
@@ -9,6 +9,7 @@ export declare class UpdateNotificationViewedDto {
9
9
  */
10
10
  export declare class NotificationsUpdateViewedKafkaDto {
11
11
  tenant: string;
12
+ userId: string;
12
13
  id: string;
13
14
  payload: UpdateNotificationViewedDto;
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"update-notification-viewed.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/update-notification-viewed.dto.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,qBAAa,2BAA2B;IAMtC,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,iCAAiC;IAG5C,MAAM,EAAE,MAAM,CAAC;IAGf,EAAE,EAAE,MAAM,CAAC;IAIX,OAAO,EAAE,2BAA2B,CAAC;CACtC"}
1
+ {"version":3,"file":"update-notification-viewed.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/update-notification-viewed.dto.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,qBAAa,2BAA2B;IAMtC,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,iCAAiC;IAG5C,MAAM,EAAE,MAAM,CAAC;IAGf,MAAM,EAAE,MAAM,CAAC;IAGf,EAAE,EAAE,MAAM,CAAC;IAIX,OAAO,EAAE,2BAA2B,CAAC;CACtC"}
@@ -33,6 +33,7 @@ __decorate([
33
33
  */
34
34
  class NotificationsUpdateViewedKafkaDto {
35
35
  tenant;
36
+ userId;
36
37
  id;
37
38
  payload;
38
39
  }
@@ -42,6 +43,10 @@ __decorate([
42
43
  (0, class_validator_1.IsNotEmpty)(),
43
44
  __metadata("design:type", String)
44
45
  ], NotificationsUpdateViewedKafkaDto.prototype, "tenant", void 0);
46
+ __decorate([
47
+ (0, class_validator_1.IsUUID)('4'),
48
+ __metadata("design:type", String)
49
+ ], NotificationsUpdateViewedKafkaDto.prototype, "userId", void 0);
45
50
  __decorate([
46
51
  (0, class_validator_1.IsUUID)('4'),
47
52
  __metadata("design:type", String)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tychat-contracts",
3
- "version": "1.0.124",
3
+ "version": "1.0.126",
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, {
@@ -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 }`. ' +
@@ -20,6 +20,7 @@ export {
20
20
  type NotificationProviderFilterDto,
21
21
  type NotificationStatusFilterDto,
22
22
  } from './list-notifications-query.dto';
23
+ export { NotificationsFindAllKafkaDto } from './notifications-find-all-kafka.dto';
23
24
  export { NotificationListItemDto } from './notification-list-item.dto';
24
25
  export {
25
26
  UpdateNotificationViewedDto,
@@ -20,7 +20,8 @@ export type NotificationStatusFilterDto =
20
20
  (typeof NOTIFICATION_STATUS_FILTERS)[number];
21
21
 
22
22
  /**
23
- * Query HTTP + payload Kafka para listar notificações do tenant.
23
+ * Query HTTP + filhos de `payload` no Kafka `notifications.findAll`.
24
+ * A lista é sempre filtrada pelo `userId` enviado no envelope Kafka (JWT na API).
24
25
  */
25
26
  export class ListNotificationsQueryDto {
26
27
  @ApiPropertyOptional({ minimum: 1, default: 1 })
@@ -0,0 +1,34 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import { Type } from 'class-transformer';
3
+ import {
4
+ IsNotEmpty,
5
+ IsOptional,
6
+ IsString,
7
+ IsUUID,
8
+ ValidateNested,
9
+ } from 'class-validator';
10
+ import { ListNotificationsQueryDto } from './list-notifications-query.dto';
11
+
12
+ /**
13
+ * Payload Kafka `notifications.findAll`.
14
+ * O `userId` deve ser o sub do JWT — só esse utilizador vê as suas notificações.
15
+ */
16
+ export class NotificationsFindAllKafkaDto {
17
+ @ApiProperty({ example: 'default' })
18
+ @IsString()
19
+ @IsNotEmpty()
20
+ tenant: string;
21
+
22
+ @ApiProperty({
23
+ description: 'ID do utilizador (ex.: JWT sub). Lista apenas linhas com este user_id.',
24
+ format: 'uuid',
25
+ })
26
+ @IsUUID('4')
27
+ userId: string;
28
+
29
+ @ApiPropertyOptional({ type: ListNotificationsQueryDto })
30
+ @IsOptional()
31
+ @ValidateNested()
32
+ @Type(() => ListNotificationsQueryDto)
33
+ payload?: ListNotificationsQueryDto;
34
+ }
@@ -28,6 +28,9 @@ export class NotificationsUpdateViewedKafkaDto {
28
28
  @IsNotEmpty()
29
29
  tenant: string;
30
30
 
31
+ @IsUUID('4')
32
+ userId: string;
33
+
31
34
  @IsUUID('4')
32
35
  id: string;
33
36