tychat-contracts 1.0.99 → 1.0.100

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.
@@ -22,4 +22,36 @@ export declare class AnalyticsDashboardQueryDto {
22
22
  startDate: string;
23
23
  endDate: string;
24
24
  }
25
+ /** Resumo financeiro agregado a partir de eventos de analytics (pagamentos + faturamento). */
26
+ export declare class AnalyticsDashboardFinancialDto {
27
+ revenue: number;
28
+ averageTicket: number;
29
+ pending: number;
30
+ }
31
+ export declare class AnalyticsDashboardTopProcedureDto {
32
+ name: string;
33
+ count: number;
34
+ }
35
+ /**
36
+ * Resposta enriquecida de `GET /analytics/dashboard` (mantém campos legados `total`, `byEventType`, `byDomain`).
37
+ */
38
+ export declare class AnalyticsDashboardResponseDto {
39
+ appointmentsCreated: number;
40
+ appointmentsFinished: number;
41
+ proceduresScheduled: number;
42
+ proceduresFinished: number;
43
+ satisfactionAverage: number | null;
44
+ noShowRatePercent: number;
45
+ financialSummary: AnalyticsDashboardFinancialDto;
46
+ topProcedures: AnalyticsDashboardTopProcedureDto[];
47
+ total: number;
48
+ byEventType: Array<{
49
+ eventType: string;
50
+ count: number;
51
+ }>;
52
+ byDomain: Array<{
53
+ domain: string;
54
+ count: number;
55
+ }>;
56
+ }
25
57
  //# sourceMappingURL=analytics-query.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-query.dto.d.ts","sourceRoot":"","sources":["../../src/analytics/analytics-query.dto.ts"],"names":[],"mappings":"AAYA,OAAO,EAAwB,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,kBAAkB,2CAA4C,CAAC;AAC5E,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE;;GAEG;AACH,qBAAa,uBAAuB;IAMlC,SAAS,EAAE,MAAM,CAAC;IAOlB,OAAO,EAAE,MAAM,CAAC;I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,EAAE,MAAM,CAAC;IAK5B,kBAAkB,EAAE,MAAM,CAAC;IAO3B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IAMnC,iBAAiB,EAAE,MAAM,CAAC;IAG1B,gBAAgB,EAAE,8BAA8B,CAAC;IAGjD,aAAa,EAAE,iCAAiC,EAAE,CAAC;IAGnD,KAAK,EAAE,MAAM,CAAC;IAKd,WAAW,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAKzD,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD"}
@@ -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.AnalyticsDashboardQueryDto = exports.AnalyticsReportQueryDto = exports.ANALYTICS_GROUP_BY = void 0;
12
+ exports.AnalyticsDashboardResponseDto = exports.AnalyticsDashboardTopProcedureDto = exports.AnalyticsDashboardFinancialDto = exports.AnalyticsDashboardQueryDto = exports.AnalyticsReportQueryDto = exports.ANALYTICS_GROUP_BY = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const class_transformer_1 = require("class-transformer");
@@ -106,3 +106,115 @@ __decorate([
106
106
  (0, class_validator_1.IsISO8601)(),
107
107
  __metadata("design:type", String)
108
108
  ], AnalyticsDashboardQueryDto.prototype, "endDate", void 0);
109
+ /** Resumo financeiro agregado a partir de eventos de analytics (pagamentos + faturamento). */
110
+ class AnalyticsDashboardFinancialDto {
111
+ revenue;
112
+ averageTicket;
113
+ pending;
114
+ }
115
+ exports.AnalyticsDashboardFinancialDto = AnalyticsDashboardFinancialDto;
116
+ __decorate([
117
+ (0, swagger_1.ApiProperty)({
118
+ description: 'Receita no período: soma de `payment.payed` e `billing.invoice_paid` (valores em metadata.amount)',
119
+ }),
120
+ __metadata("design:type", Number)
121
+ ], AnalyticsDashboardFinancialDto.prototype, "revenue", void 0);
122
+ __decorate([
123
+ (0, swagger_1.ApiProperty)({
124
+ description: 'Ticket médio: revenue / número de eventos pagos (payment.payed + billing.invoice_paid); 0 se não houver pagamentos',
125
+ }),
126
+ __metadata("design:type", Number)
127
+ ], AnalyticsDashboardFinancialDto.prototype, "averageTicket", void 0);
128
+ __decorate([
129
+ (0, swagger_1.ApiProperty)({
130
+ description: 'Volume de cobranças criadas no período ainda não quitadas no momento do registro: soma de `payment.created` + faturas `billing.invoice_created` com status PENDING ou OVERDUE no metadata (aproximação; não substitui saldo contábil)',
131
+ }),
132
+ __metadata("design:type", Number)
133
+ ], AnalyticsDashboardFinancialDto.prototype, "pending", void 0);
134
+ class AnalyticsDashboardTopProcedureDto {
135
+ name;
136
+ count;
137
+ }
138
+ exports.AnalyticsDashboardTopProcedureDto = AnalyticsDashboardTopProcedureDto;
139
+ __decorate([
140
+ (0, swagger_1.ApiProperty)({ description: 'Nome do procedimento (agendamento)' }),
141
+ __metadata("design:type", String)
142
+ ], AnalyticsDashboardTopProcedureDto.prototype, "name", void 0);
143
+ __decorate([
144
+ (0, swagger_1.ApiProperty)({ description: 'Quantidade de ocorrências no período' }),
145
+ __metadata("design:type", Number)
146
+ ], AnalyticsDashboardTopProcedureDto.prototype, "count", void 0);
147
+ /**
148
+ * Resposta enriquecida de `GET /analytics/dashboard` (mantém campos legados `total`, `byEventType`, `byDomain`).
149
+ */
150
+ class AnalyticsDashboardResponseDto {
151
+ appointmentsCreated;
152
+ appointmentsFinished;
153
+ proceduresScheduled;
154
+ proceduresFinished;
155
+ satisfactionAverage;
156
+ noShowRatePercent;
157
+ financialSummary;
158
+ topProcedures;
159
+ total;
160
+ byEventType;
161
+ byDomain;
162
+ }
163
+ exports.AnalyticsDashboardResponseDto = AnalyticsDashboardResponseDto;
164
+ __decorate([
165
+ (0, swagger_1.ApiProperty)({ description: 'Agendamentos criados no período (`appointment.created`)' }),
166
+ __metadata("design:type", Number)
167
+ ], AnalyticsDashboardResponseDto.prototype, "appointmentsCreated", void 0);
168
+ __decorate([
169
+ (0, swagger_1.ApiProperty)({ description: 'Agendamentos finalizados no período (`appointment.finished`)' }),
170
+ __metadata("design:type", Number)
171
+ ], AnalyticsDashboardResponseDto.prototype, "appointmentsFinished", void 0);
172
+ __decorate([
173
+ (0, swagger_1.ApiProperty)({
174
+ description: 'Procedimentos agendados: soma dos itens em metadata.procedures em `appointment.created` + vínculos posteriores (`appointment.updated` com reason procedure_added)',
175
+ }),
176
+ __metadata("design:type", Number)
177
+ ], AnalyticsDashboardResponseDto.prototype, "proceduresScheduled", void 0);
178
+ __decorate([
179
+ (0, swagger_1.ApiProperty)({
180
+ description: 'Procedimentos marcados como concluídos no período (`appointment.procedure_finished`)',
181
+ }),
182
+ __metadata("design:type", Number)
183
+ ], AnalyticsDashboardResponseDto.prototype, "proceduresFinished", void 0);
184
+ __decorate([
185
+ (0, swagger_1.ApiProperty)({
186
+ description: 'Média das notas 1–5 em respostas de satisfação (followup booking + pós-atendimento); null se não houver respostas',
187
+ nullable: true,
188
+ }),
189
+ __metadata("design:type", Object)
190
+ ], AnalyticsDashboardResponseDto.prototype, "satisfactionAverage", void 0);
191
+ __decorate([
192
+ (0, swagger_1.ApiProperty)({
193
+ description: 'Taxa de no-show (%): appointment.no_show / appointment.created no período (0 se não houver criações)',
194
+ }),
195
+ __metadata("design:type", Number)
196
+ ], AnalyticsDashboardResponseDto.prototype, "noShowRatePercent", void 0);
197
+ __decorate([
198
+ (0, swagger_1.ApiProperty)({ type: AnalyticsDashboardFinancialDto }),
199
+ __metadata("design:type", AnalyticsDashboardFinancialDto)
200
+ ], AnalyticsDashboardResponseDto.prototype, "financialSummary", void 0);
201
+ __decorate([
202
+ (0, swagger_1.ApiProperty)({ type: [AnalyticsDashboardTopProcedureDto], maxItems: 5 }),
203
+ __metadata("design:type", Array)
204
+ ], AnalyticsDashboardResponseDto.prototype, "topProcedures", void 0);
205
+ __decorate([
206
+ (0, swagger_1.ApiProperty)({ description: 'Total de eventos de analytics no período (legado)' }),
207
+ __metadata("design:type", Number)
208
+ ], AnalyticsDashboardResponseDto.prototype, "total", void 0);
209
+ __decorate([
210
+ (0, swagger_1.ApiProperty)({
211
+ description: 'Contagens por eventType (legado)',
212
+ }),
213
+ __metadata("design:type", Array)
214
+ ], AnalyticsDashboardResponseDto.prototype, "byEventType", void 0);
215
+ __decorate([
216
+ (0, swagger_1.ApiProperty)({
217
+ description: 'Contagens por domínio (prefixo antes do ponto no eventType) (legado)',
218
+ }),
219
+ __metadata("design:type", Array)
220
+ ], AnalyticsDashboardResponseDto.prototype, "byDomain", void 0);
@@ -2,6 +2,6 @@
2
2
  * Enum of all analytic event types emitted by microservices.
3
3
  * Each value follows the pattern: `domain.action`.
4
4
  */
5
- export declare const EVENT_ANALYTIC_TYPES: readonly ["patient.created", "patient.updated", "patient.deleted", "patient.status_changed", "appointment.created", "appointment.updated", "appointment.canceled", "appointment.rescheduled", "appointment.no_show", "appointment.finished", "checkin.effectued", "checkout.effectued", "message.sent", "message.received", "conversation.session_started", "conversation.session_ended", "conversation.transferred_to_human", "followup.abandonment.sent", "followup.appointment_confirmation.sent", "followup.satisfaction_booking.sent", "followup.satisfaction_finished.sent", "followup.no_show_reschedule.sent", "followup.wellness_check.sent", "followup.return_suggestion.sent", "followup.satisfaction_booking.response_received", "followup.satisfaction_finished.response_received", "followup.config_updated", "payment.created", "payment.payed", "payment.refunded", "payment.canceled", "payment.overdue", "payment_gateway.payment_created", "payment_gateway.payment_confirmed", "payment_gateway.payment_failed", "payment_gateway.payment_refunded", "payment_gateway.payment_canceled", "payment_gateway.payment_expired", "payment_gateway.webhook_received", "billing.invoice_created", "billing.invoice_paid", "ai.interaction", "ai.fallback", "auth.login", "auth.logout", "auth.password_reset", "user.created", "user.updated", "user.deleted", "notification.sent", "notification.failed", "whatsapp.connection_established", "whatsapp.connection_lost", "procedure.created", "procedure.updated", "procedure.deleted", "specialty.created", "specialty.updated", "specialty.deleted", "professional.created", "professional.updated", "professional.deleted", "configuration.updated", "storage.file_uploaded", "storage.file_deleted", "tenant.created", "tenant.updated"];
5
+ export declare const EVENT_ANALYTIC_TYPES: readonly ["patient.created", "patient.updated", "patient.deleted", "patient.status_changed", "appointment.created", "appointment.updated", "appointment.canceled", "appointment.rescheduled", "appointment.no_show", "appointment.finished", "appointment.procedure_finished", "checkin.effectued", "checkout.effectued", "message.sent", "message.received", "conversation.session_started", "conversation.session_ended", "conversation.transferred_to_human", "followup.abandonment.sent", "followup.appointment_confirmation.sent", "followup.satisfaction_booking.sent", "followup.satisfaction_finished.sent", "followup.no_show_reschedule.sent", "followup.wellness_check.sent", "followup.return_suggestion.sent", "followup.satisfaction_booking.response_received", "followup.satisfaction_finished.response_received", "followup.config_updated", "payment.created", "payment.payed", "payment.refunded", "payment.canceled", "payment.overdue", "payment_gateway.payment_created", "payment_gateway.payment_confirmed", "payment_gateway.payment_failed", "payment_gateway.payment_refunded", "payment_gateway.payment_canceled", "payment_gateway.payment_expired", "payment_gateway.webhook_received", "billing.invoice_created", "billing.invoice_paid", "ai.interaction", "ai.fallback", "auth.login", "auth.logout", "auth.password_reset", "user.created", "user.updated", "user.deleted", "notification.sent", "notification.failed", "whatsapp.connection_established", "whatsapp.connection_lost", "procedure.created", "procedure.updated", "procedure.deleted", "specialty.created", "specialty.updated", "specialty.deleted", "professional.created", "professional.updated", "professional.deleted", "configuration.updated", "storage.file_uploaded", "storage.file_deleted", "tenant.created", "tenant.updated"];
6
6
  export type EventAnalyticType = (typeof EVENT_ANALYTIC_TYPES)[number];
7
7
  //# sourceMappingURL=event-analytic.enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-analytic.enum.d.ts","sourceRoot":"","sources":["../../src/analytics/event-analytic.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,4sDA2GvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"event-analytic.enum.d.ts","sourceRoot":"","sources":["../../src/analytics/event-analytic.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,8uDA6GvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -18,6 +18,8 @@ exports.EVENT_ANALYTIC_TYPES = [
18
18
  'appointment.rescheduled',
19
19
  'appointment.no_show',
20
20
  'appointment.finished',
21
+ /** Procedimento do agendamento marcado como concluído (add/update com finished). */
22
+ 'appointment.procedure_finished',
21
23
  // ── Check-in / Check-out events ─────────────────────────────────
22
24
  'checkin.effectued',
23
25
  'checkout.effectued',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tychat-contracts",
3
- "version": "1.0.99",
3
+ "version": "1.0.100",
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",
@@ -87,3 +87,86 @@ export class AnalyticsDashboardQueryDto {
87
87
  @IsISO8601()
88
88
  endDate: string;
89
89
  }
90
+
91
+ /** Resumo financeiro agregado a partir de eventos de analytics (pagamentos + faturamento). */
92
+ export class AnalyticsDashboardFinancialDto {
93
+ @ApiProperty({
94
+ description:
95
+ 'Receita no período: soma de `payment.payed` e `billing.invoice_paid` (valores em metadata.amount)',
96
+ })
97
+ revenue: number;
98
+
99
+ @ApiProperty({
100
+ description:
101
+ 'Ticket médio: revenue / número de eventos pagos (payment.payed + billing.invoice_paid); 0 se não houver pagamentos',
102
+ })
103
+ averageTicket: number;
104
+
105
+ @ApiProperty({
106
+ description:
107
+ 'Volume de cobranças criadas no período ainda não quitadas no momento do registro: soma de `payment.created` + faturas `billing.invoice_created` com status PENDING ou OVERDUE no metadata (aproximação; não substitui saldo contábil)',
108
+ })
109
+ pending: number;
110
+ }
111
+
112
+ export class AnalyticsDashboardTopProcedureDto {
113
+ @ApiProperty({ description: 'Nome do procedimento (agendamento)' })
114
+ name: string;
115
+
116
+ @ApiProperty({ description: 'Quantidade de ocorrências no período' })
117
+ count: number;
118
+ }
119
+
120
+ /**
121
+ * Resposta enriquecida de `GET /analytics/dashboard` (mantém campos legados `total`, `byEventType`, `byDomain`).
122
+ */
123
+ export class AnalyticsDashboardResponseDto {
124
+ @ApiProperty({ description: 'Agendamentos criados no período (`appointment.created`)' })
125
+ appointmentsCreated: number;
126
+
127
+ @ApiProperty({ description: 'Agendamentos finalizados no período (`appointment.finished`)' })
128
+ appointmentsFinished: number;
129
+
130
+ @ApiProperty({
131
+ description:
132
+ 'Procedimentos agendados: soma dos itens em metadata.procedures em `appointment.created` + vínculos posteriores (`appointment.updated` com reason procedure_added)',
133
+ })
134
+ proceduresScheduled: number;
135
+
136
+ @ApiProperty({
137
+ description: 'Procedimentos marcados como concluídos no período (`appointment.procedure_finished`)',
138
+ })
139
+ proceduresFinished: number;
140
+
141
+ @ApiProperty({
142
+ description:
143
+ 'Média das notas 1–5 em respostas de satisfação (followup booking + pós-atendimento); null se não houver respostas',
144
+ nullable: true,
145
+ })
146
+ satisfactionAverage: number | null;
147
+
148
+ @ApiProperty({
149
+ description:
150
+ 'Taxa de no-show (%): appointment.no_show / appointment.created no período (0 se não houver criações)',
151
+ })
152
+ noShowRatePercent: number;
153
+
154
+ @ApiProperty({ type: AnalyticsDashboardFinancialDto })
155
+ financialSummary: AnalyticsDashboardFinancialDto;
156
+
157
+ @ApiProperty({ type: [AnalyticsDashboardTopProcedureDto], maxItems: 5 })
158
+ topProcedures: AnalyticsDashboardTopProcedureDto[];
159
+
160
+ @ApiProperty({ description: 'Total de eventos de analytics no período (legado)' })
161
+ total: number;
162
+
163
+ @ApiProperty({
164
+ description: 'Contagens por eventType (legado)',
165
+ })
166
+ byEventType: Array<{ eventType: string; count: number }>;
167
+
168
+ @ApiProperty({
169
+ description: 'Contagens por domínio (prefixo antes do ponto no eventType) (legado)',
170
+ })
171
+ byDomain: Array<{ domain: string; count: number }>;
172
+ }
@@ -16,6 +16,8 @@ export const EVENT_ANALYTIC_TYPES = [
16
16
  'appointment.rescheduled',
17
17
  'appointment.no_show',
18
18
  'appointment.finished',
19
+ /** Procedimento do agendamento marcado como concluído (add/update com finished). */
20
+ 'appointment.procedure_finished',
19
21
 
20
22
  // ── Check-in / Check-out events ─────────────────────────────────
21
23
  'checkin.effectued',