tychat-contracts 1.3.17 → 1.3.19

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,5 +1,6 @@
1
1
  export * from './legal-term-template.dto';
2
2
  export * from './legal-term-preview.dto';
3
+ export * from './legal-term-dispatch.dto';
3
4
  export * from './legal-term-signature-rpc.dto';
4
5
  export * from './legal-term-rmq-patterns';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/legal-terms/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/legal-terms/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC"}
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./legal-term-template.dto"), exports);
18
18
  __exportStar(require("./legal-term-preview.dto"), exports);
19
+ __exportStar(require("./legal-term-dispatch.dto"), exports);
19
20
  __exportStar(require("./legal-term-signature-rpc.dto"), exports);
20
21
  __exportStar(require("./legal-term-rmq-patterns"), exports);
@@ -0,0 +1,21 @@
1
+ /** Status do registro de envio na clínica (WhatsApp / fluxo). */
2
+ export type LegalTermDispatchStatusValue = 'created' | 'sent' | 'failed';
3
+ /** Status do documento na Clicksign (signature-service). */
4
+ export type SignatureDocumentStatusValue = 'pending' | 'signed' | 'refused' | 'cancelled' | 'expired';
5
+ /** Item agregado para a ficha do paciente (API: clinic + signature). */
6
+ export type PatientLegalTermDispatchItemDto = {
7
+ id: string;
8
+ created_at: string;
9
+ procedure_ids: string[];
10
+ procedure_names: string[];
11
+ dispatch_status: LegalTermDispatchStatusValue;
12
+ error_code: string | null;
13
+ signature_document_id: string | null;
14
+ signature_status: SignatureDocumentStatusValue | null;
15
+ signed_at: string | null;
16
+ patient_signed: boolean | null;
17
+ };
18
+ export type PatientLegalTermDispatchesResponseDto = {
19
+ items: PatientLegalTermDispatchItemDto[];
20
+ };
21
+ //# sourceMappingURL=legal-term-dispatch.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legal-term-dispatch.dto.d.ts","sourceRoot":"","sources":["../../src/legal-terms/legal-term-dispatch.dto.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,MAAM,4BAA4B,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEzE,4DAA4D;AAC5D,MAAM,MAAM,4BAA4B,GACpC,SAAS,GACT,QAAQ,GACR,SAAS,GACT,WAAW,GACX,SAAS,CAAC;AAEd,wEAAwE;AACxE,MAAM,MAAM,+BAA+B,GAAG;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,4BAA4B,CAAC;IAC9C,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,gBAAgB,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACtD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG;IAClD,KAAK,EAAE,+BAA+B,EAAE,CAAC;CAC1C,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -12,5 +12,10 @@ export declare class LegalTermSendDto {
12
12
  whatsappMessage: string;
13
13
  signerEmail?: string;
14
14
  instanceKey?: string;
15
+ tenantAutoSign?: boolean;
16
+ tenantSignerName?: string;
17
+ tenantSignerEmail?: string;
18
+ tenantSignerBirthday?: string;
19
+ tenantSignerDocumentation?: string;
15
20
  }
16
21
  //# sourceMappingURL=legal-term-preview.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legal-term-preview.dto.d.ts","sourceRoot":"","sources":["../../src/legal-terms/legal-term-preview.dto.ts"],"names":[],"mappings":"AAGA,4FAA4F;AAC5F,qBAAa,0BAA0B;IAQrC,SAAS,CAAC,EAAE,MAAM,CAAC;IAMnB,aAAa,CAAC,EAAE,MAAM,CAAC;IAMvB,WAAW,CAAC,EAAE,MAAM,CAAC;IAMrB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAU9B,+BAA+B,CAAC,EAAE,MAAM,EAAE,CAAC;IAM3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,gBAAgB;IAI3B,YAAY,EAAE,MAAM,EAAE,CAAC;IASvB,eAAe,EAAE,MAAM,CAAC;IAMxB,WAAW,CAAC,EAAE,MAAM,CAAC;IASrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
1
+ {"version":3,"file":"legal-term-preview.dto.d.ts","sourceRoot":"","sources":["../../src/legal-terms/legal-term-preview.dto.ts"],"names":[],"mappings":"AAcA,4FAA4F;AAC5F,qBAAa,0BAA0B;IAQrC,SAAS,CAAC,EAAE,MAAM,CAAC;IAMnB,aAAa,CAAC,EAAE,MAAM,CAAC;IAMvB,WAAW,CAAC,EAAE,MAAM,CAAC;IAMrB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAU9B,+BAA+B,CAAC,EAAE,MAAM,EAAE,CAAC;IAM3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,gBAAgB;IAI3B,YAAY,EAAE,MAAM,EAAE,CAAC;IASvB,eAAe,EAAE,MAAM,CAAC;IAMxB,WAAW,CAAC,EAAE,MAAM,CAAC;IASrB,WAAW,CAAC,EAAE,MAAM,CAAC;IAQrB,cAAc,CAAC,EAAE,OAAO,CAAC;IAMzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAK1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAO3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAM9B,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC"}
@@ -75,6 +75,11 @@ class LegalTermSendDto {
75
75
  whatsappMessage;
76
76
  signerEmail;
77
77
  instanceKey;
78
+ tenantAutoSign;
79
+ tenantSignerName;
80
+ tenantSignerEmail;
81
+ tenantSignerBirthday;
82
+ tenantSignerDocumentation;
78
83
  }
79
84
  exports.LegalTermSendDto = LegalTermSendDto;
80
85
  __decorate([
@@ -109,3 +114,39 @@ __decorate([
109
114
  (0, class_validator_1.MaxLength)(128),
110
115
  __metadata("design:type", String)
111
116
  ], LegalTermSendDto.prototype, "instanceKey", void 0);
117
+ __decorate([
118
+ (0, swagger_1.ApiPropertyOptional)({
119
+ description: 'Assinatura automática do representante da clínica (Clicksign) antes do paciente. Exige tenantSignerName, tenantSignerEmail, tenantSignerBirthday (YYYY-MM-DD) e tenantSignerDocumentation (CPF).',
120
+ }),
121
+ (0, class_validator_1.IsOptional)(),
122
+ (0, class_validator_1.IsBoolean)(),
123
+ __metadata("design:type", Boolean)
124
+ ], LegalTermSendDto.prototype, "tenantAutoSign", void 0);
125
+ __decorate([
126
+ (0, class_validator_1.ValidateIf)((o) => o.tenantAutoSign === true),
127
+ (0, class_validator_1.IsString)(),
128
+ (0, class_validator_1.MinLength)(1),
129
+ (0, class_validator_1.MaxLength)(500),
130
+ __metadata("design:type", String)
131
+ ], LegalTermSendDto.prototype, "tenantSignerName", void 0);
132
+ __decorate([
133
+ (0, class_validator_1.ValidateIf)((o) => o.tenantAutoSign === true),
134
+ (0, class_validator_1.IsEmail)(),
135
+ (0, class_validator_1.MaxLength)(320),
136
+ __metadata("design:type", String)
137
+ ], LegalTermSendDto.prototype, "tenantSignerEmail", void 0);
138
+ __decorate([
139
+ (0, class_validator_1.ValidateIf)((o) => o.tenantAutoSign === true),
140
+ (0, class_validator_1.IsString)(),
141
+ (0, class_validator_1.Matches)(/^\d{4}-\d{2}-\d{2}$/, {
142
+ message: 'tenantSignerBirthday deve ser ISO (YYYY-MM-DD)',
143
+ }),
144
+ __metadata("design:type", String)
145
+ ], LegalTermSendDto.prototype, "tenantSignerBirthday", void 0);
146
+ __decorate([
147
+ (0, class_validator_1.ValidateIf)((o) => o.tenantAutoSign === true),
148
+ (0, class_validator_1.IsString)(),
149
+ (0, class_validator_1.MinLength)(11),
150
+ (0, class_validator_1.MaxLength)(14),
151
+ __metadata("design:type", String)
152
+ ], LegalTermSendDto.prototype, "tenantSignerDocumentation", void 0);
@@ -3,4 +3,6 @@ export declare const LEGAL_TERM_TEMPLATE_UPSERT = "legalTerm.template.upsert";
3
3
  export declare const LEGAL_TERM_DISPATCH_CREATE = "legalTerm.dispatch.create";
4
4
  export declare const LEGAL_TERM_DISPATCH_LIST_BY_PATIENT = "legalTerm.dispatch.listByPatient";
5
5
  export declare const SIGNATURE_LEGAL_ENVELOPE_CREATE = "signature.legalEnvelope.create";
6
+ /** Resumo de documentos por IDs (tenant + escopo); usado pela API para enriquecer dispatches. */
7
+ export declare const SIGNATURE_DOCUMENTS_SUMMARY_BY_IDS = "signature.documents.summaryByIds";
6
8
  //# sourceMappingURL=legal-term-rmq-patterns.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legal-term-rmq-patterns.d.ts","sourceRoot":"","sources":["../../src/legal-terms/legal-term-rmq-patterns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AAChE,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,eAAO,MAAM,mCAAmC,qCAAqC,CAAC;AACtF,eAAO,MAAM,+BAA+B,mCAAmC,CAAC"}
1
+ {"version":3,"file":"legal-term-rmq-patterns.d.ts","sourceRoot":"","sources":["../../src/legal-terms/legal-term-rmq-patterns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AAChE,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,eAAO,MAAM,mCAAmC,qCAAqC,CAAC;AACtF,eAAO,MAAM,+BAA+B,mCAAmC,CAAC;AAChF,iGAAiG;AACjG,eAAO,MAAM,kCAAkC,qCAAqC,CAAC"}
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SIGNATURE_LEGAL_ENVELOPE_CREATE = exports.LEGAL_TERM_DISPATCH_LIST_BY_PATIENT = exports.LEGAL_TERM_DISPATCH_CREATE = exports.LEGAL_TERM_TEMPLATE_UPSERT = exports.LEGAL_TERM_TEMPLATE_GET = void 0;
3
+ exports.SIGNATURE_DOCUMENTS_SUMMARY_BY_IDS = exports.SIGNATURE_LEGAL_ENVELOPE_CREATE = exports.LEGAL_TERM_DISPATCH_LIST_BY_PATIENT = exports.LEGAL_TERM_DISPATCH_CREATE = exports.LEGAL_TERM_TEMPLATE_UPSERT = exports.LEGAL_TERM_TEMPLATE_GET = void 0;
4
4
  exports.LEGAL_TERM_TEMPLATE_GET = 'legalTerm.template.get';
5
5
  exports.LEGAL_TERM_TEMPLATE_UPSERT = 'legalTerm.template.upsert';
6
6
  exports.LEGAL_TERM_DISPATCH_CREATE = 'legalTerm.dispatch.create';
7
7
  exports.LEGAL_TERM_DISPATCH_LIST_BY_PATIENT = 'legalTerm.dispatch.listByPatient';
8
8
  exports.SIGNATURE_LEGAL_ENVELOPE_CREATE = 'signature.legalEnvelope.create';
9
+ /** Resumo de documentos por IDs (tenant + escopo); usado pela API para enriquecer dispatches. */
10
+ exports.SIGNATURE_DOCUMENTS_SUMMARY_BY_IDS = 'signature.documents.summaryByIds';
@@ -9,6 +9,11 @@ export declare class CreateLegalSigningEnvelopeRpcDto {
9
9
  renderedHtml?: string;
10
10
  documentFilename: string;
11
11
  envelopeName?: string;
12
+ tenantAutoSign?: boolean;
13
+ tenantSignerName?: string;
14
+ tenantSignerEmail?: string;
15
+ tenantSignerBirthday?: string;
16
+ tenantSignerDocumentation?: string;
12
17
  }
13
18
  export declare class CreateLegalSigningEnvelopeRpcResultDto {
14
19
  signatureDocumentId: string;
@@ -17,4 +22,12 @@ export declare class CreateLegalSigningEnvelopeRpcResultDto {
17
22
  clicksignDocumentId: string;
18
23
  clicksignSignerId?: string;
19
24
  }
25
+ /** Resposta RPC: um documento por ID solicitado (apenas linhas do tenant). */
26
+ export type SignatureDocumentSummaryItemDto = {
27
+ id: string;
28
+ signature_status: 'pending' | 'signed' | 'refused' | 'cancelled' | 'expired';
29
+ patient_signed: boolean;
30
+ /** ISO-8601 UTC ou null */
31
+ signed_at: string | null;
32
+ };
20
33
  //# sourceMappingURL=legal-term-signature-rpc.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legal-term-signature-rpc.dto.d.ts","sourceRoot":"","sources":["../../src/legal-terms/legal-term-signature-rpc.dto.ts"],"names":[],"mappings":"AAWA,wFAAwF;AACxF,qBAAa,gCAAgC;IAK3C,MAAM,EAAE,MAAM,CAAC;IAIf,SAAS,EAAE,MAAM,CAAC;IAKlB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAM7B,UAAU,EAAE,MAAM,CAAC;IAKnB,WAAW,EAAE,MAAM,CAAC;IAMpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAQnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAMtB,gBAAgB,EAAE,MAAM,CAAC;IAMzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,sCAAsC;IAEjD,mBAAmB,EAAE,MAAM,CAAC;IAG5B,UAAU,EAAE,MAAM,CAAC;IAGnB,mBAAmB,EAAE,MAAM,CAAC;IAG5B,mBAAmB,EAAE,MAAM,CAAC;IAG5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
1
+ {"version":3,"file":"legal-term-signature-rpc.dto.d.ts","sourceRoot":"","sources":["../../src/legal-terms/legal-term-signature-rpc.dto.ts"],"names":[],"mappings":"AAaA,wFAAwF;AACxF,qBAAa,gCAAgC;IAK3C,MAAM,EAAE,MAAM,CAAC;IAIf,SAAS,EAAE,MAAM,CAAC;IAKlB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAM7B,UAAU,EAAE,MAAM,CAAC;IAKnB,WAAW,EAAE,MAAM,CAAC;IAMpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAQnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAUtB,gBAAgB,EAAE,MAAM,CAAC;IAMzB,YAAY,CAAC,EAAE,MAAM,CAAC;IAQtB,cAAc,CAAC,EAAE,OAAO,CAAC;IAMzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAK1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAO3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAM9B,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,qBAAa,sCAAsC;IAEjD,mBAAmB,EAAE,MAAM,CAAC;IAG5B,UAAU,EAAE,MAAM,CAAC;IAGnB,mBAAmB,EAAE,MAAM,CAAC;IAG5B,mBAAmB,EAAE,MAAM,CAAC;IAG5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,8EAA8E;AAC9E,MAAM,MAAM,+BAA+B,GAAG;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EACZ,SAAS,GACT,QAAQ,GACR,SAAS,GACT,WAAW,GACX,SAAS,CAAC;IACd,cAAc,EAAE,OAAO,CAAC;IACxB,2BAA2B;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC"}
@@ -23,6 +23,11 @@ class CreateLegalSigningEnvelopeRpcDto {
23
23
  renderedHtml;
24
24
  documentFilename;
25
25
  envelopeName;
26
+ tenantAutoSign;
27
+ tenantSignerName;
28
+ tenantSignerEmail;
29
+ tenantSignerBirthday;
30
+ tenantSignerDocumentation;
26
31
  }
27
32
  exports.CreateLegalSigningEnvelopeRpcDto = CreateLegalSigningEnvelopeRpcDto;
28
33
  __decorate([
@@ -73,7 +78,10 @@ __decorate([
73
78
  __metadata("design:type", String)
74
79
  ], CreateLegalSigningEnvelopeRpcDto.prototype, "renderedHtml", void 0);
75
80
  __decorate([
76
- (0, swagger_1.ApiProperty)({ example: 'termo-juridico.pdf' }),
81
+ (0, swagger_1.ApiProperty)({
82
+ example: 'termo-juridico.pdf',
83
+ description: 'Nome do arquivo no envelope. Com renderedHtml o PDF é gerado no signature-service (html-to-pdfmake + pdfmake); com pdfBase64, o binário enviado já é PDF.',
84
+ }),
77
85
  (0, class_validator_1.IsString)(),
78
86
  (0, class_validator_1.MinLength)(1),
79
87
  (0, class_validator_1.MaxLength)(255),
@@ -86,6 +94,42 @@ __decorate([
86
94
  (0, class_validator_1.MaxLength)(500),
87
95
  __metadata("design:type", String)
88
96
  ], CreateLegalSigningEnvelopeRpcDto.prototype, "envelopeName", void 0);
97
+ __decorate([
98
+ (0, swagger_1.ApiPropertyOptional)({
99
+ description: 'Incluir signatário da clínica (PJ) com assinatura automática na Clicksign antes do paciente. Exige conta com termo de assinatura automática válido.',
100
+ }),
101
+ (0, class_validator_1.IsOptional)(),
102
+ (0, class_validator_1.IsBoolean)(),
103
+ __metadata("design:type", Boolean)
104
+ ], CreateLegalSigningEnvelopeRpcDto.prototype, "tenantAutoSign", void 0);
105
+ __decorate([
106
+ (0, class_validator_1.ValidateIf)((o) => o.tenantAutoSign === true),
107
+ (0, class_validator_1.IsString)(),
108
+ (0, class_validator_1.MinLength)(1),
109
+ (0, class_validator_1.MaxLength)(500),
110
+ __metadata("design:type", String)
111
+ ], CreateLegalSigningEnvelopeRpcDto.prototype, "tenantSignerName", void 0);
112
+ __decorate([
113
+ (0, class_validator_1.ValidateIf)((o) => o.tenantAutoSign === true),
114
+ (0, class_validator_1.IsEmail)(),
115
+ (0, class_validator_1.MaxLength)(320),
116
+ __metadata("design:type", String)
117
+ ], CreateLegalSigningEnvelopeRpcDto.prototype, "tenantSignerEmail", void 0);
118
+ __decorate([
119
+ (0, class_validator_1.ValidateIf)((o) => o.tenantAutoSign === true),
120
+ (0, class_validator_1.IsString)(),
121
+ (0, class_validator_1.Matches)(/^\d{4}-\d{2}-\d{2}$/, {
122
+ message: 'tenantSignerBirthday deve ser ISO (YYYY-MM-DD)',
123
+ }),
124
+ __metadata("design:type", String)
125
+ ], CreateLegalSigningEnvelopeRpcDto.prototype, "tenantSignerBirthday", void 0);
126
+ __decorate([
127
+ (0, class_validator_1.ValidateIf)((o) => o.tenantAutoSign === true),
128
+ (0, class_validator_1.IsString)(),
129
+ (0, class_validator_1.MinLength)(11),
130
+ (0, class_validator_1.MaxLength)(14),
131
+ __metadata("design:type", String)
132
+ ], CreateLegalSigningEnvelopeRpcDto.prototype, "tenantSignerDocumentation", void 0);
89
133
  class CreateLegalSigningEnvelopeRpcResultDto {
90
134
  signatureDocumentId;
91
135
  signingUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tychat-contracts",
3
- "version": "1.3.17",
3
+ "version": "1.3.19",
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",
@@ -1,4 +1,5 @@
1
1
  export * from './legal-term-template.dto';
2
2
  export * from './legal-term-preview.dto';
3
+ export * from './legal-term-dispatch.dto';
3
4
  export * from './legal-term-signature-rpc.dto';
4
5
  export * from './legal-term-rmq-patterns';
@@ -0,0 +1,28 @@
1
+ /** Status do registro de envio na clínica (WhatsApp / fluxo). */
2
+ export type LegalTermDispatchStatusValue = 'created' | 'sent' | 'failed';
3
+
4
+ /** Status do documento na Clicksign (signature-service). */
5
+ export type SignatureDocumentStatusValue =
6
+ | 'pending'
7
+ | 'signed'
8
+ | 'refused'
9
+ | 'cancelled'
10
+ | 'expired';
11
+
12
+ /** Item agregado para a ficha do paciente (API: clinic + signature). */
13
+ export type PatientLegalTermDispatchItemDto = {
14
+ id: string;
15
+ created_at: string;
16
+ procedure_ids: string[];
17
+ procedure_names: string[];
18
+ dispatch_status: LegalTermDispatchStatusValue;
19
+ error_code: string | null;
20
+ signature_document_id: string | null;
21
+ signature_status: SignatureDocumentStatusValue | null;
22
+ signed_at: string | null;
23
+ patient_signed: boolean | null;
24
+ };
25
+
26
+ export type PatientLegalTermDispatchesResponseDto = {
27
+ items: PatientLegalTermDispatchItemDto[];
28
+ };
@@ -1,5 +1,16 @@
1
1
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
- import { IsArray, IsOptional, IsString, IsUUID, MaxLength, MinLength } from 'class-validator';
2
+ import {
3
+ IsArray,
4
+ IsBoolean,
5
+ IsEmail,
6
+ IsOptional,
7
+ IsString,
8
+ IsUUID,
9
+ Matches,
10
+ MaxLength,
11
+ MinLength,
12
+ ValidateIf,
13
+ } from 'class-validator';
3
14
 
4
15
  /** Valores explícitos para substituição na pré-visualização (sem inferência heurística). */
5
16
  export class LegalTermPreviewRequestDto {
@@ -76,4 +87,36 @@ export class LegalTermSendDto {
76
87
  @IsString()
77
88
  @MaxLength(128)
78
89
  instanceKey?: string;
90
+
91
+ @ApiPropertyOptional({
92
+ description:
93
+ 'Assinatura automática do representante da clínica (Clicksign) antes do paciente. Exige tenantSignerName, tenantSignerEmail, tenantSignerBirthday (YYYY-MM-DD) e tenantSignerDocumentation (CPF).',
94
+ })
95
+ @IsOptional()
96
+ @IsBoolean()
97
+ tenantAutoSign?: boolean;
98
+
99
+ @ValidateIf((o: LegalTermSendDto) => o.tenantAutoSign === true)
100
+ @IsString()
101
+ @MinLength(1)
102
+ @MaxLength(500)
103
+ tenantSignerName?: string;
104
+
105
+ @ValidateIf((o: LegalTermSendDto) => o.tenantAutoSign === true)
106
+ @IsEmail()
107
+ @MaxLength(320)
108
+ tenantSignerEmail?: string;
109
+
110
+ @ValidateIf((o: LegalTermSendDto) => o.tenantAutoSign === true)
111
+ @IsString()
112
+ @Matches(/^\d{4}-\d{2}-\d{2}$/, {
113
+ message: 'tenantSignerBirthday deve ser ISO (YYYY-MM-DD)',
114
+ })
115
+ tenantSignerBirthday?: string;
116
+
117
+ @ValidateIf((o: LegalTermSendDto) => o.tenantAutoSign === true)
118
+ @IsString()
119
+ @MinLength(11)
120
+ @MaxLength(14)
121
+ tenantSignerDocumentation?: string;
79
122
  }
@@ -3,3 +3,5 @@ export const LEGAL_TERM_TEMPLATE_UPSERT = 'legalTerm.template.upsert';
3
3
  export const LEGAL_TERM_DISPATCH_CREATE = 'legalTerm.dispatch.create';
4
4
  export const LEGAL_TERM_DISPATCH_LIST_BY_PATIENT = 'legalTerm.dispatch.listByPatient';
5
5
  export const SIGNATURE_LEGAL_ENVELOPE_CREATE = 'signature.legalEnvelope.create';
6
+ /** Resumo de documentos por IDs (tenant + escopo); usado pela API para enriquecer dispatches. */
7
+ export const SIGNATURE_DOCUMENTS_SUMMARY_BY_IDS = 'signature.documents.summaryByIds';
@@ -1,9 +1,11 @@
1
1
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
2
  import {
3
+ IsBoolean,
3
4
  IsEmail,
4
5
  IsOptional,
5
6
  IsString,
6
7
  IsUUID,
8
+ Matches,
7
9
  MaxLength,
8
10
  MinLength,
9
11
  ValidateIf,
@@ -51,7 +53,11 @@ export class CreateLegalSigningEnvelopeRpcDto {
51
53
  @MinLength(1)
52
54
  renderedHtml?: string;
53
55
 
54
- @ApiProperty({ example: 'termo-juridico.pdf' })
56
+ @ApiProperty({
57
+ example: 'termo-juridico.pdf',
58
+ description:
59
+ 'Nome do arquivo no envelope. Com renderedHtml o PDF é gerado no signature-service (html-to-pdfmake + pdfmake); com pdfBase64, o binário enviado já é PDF.',
60
+ })
55
61
  @IsString()
56
62
  @MinLength(1)
57
63
  @MaxLength(255)
@@ -62,6 +68,38 @@ export class CreateLegalSigningEnvelopeRpcDto {
62
68
  @IsString()
63
69
  @MaxLength(500)
64
70
  envelopeName?: string;
71
+
72
+ @ApiPropertyOptional({
73
+ description:
74
+ 'Incluir signatário da clínica (PJ) com assinatura automática na Clicksign antes do paciente. Exige conta com termo de assinatura automática válido.',
75
+ })
76
+ @IsOptional()
77
+ @IsBoolean()
78
+ tenantAutoSign?: boolean;
79
+
80
+ @ValidateIf((o: CreateLegalSigningEnvelopeRpcDto) => o.tenantAutoSign === true)
81
+ @IsString()
82
+ @MinLength(1)
83
+ @MaxLength(500)
84
+ tenantSignerName?: string;
85
+
86
+ @ValidateIf((o: CreateLegalSigningEnvelopeRpcDto) => o.tenantAutoSign === true)
87
+ @IsEmail()
88
+ @MaxLength(320)
89
+ tenantSignerEmail?: string;
90
+
91
+ @ValidateIf((o: CreateLegalSigningEnvelopeRpcDto) => o.tenantAutoSign === true)
92
+ @IsString()
93
+ @Matches(/^\d{4}-\d{2}-\d{2}$/, {
94
+ message: 'tenantSignerBirthday deve ser ISO (YYYY-MM-DD)',
95
+ })
96
+ tenantSignerBirthday?: string;
97
+
98
+ @ValidateIf((o: CreateLegalSigningEnvelopeRpcDto) => o.tenantAutoSign === true)
99
+ @IsString()
100
+ @MinLength(11)
101
+ @MaxLength(14)
102
+ tenantSignerDocumentation?: string;
65
103
  }
66
104
 
67
105
  export class CreateLegalSigningEnvelopeRpcResultDto {
@@ -80,3 +118,17 @@ export class CreateLegalSigningEnvelopeRpcResultDto {
80
118
  @ApiPropertyOptional()
81
119
  clicksignSignerId?: string;
82
120
  }
121
+
122
+ /** Resposta RPC: um documento por ID solicitado (apenas linhas do tenant). */
123
+ export type SignatureDocumentSummaryItemDto = {
124
+ id: string;
125
+ signature_status:
126
+ | 'pending'
127
+ | 'signed'
128
+ | 'refused'
129
+ | 'cancelled'
130
+ | 'expired';
131
+ patient_signed: boolean;
132
+ /** ISO-8601 UTC ou null */
133
+ signed_at: string | null;
134
+ };