tychat-contracts 1.0.85 → 1.0.87

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 (69) hide show
  1. package/dist/billing/list-billings-query.dto.d.ts +3 -0
  2. package/dist/billing/list-billings-query.dto.d.ts.map +1 -1
  3. package/dist/billing/list-billings-query.dto.js +21 -0
  4. package/dist/cashback/cashback-balance-response.dto.d.ts +15 -0
  5. package/dist/cashback/cashback-balance-response.dto.d.ts.map +1 -0
  6. package/dist/cashback/cashback-balance-response.dto.js +64 -0
  7. package/dist/cashback/cashback-config-response.dto.d.ts +19 -0
  8. package/dist/cashback/cashback-config-response.dto.d.ts.map +1 -0
  9. package/dist/cashback/cashback-config-response.dto.js +80 -0
  10. package/dist/cashback/cashback-enums.d.ts +32 -0
  11. package/dist/cashback/cashback-enums.d.ts.map +1 -0
  12. package/dist/cashback/cashback-enums.js +37 -0
  13. package/dist/cashback/cashback-kafka-payloads.d.ts +83 -0
  14. package/dist/cashback/cashback-kafka-payloads.d.ts.map +1 -0
  15. package/dist/cashback/cashback-kafka-payloads.js +2 -0
  16. package/dist/cashback/cashback-kafka-topics.d.ts +18 -0
  17. package/dist/cashback/cashback-kafka-topics.d.ts.map +1 -0
  18. package/dist/cashback/cashback-kafka-topics.js +23 -0
  19. package/dist/cashback/index.d.ts +8 -0
  20. package/dist/cashback/index.d.ts.map +1 -0
  21. package/dist/cashback/index.js +23 -0
  22. package/dist/cashback/referral-code-response.dto.d.ts +21 -0
  23. package/dist/cashback/referral-code-response.dto.d.ts.map +1 -0
  24. package/dist/cashback/referral-code-response.dto.js +90 -0
  25. package/dist/cashback/use-referral-code-response.dto.d.ts +9 -0
  26. package/dist/cashback/use-referral-code-response.dto.d.ts.map +1 -0
  27. package/dist/cashback/use-referral-code-response.dto.js +34 -0
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +1 -0
  31. package/dist/payment-gateway/create-gateway-payment.dto.d.ts +1 -1
  32. package/dist/payment-gateway/create-gateway-payment.dto.d.ts.map +1 -1
  33. package/dist/payment-gateway/create-gateway-payment.dto.js +3 -3
  34. package/dist/payment-gateway/index.d.ts +5 -0
  35. package/dist/payment-gateway/index.d.ts.map +1 -1
  36. package/dist/payment-gateway/index.js +5 -0
  37. package/dist/payment-gateway/initiate-billing-payment-response.dto.d.ts +13 -0
  38. package/dist/payment-gateway/initiate-billing-payment-response.dto.d.ts.map +1 -0
  39. package/dist/payment-gateway/initiate-billing-payment-response.dto.js +48 -0
  40. package/dist/payment-gateway/initiate-billing-payment.mapper.d.ts +7 -0
  41. package/dist/payment-gateway/initiate-billing-payment.mapper.d.ts.map +1 -0
  42. package/dist/payment-gateway/initiate-billing-payment.mapper.js +17 -0
  43. package/dist/payment-gateway/payment-gateway-routing-matrix.d.ts +3 -0
  44. package/dist/payment-gateway/payment-gateway-routing-matrix.d.ts.map +1 -0
  45. package/dist/payment-gateway/payment-gateway-routing-matrix.js +15 -0
  46. package/dist/payment-gateway/payment-gateway-routing.dto.d.ts +14 -0
  47. package/dist/payment-gateway/payment-gateway-routing.dto.d.ts.map +1 -0
  48. package/dist/payment-gateway/payment-gateway-routing.dto.js +89 -0
  49. package/dist/payment-gateway/platform-configuration.topics.d.ts +3 -0
  50. package/dist/payment-gateway/platform-configuration.topics.d.ts.map +1 -0
  51. package/dist/payment-gateway/platform-configuration.topics.js +5 -0
  52. package/package.json +1 -1
  53. package/src/billing/list-billings-query.dto.ts +22 -0
  54. package/src/cashback/cashback-balance-response.dto.ts +33 -0
  55. package/src/cashback/cashback-config-response.dto.ts +43 -0
  56. package/src/cashback/cashback-enums.ts +33 -0
  57. package/src/cashback/cashback-kafka-payloads.ts +102 -0
  58. package/src/cashback/cashback-kafka-topics.ts +23 -0
  59. package/src/cashback/index.ts +7 -0
  60. package/src/cashback/referral-code-response.dto.ts +49 -0
  61. package/src/cashback/use-referral-code-response.dto.ts +15 -0
  62. package/src/index.ts +1 -0
  63. package/src/payment-gateway/create-gateway-payment.dto.ts +5 -4
  64. package/src/payment-gateway/index.ts +5 -0
  65. package/src/payment-gateway/initiate-billing-payment-response.dto.ts +25 -0
  66. package/src/payment-gateway/initiate-billing-payment.mapper.ts +19 -0
  67. package/src/payment-gateway/payment-gateway-routing-matrix.ts +18 -0
  68. package/src/payment-gateway/payment-gateway-routing.dto.ts +84 -0
  69. package/src/payment-gateway/platform-configuration.topics.ts +2 -0
@@ -0,0 +1,34 @@
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.UseReferralCodeResponseDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ /**
15
+ * Response DTO for using a referral code
16
+ */
17
+ class UseReferralCodeResponseDto {
18
+ cashbackAmount;
19
+ discountAmount;
20
+ referrerPatientId;
21
+ }
22
+ exports.UseReferralCodeResponseDto = UseReferralCodeResponseDto;
23
+ __decorate([
24
+ (0, swagger_1.ApiProperty)({ description: 'Cashback amount awarded to the referrer' }),
25
+ __metadata("design:type", Number)
26
+ ], UseReferralCodeResponseDto.prototype, "cashbackAmount", void 0);
27
+ __decorate([
28
+ (0, swagger_1.ApiProperty)({ description: 'Discount amount applied to the referred patient' }),
29
+ __metadata("design:type", Number)
30
+ ], UseReferralCodeResponseDto.prototype, "discountAmount", void 0);
31
+ __decorate([
32
+ (0, swagger_1.ApiProperty)({ description: 'Patient ID of the referrer (code owner)' }),
33
+ __metadata("design:type", String)
34
+ ], UseReferralCodeResponseDto.prototype, "referrerPatientId", void 0);
package/dist/index.d.ts CHANGED
@@ -16,4 +16,5 @@ export * from './tenants';
16
16
  export * from './conversations';
17
17
  export * from './connections';
18
18
  export * from './analytics';
19
+ export * from './cashback';
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -32,3 +32,4 @@ __exportStar(require("./tenants"), exports);
32
32
  __exportStar(require("./conversations"), exports);
33
33
  __exportStar(require("./connections"), exports);
34
34
  __exportStar(require("./analytics"), exports);
35
+ __exportStar(require("./cashback"), exports);
@@ -15,7 +15,7 @@ export declare class CreateGatewayPaymentDto {
15
15
  tenantId: string;
16
16
  billingId: string;
17
17
  amount: number;
18
- gateway: PaymentGatewayDto;
18
+ gateway?: PaymentGatewayDto;
19
19
  method: GatewayPaymentMethodDto;
20
20
  dueDate: string;
21
21
  description?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"create-gateway-payment.dto.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/create-gateway-payment.dto.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,iBAAiB,EAEjB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,qBAAa,kBAAkB;IAI7B,IAAI,EAAE,MAAM,CAAC;IAKb,KAAK,EAAE,MAAM,CAAC;IAKd,OAAO,CAAC,EAAE,MAAM,CAAC;IAKjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAOlC,QAAQ,EAAE,MAAM,CAAC;IAQjB,SAAS,EAAE,MAAM,CAAC;IASlB,MAAM,EAAE,MAAM,CAAC;IASf,OAAO,EAAE,iBAAiB,CAAC;IAS3B,MAAM,EAAE,uBAAuB,CAAC;IAOhC,OAAO,EAAE,MAAM,CAAC;IAQhB,WAAW,CAAC,EAAE,MAAM,CAAC;IAQrB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAO9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
1
+ {"version":3,"file":"create-gateway-payment.dto.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/create-gateway-payment.dto.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,iBAAiB,EAEjB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,qBAAa,kBAAkB;IAI7B,IAAI,EAAE,MAAM,CAAC;IAKb,KAAK,EAAE,MAAM,CAAC;IAKd,OAAO,CAAC,EAAE,MAAM,CAAC;IAKjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAOlC,QAAQ,EAAE,MAAM,CAAC;IAQjB,SAAS,EAAE,MAAM,CAAC;IASlB,MAAM,EAAE,MAAM,CAAC;IAUf,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAS5B,MAAM,EAAE,uBAAuB,CAAC;IAOhC,OAAO,EAAE,MAAM,CAAC;IAQhB,WAAW,CAAC,EAAE,MAAM,CAAC;IAQrB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAO9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
@@ -92,13 +92,13 @@ __decorate([
92
92
  __metadata("design:type", Number)
93
93
  ], CreateGatewayPaymentDto.prototype, "amount", void 0);
94
94
  __decorate([
95
- (0, swagger_1.ApiProperty)({
96
- description: 'Payment gateway to use',
95
+ (0, swagger_1.ApiPropertyOptional)({
96
+ description: 'Gateway explícito. Se omitido, o payment-gateway-service resolve pela rota global (prioridade + métodos).',
97
97
  enum: payment_gateway_enums_1.PAYMENT_GATEWAYS,
98
98
  example: 'ASAAS',
99
99
  }),
100
+ (0, class_validator_1.IsOptional)(),
100
101
  (0, class_validator_1.IsEnum)(payment_gateway_enums_1.PAYMENT_GATEWAYS),
101
- (0, class_validator_1.IsNotEmpty)(),
102
102
  __metadata("design:type", String)
103
103
  ], CreateGatewayPaymentDto.prototype, "gateway", void 0);
104
104
  __decorate([
@@ -1,4 +1,9 @@
1
1
  export * from './payment-gateway.enums';
2
+ export * from './payment-gateway-routing-matrix';
3
+ export * from './payment-gateway-routing.dto';
4
+ export * from './initiate-billing-payment-response.dto';
5
+ export * from './initiate-billing-payment.mapper';
6
+ export * from './platform-configuration.topics';
2
7
  export * from './create-gateway-payment.dto';
3
8
  export * from './update-gateway-payment.dto';
4
9
  export * from './gateway-payment-response.dto';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC"}
@@ -15,6 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./payment-gateway.enums"), exports);
18
+ __exportStar(require("./payment-gateway-routing-matrix"), exports);
19
+ __exportStar(require("./payment-gateway-routing.dto"), exports);
20
+ __exportStar(require("./initiate-billing-payment-response.dto"), exports);
21
+ __exportStar(require("./initiate-billing-payment.mapper"), exports);
22
+ __exportStar(require("./platform-configuration.topics"), exports);
18
23
  __exportStar(require("./create-gateway-payment.dto"), exports);
19
24
  __exportStar(require("./update-gateway-payment.dto"), exports);
20
25
  __exportStar(require("./gateway-payment-response.dto"), exports);
@@ -0,0 +1,13 @@
1
+ import { GatewayPaymentResponseDto } from './gateway-payment-response.dto';
2
+ /**
3
+ * Resposta de iniciar pagamento de cobrança: inclui o registro do pagamento e
4
+ * campos explícitos copiados de metadata quando presentes (PIX, checkout, boleto).
5
+ */
6
+ export declare class InitiateBillingPaymentResponseDto extends GatewayPaymentResponseDto {
7
+ checkoutUrl?: string | null;
8
+ pixQrCode?: string | null;
9
+ pixCopyPaste?: string | null;
10
+ boletoUrl?: string | null;
11
+ boletoBarcode?: string | null;
12
+ }
13
+ //# sourceMappingURL=initiate-billing-payment-response.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initiate-billing-payment-response.dto.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/initiate-billing-payment-response.dto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;GAGG;AACH,qBAAa,iCAAkC,SAAQ,yBAAyB;IAI9E,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG7B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
@@ -0,0 +1,48 @@
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.InitiateBillingPaymentResponseDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const gateway_payment_response_dto_1 = require("./gateway-payment-response.dto");
15
+ /**
16
+ * Resposta de iniciar pagamento de cobrança: inclui o registro do pagamento e
17
+ * campos explícitos copiados de metadata quando presentes (PIX, checkout, boleto).
18
+ */
19
+ class InitiateBillingPaymentResponseDto extends gateway_payment_response_dto_1.GatewayPaymentResponseDto {
20
+ checkoutUrl;
21
+ pixQrCode;
22
+ pixCopyPaste;
23
+ boletoUrl;
24
+ boletoBarcode;
25
+ }
26
+ exports.InitiateBillingPaymentResponseDto = InitiateBillingPaymentResponseDto;
27
+ __decorate([
28
+ (0, swagger_1.ApiPropertyOptional)({
29
+ description: 'URL para fluxo de pagamento (cartão, checkout hospedado, etc.)',
30
+ }),
31
+ __metadata("design:type", Object)
32
+ ], InitiateBillingPaymentResponseDto.prototype, "checkoutUrl", void 0);
33
+ __decorate([
34
+ (0, swagger_1.ApiPropertyOptional)({ description: 'QR Code PIX em base64 quando aplicável' }),
35
+ __metadata("design:type", Object)
36
+ ], InitiateBillingPaymentResponseDto.prototype, "pixQrCode", void 0);
37
+ __decorate([
38
+ (0, swagger_1.ApiPropertyOptional)({ description: 'PIX copia e cola quando aplicável' }),
39
+ __metadata("design:type", Object)
40
+ ], InitiateBillingPaymentResponseDto.prototype, "pixCopyPaste", void 0);
41
+ __decorate([
42
+ (0, swagger_1.ApiPropertyOptional)({ description: 'URL do boleto quando aplicável' }),
43
+ __metadata("design:type", Object)
44
+ ], InitiateBillingPaymentResponseDto.prototype, "boletoUrl", void 0);
45
+ __decorate([
46
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Código de barras do boleto quando aplicável' }),
47
+ __metadata("design:type", Object)
48
+ ], InitiateBillingPaymentResponseDto.prototype, "boletoBarcode", void 0);
@@ -0,0 +1,7 @@
1
+ import type { GatewayPaymentResponseDto } from './gateway-payment-response.dto';
2
+ import { InitiateBillingPaymentResponseDto } from './initiate-billing-payment-response.dto';
3
+ /**
4
+ * Copia campos conhecidos de `metadata` para a resposta explícita de checkout/PIX/boleto.
5
+ */
6
+ export declare function toInitiateBillingPaymentResponseDto(payment: GatewayPaymentResponseDto): InitiateBillingPaymentResponseDto;
7
+ //# sourceMappingURL=initiate-billing-payment.mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initiate-billing-payment.mapper.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/initiate-billing-payment.mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAE5F;;GAEG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,yBAAyB,GACjC,iCAAiC,CAUnC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toInitiateBillingPaymentResponseDto = toInitiateBillingPaymentResponseDto;
4
+ /**
5
+ * Copia campos conhecidos de `metadata` para a resposta explícita de checkout/PIX/boleto.
6
+ */
7
+ function toInitiateBillingPaymentResponseDto(payment) {
8
+ const meta = (payment.metadata ?? {});
9
+ return {
10
+ ...payment,
11
+ checkoutUrl: meta.paymentUrl ?? undefined,
12
+ pixQrCode: meta.pixQrCode ?? undefined,
13
+ pixCopyPaste: meta.pixCopyPaste ?? undefined,
14
+ boletoUrl: meta.boletoUrl ?? undefined,
15
+ boletoBarcode: meta.boletoBarcode ?? undefined,
16
+ };
17
+ }
@@ -0,0 +1,3 @@
1
+ import type { GatewayPaymentMethodDto, PaymentGatewayDto } from './payment-gateway.enums';
2
+ export declare function isMethodSupportedByGateway(gateway: PaymentGatewayDto, method: GatewayPaymentMethodDto): boolean;
3
+ //# sourceMappingURL=payment-gateway-routing-matrix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-gateway-routing-matrix.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/payment-gateway-routing-matrix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAY1F,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAET"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMethodSupportedByGateway = isMethodSupportedByGateway;
4
+ /**
5
+ * Matriz fixa gateway × meio (alinhada ao README do payment-gateway-service).
6
+ * Usada para validar configuração persistida e para checagens determinísticas.
7
+ */
8
+ const SUPPORTED = {
9
+ ASAAS: new Set(['PIX', 'CREDIT_CARD', 'DEBIT_CARD', 'BOLETO']),
10
+ MERCADO_PAGO: new Set(['PIX', 'CREDIT_CARD', 'DEBIT_CARD']),
11
+ STRIPE: new Set(['CREDIT_CARD', 'DEBIT_CARD']),
12
+ };
13
+ function isMethodSupportedByGateway(gateway, method) {
14
+ return SUPPORTED[gateway]?.has(method) ?? false;
15
+ }
@@ -0,0 +1,14 @@
1
+ import { ValidationArguments, ValidatorConstraintInterface } from 'class-validator';
2
+ import { type GatewayPaymentMethodDto, type PaymentGatewayDto } from './payment-gateway.enums';
3
+ export declare class PaymentGatewayRoutingEntriesConstraint implements ValidatorConstraintInterface {
4
+ validate(entries: unknown, _args: ValidationArguments): boolean;
5
+ defaultMessage(): string;
6
+ }
7
+ export declare class PaymentGatewayRoutingEntryDto {
8
+ gateway: PaymentGatewayDto;
9
+ methods: GatewayPaymentMethodDto[];
10
+ }
11
+ export declare class PaymentGatewayRoutingDto {
12
+ entries: PaymentGatewayRoutingEntryDto[];
13
+ }
14
+ //# sourceMappingURL=payment-gateway-routing.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-gateway-routing.dto.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/payment-gateway-routing.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,mBAAmB,EAEnB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,uBAAuB,EAE5B,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAGjC,qBACa,sCAAuC,YAAW,4BAA4B;IACzF,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO;IAiC/D,cAAc,IAAI,MAAM;CAMzB;AAED,qBAAa,6BAA6B;IAGxC,OAAO,EAAE,iBAAiB,CAAC;IAM3B,OAAO,EAAE,uBAAuB,EAAE,CAAC;CACpC;AAED,qBAAa,wBAAwB;IAOnC,OAAO,EAAE,6BAA6B,EAAE,CAAC;CAC1C"}
@@ -0,0 +1,89 @@
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.PaymentGatewayRoutingDto = exports.PaymentGatewayRoutingEntryDto = exports.PaymentGatewayRoutingEntriesConstraint = 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 payment_gateway_enums_1 = require("./payment-gateway.enums");
17
+ const payment_gateway_routing_matrix_1 = require("./payment-gateway-routing-matrix");
18
+ let PaymentGatewayRoutingEntriesConstraint = class PaymentGatewayRoutingEntriesConstraint {
19
+ validate(entries, _args) {
20
+ if (!Array.isArray(entries) || entries.length < 1) {
21
+ return false;
22
+ }
23
+ const seenGateways = new Set();
24
+ for (const raw of entries) {
25
+ if (!raw || typeof raw !== 'object') {
26
+ return false;
27
+ }
28
+ const e = raw;
29
+ if (typeof e.gateway !== 'string' || !payment_gateway_enums_1.PAYMENT_GATEWAYS.includes(e.gateway)) {
30
+ return false;
31
+ }
32
+ const gateway = e.gateway;
33
+ if (seenGateways.has(gateway)) {
34
+ return false;
35
+ }
36
+ seenGateways.add(gateway);
37
+ if (!Array.isArray(e.methods) || e.methods.length < 1) {
38
+ return false;
39
+ }
40
+ for (const m of e.methods) {
41
+ if (typeof m !== 'string' || !payment_gateway_enums_1.GATEWAY_PAYMENT_METHODS.includes(m)) {
42
+ return false;
43
+ }
44
+ if (!(0, payment_gateway_routing_matrix_1.isMethodSupportedByGateway)(gateway, m)) {
45
+ return false;
46
+ }
47
+ }
48
+ }
49
+ return true;
50
+ }
51
+ defaultMessage() {
52
+ return ('paymentGatewayRouting.entries inválido: ordem vazia, gateway duplicado, methods vazio ' +
53
+ 'ou combinação gateway/método não suportada pela plataforma');
54
+ }
55
+ };
56
+ exports.PaymentGatewayRoutingEntriesConstraint = PaymentGatewayRoutingEntriesConstraint;
57
+ exports.PaymentGatewayRoutingEntriesConstraint = PaymentGatewayRoutingEntriesConstraint = __decorate([
58
+ (0, class_validator_1.ValidatorConstraint)({ name: 'paymentGatewayRoutingEntriesValid', async: false })
59
+ ], PaymentGatewayRoutingEntriesConstraint);
60
+ class PaymentGatewayRoutingEntryDto {
61
+ gateway;
62
+ methods;
63
+ }
64
+ exports.PaymentGatewayRoutingEntryDto = PaymentGatewayRoutingEntryDto;
65
+ __decorate([
66
+ (0, swagger_1.ApiProperty)({ enum: payment_gateway_enums_1.PAYMENT_GATEWAYS }),
67
+ (0, class_validator_1.IsEnum)(payment_gateway_enums_1.PAYMENT_GATEWAYS),
68
+ __metadata("design:type", String)
69
+ ], PaymentGatewayRoutingEntryDto.prototype, "gateway", void 0);
70
+ __decorate([
71
+ (0, swagger_1.ApiProperty)({ enum: payment_gateway_enums_1.GATEWAY_PAYMENT_METHODS, isArray: true }),
72
+ (0, class_validator_1.IsArray)(),
73
+ (0, class_validator_1.ArrayMinSize)(1),
74
+ (0, class_validator_1.IsEnum)(payment_gateway_enums_1.GATEWAY_PAYMENT_METHODS, { each: true }),
75
+ __metadata("design:type", Array)
76
+ ], PaymentGatewayRoutingEntryDto.prototype, "methods", void 0);
77
+ class PaymentGatewayRoutingDto {
78
+ entries;
79
+ }
80
+ exports.PaymentGatewayRoutingDto = PaymentGatewayRoutingDto;
81
+ __decorate([
82
+ (0, swagger_1.ApiProperty)({ type: [PaymentGatewayRoutingEntryDto] }),
83
+ (0, class_validator_1.IsArray)(),
84
+ (0, class_validator_1.ArrayMinSize)(1),
85
+ (0, class_validator_1.ValidateNested)({ each: true }),
86
+ (0, class_transformer_1.Type)(() => PaymentGatewayRoutingEntryDto),
87
+ (0, class_validator_1.Validate)(PaymentGatewayRoutingEntriesConstraint),
88
+ __metadata("design:type", Array)
89
+ ], PaymentGatewayRoutingDto.prototype, "entries", void 0);
@@ -0,0 +1,3 @@
1
+ /** RPC: retorno da configuração global da plataforma (tenant-service → consumidores). */
2
+ export declare const TOPIC_PLATFORM_CONFIGURATION_GET = "platform.configuration.get";
3
+ //# sourceMappingURL=platform-configuration.topics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-configuration.topics.d.ts","sourceRoot":"","sources":["../../src/payment-gateway/platform-configuration.topics.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,eAAO,MAAM,gCAAgC,+BAA+B,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOPIC_PLATFORM_CONFIGURATION_GET = void 0;
4
+ /** RPC: retorno da configuração global da plataforma (tenant-service → consumidores). */
5
+ exports.TOPIC_PLATFORM_CONFIGURATION_GET = 'platform.configuration.get';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tychat-contracts",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
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",
@@ -4,6 +4,12 @@ import {
4
4
  BILLING_STATUSES,
5
5
  BillingStatusDto,
6
6
  } from './create-billing.dto';
7
+ import {
8
+ GATEWAY_PAYMENT_METHODS,
9
+ type GatewayPaymentMethodDto,
10
+ PAYMENT_GATEWAYS,
11
+ type PaymentGatewayDto,
12
+ } from '../payment-gateway/payment-gateway.enums';
7
13
 
8
14
  export class ListBillingsQueryDto {
9
15
  @ApiPropertyOptional({
@@ -31,6 +37,22 @@ export class ListBillingsQueryDto {
31
37
  @IsUUID('4')
32
38
  paymentId?: string;
33
39
 
40
+ @ApiPropertyOptional({
41
+ description: 'Filtro por método de pagamento associado à cobrança',
42
+ enum: GATEWAY_PAYMENT_METHODS,
43
+ })
44
+ @IsOptional()
45
+ @IsEnum(GATEWAY_PAYMENT_METHODS)
46
+ method?: GatewayPaymentMethodDto;
47
+
48
+ @ApiPropertyOptional({
49
+ description: 'Filtro por gateway de pagamento',
50
+ enum: PAYMENT_GATEWAYS,
51
+ })
52
+ @IsOptional()
53
+ @IsEnum(PAYMENT_GATEWAYS)
54
+ gateway?: PaymentGatewayDto;
55
+
34
56
  @ApiPropertyOptional({
35
57
  description: 'Page number (starting at 1)',
36
58
  example: 1,
@@ -0,0 +1,33 @@
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+
3
+ /**
4
+ * Response DTO for cashback balance
5
+ */
6
+ export class CashbackBalanceResponseDto {
7
+ @ApiProperty({ description: 'Balance ID (UUID)' })
8
+ id: string;
9
+
10
+ @ApiProperty({ description: 'Patient ID' })
11
+ patientId: string;
12
+
13
+ @ApiProperty({ description: 'Available (usable) balance' })
14
+ availableBalance: number;
15
+
16
+ @ApiProperty({ description: 'Pending balance (future use)' })
17
+ pendingBalance: number;
18
+
19
+ @ApiProperty({ description: 'Lifetime total earned' })
20
+ totalEarned: number;
21
+
22
+ @ApiProperty({ description: 'Lifetime total used/redeemed' })
23
+ totalUsed: number;
24
+
25
+ @ApiProperty({ description: 'Lifetime total expired' })
26
+ totalExpired: number;
27
+
28
+ @ApiProperty({ description: 'Creation timestamp' })
29
+ createdAt: string;
30
+
31
+ @ApiProperty({ description: 'Last update timestamp' })
32
+ updatedAt: string;
33
+ }
@@ -0,0 +1,43 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import { CashbackDiscountTypeDto, CashbackExpirationTypeDto } from './cashback-enums';
3
+
4
+ /**
5
+ * Response DTO for cashback configuration
6
+ */
7
+ export class CashbackConfigResponseDto {
8
+ @ApiProperty({ description: 'Config ID (UUID)' })
9
+ id: string;
10
+
11
+ @ApiProperty({ description: 'Whether cashback system is active' })
12
+ isActive: boolean;
13
+
14
+ @ApiProperty({ description: 'Cashback percentage for referrer', example: 10.0 })
15
+ cashbackPercentage: number;
16
+
17
+ @ApiProperty({ description: 'Discount type for referred patient', enum: CashbackDiscountTypeDto })
18
+ discountType: CashbackDiscountTypeDto;
19
+
20
+ @ApiProperty({ description: 'Discount value', example: 10.0 })
21
+ discountValue: number;
22
+
23
+ @ApiProperty({ description: 'Expiration type', enum: CashbackExpirationTypeDto })
24
+ expirationType: CashbackExpirationTypeDto;
25
+
26
+ @ApiPropertyOptional({ description: 'Expiration days (PERIOD_PER_PATIENT)' })
27
+ expirationDays?: number | null;
28
+
29
+ @ApiPropertyOptional({ description: 'Max total uses (LIMITED)' })
30
+ maxTotalUses?: number | null;
31
+
32
+ @ApiPropertyOptional({ description: 'Max uses per patient (LIMITED)' })
33
+ maxUsesPerPatient?: number | null;
34
+
35
+ @ApiPropertyOptional({ description: 'Code expiration days (LIMITED)' })
36
+ codeExpirationDays?: number | null;
37
+
38
+ @ApiProperty({ description: 'Creation timestamp' })
39
+ createdAt: string;
40
+
41
+ @ApiProperty({ description: 'Last update timestamp' })
42
+ updatedAt: string;
43
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Expiration type for referral codes
3
+ */
4
+ export enum CashbackExpirationTypeDto {
5
+ /** Each referred patient can only use the code once */
6
+ SINGLE_USE_PER_PATIENT = 'SINGLE_USE_PER_PATIENT',
7
+ /** Code stays active for a limited period per patient */
8
+ PERIOD_PER_PATIENT = 'PERIOD_PER_PATIENT',
9
+ /** Code has total use limit and optional per-patient limit */
10
+ LIMITED = 'LIMITED',
11
+ }
12
+
13
+ /**
14
+ * Discount type for referred patients
15
+ */
16
+ export enum CashbackDiscountTypeDto {
17
+ /** Discount is a percentage of the checkout amount */
18
+ PERCENTAGE = 'PERCENTAGE',
19
+ /** Discount is a fixed amount */
20
+ FIXED = 'FIXED',
21
+ }
22
+
23
+ /**
24
+ * Cashback ledger transaction type
25
+ */
26
+ export enum CashbackLedgerTypeDto {
27
+ /** Cashback earned from referral */
28
+ CREDIT = 'CREDIT',
29
+ /** Cashback redeemed/used */
30
+ DEBIT = 'DEBIT',
31
+ /** Credits expired */
32
+ EXPIRATION = 'EXPIRATION',
33
+ }
@@ -0,0 +1,102 @@
1
+ import { CashbackDiscountTypeDto, CashbackExpirationTypeDto } from './cashback-enums';
2
+
3
+ // ─── Config Payloads ───
4
+
5
+ export interface GetCashbackConfigPayload {
6
+ tenant: string;
7
+ }
8
+
9
+ export interface UpdateCashbackConfigPayload {
10
+ tenant: string;
11
+ isActive?: boolean;
12
+ cashbackPercentage?: number;
13
+ discountType?: CashbackDiscountTypeDto;
14
+ discountValue?: number;
15
+ expirationType?: CashbackExpirationTypeDto;
16
+ expirationDays?: number | null;
17
+ maxTotalUses?: number | null;
18
+ maxUsesPerPatient?: number | null;
19
+ codeExpirationDays?: number | null;
20
+ }
21
+
22
+ // ─── Referral Payloads ───
23
+
24
+ export interface GenerateReferralCodePayload {
25
+ tenant: string;
26
+ patientId: string;
27
+ /** Se true, não cria código novo quando cashback global está inativo (resposta null). */
28
+ onlyIfActive?: boolean;
29
+ }
30
+
31
+ export interface ValidateReferralCodePayload {
32
+ tenant: string;
33
+ code: string;
34
+ referredPatientId: string;
35
+ }
36
+
37
+ export interface UseReferralCodePayload {
38
+ tenant: string;
39
+ code: string;
40
+ referredPatientId: string;
41
+ checkoutId: string;
42
+ checkoutAmount: number;
43
+ }
44
+
45
+ /** Vínculo de código no cadastro do paciente (sem checkout). */
46
+ export interface LinkReferralAtRegistrationPayload {
47
+ tenant: string;
48
+ code: string;
49
+ referredPatientId: string;
50
+ }
51
+
52
+ export interface GetReferralByPatientPayload {
53
+ tenant: string;
54
+ patientId: string;
55
+ }
56
+
57
+ export interface GetReferralByCodePayload {
58
+ tenant: string;
59
+ code: string;
60
+ }
61
+
62
+ export interface GetReferralUsagesPayload {
63
+ tenant: string;
64
+ referralCodeId: string;
65
+ }
66
+
67
+ // ─── Balance / Ledger Payloads ───
68
+
69
+ export interface GetCashbackBalancePayload {
70
+ tenant: string;
71
+ patientId: string;
72
+ }
73
+
74
+ export interface CreditCashbackPayload {
75
+ tenant: string;
76
+ patientId: string;
77
+ amount: number;
78
+ description: string;
79
+ referenceId?: string;
80
+ referenceType?: string;
81
+ expiresAt?: string;
82
+ }
83
+
84
+ export interface DebitCashbackPayload {
85
+ tenant: string;
86
+ patientId: string;
87
+ amount: number;
88
+ description: string;
89
+ referenceId?: string;
90
+ referenceType?: string;
91
+ }
92
+
93
+ export interface GetCashbackLedgerPayload {
94
+ tenant: string;
95
+ patientId: string;
96
+ page?: number;
97
+ limit?: number;
98
+ }
99
+
100
+ export interface ExpireCashbackCreditsPayload {
101
+ tenant: string;
102
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Kafka topic constants for the cashback microservice.
3
+ * All topics follow the pattern: cashback.<module>.<action>
4
+ */
5
+
6
+ // ─── Promotion / Config ───
7
+ export const TOPIC_CASHBACK_CONFIG_GET = 'cashback.config.get';
8
+ export const TOPIC_CASHBACK_CONFIG_UPDATE = 'cashback.config.update';
9
+
10
+ // ─── Referral ───
11
+ export const TOPIC_CASHBACK_REFERRAL_GENERATE = 'cashback.referral.generate';
12
+ export const TOPIC_CASHBACK_REFERRAL_VALIDATE = 'cashback.referral.validate';
13
+ export const TOPIC_CASHBACK_REFERRAL_USE = 'cashback.referral.use';
14
+ export const TOPIC_CASHBACK_REFERRAL_GET_BY_PATIENT = 'cashback.referral.getByPatient';
15
+ export const TOPIC_CASHBACK_REFERRAL_GET_BY_CODE = 'cashback.referral.getByCode';
16
+ export const TOPIC_CASHBACK_REFERRAL_GET_USAGES = 'cashback.referral.getUsagesByCode';
17
+
18
+ // ─── Balance / Ledger ───
19
+ export const TOPIC_CASHBACK_BALANCE_GET = 'cashback.balance.get';
20
+ export const TOPIC_CASHBACK_BALANCE_CREDIT = 'cashback.balance.credit';
21
+ export const TOPIC_CASHBACK_BALANCE_DEBIT = 'cashback.balance.debit';
22
+ export const TOPIC_CASHBACK_LEDGER_GET = 'cashback.ledger.get';
23
+ export const TOPIC_CASHBACK_CREDITS_EXPIRE = 'cashback.credits.expire';