tychat-contracts 1.3.6 → 1.3.8

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.
@@ -1,3 +1,5 @@
1
+ export declare const ADMIN_NOTIFICATION_KINDS: readonly ["notification", "alert"];
2
+ export type AdminNotificationKind = (typeof ADMIN_NOTIFICATION_KINDS)[number];
1
3
  /**
2
4
  * Pedido de envio em massa de push (FCM) disparado pelo painel admin.
3
5
  * O tenant-service publica no Kafka; o notifications-service consome e envia.
@@ -9,6 +11,7 @@ export declare class AdminBroadcastPushDto {
9
11
  userIds?: string[];
10
12
  title: string;
11
13
  body: string;
14
+ notificationKind?: AdminNotificationKind;
12
15
  data?: Record<string, string>;
13
16
  }
14
17
  //# sourceMappingURL=admin-broadcast-push.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin-broadcast-push.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/admin-broadcast-push.dto.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,qBAAa,qBAAqB;IAGhC,UAAU,EAAG,OAAO,CAAC;IAUrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAIvB,QAAQ,EAAG,OAAO,CAAC;IAUnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAKnB,KAAK,EAAG,MAAM,CAAC;IAKf,IAAI,EAAG,MAAM,CAAC;IASd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B"}
1
+ {"version":3,"file":"admin-broadcast-push.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/admin-broadcast-push.dto.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,wBAAwB,oCAAqC,CAAC;AAC3E,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E;;;GAGG;AACH,qBAAa,qBAAqB;IAGhC,UAAU,EAAG,OAAO,CAAC;IAUrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAIvB,QAAQ,EAAG,OAAO,CAAC;IAUnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAKnB,KAAK,EAAG,MAAM,CAAC;IAKf,IAAI,EAAG,MAAM,CAAC;IAUd,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;IASzC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B"}
@@ -9,9 +9,10 @@ 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.AdminBroadcastPushDto = void 0;
12
+ exports.AdminBroadcastPushDto = exports.ADMIN_NOTIFICATION_KINDS = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
+ exports.ADMIN_NOTIFICATION_KINDS = ['notification', 'alert'];
15
16
  /**
16
17
  * Pedido de envio em massa de push (FCM) disparado pelo painel admin.
17
18
  * O tenant-service publica no Kafka; o notifications-service consome e envia.
@@ -23,6 +24,7 @@ class AdminBroadcastPushDto {
23
24
  userIds;
24
25
  title;
25
26
  body;
27
+ notificationKind;
26
28
  data;
27
29
  }
28
30
  exports.AdminBroadcastPushDto = AdminBroadcastPushDto;
@@ -70,6 +72,17 @@ __decorate([
70
72
  (0, class_validator_1.MaxLength)(4000),
71
73
  __metadata("design:type", String)
72
74
  ], AdminBroadcastPushDto.prototype, "body", void 0);
75
+ __decorate([
76
+ (0, swagger_1.ApiPropertyOptional)({
77
+ description: 'Categoria de entrega no app (notification = centro; alert = modal no login).',
78
+ enum: exports.ADMIN_NOTIFICATION_KINDS,
79
+ default: 'notification',
80
+ }),
81
+ (0, class_validator_1.IsOptional)(),
82
+ (0, class_validator_1.IsString)(),
83
+ (0, class_validator_1.IsIn)(exports.ADMIN_NOTIFICATION_KINDS),
84
+ __metadata("design:type", String)
85
+ ], AdminBroadcastPushDto.prototype, "notificationKind", void 0);
73
86
  __decorate([
74
87
  (0, swagger_1.ApiPropertyOptional)({
75
88
  description: 'Payload FCM `data` (valores devem ser strings)',
@@ -1,6 +1,6 @@
1
- export { NotificationUserCreatedEventPayload, NotificationPasswordResetRequestedEventPayload, NotificationConversationChangeToHumanEventPayload, } from './notifications-kafka.payloads';
2
- export { TOPIC_NOTIFICATIONS_FIND_ALL, TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN, TOPIC_NOTIFICATIONS_UPDATE_VIEWED, EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH, EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH, } from './notifications-kafka-topics';
3
- export { AdminBroadcastPushDto } from './admin-broadcast-push.dto';
1
+ export { NotificationUserCreatedEventPayload, NotificationPasswordResetRequestedEventPayload, NotificationConversationChangeToHumanEventPayload, NotificationTenantAiTokensThresholdEventPayload, } from './notifications-kafka.payloads';
2
+ export { TOPIC_NOTIFICATIONS_FIND_ALL, TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN, TOPIC_NOTIFICATIONS_UPDATE_VIEWED, EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH, EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH, EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD, } from './notifications-kafka-topics';
3
+ export { AdminBroadcastPushDto, ADMIN_NOTIFICATION_KINDS, type AdminNotificationKind, } 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
6
  export { NotificationsFindAllKafkaDto } from './notifications-find-all-kafka.dto';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EACnC,8CAA8C,EAC9C,iDAAiD,GAClD,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,4BAA4B,EAC5B,uCAAuC,EACvC,iCAAiC,EACjC,wCAAwC,EACxC,6CAA6C,GAC9C,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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EACnC,8CAA8C,EAC9C,iDAAiD,EACjD,+CAA+C,GAChD,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,4BAA4B,EAC5B,uCAAuC,EACvC,iCAAiC,EACjC,wCAAwC,EACxC,6CAA6C,EAC7C,8CAA8C,GAC/C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,4BAA4B,CAAC;AACpC,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,18 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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_CONVERSATION_HANDOFF_PUSH = exports.EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH = exports.TOPIC_NOTIFICATIONS_UPDATE_VIEWED = exports.TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN = exports.TOPIC_NOTIFICATIONS_FIND_ALL = exports.NotificationConversationChangeToHumanEventPayload = 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.ADMIN_NOTIFICATION_KINDS = exports.AdminBroadcastPushDto = exports.EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD = exports.EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH = exports.EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH = exports.TOPIC_NOTIFICATIONS_UPDATE_VIEWED = exports.TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN = exports.TOPIC_NOTIFICATIONS_FIND_ALL = exports.NotificationTenantAiTokensThresholdEventPayload = exports.NotificationConversationChangeToHumanEventPayload = 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; } });
7
7
  Object.defineProperty(exports, "NotificationConversationChangeToHumanEventPayload", { enumerable: true, get: function () { return notifications_kafka_payloads_1.NotificationConversationChangeToHumanEventPayload; } });
8
+ Object.defineProperty(exports, "NotificationTenantAiTokensThresholdEventPayload", { enumerable: true, get: function () { return notifications_kafka_payloads_1.NotificationTenantAiTokensThresholdEventPayload; } });
8
9
  var notifications_kafka_topics_1 = require("./notifications-kafka-topics");
9
10
  Object.defineProperty(exports, "TOPIC_NOTIFICATIONS_FIND_ALL", { enumerable: true, get: function () { return notifications_kafka_topics_1.TOPIC_NOTIFICATIONS_FIND_ALL; } });
10
11
  Object.defineProperty(exports, "TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN", { enumerable: true, get: function () { return notifications_kafka_topics_1.TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN; } });
11
12
  Object.defineProperty(exports, "TOPIC_NOTIFICATIONS_UPDATE_VIEWED", { enumerable: true, get: function () { return notifications_kafka_topics_1.TOPIC_NOTIFICATIONS_UPDATE_VIEWED; } });
12
13
  Object.defineProperty(exports, "EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH", { enumerable: true, get: function () { return notifications_kafka_topics_1.EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH; } });
13
14
  Object.defineProperty(exports, "EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH", { enumerable: true, get: function () { return notifications_kafka_topics_1.EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH; } });
15
+ Object.defineProperty(exports, "EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD", { enumerable: true, get: function () { return notifications_kafka_topics_1.EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD; } });
14
16
  var admin_broadcast_push_dto_1 = require("./admin-broadcast-push.dto");
15
17
  Object.defineProperty(exports, "AdminBroadcastPushDto", { enumerable: true, get: function () { return admin_broadcast_push_dto_1.AdminBroadcastPushDto; } });
18
+ Object.defineProperty(exports, "ADMIN_NOTIFICATION_KINDS", { enumerable: true, get: function () { return admin_broadcast_push_dto_1.ADMIN_NOTIFICATION_KINDS; } });
16
19
  var register_push_token_dto_1 = require("./register-push-token.dto");
17
20
  Object.defineProperty(exports, "RegisterPushTokenDto", { enumerable: true, get: function () { return register_push_token_dto_1.RegisterPushTokenDto; } });
18
21
  Object.defineProperty(exports, "NotificationsRegisterPushTokenKafkaDto", { enumerable: true, get: function () { return register_push_token_dto_1.NotificationsRegisterPushTokenKafkaDto; } });
@@ -1,9 +1,11 @@
1
+ import { type AdminNotificationKind } from './admin-broadcast-push.dto';
1
2
  /** Item retornado em GET /notifications (e RPC notifications.findAll). */
2
3
  export declare class NotificationListItemDto {
3
4
  id: string;
4
5
  notificationEvent: string;
5
6
  provider: string;
6
7
  status: string;
8
+ kind: AdminNotificationKind;
7
9
  createdAt: string;
8
10
  updatedAt: string;
9
11
  viewed: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"notification-list-item.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/notification-list-item.dto.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,qBAAa,uBAAuB;IAElC,EAAE,EAAE,MAAM,CAAC;IAGX,iBAAiB,EAAE,MAAM,CAAC;IAG1B,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,MAAM,CAAC;IAGf,SAAS,EAAE,MAAM,CAAC;IAGlB,SAAS,EAAE,MAAM,CAAC;IAMlB,MAAM,EAAE,OAAO,CAAC;IAOhB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAOxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAOvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAOtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB"}
1
+ {"version":3,"file":"notification-list-item.dto.d.ts","sourceRoot":"","sources":["../../src/notifications/notification-list-item.dto.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAElG,0EAA0E;AAC1E,qBAAa,uBAAuB;IAElC,EAAE,EAAE,MAAM,CAAC;IAGX,iBAAiB,EAAE,MAAM,CAAC;IAG1B,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,MAAM,CAAC;IAOf,IAAI,EAAE,qBAAqB,CAAC;IAG5B,SAAS,EAAE,MAAM,CAAC;IAGlB,SAAS,EAAE,MAAM,CAAC;IAMlB,MAAM,EAAE,OAAO,CAAC;IAOhB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAOxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAOvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAOtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB"}
@@ -11,12 +11,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.NotificationListItemDto = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
+ const admin_broadcast_push_dto_1 = require("./admin-broadcast-push.dto");
14
15
  /** Item retornado em GET /notifications (e RPC notifications.findAll). */
15
16
  class NotificationListItemDto {
16
17
  id;
17
18
  notificationEvent;
18
19
  provider;
19
20
  status;
21
+ kind;
20
22
  createdAt;
21
23
  updatedAt;
22
24
  viewed;
@@ -42,6 +44,14 @@ __decorate([
42
44
  (0, swagger_1.ApiProperty)({ enum: ['pending', 'sent', 'failed'] }),
43
45
  __metadata("design:type", String)
44
46
  ], NotificationListItemDto.prototype, "status", void 0);
47
+ __decorate([
48
+ (0, swagger_1.ApiProperty)({
49
+ description: 'Categoria de exibição no app.',
50
+ enum: admin_broadcast_push_dto_1.ADMIN_NOTIFICATION_KINDS,
51
+ default: 'notification',
52
+ }),
53
+ __metadata("design:type", String)
54
+ ], NotificationListItemDto.prototype, "kind", void 0);
45
55
  __decorate([
46
56
  (0, swagger_1.ApiProperty)({ example: '2026-04-08T12:00:00.000Z' }),
47
57
  __metadata("design:type", String)
@@ -7,4 +7,6 @@ export declare const TOPIC_NOTIFICATIONS_UPDATE_VIEWED = "notifications.updateVi
7
7
  export declare const EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH = "notifications.admin_broadcast_push";
8
8
  /** Registo `notifications` / FCM quando a clínica recebe alerta de conversa para humano. */
9
9
  export declare const EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH = "notifications.conversation_change_to_human_push";
10
+ /** Evento Kafka: alerta de cota mensal de tokens de IA para administradores do tenant. */
11
+ export declare const EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD = "notifications.tenant_ai_tokens_threshold";
10
12
  //# sourceMappingURL=notifications-kafka-topics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications-kafka-topics.d.ts","sourceRoot":"","sources":["../../src/notifications/notifications-kafka-topics.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,4BAA4B,0BAA0B,CAAC;AAEpE,eAAO,MAAM,uCAAuC,oCACjB,CAAC;AAEpC,iFAAiF;AACjF,eAAO,MAAM,iCAAiC,+BAA+B,CAAC;AAE9E,8DAA8D;AAC9D,eAAO,MAAM,wCAAwC,uCACf,CAAC;AAEvC,4FAA4F;AAC5F,eAAO,MAAM,6CAA6C,oDACP,CAAC"}
1
+ {"version":3,"file":"notifications-kafka-topics.d.ts","sourceRoot":"","sources":["../../src/notifications/notifications-kafka-topics.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,4BAA4B,0BAA0B,CAAC;AAEpE,eAAO,MAAM,uCAAuC,oCACjB,CAAC;AAEpC,iFAAiF;AACjF,eAAO,MAAM,iCAAiC,+BAA+B,CAAC;AAE9E,8DAA8D;AAC9D,eAAO,MAAM,wCAAwC,uCACf,CAAC;AAEvC,4FAA4F;AAC5F,eAAO,MAAM,6CAA6C,oDACP,CAAC;AAEpD,0FAA0F;AAC1F,eAAO,MAAM,8CAA8C,6CACf,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH = exports.EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH = exports.TOPIC_NOTIFICATIONS_UPDATE_VIEWED = exports.TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN = exports.TOPIC_NOTIFICATIONS_FIND_ALL = void 0;
3
+ exports.EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD = exports.EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH = exports.EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH = exports.TOPIC_NOTIFICATIONS_UPDATE_VIEWED = exports.TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN = exports.TOPIC_NOTIFICATIONS_FIND_ALL = void 0;
4
4
  /** Kafka request–reply: lista notificações persistidas no banco do tenant. */
5
5
  exports.TOPIC_NOTIFICATIONS_FIND_ALL = 'notifications.findAll';
6
6
  exports.TOPIC_NOTIFICATIONS_REGISTER_PUSH_TOKEN = 'notifications.registerPushToken';
@@ -10,3 +10,5 @@ exports.TOPIC_NOTIFICATIONS_UPDATE_VIEWED = 'notifications.updateViewed';
10
10
  exports.EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH = 'notifications.admin_broadcast_push';
11
11
  /** Registo `notifications` / FCM quando a clínica recebe alerta de conversa para humano. */
12
12
  exports.EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH = 'notifications.conversation_change_to_human_push';
13
+ /** Evento Kafka: alerta de cota mensal de tokens de IA para administradores do tenant. */
14
+ exports.EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD = 'notifications.tenant_ai_tokens_threshold';
@@ -26,4 +26,17 @@ export declare class NotificationConversationChangeToHumanEventPayload {
26
26
  isUrgent?: boolean;
27
27
  handoffSource?: 'ai' | 'manual';
28
28
  }
29
+ /** Evento Kafka `notifications.tenant_ai_tokens_threshold` para alertas de cota de IA. */
30
+ export declare class NotificationTenantAiTokensThresholdEventPayload {
31
+ eventId: string;
32
+ tenant: string;
33
+ thresholdPercent: 70 | 80 | 90 | 100;
34
+ consumedPercent: number;
35
+ remainingPercent: number;
36
+ currentBalance: number;
37
+ monthlyAllowance: number;
38
+ cycleStartedAt: string;
39
+ nextRenewalAt: string;
40
+ occurredAt: string;
41
+ }
29
42
  //# sourceMappingURL=notifications-kafka.payloads.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications-kafka.payloads.d.ts","sourceRoot":"","sources":["../../src/notifications/notifications-kafka.payloads.ts"],"names":[],"mappings":"AAcA,qBAAa,mCAAmC;IAM9C,OAAO,EAAE,MAAM,CAAC;IAShB,MAAM,EAAE,MAAM,CAAC;IAQf,KAAK,EAAE,MAAM,CAAC;IASd,IAAI,EAAE,MAAM,CAAC;IASb,QAAQ,EAAE,MAAM,CAAC;IAOjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,8CAA8C;IAMzD,OAAO,EAAE,MAAM,CAAC;IAShB,MAAM,EAAE,MAAM,CAAC;IAQf,KAAK,EAAE,MAAM,CAAC;IASd,WAAW,EAAE,MAAM,CAAC;IAOpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,+FAA+F;AAC/F,qBAAa,iDAAiD;IAG5D,OAAO,EAAE,MAAM,CAAC;IAMhB,MAAM,EAAE,MAAM,CAAC;IAIf,SAAS,EAAE,MAAM,CAAC;IAKlB,WAAW,EAAE,MAAM,CAAC;IAMpB,MAAM,EAAE,MAAM,CAAC;IAIf,UAAU,EAAE,MAAM,CAAC;IAMnB,WAAW,CAAC,EAAE,MAAM,CAAC;IAKrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAOhB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAKnB,aAAa,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC;CACjC"}
1
+ {"version":3,"file":"notifications-kafka.payloads.d.ts","sourceRoot":"","sources":["../../src/notifications/notifications-kafka.payloads.ts"],"names":[],"mappings":"AAiBA,qBAAa,mCAAmC;IAM9C,OAAO,EAAE,MAAM,CAAC;IAShB,MAAM,EAAE,MAAM,CAAC;IAQf,KAAK,EAAE,MAAM,CAAC;IASd,IAAI,EAAE,MAAM,CAAC;IASb,QAAQ,EAAE,MAAM,CAAC;IAOjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,8CAA8C;IAMzD,OAAO,EAAE,MAAM,CAAC;IAShB,MAAM,EAAE,MAAM,CAAC;IAQf,KAAK,EAAE,MAAM,CAAC;IASd,WAAW,EAAE,MAAM,CAAC;IAOpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,+FAA+F;AAC/F,qBAAa,iDAAiD;IAG5D,OAAO,EAAE,MAAM,CAAC;IAMhB,MAAM,EAAE,MAAM,CAAC;IAIf,SAAS,EAAE,MAAM,CAAC;IAKlB,WAAW,EAAE,MAAM,CAAC;IAMpB,MAAM,EAAE,MAAM,CAAC;IAIf,UAAU,EAAE,MAAM,CAAC;IAMnB,WAAW,CAAC,EAAE,MAAM,CAAC;IAKrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAOhB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAKnB,aAAa,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC;CACjC;AAED,0FAA0F;AAC1F,qBAAa,+CAA+C;IAG1D,OAAO,EAAE,MAAM,CAAC;IAMhB,MAAM,EAAE,MAAM,CAAC;IASf,gBAAgB,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAMrC,eAAe,EAAE,MAAM,CAAC;IAMxB,gBAAgB,EAAE,MAAM,CAAC;IAKzB,cAAc,EAAE,MAAM,CAAC;IAKvB,gBAAgB,EAAE,MAAM,CAAC;IAIzB,cAAc,EAAE,MAAM,CAAC;IAIvB,aAAa,EAAE,MAAM,CAAC;IAItB,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.NotificationConversationChangeToHumanEventPayload = exports.NotificationPasswordResetRequestedEventPayload = exports.NotificationUserCreatedEventPayload = void 0;
12
+ exports.NotificationTenantAiTokensThresholdEventPayload = exports.NotificationConversationChangeToHumanEventPayload = exports.NotificationPasswordResetRequestedEventPayload = exports.NotificationUserCreatedEventPayload = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  class NotificationUserCreatedEventPayload {
@@ -205,3 +205,80 @@ __decorate([
205
205
  (0, class_validator_1.IsIn)(['ai', 'manual']),
206
206
  __metadata("design:type", String)
207
207
  ], NotificationConversationChangeToHumanEventPayload.prototype, "handoffSource", void 0);
208
+ /** Evento Kafka `notifications.tenant_ai_tokens_threshold` para alertas de cota de IA. */
209
+ class NotificationTenantAiTokensThresholdEventPayload {
210
+ eventId;
211
+ tenant;
212
+ thresholdPercent;
213
+ consumedPercent;
214
+ remainingPercent;
215
+ currentBalance;
216
+ monthlyAllowance;
217
+ cycleStartedAt;
218
+ nextRenewalAt;
219
+ occurredAt;
220
+ }
221
+ exports.NotificationTenantAiTokensThresholdEventPayload = NotificationTenantAiTokensThresholdEventPayload;
222
+ __decorate([
223
+ (0, swagger_1.ApiProperty)({ description: 'Idempotência do evento' }),
224
+ (0, class_validator_1.IsUUID)(),
225
+ __metadata("design:type", String)
226
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "eventId", void 0);
227
+ __decorate([
228
+ (0, swagger_1.ApiProperty)({ description: 'Slug do tenant', example: 'default' }),
229
+ (0, class_validator_1.IsString)(),
230
+ (0, class_validator_1.MinLength)(1),
231
+ (0, class_validator_1.MaxLength)(255),
232
+ __metadata("design:type", String)
233
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "tenant", void 0);
234
+ __decorate([
235
+ (0, swagger_1.ApiProperty)({
236
+ description: 'Limiar de consumo atingido em percentual',
237
+ example: 70,
238
+ enum: [70, 80, 90, 100],
239
+ }),
240
+ (0, class_validator_1.IsInt)(),
241
+ (0, class_validator_1.IsIn)([70, 80, 90, 100]),
242
+ __metadata("design:type", Number)
243
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "thresholdPercent", void 0);
244
+ __decorate([
245
+ (0, swagger_1.ApiProperty)({ description: 'Percentual consumido após o débito', example: 72 }),
246
+ (0, class_validator_1.IsInt)(),
247
+ (0, class_validator_1.Min)(0),
248
+ (0, class_validator_1.Max)(100),
249
+ __metadata("design:type", Number)
250
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "consumedPercent", void 0);
251
+ __decorate([
252
+ (0, swagger_1.ApiProperty)({ description: 'Percentual restante após o débito', example: 28 }),
253
+ (0, class_validator_1.IsInt)(),
254
+ (0, class_validator_1.Min)(0),
255
+ (0, class_validator_1.Max)(100),
256
+ __metadata("design:type", Number)
257
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "remainingPercent", void 0);
258
+ __decorate([
259
+ (0, swagger_1.ApiProperty)({ description: 'Saldo atual de tokens após o débito', example: 2800 }),
260
+ (0, class_validator_1.IsInt)(),
261
+ (0, class_validator_1.Min)(0),
262
+ __metadata("design:type", Number)
263
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "currentBalance", void 0);
264
+ __decorate([
265
+ (0, swagger_1.ApiProperty)({ description: 'Cota mensal total do ciclo', example: 10000 }),
266
+ (0, class_validator_1.IsInt)(),
267
+ (0, class_validator_1.Min)(0),
268
+ __metadata("design:type", Number)
269
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "monthlyAllowance", void 0);
270
+ __decorate([
271
+ (0, swagger_1.ApiProperty)({ description: 'Data de início do ciclo atual (UTC ISO-8601)' }),
272
+ (0, class_validator_1.IsISO8601)(),
273
+ __metadata("design:type", String)
274
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "cycleStartedAt", void 0);
275
+ __decorate([
276
+ (0, swagger_1.ApiProperty)({ description: 'Data prevista para renovação do ciclo (UTC ISO-8601)' }),
277
+ (0, class_validator_1.IsISO8601)(),
278
+ __metadata("design:type", String)
279
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "nextRenewalAt", void 0);
280
+ __decorate([
281
+ (0, swagger_1.ApiProperty)({ description: 'Timestamp do disparo (UTC ISO-8601)' }),
282
+ (0, class_validator_1.IsISO8601)(),
283
+ __metadata("design:type", String)
284
+ ], NotificationTenantAiTokensThresholdEventPayload.prototype, "occurredAt", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tychat-contracts",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
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",
@@ -3,6 +3,7 @@ import {
3
3
  ArrayMinSize,
4
4
  IsArray,
5
5
  IsBoolean,
6
+ IsIn,
6
7
  IsObject,
7
8
  IsOptional,
8
9
  IsString,
@@ -11,6 +12,9 @@ import {
11
12
  ValidateIf,
12
13
  } from 'class-validator';
13
14
 
15
+ export const ADMIN_NOTIFICATION_KINDS = ['notification', 'alert'] as const;
16
+ export type AdminNotificationKind = (typeof ADMIN_NOTIFICATION_KINDS)[number];
17
+
14
18
  /**
15
19
  * Pedido de envio em massa de push (FCM) disparado pelo painel admin.
16
20
  * O tenant-service publica no Kafka; o notifications-service consome e envia.
@@ -54,6 +58,16 @@ export class AdminBroadcastPushDto {
54
58
  @MaxLength(4000)
55
59
  body!: string;
56
60
 
61
+ @ApiPropertyOptional({
62
+ description: 'Categoria de entrega no app (notification = centro; alert = modal no login).',
63
+ enum: ADMIN_NOTIFICATION_KINDS,
64
+ default: 'notification',
65
+ })
66
+ @IsOptional()
67
+ @IsString()
68
+ @IsIn(ADMIN_NOTIFICATION_KINDS)
69
+ notificationKind?: AdminNotificationKind;
70
+
57
71
  @ApiPropertyOptional({
58
72
  description: 'Payload FCM `data` (valores devem ser strings)',
59
73
  type: 'object',
@@ -2,6 +2,7 @@ export {
2
2
  NotificationUserCreatedEventPayload,
3
3
  NotificationPasswordResetRequestedEventPayload,
4
4
  NotificationConversationChangeToHumanEventPayload,
5
+ NotificationTenantAiTokensThresholdEventPayload,
5
6
  } from './notifications-kafka.payloads';
6
7
  export {
7
8
  TOPIC_NOTIFICATIONS_FIND_ALL,
@@ -9,8 +10,13 @@ export {
9
10
  TOPIC_NOTIFICATIONS_UPDATE_VIEWED,
10
11
  EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH,
11
12
  EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH,
13
+ EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD,
12
14
  } from './notifications-kafka-topics';
13
- export { AdminBroadcastPushDto } from './admin-broadcast-push.dto';
15
+ export {
16
+ AdminBroadcastPushDto,
17
+ ADMIN_NOTIFICATION_KINDS,
18
+ type AdminNotificationKind,
19
+ } from './admin-broadcast-push.dto';
14
20
  export {
15
21
  RegisterPushTokenDto,
16
22
  NotificationsRegisterPushTokenKafkaDto,
@@ -1,4 +1,5 @@
1
1
  import { ApiProperty } from '@nestjs/swagger';
2
+ import { ADMIN_NOTIFICATION_KINDS, type AdminNotificationKind } from './admin-broadcast-push.dto';
2
3
 
3
4
  /** Item retornado em GET /notifications (e RPC notifications.findAll). */
4
5
  export class NotificationListItemDto {
@@ -14,6 +15,13 @@ export class NotificationListItemDto {
14
15
  @ApiProperty({ enum: ['pending', 'sent', 'failed'] })
15
16
  status: string;
16
17
 
18
+ @ApiProperty({
19
+ description: 'Categoria de exibição no app.',
20
+ enum: ADMIN_NOTIFICATION_KINDS,
21
+ default: 'notification',
22
+ })
23
+ kind: AdminNotificationKind;
24
+
17
25
  @ApiProperty({ example: '2026-04-08T12:00:00.000Z' })
18
26
  createdAt: string;
19
27
 
@@ -14,3 +14,7 @@ export const EVENT_NOTIFICATIONS_ADMIN_BROADCAST_PUSH =
14
14
  /** Registo `notifications` / FCM quando a clínica recebe alerta de conversa para humano. */
15
15
  export const EVENT_NOTIFICATIONS_CONVERSATION_HANDOFF_PUSH =
16
16
  'notifications.conversation_change_to_human_push';
17
+
18
+ /** Evento Kafka: alerta de cota mensal de tokens de IA para administradores do tenant. */
19
+ export const EVENT_NOTIFICATIONS_TENANT_AI_TOKENS_THRESHOLD =
20
+ 'notifications.tenant_ai_tokens_threshold';
@@ -4,11 +4,14 @@ import {
4
4
  IsEmail,
5
5
  IsIn,
6
6
  IsISO8601,
7
+ IsInt,
7
8
  IsNumber,
8
9
  IsOptional,
9
10
  IsString,
10
11
  IsUUID,
12
+ Max,
11
13
  MaxLength,
14
+ Min,
12
15
  MinLength,
13
16
  } from 'class-validator';
14
17
 
@@ -159,3 +162,59 @@ export class NotificationConversationChangeToHumanEventPayload {
159
162
  @IsIn(['ai', 'manual'])
160
163
  handoffSource?: 'ai' | 'manual';
161
164
  }
165
+
166
+ /** Evento Kafka `notifications.tenant_ai_tokens_threshold` para alertas de cota de IA. */
167
+ export class NotificationTenantAiTokensThresholdEventPayload {
168
+ @ApiProperty({ description: 'Idempotência do evento' })
169
+ @IsUUID()
170
+ eventId: string;
171
+
172
+ @ApiProperty({ description: 'Slug do tenant', example: 'default' })
173
+ @IsString()
174
+ @MinLength(1)
175
+ @MaxLength(255)
176
+ tenant: string;
177
+
178
+ @ApiProperty({
179
+ description: 'Limiar de consumo atingido em percentual',
180
+ example: 70,
181
+ enum: [70, 80, 90, 100],
182
+ })
183
+ @IsInt()
184
+ @IsIn([70, 80, 90, 100])
185
+ thresholdPercent: 70 | 80 | 90 | 100;
186
+
187
+ @ApiProperty({ description: 'Percentual consumido após o débito', example: 72 })
188
+ @IsInt()
189
+ @Min(0)
190
+ @Max(100)
191
+ consumedPercent: number;
192
+
193
+ @ApiProperty({ description: 'Percentual restante após o débito', example: 28 })
194
+ @IsInt()
195
+ @Min(0)
196
+ @Max(100)
197
+ remainingPercent: number;
198
+
199
+ @ApiProperty({ description: 'Saldo atual de tokens após o débito', example: 2800 })
200
+ @IsInt()
201
+ @Min(0)
202
+ currentBalance: number;
203
+
204
+ @ApiProperty({ description: 'Cota mensal total do ciclo', example: 10000 })
205
+ @IsInt()
206
+ @Min(0)
207
+ monthlyAllowance: number;
208
+
209
+ @ApiProperty({ description: 'Data de início do ciclo atual (UTC ISO-8601)' })
210
+ @IsISO8601()
211
+ cycleStartedAt: string;
212
+
213
+ @ApiProperty({ description: 'Data prevista para renovação do ciclo (UTC ISO-8601)' })
214
+ @IsISO8601()
215
+ nextRenewalAt: string;
216
+
217
+ @ApiProperty({ description: 'Timestamp do disparo (UTC ISO-8601)' })
218
+ @IsISO8601()
219
+ occurredAt: string;
220
+ }