tychat-contracts 1.0.80 → 1.0.82

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 (61) hide show
  1. package/dist/analytics/event-analytic.enum.d.ts +1 -1
  2. package/dist/analytics/event-analytic.enum.d.ts.map +1 -1
  3. package/dist/analytics/event-analytic.enum.js +8 -0
  4. package/dist/appointments/available-slots-query.dto.d.ts +2 -0
  5. package/dist/appointments/available-slots-query.dto.d.ts.map +1 -1
  6. package/dist/appointments/available-slots-query.dto.js +20 -0
  7. package/dist/appointments/available-slots-response.dto.d.ts +18 -7
  8. package/dist/appointments/available-slots-response.dto.d.ts.map +1 -1
  9. package/dist/appointments/available-slots-response.dto.js +76 -27
  10. package/dist/billing/billing-response.dto.d.ts +2 -3
  11. package/dist/billing/billing-response.dto.d.ts.map +1 -1
  12. package/dist/billing/billing-response.dto.js +6 -16
  13. package/dist/billing/create-billing.dto.d.ts +1 -6
  14. package/dist/billing/create-billing.dto.d.ts.map +1 -1
  15. package/dist/billing/create-billing.dto.js +8 -28
  16. package/dist/billing/list-billings-query.dto.d.ts +2 -3
  17. package/dist/billing/list-billings-query.dto.d.ts.map +1 -1
  18. package/dist/billing/list-billings-query.dto.js +5 -17
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -0
  22. package/dist/payment-gateway/create-gateway-payment.dto.d.ts +25 -0
  23. package/dist/payment-gateway/create-gateway-payment.dto.d.ts.map +1 -0
  24. package/dist/payment-gateway/create-gateway-payment.dto.js +147 -0
  25. package/dist/payment-gateway/gateway-payment-response.dto.d.ts +24 -0
  26. package/dist/payment-gateway/gateway-payment-response.dto.d.ts.map +1 -0
  27. package/dist/payment-gateway/gateway-payment-response.dto.js +105 -0
  28. package/dist/payment-gateway/index.d.ts +8 -0
  29. package/dist/payment-gateway/index.d.ts.map +1 -0
  30. package/dist/payment-gateway/index.js +23 -0
  31. package/dist/payment-gateway/list-gateway-payments-query.dto.d.ts +14 -0
  32. package/dist/payment-gateway/list-gateway-payments-query.dto.d.ts.map +1 -0
  33. package/dist/payment-gateway/list-gateway-payments-query.dto.js +73 -0
  34. package/dist/payment-gateway/payment-gateway-kafka-topics.d.ts +19 -0
  35. package/dist/payment-gateway/payment-gateway-kafka-topics.d.ts.map +1 -0
  36. package/dist/payment-gateway/payment-gateway-kafka-topics.js +21 -0
  37. package/dist/payment-gateway/payment-gateway.enums.d.ts +16 -0
  38. package/dist/payment-gateway/payment-gateway.enums.d.ts.map +1 -0
  39. package/dist/payment-gateway/payment-gateway.enums.js +32 -0
  40. package/dist/payment-gateway/update-gateway-payment.dto.d.ts +9 -0
  41. package/dist/payment-gateway/update-gateway-payment.dto.d.ts.map +1 -0
  42. package/dist/payment-gateway/update-gateway-payment.dto.js +11 -0
  43. package/dist/payment-gateway/webhook-payload.dto.d.ts +12 -0
  44. package/dist/payment-gateway/webhook-payload.dto.d.ts.map +1 -0
  45. package/dist/payment-gateway/webhook-payload.dto.js +55 -0
  46. package/package.json +1 -1
  47. package/src/analytics/event-analytic.enum.ts +9 -0
  48. package/src/appointments/available-slots-query.dto.ts +19 -0
  49. package/src/appointments/available-slots-response.dto.ts +63 -20
  50. package/src/billing/billing-response.dto.ts +4 -16
  51. package/src/billing/create-billing.dto.ts +6 -28
  52. package/src/billing/list-billings-query.dto.ts +4 -18
  53. package/src/index.ts +1 -0
  54. package/src/payment-gateway/create-gateway-payment.dto.ts +122 -0
  55. package/src/payment-gateway/gateway-payment-response.dto.ts +65 -0
  56. package/src/payment-gateway/index.ts +7 -0
  57. package/src/payment-gateway/list-gateway-payments-query.dto.ts +53 -0
  58. package/src/payment-gateway/payment-gateway-kafka-topics.ts +25 -0
  59. package/src/payment-gateway/payment-gateway.enums.ts +34 -0
  60. package/src/payment-gateway/update-gateway-payment.dto.ts +7 -0
  61. package/src/payment-gateway/webhook-payload.dto.ts +32 -0
@@ -4,6 +4,7 @@ import {
4
4
  IsArray,
5
5
  IsOptional,
6
6
  IsUUID,
7
+ Matches,
7
8
  } from 'class-validator';
8
9
 
9
10
  export class AvailableSlotsQueryDto {
@@ -28,5 +29,23 @@ export class AvailableSlotsQueryDto {
28
29
  @IsOptional()
29
30
  @IsUUID('4')
30
31
  userId?: string;
32
+
33
+ @ApiPropertyOptional({
34
+ description:
35
+ 'Início do intervalo (YYYY-MM-DD). Com `endDate`, delimita o período. Se ambos forem omitidos, usa só o mês civil atual.',
36
+ example: '2026-03-01',
37
+ })
38
+ @IsOptional()
39
+ @Matches(/^\d{4}-\d{2}-\d{2}$/)
40
+ startDate?: string;
41
+
42
+ @ApiPropertyOptional({
43
+ description:
44
+ 'Fim do intervalo (YYYY-MM-DD), inclusivo. Se omitido com `startDate`, usa o fim do mês de `startDate`.',
45
+ example: '2026-03-31',
46
+ })
47
+ @IsOptional()
48
+ @Matches(/^\d{4}-\d{2}-\d{2}$/)
49
+ endDate?: string;
31
50
  }
32
51
 
@@ -1,35 +1,40 @@
1
1
  import { ApiProperty } from '@nestjs/swagger';
2
2
  import {
3
3
  IsArray,
4
+ IsInt,
4
5
  IsNotEmpty,
5
6
  IsString,
6
7
  Matches,
8
+ Min,
9
+ Max,
10
+ ValidateNested,
7
11
  } from 'class-validator';
12
+ import { Type } from 'class-transformer';
8
13
 
9
- export class AvailableDaySlotsDto {
14
+ /** Dia do mês com lista de horários (formato HH:mm). */
15
+ export class AvailableSlotsDayHoursDto {
10
16
  @ApiProperty({
11
- description: 'Data do dia disponível para agendamentos (formato YYYY-MM-DD)',
12
- example: '2026-03-10',
17
+ description: 'Dia do mês (1–31)',
18
+ example: 15,
13
19
  })
14
- @IsString()
15
- @IsNotEmpty()
16
- @Matches(/^\d{4}-\d{2}-\d{2}$/)
17
- date: string;
20
+ @IsInt()
21
+ @Min(1)
22
+ @Max(31)
23
+ day: number;
18
24
 
19
25
  @ApiProperty({
20
- description:
21
- 'Lista de horários disponíveis para agendamento no dia (formato HH:mm)',
26
+ description: 'Horários disponíveis neste dia',
22
27
  example: ['08:00', '08:30', '09:00'],
23
28
  })
24
29
  @IsArray()
25
30
  @IsString({ each: true })
26
31
  @Matches(/^\d{2}:\d{2}$/, { each: true })
27
- slots: string[];
32
+ hours: string[];
28
33
  }
29
34
 
30
- export class AvailableMonthSlotsDto {
35
+ export class AvailableSlotsProcedureMonthDto {
31
36
  @ApiProperty({
32
- description: 'Mês de referência (formato YYYY-MM)',
37
+ description: 'Mês (YYYY-MM)',
33
38
  example: '2026-03',
34
39
  })
35
40
  @IsString()
@@ -38,20 +43,58 @@ export class AvailableMonthSlotsDto {
38
43
  month: string;
39
44
 
40
45
  @ApiProperty({
41
- description: 'Dias e horários disponíveis dentro do mês',
42
- type: [AvailableDaySlotsDto],
46
+ description: 'Dias do mês com horários',
47
+ type: [AvailableSlotsDayHoursDto],
48
+ })
49
+ @IsArray()
50
+ @ValidateNested({ each: true })
51
+ @Type(() => AvailableSlotsDayHoursDto)
52
+ days: AvailableSlotsDayHoursDto[];
53
+ }
54
+
55
+ export class AvailableSlotsProcedureItemDto {
56
+ @ApiProperty({
57
+ description: 'Nome do procedimento',
58
+ example: 'Consulta de rotina',
59
+ })
60
+ @IsString()
61
+ @IsNotEmpty()
62
+ name: string;
63
+
64
+ @ApiProperty({
65
+ description: 'Disponibilidade por mês',
66
+ type: [AvailableSlotsProcedureMonthDto],
43
67
  })
44
68
  @IsArray()
45
- days: AvailableDaySlotsDto[];
69
+ @ValidateNested({ each: true })
70
+ @Type(() => AvailableSlotsProcedureMonthDto)
71
+ slots: AvailableSlotsProcedureMonthDto[];
46
72
  }
47
73
 
48
- export class AvailableSlotsResponseDto {
74
+ export class AvailableSlotsProfessionalNameDto {
75
+ @ApiProperty({
76
+ description: 'Nome do profissional (vazio ou “Clínica” quando não filtrado por profissional)',
77
+ example: 'Dr. João Silva',
78
+ })
79
+ @IsString()
80
+ name: string;
81
+ }
82
+
83
+ export class AvailableSlotsProfessionalItemDto {
84
+ @ApiProperty({ type: AvailableSlotsProfessionalNameDto })
85
+ @ValidateNested()
86
+ @Type(() => AvailableSlotsProfessionalNameDto)
87
+ professional: AvailableSlotsProfessionalNameDto;
88
+
49
89
  @ApiProperty({
50
- description:
51
- 'Meses, dias e horários disponíveis para agendamentos nos próximos três meses',
52
- type: [AvailableMonthSlotsDto],
90
+ description: 'Um item por procedimento solicitado',
91
+ type: [AvailableSlotsProcedureItemDto],
53
92
  })
54
93
  @IsArray()
55
- months: AvailableMonthSlotsDto[];
94
+ @ValidateNested({ each: true })
95
+ @Type(() => AvailableSlotsProcedureItemDto)
96
+ procedures: AvailableSlotsProcedureItemDto[];
56
97
  }
57
98
 
99
+ /** Resposta de GET available-slots: array com um elemento (profissional + procedimentos). */
100
+ export type AvailableSlotsGroupedResponseDto = AvailableSlotsProfessionalItemDto[];
@@ -1,10 +1,6 @@
1
1
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
2
  import {
3
- BILLING_GATEWAYS,
4
- BILLING_METHODS,
5
3
  BILLING_STATUSES,
6
- BillingGatewayDto,
7
- BillingMethodDto,
8
4
  BillingStatusDto,
9
5
  } from './create-billing.dto';
10
6
 
@@ -34,19 +30,11 @@ export class BillingResponseDto {
34
30
  })
35
31
  status: BillingStatusDto;
36
32
 
37
- @ApiProperty({
38
- description: 'Payment method',
39
- enum: BILLING_METHODS,
40
- example: 'PIX',
41
- })
42
- method: BillingMethodDto;
43
-
44
- @ApiProperty({
45
- description: 'Payment gateway',
46
- enum: BILLING_GATEWAYS,
47
- example: 'ASAAS',
33
+ @ApiPropertyOptional({
34
+ description: 'Payment ID from payment-gateway service (UUID)',
35
+ example: '550e8400-e29b-41d4-a716-446655440002',
48
36
  })
49
- gateway: BillingGatewayDto;
37
+ paymentId?: string | null;
50
38
 
51
39
  @ApiProperty({
52
40
  description: 'Due date (ISO 8601)',
@@ -18,18 +18,6 @@ export const BILLING_STATUSES = [
18
18
  ] as const;
19
19
  export type BillingStatusDto = (typeof BILLING_STATUSES)[number];
20
20
 
21
- export const BILLING_METHODS = [
22
- 'PIX',
23
- 'CREDIT_CARD',
24
- 'DEBIT_CARD',
25
- 'VOUCHER',
26
- 'CASH',
27
- ] as const;
28
- export type BillingMethodDto = (typeof BILLING_METHODS)[number];
29
-
30
- export const BILLING_GATEWAYS = ['ASAAS', 'MERCADO_PAGO', 'STRIPE'] as const;
31
- export type BillingGatewayDto = (typeof BILLING_GATEWAYS)[number];
32
-
33
21
  export class CreateBillingDto {
34
22
  @ApiProperty({
35
23
  description: 'Tenant ID (UUID)',
@@ -57,23 +45,13 @@ export class CreateBillingDto {
57
45
  @IsEnum(BILLING_STATUSES)
58
46
  status?: BillingStatusDto;
59
47
 
60
- @ApiProperty({
61
- description: 'Payment method',
62
- enum: BILLING_METHODS,
63
- example: 'PIX',
64
- })
65
- @IsEnum(BILLING_METHODS)
66
- @IsNotEmpty()
67
- method: BillingMethodDto;
68
-
69
- @ApiProperty({
70
- description: 'Payment gateway',
71
- enum: BILLING_GATEWAYS,
72
- example: 'ASAAS',
48
+ @ApiPropertyOptional({
49
+ description: 'Payment ID from payment-gateway service (UUID)',
50
+ example: '550e8400-e29b-41d4-a716-446655440002',
73
51
  })
74
- @IsEnum(BILLING_GATEWAYS)
75
- @IsNotEmpty()
76
- gateway: BillingGatewayDto;
52
+ @IsOptional()
53
+ @IsUUID('4')
54
+ paymentId?: string;
77
55
 
78
56
  @ApiProperty({
79
57
  description: 'Due date (ISO 8601)',
@@ -1,11 +1,7 @@
1
1
  import { ApiPropertyOptional } from '@nestjs/swagger';
2
2
  import { IsEnum, IsInt, IsOptional, IsUUID, Max, Min } from 'class-validator';
3
3
  import {
4
- BILLING_GATEWAYS,
5
- BILLING_METHODS,
6
4
  BILLING_STATUSES,
7
- BillingGatewayDto,
8
- BillingMethodDto,
9
5
  BillingStatusDto,
10
6
  } from './create-billing.dto';
11
7
 
@@ -28,22 +24,12 @@ export class ListBillingsQueryDto {
28
24
  status?: BillingStatusDto;
29
25
 
30
26
  @ApiPropertyOptional({
31
- description: 'Billing method filter',
32
- enum: BILLING_METHODS,
33
- example: 'PIX',
27
+ description: 'Payment ID filter (UUID)',
28
+ example: '550e8400-e29b-41d4-a716-446655440002',
34
29
  })
35
30
  @IsOptional()
36
- @IsEnum(BILLING_METHODS)
37
- method?: BillingMethodDto;
38
-
39
- @ApiPropertyOptional({
40
- description: 'Billing gateway filter',
41
- enum: BILLING_GATEWAYS,
42
- example: 'ASAAS',
43
- })
44
- @IsOptional()
45
- @IsEnum(BILLING_GATEWAYS)
46
- gateway?: BillingGatewayDto;
31
+ @IsUUID('4')
32
+ paymentId?: string;
47
33
 
48
34
  @ApiPropertyOptional({
49
35
  description: 'Page number (starting at 1)',
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export * from './specialties';
8
8
  export * from './professionals';
9
9
  export * from './payments';
10
10
  export * from './billing';
11
+ export * from './payment-gateway';
11
12
  export * from './ai';
12
13
  export * from './storage';
13
14
  export * from './notifications';
@@ -0,0 +1,122 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import {
3
+ IsDateString,
4
+ IsEnum,
5
+ IsNotEmpty,
6
+ IsNumber,
7
+ IsOptional,
8
+ IsString,
9
+ IsUUID,
10
+ Min,
11
+ ValidateNested,
12
+ } from 'class-validator';
13
+ import { Type } from 'class-transformer';
14
+ import {
15
+ PAYMENT_GATEWAYS,
16
+ PaymentGatewayDto,
17
+ GATEWAY_PAYMENT_METHODS,
18
+ GatewayPaymentMethodDto,
19
+ } from './payment-gateway.enums';
20
+
21
+ /**
22
+ * Optional customer data for gateway registration.
23
+ */
24
+ export class GatewayCustomerDto {
25
+ @ApiProperty({ description: 'Customer name', example: 'John Doe' })
26
+ @IsString()
27
+ @IsNotEmpty()
28
+ name: string;
29
+
30
+ @ApiProperty({ description: 'Customer email', example: 'john@example.com' })
31
+ @IsString()
32
+ @IsNotEmpty()
33
+ email: string;
34
+
35
+ @ApiPropertyOptional({ description: 'Customer CPF/CNPJ', example: '12345678900' })
36
+ @IsOptional()
37
+ @IsString()
38
+ cpfCnpj?: string;
39
+
40
+ @ApiPropertyOptional({ description: 'Customer phone', example: '+5511999999999' })
41
+ @IsOptional()
42
+ @IsString()
43
+ phone?: string;
44
+ }
45
+
46
+ /**
47
+ * DTO for creating a payment through the payment gateway service.
48
+ */
49
+ export class CreateGatewayPaymentDto {
50
+ @ApiProperty({
51
+ description: 'Tenant ID (UUID)',
52
+ example: '550e8400-e29b-41d4-a716-446655440000',
53
+ })
54
+ @IsUUID('4')
55
+ @IsNotEmpty()
56
+ tenantId: string;
57
+
58
+ @ApiProperty({
59
+ description: 'Billing ID from billing service (UUID)',
60
+ example: '550e8400-e29b-41d4-a716-446655440001',
61
+ })
62
+ @IsUUID('4')
63
+ @IsNotEmpty()
64
+ billingId: string;
65
+
66
+ @ApiProperty({
67
+ description: 'Payment amount',
68
+ example: 99.90,
69
+ minimum: 0.01,
70
+ })
71
+ @IsNumber()
72
+ @Min(0.01)
73
+ amount: number;
74
+
75
+ @ApiProperty({
76
+ description: 'Payment gateway to use',
77
+ enum: PAYMENT_GATEWAYS,
78
+ example: 'ASAAS',
79
+ })
80
+ @IsEnum(PAYMENT_GATEWAYS)
81
+ @IsNotEmpty()
82
+ gateway: PaymentGatewayDto;
83
+
84
+ @ApiProperty({
85
+ description: 'Payment method',
86
+ enum: GATEWAY_PAYMENT_METHODS,
87
+ example: 'PIX',
88
+ })
89
+ @IsEnum(GATEWAY_PAYMENT_METHODS)
90
+ @IsNotEmpty()
91
+ method: GatewayPaymentMethodDto;
92
+
93
+ @ApiProperty({
94
+ description: 'Due date (ISO 8601)',
95
+ example: '2026-04-15T00:00:00.000Z',
96
+ })
97
+ @IsDateString()
98
+ dueDate: string;
99
+
100
+ @ApiPropertyOptional({
101
+ description: 'Description of the payment',
102
+ example: 'Monthly subscription - April 2026',
103
+ })
104
+ @IsOptional()
105
+ @IsString()
106
+ description?: string;
107
+
108
+ @ApiPropertyOptional({
109
+ description: 'Customer data for gateway registration',
110
+ })
111
+ @IsOptional()
112
+ @ValidateNested()
113
+ @Type(() => GatewayCustomerDto)
114
+ customer?: GatewayCustomerDto;
115
+
116
+ @ApiPropertyOptional({
117
+ description: 'Additional metadata as JSON',
118
+ example: { invoiceNumber: 'INV-001' },
119
+ })
120
+ @IsOptional()
121
+ metadata?: Record<string, unknown>;
122
+ }
@@ -0,0 +1,65 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import {
3
+ PAYMENT_GATEWAYS,
4
+ PaymentGatewayDto,
5
+ GATEWAY_PAYMENT_METHODS,
6
+ GatewayPaymentMethodDto,
7
+ GATEWAY_PAYMENT_STATUSES,
8
+ GatewayPaymentStatusDto,
9
+ } from './payment-gateway.enums';
10
+
11
+ /**
12
+ * Response DTO for a gateway payment record.
13
+ */
14
+ export class GatewayPaymentResponseDto {
15
+ @ApiProperty({ description: 'Payment ID (UUID)', example: '550e8400-e29b-41d4-a716-446655440111' })
16
+ id: string;
17
+
18
+ @ApiProperty({ description: 'Tenant ID (UUID)', example: '550e8400-e29b-41d4-a716-446655440000' })
19
+ tenantId: string;
20
+
21
+ @ApiProperty({ description: 'Billing ID (UUID)', example: '550e8400-e29b-41d4-a716-446655440001' })
22
+ billingId: string;
23
+
24
+ @ApiProperty({ description: 'Payment amount', example: 99.90 })
25
+ amount: number;
26
+
27
+ @ApiProperty({ description: 'Payment gateway', enum: PAYMENT_GATEWAYS, example: 'ASAAS' })
28
+ gateway: PaymentGatewayDto;
29
+
30
+ @ApiProperty({ description: 'Payment method', enum: GATEWAY_PAYMENT_METHODS, example: 'PIX' })
31
+ method: GatewayPaymentMethodDto;
32
+
33
+ @ApiProperty({ description: 'Payment status', enum: GATEWAY_PAYMENT_STATUSES, example: 'PENDING' })
34
+ status: GatewayPaymentStatusDto;
35
+
36
+ @ApiPropertyOptional({ description: 'External ID from the gateway', example: 'pay_abc123' })
37
+ externalId?: string | null;
38
+
39
+ @ApiPropertyOptional({ description: 'Error message if payment failed', example: null })
40
+ errorMessage?: string | null;
41
+
42
+ @ApiPropertyOptional({ description: 'Additional metadata', example: {} })
43
+ metadata?: Record<string, unknown> | null;
44
+
45
+ @ApiProperty({ description: 'Due date (ISO 8601)', example: '2026-04-15T00:00:00.000Z' })
46
+ dueDate: string;
47
+
48
+ @ApiPropertyOptional({ description: 'Date when payment was confirmed (ISO 8601)', example: null })
49
+ paidAt?: string | null;
50
+
51
+ @ApiPropertyOptional({ description: 'Payment expiration date (ISO 8601)', example: null })
52
+ expiresAt?: string | null;
53
+
54
+ @ApiPropertyOptional({ description: 'Refund amount if partially/fully refunded', example: null })
55
+ refundAmount?: number | null;
56
+
57
+ @ApiProperty({ description: 'Creation timestamp (ISO 8601)', example: '2026-03-14T12:00:00.000Z' })
58
+ createdAt: string;
59
+
60
+ @ApiProperty({ description: 'Last update timestamp (ISO 8601)', example: '2026-03-14T12:00:00.000Z' })
61
+ updatedAt: string;
62
+
63
+ @ApiPropertyOptional({ description: 'Soft deletion timestamp (ISO 8601)', example: null })
64
+ deletedAt?: string | null;
65
+ }
@@ -0,0 +1,7 @@
1
+ export * from './payment-gateway.enums';
2
+ export * from './create-gateway-payment.dto';
3
+ export * from './update-gateway-payment.dto';
4
+ export * from './gateway-payment-response.dto';
5
+ export * from './list-gateway-payments-query.dto';
6
+ export * from './payment-gateway-kafka-topics';
7
+ export * from './webhook-payload.dto';
@@ -0,0 +1,53 @@
1
+ import { ApiPropertyOptional } from '@nestjs/swagger';
2
+ import { IsEnum, IsInt, IsOptional, IsUUID, Max, Min } from 'class-validator';
3
+ import {
4
+ PAYMENT_GATEWAYS,
5
+ PaymentGatewayDto,
6
+ GATEWAY_PAYMENT_METHODS,
7
+ GatewayPaymentMethodDto,
8
+ GATEWAY_PAYMENT_STATUSES,
9
+ GatewayPaymentStatusDto,
10
+ } from './payment-gateway.enums';
11
+
12
+ /**
13
+ * Query DTO for listing gateway payments with optional filters and pagination.
14
+ */
15
+ export class ListGatewayPaymentsQueryDto {
16
+ @ApiPropertyOptional({ description: 'Tenant ID filter (UUID)', example: '550e8400-e29b-41d4-a716-446655440000' })
17
+ @IsOptional()
18
+ @IsUUID('4')
19
+ tenantId?: string;
20
+
21
+ @ApiPropertyOptional({ description: 'Billing ID filter (UUID)' })
22
+ @IsOptional()
23
+ @IsUUID('4')
24
+ billingId?: string;
25
+
26
+ @ApiPropertyOptional({ description: 'Gateway filter', enum: PAYMENT_GATEWAYS })
27
+ @IsOptional()
28
+ @IsEnum(PAYMENT_GATEWAYS)
29
+ gateway?: PaymentGatewayDto;
30
+
31
+ @ApiPropertyOptional({ description: 'Method filter', enum: GATEWAY_PAYMENT_METHODS })
32
+ @IsOptional()
33
+ @IsEnum(GATEWAY_PAYMENT_METHODS)
34
+ method?: GatewayPaymentMethodDto;
35
+
36
+ @ApiPropertyOptional({ description: 'Status filter', enum: GATEWAY_PAYMENT_STATUSES })
37
+ @IsOptional()
38
+ @IsEnum(GATEWAY_PAYMENT_STATUSES)
39
+ status?: GatewayPaymentStatusDto;
40
+
41
+ @ApiPropertyOptional({ description: 'Page number (starting at 1)', example: 1, minimum: 1, default: 1 })
42
+ @IsOptional()
43
+ @IsInt()
44
+ @Min(1)
45
+ page?: number;
46
+
47
+ @ApiPropertyOptional({ description: 'Records per page', example: 20, minimum: 1, maximum: 100, default: 20 })
48
+ @IsOptional()
49
+ @IsInt()
50
+ @Min(1)
51
+ @Max(100)
52
+ limit?: number;
53
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Kafka topic names used by the payment-gateway service.
3
+ * Topics follow the pattern: payment.{action}
4
+ */
5
+
6
+ /** Topic for creating a new payment through a gateway. */
7
+ export const TOPIC_PAYMENT_CREATE = 'payment.create';
8
+
9
+ /** Topic for canceling an existing payment. */
10
+ export const TOPIC_PAYMENT_CANCEL = 'payment.cancel';
11
+
12
+ /** Topic for requesting a refund. */
13
+ export const TOPIC_PAYMENT_REFUND = 'payment.refund';
14
+
15
+ /** Topic for querying payment status. */
16
+ export const TOPIC_PAYMENT_STATUS = 'payment.status';
17
+
18
+ /** Topic for listing payments (RPC). */
19
+ export const TOPIC_PAYMENT_FIND_ALL = 'payment.findAll';
20
+
21
+ /** Topic for finding a single payment (RPC). */
22
+ export const TOPIC_PAYMENT_FIND_ONE = 'payment.findOne';
23
+
24
+ /** Topic for payment webhook events (internal broadcast). */
25
+ export const TOPIC_PAYMENT_WEBHOOK = 'payment.webhook';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Supported payment gateways.
3
+ */
4
+ export const PAYMENT_GATEWAYS = ['ASAAS', 'MERCADO_PAGO', 'STRIPE'] as const;
5
+ export type PaymentGatewayDto = (typeof PAYMENT_GATEWAYS)[number];
6
+
7
+ /**
8
+ * Payment methods supported across gateways.
9
+ */
10
+ export const GATEWAY_PAYMENT_METHODS = [
11
+ 'PIX',
12
+ 'CREDIT_CARD',
13
+ 'DEBIT_CARD',
14
+ 'BOLETO',
15
+ 'VOUCHER',
16
+ 'CASH',
17
+ ] as const;
18
+ export type GatewayPaymentMethodDto = (typeof GATEWAY_PAYMENT_METHODS)[number];
19
+
20
+ /**
21
+ * Payment statuses tracked by the payment gateway.
22
+ */
23
+ export const GATEWAY_PAYMENT_STATUSES = [
24
+ 'PENDING',
25
+ 'PROCESSING',
26
+ 'CONFIRMED',
27
+ 'PAYED',
28
+ 'REFUNDED',
29
+ 'CANCELED',
30
+ 'FAILED',
31
+ 'OVERDUE',
32
+ 'EXPIRED',
33
+ ] as const;
34
+ export type GatewayPaymentStatusDto = (typeof GATEWAY_PAYMENT_STATUSES)[number];
@@ -0,0 +1,7 @@
1
+ import { PartialType } from '@nestjs/swagger';
2
+ import { CreateGatewayPaymentDto } from './create-gateway-payment.dto';
3
+
4
+ /**
5
+ * DTO for updating an existing gateway payment (all fields optional).
6
+ */
7
+ export class UpdateGatewayPaymentDto extends PartialType(CreateGatewayPaymentDto) {}
@@ -0,0 +1,32 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
3
+ import { PAYMENT_GATEWAYS, PaymentGatewayDto, GATEWAY_PAYMENT_STATUSES, GatewayPaymentStatusDto } from './payment-gateway.enums';
4
+
5
+ /**
6
+ * Normalized webhook event payload received from any payment gateway.
7
+ */
8
+ export class GatewayWebhookEventDto {
9
+ @ApiProperty({ description: 'Payment gateway that originated the event', enum: PAYMENT_GATEWAYS })
10
+ @IsEnum(PAYMENT_GATEWAYS)
11
+ @IsNotEmpty()
12
+ gateway: PaymentGatewayDto;
13
+
14
+ @ApiProperty({ description: 'Event type from the gateway', example: 'PAYMENT_RECEIVED' })
15
+ @IsString()
16
+ @IsNotEmpty()
17
+ eventType: string;
18
+
19
+ @ApiProperty({ description: 'External payment ID from the gateway', example: 'pay_abc123' })
20
+ @IsString()
21
+ @IsNotEmpty()
22
+ externalId: string;
23
+
24
+ @ApiPropertyOptional({ description: 'New payment status after the event', enum: GATEWAY_PAYMENT_STATUSES })
25
+ @IsOptional()
26
+ @IsEnum(GATEWAY_PAYMENT_STATUSES)
27
+ status?: GatewayPaymentStatusDto;
28
+
29
+ @ApiPropertyOptional({ description: 'Raw payload from the gateway for auditing' })
30
+ @IsOptional()
31
+ rawPayload?: Record<string, unknown>;
32
+ }