@muni-sanfer/types-gestor-documental 0.0.1-beta.5 → 0.0.1-beta.7

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 (37) hide show
  1. package/dist/base/entities.d.ts +18 -0
  2. package/dist/contracts/document.contract.d.ts +27 -1
  3. package/dist/contracts/document.contract.js +1 -0
  4. package/dist/contracts/documentType.contract.d.ts +1 -0
  5. package/dist/contracts/index.d.ts +18 -1
  6. package/dist/contracts/index.js +6 -0
  7. package/dist/contracts/registerBook.contract.d.ts +27 -0
  8. package/dist/contracts/registerBook.contract.js +8 -0
  9. package/dist/contracts/signatureBatch.contract.d.ts +108 -0
  10. package/dist/contracts/signatureBatch.contract.js +12 -0
  11. package/dist/entities/document/document.entity.d.ts +33 -0
  12. package/dist/entities/documentType/documentType.entity.d.ts +1 -0
  13. package/dist/entities/index.d.ts +2 -0
  14. package/dist/entities/index.js +2 -0
  15. package/dist/entities/registerBook/index.d.ts +1 -0
  16. package/dist/entities/registerBook/index.js +17 -0
  17. package/dist/entities/registerBook/registerBook.entity.d.ts +42 -0
  18. package/dist/entities/registerBook/registerBook.entity.js +2 -0
  19. package/dist/entities/signatureBatch/index.d.ts +1 -0
  20. package/dist/entities/signatureBatch/index.js +17 -0
  21. package/dist/entities/signatureBatch/signatureBatch.entity.d.ts +106 -0
  22. package/dist/entities/signatureBatch/signatureBatch.entity.js +2 -0
  23. package/package.json +1 -1
  24. package/src/base/entities.ts +19 -0
  25. package/src/contracts/document.contract.ts +25 -0
  26. package/src/contracts/documentType.contract.ts +2 -0
  27. package/src/contracts/index.ts +9 -1
  28. package/src/contracts/registerBook.contract.ts +24 -0
  29. package/src/contracts/signatureBatch.contract.ts +94 -0
  30. package/src/entities/document/document.entity.ts +29 -0
  31. package/src/entities/documentType/documentType.entity.ts +2 -0
  32. package/src/entities/index.ts +2 -0
  33. package/src/entities/registerBook/index.ts +1 -0
  34. package/src/entities/registerBook/registerBook.entity.ts +46 -0
  35. package/src/entities/signatureBatch/index.ts +1 -0
  36. package/src/entities/signatureBatch/signatureBatch.entity.ts +104 -0
  37. package/tsconfig.json +1 -3
@@ -169,11 +169,13 @@ export interface DocumentTypeEntity {
169
169
  nextCorrelative: number;
170
170
  correlativeYear?: number | null;
171
171
  resetsYearly: boolean;
172
+ numbered: boolean;
172
173
  directorateCodeReference?: number | null;
173
174
  enabled: boolean;
174
175
  documents?: DocumentEntity[];
175
176
  annulledNumbers?: DocumentAnnulledNumberEntity[];
176
177
  flowSteps?: DocumentTypeFlowStepEntity[];
178
+ signatureBatches?: SignatureBatchEntity[];
177
179
  deleted: boolean;
178
180
  createdAt: string;
179
181
  updatedAt: string;
@@ -199,6 +201,10 @@ export interface DocumentEntity {
199
201
  externalFolio?: string | null;
200
202
  externalSender?: string | null;
201
203
  externalDate?: string | null;
204
+ contentText?: string | null;
205
+ textExtractedAt?: string | null;
206
+ batch?: SignatureBatchEntity | null;
207
+ batchId?: string | null;
202
208
  replyTo?: DocumentEntity | null;
203
209
  replyToDocumentId?: string | null;
204
210
  replies?: DocumentEntity[];
@@ -228,6 +234,18 @@ export interface DocumentEntity {
228
234
  createdAt: string;
229
235
  updatedAt: string;
230
236
  }
237
+ export interface SignatureBatchEntity {
238
+ id: string;
239
+ name: string;
240
+ createdByEmployeeId: string;
241
+ createdByFullName: string;
242
+ documentType?: DocumentTypeEntity;
243
+ documentTypeId: string;
244
+ documents?: DocumentEntity[];
245
+ deleted: boolean;
246
+ createdAt: string;
247
+ updatedAt: string;
248
+ }
231
249
  export interface DocumentParticipantEntity {
232
250
  id: string;
233
251
  role: DocumentParticipantRole;
@@ -1,5 +1,5 @@
1
1
  import { type DocumentAccessLevel, type DocumentAttachmentEntity, type DocumentDeliveryEntity, type DocumentEntity, type DocumentInstruction, type DocumentParticipantEntity, type DocumentStatus } from '../base/entities';
2
- import { type DocumentAnnulResponseEntity, type DocumentCloseDeliveryResponseEntity, type DocumentCreateResponseEntity, type DocumentDeriveResponseEntity, type DocumentDiscardResponseEntity, type DocumentGetAllResponseEntity, type DocumentGetByIdResponseEntity, type DocumentGetSummaryResponseEntity, type DocumentInboxItemEntity, type DocumentPublicFileResponseEntity, type DocumentReassignResponseEntity, type DocumentReviewResponseEntity, type DocumentUpdateResponseEntity, type DocumentVerifyResponseEntity } from '../entities';
2
+ import { type DocumentAnnulResponseEntity, type DocumentCloseDeliveryResponseEntity, type DocumentCreateResponseEntity, type DocumentDeriveResponseEntity, type DocumentDiscardResponseEntity, type DocumentGetAllResponseEntity, type DocumentGetByIdResponseEntity, type DocumentGetSummaryResponseEntity, type DocumentInboxItemEntity, type DocumentPublicFileResponseEntity, type DocumentReassignResponseEntity, type DocumentReviewResponseEntity, type DocumentSignManyResponseEntity, type DocumentUpdateResponseEntity, type DocumentVerifyResponseEntity } from '../entities';
3
3
  import { type RpcPage } from './contract';
4
4
  /** Patrones NATS de `document`: `<servicio>.<recurso>.<acción>`. */
5
5
  export declare const DocumentPatterns: {
@@ -10,6 +10,7 @@ export declare const DocumentPatterns: {
10
10
  readonly create: "gestorDocumental.document.create";
11
11
  readonly update: "gestorDocumental.document.update";
12
12
  readonly review: "gestorDocumental.document.review";
13
+ readonly signMany: "gestorDocumental.document.signMany";
13
14
  readonly reassign: "gestorDocumental.document.reassign";
14
15
  readonly discard: "gestorDocumental.document.discard";
15
16
  readonly annul: "gestorDocumental.document.annul";
@@ -99,6 +100,12 @@ export interface DocumentContract {
99
100
  documentTypeId?: string;
100
101
  dateFrom?: string;
101
102
  dateTo?: string;
103
+ number?: number;
104
+ year?: number;
105
+ signerEmployeeId?: string;
106
+ authorEmployeeId?: string;
107
+ directorateCodeReference?: number;
108
+ text?: string;
102
109
  };
103
110
  actor?: DocumentActor;
104
111
  };
@@ -155,6 +162,25 @@ export interface DocumentContract {
155
162
  };
156
163
  response: DocumentReviewResponseEntity;
157
164
  };
165
+ /**
166
+ * Firma con un solo OTP varios documentos que el funcionario tiene en su turno de firma (los de un lote, o los que
167
+ * marcó en su bandeja). Cada uno queda firmado aparte; los que no caben en la solicitud quedan en `remaining`.
168
+ */
169
+ [DocumentPatterns.signMany]: {
170
+ payload: {
171
+ ids: DocumentEntity['id'][];
172
+ observation?: string | null;
173
+ signer: {
174
+ rut: string;
175
+ fullName: string;
176
+ role: string;
177
+ areaName: string;
178
+ };
179
+ otp?: string;
180
+ actor: DocumentActor;
181
+ };
182
+ response: DocumentSignManyResponseEntity;
183
+ };
158
184
  /**
159
185
  * Pasa un turno pendiente (de visación o de firma) a otro funcionario, por ausencia o por error, y lo deja en la
160
186
  * trazabilidad con su motivo. Puede hacerlo quien redactó el documento; con `anyDocument`, quien lleva el registro.
@@ -10,6 +10,7 @@ exports.DocumentPatterns = {
10
10
  create: 'gestorDocumental.document.create',
11
11
  update: 'gestorDocumental.document.update',
12
12
  review: 'gestorDocumental.document.review',
13
+ signMany: 'gestorDocumental.document.signMany',
13
14
  reassign: 'gestorDocumental.document.reassign',
14
15
  discard: 'gestorDocumental.document.discard',
15
16
  annul: 'gestorDocumental.document.annul',
@@ -32,6 +32,7 @@ export interface DocumentTypeWritePayload {
32
32
  description?: string | null;
33
33
  nextCorrelative?: number;
34
34
  resetsYearly?: boolean;
35
+ numbered?: boolean;
35
36
  directorateCodeReference?: number | null;
36
37
  enabled?: boolean;
37
38
  flowSteps?: DocumentFlowStepInput[];
@@ -3,12 +3,16 @@ import { type DocumentContract } from './document.contract';
3
3
  import { type DocumentTypeContract } from './documentType.contract';
4
4
  import { type PartsOfficeContract } from './partsOffice.contract';
5
5
  import { type ProcedureContract } from './procedure.contract';
6
+ import { type RegisterBookContract } from './registerBook.contract';
7
+ import { type SignatureBatchContract } from './signatureBatch.contract';
6
8
  export * from './contract';
7
9
  export * from './document.contract';
8
10
  export * from './documentType.contract';
9
11
  export * from './procedure.contract';
10
12
  export * from './caseFile.contract';
11
13
  export * from './partsOffice.contract';
14
+ export * from './registerBook.contract';
15
+ export * from './signatureBatch.contract';
12
16
  /** Patrones NATS de gestor-documental-ms, por recurso: `gestorDocumental.<recurso>.<acción>`. */
13
17
  export declare const GestorDocumentalPatterns: {
14
18
  readonly documentType: {
@@ -26,6 +30,7 @@ export declare const GestorDocumentalPatterns: {
26
30
  readonly create: "gestorDocumental.document.create";
27
31
  readonly update: "gestorDocumental.document.update";
28
32
  readonly review: "gestorDocumental.document.review";
33
+ readonly signMany: "gestorDocumental.document.signMany";
29
34
  readonly reassign: "gestorDocumental.document.reassign";
30
35
  readonly discard: "gestorDocumental.document.discard";
31
36
  readonly annul: "gestorDocumental.document.annul";
@@ -73,6 +78,18 @@ export declare const GestorDocumentalPatterns: {
73
78
  readonly returnInbound: "gestorDocumental.partsOffice.returnInbound";
74
79
  readonly getInboundFile: "gestorDocumental.partsOffice.getInboundFile";
75
80
  };
81
+ readonly registerBook: {
82
+ readonly get: "gestorDocumental.registerBook.get";
83
+ readonly export: "gestorDocumental.registerBook.export";
84
+ };
85
+ readonly signatureBatch: {
86
+ readonly getAll: "gestorDocumental.signatureBatch.getAll";
87
+ readonly getById: "gestorDocumental.signatureBatch.getById";
88
+ readonly create: "gestorDocumental.signatureBatch.create";
89
+ readonly visa: "gestorDocumental.signatureBatch.visa";
90
+ readonly sign: "gestorDocumental.signatureBatch.sign";
91
+ readonly reject: "gestorDocumental.signatureBatch.reject";
92
+ };
76
93
  };
77
94
  /** Contrato completo de gestor-documental-ms: la unión de los contratos de sus recursos. */
78
- export type GestorDocumentalContract = DocumentTypeContract & DocumentContract & ProcedureContract & CaseFileContract & PartsOfficeContract;
95
+ export type GestorDocumentalContract = DocumentTypeContract & DocumentContract & ProcedureContract & CaseFileContract & PartsOfficeContract & RegisterBookContract & SignatureBatchContract;
@@ -20,12 +20,16 @@ const document_contract_1 = require("./document.contract");
20
20
  const documentType_contract_1 = require("./documentType.contract");
21
21
  const partsOffice_contract_1 = require("./partsOffice.contract");
22
22
  const procedure_contract_1 = require("./procedure.contract");
23
+ const registerBook_contract_1 = require("./registerBook.contract");
24
+ const signatureBatch_contract_1 = require("./signatureBatch.contract");
23
25
  __exportStar(require("./contract"), exports);
24
26
  __exportStar(require("./document.contract"), exports);
25
27
  __exportStar(require("./documentType.contract"), exports);
26
28
  __exportStar(require("./procedure.contract"), exports);
27
29
  __exportStar(require("./caseFile.contract"), exports);
28
30
  __exportStar(require("./partsOffice.contract"), exports);
31
+ __exportStar(require("./registerBook.contract"), exports);
32
+ __exportStar(require("./signatureBatch.contract"), exports);
29
33
  /** Patrones NATS de gestor-documental-ms, por recurso: `gestorDocumental.<recurso>.<acción>`. */
30
34
  exports.GestorDocumentalPatterns = {
31
35
  documentType: documentType_contract_1.DocumentTypePatterns,
@@ -33,4 +37,6 @@ exports.GestorDocumentalPatterns = {
33
37
  procedure: procedure_contract_1.ProcedurePatterns,
34
38
  caseFile: caseFile_contract_1.CaseFilePatterns,
35
39
  partsOffice: partsOffice_contract_1.PartsOfficePatterns,
40
+ registerBook: registerBook_contract_1.RegisterBookPatterns,
41
+ signatureBatch: signatureBatch_contract_1.SignatureBatchPatterns,
36
42
  };
@@ -0,0 +1,27 @@
1
+ import { type RegisterBookEntity, type RegisterBookExportEntity, type RegisterBookKind } from '../entities';
2
+ /** Patrones NATS de `registerBook` (libros de registro): `<servicio>.<recurso>.<acción>`. */
3
+ export declare const RegisterBookPatterns: {
4
+ readonly get: "gestorDocumental.registerBook.get";
5
+ readonly export: "gestorDocumental.registerBook.export";
6
+ };
7
+ /** Qué libro y qué período: un año y, si se indica, un mes. El de un tipo documental exige el tipo. */
8
+ export interface RegisterBookQuery {
9
+ kind: RegisterBookKind;
10
+ documentTypeId?: string;
11
+ year: number;
12
+ month?: number | null;
13
+ }
14
+ export interface RegisterBookContract {
15
+ [RegisterBookPatterns.get]: {
16
+ payload: RegisterBookQuery;
17
+ response: RegisterBookEntity;
18
+ };
19
+ /** El libro en Excel o PDF. `generatedBy`: quién lo descarga (va en el encabezado). */
20
+ [RegisterBookPatterns.export]: {
21
+ payload: RegisterBookQuery & {
22
+ format: 'xlsx' | 'pdf';
23
+ generatedBy: string;
24
+ };
25
+ response: RegisterBookExportEntity;
26
+ };
27
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegisterBookPatterns = void 0;
4
+ /** Patrones NATS de `registerBook` (libros de registro): `<servicio>.<recurso>.<acción>`. */
5
+ exports.RegisterBookPatterns = {
6
+ get: 'gestorDocumental.registerBook.get',
7
+ export: 'gestorDocumental.registerBook.export',
8
+ };
@@ -0,0 +1,108 @@
1
+ import { type DocumentAccessLevel } from '../base/entities';
2
+ import { type SignatureBatchCreateResponseEntity, type SignatureBatchGetAllResponseEntity, type SignatureBatchGetByIdResponseEntity, type SignatureBatchRejectResponseEntity, type SignatureBatchSignResponseEntity, type SignatureBatchTab, type SignatureBatchVisaResponseEntity } from '../entities';
3
+ import { type RpcPage } from './contract';
4
+ import { type DocumentActor } from './document.contract';
5
+ /** Patrones NATS de `signatureBatch` (lotes de firma): `<servicio>.<recurso>.<acción>`. */
6
+ export declare const SignatureBatchPatterns: {
7
+ readonly getAll: "gestorDocumental.signatureBatch.getAll";
8
+ readonly getById: "gestorDocumental.signatureBatch.getById";
9
+ readonly create: "gestorDocumental.signatureBatch.create";
10
+ readonly visa: "gestorDocumental.signatureBatch.visa";
11
+ readonly sign: "gestorDocumental.signatureBatch.sign";
12
+ readonly reject: "gestorDocumental.signatureBatch.reject";
13
+ };
14
+ /** Datos de quien firma, para el sello de la firma (los resuelve el gateway desde la sesión). */
15
+ export interface SignatureBatchSigner {
16
+ rut: string;
17
+ fullName: string;
18
+ role: string;
19
+ areaName: string;
20
+ }
21
+ export interface SignatureBatchContract {
22
+ [SignatureBatchPatterns.getAll]: {
23
+ payload: {
24
+ pagination?: {
25
+ page?: number;
26
+ limit?: number;
27
+ };
28
+ filters?: {
29
+ search?: string;
30
+ tab?: SignatureBatchTab;
31
+ };
32
+ actor: DocumentActor;
33
+ };
34
+ response: RpcPage<SignatureBatchGetAllResponseEntity[]>;
35
+ };
36
+ /** Lo ven su redactor y quienes visan o firman sus documentos; con `viewAll`, quien lleva el registro. */
37
+ [SignatureBatchPatterns.getById]: {
38
+ payload: {
39
+ id: string;
40
+ actor: DocumentActor;
41
+ viewAll?: boolean;
42
+ };
43
+ response: SignatureBatchGetByIdResponseEntity;
44
+ };
45
+ /**
46
+ * Crea el lote y lo envía a tramitación: un documento por cada PDF, todos del mismo tipo y con el mismo flujo.
47
+ * Cada documento recibe su código de verificación y, con su primera firma, su número (si el tipo lo lleva).
48
+ */
49
+ [SignatureBatchPatterns.create]: {
50
+ payload: {
51
+ name: string;
52
+ documentTypeId: string;
53
+ keywords: string[];
54
+ accessLevel?: DocumentAccessLevel;
55
+ hasSensitiveData?: boolean;
56
+ directorateCodeReference?: number | null;
57
+ departmentId?: string | null;
58
+ visaEmployeeIds?: string[];
59
+ signatureEmployeeIds: string[];
60
+ signatureSheet?: boolean;
61
+ documents: {
62
+ subject: string;
63
+ file: {
64
+ fileId: string;
65
+ name: string;
66
+ };
67
+ }[];
68
+ actor: DocumentActor;
69
+ };
70
+ response: SignatureBatchCreateResponseEntity;
71
+ };
72
+ /** Visa de una vez los documentos del lote que el funcionario tiene en su turno de visación. */
73
+ [SignatureBatchPatterns.visa]: {
74
+ payload: {
75
+ id: string;
76
+ observation?: string | null;
77
+ actor: DocumentActor;
78
+ };
79
+ response: SignatureBatchVisaResponseEntity;
80
+ };
81
+ /**
82
+ * Firma con un solo OTP los documentos del lote que el funcionario tiene en su turno de firma. FirmaGob admite 5 MB
83
+ * por solicitud: los que no caben quedan en `remaining`, para firmarlos con un OTP nuevo.
84
+ */
85
+ [SignatureBatchPatterns.sign]: {
86
+ payload: {
87
+ id: string;
88
+ observation?: string | null;
89
+ signer: SignatureBatchSigner;
90
+ otp?: string;
91
+ actor: DocumentActor;
92
+ };
93
+ response: SignatureBatchSignResponseEntity;
94
+ };
95
+ /**
96
+ * Devuelve a su redactor los documentos del lote que el funcionario tiene en su turno: todos, o los indicados en
97
+ * `documentIds`. Los demás siguen su curso.
98
+ */
99
+ [SignatureBatchPatterns.reject]: {
100
+ payload: {
101
+ id: string;
102
+ observation: string;
103
+ documentIds?: string[];
104
+ actor: DocumentActor;
105
+ };
106
+ response: SignatureBatchRejectResponseEntity;
107
+ };
108
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SignatureBatchPatterns = void 0;
4
+ /** Patrones NATS de `signatureBatch` (lotes de firma): `<servicio>.<recurso>.<acción>`. */
5
+ exports.SignatureBatchPatterns = {
6
+ getAll: 'gestorDocumental.signatureBatch.getAll',
7
+ getById: 'gestorDocumental.signatureBatch.getById',
8
+ create: 'gestorDocumental.signatureBatch.create',
9
+ visa: 'gestorDocumental.signatureBatch.visa',
10
+ sign: 'gestorDocumental.signatureBatch.sign',
11
+ reject: 'gestorDocumental.signatureBatch.reject',
12
+ };
@@ -97,6 +97,8 @@ export interface DocumentGetAllResponseEntity {
97
97
  intakeNumber: DocumentEntity['intakeNumber'];
98
98
  intakeYear: DocumentEntity['intakeYear'];
99
99
  origin: DocumentEntity['origin'];
100
+ /** Con búsqueda de texto completo: el fragmento donde aparece lo buscado, con lo encontrado entre ⟦ y ⟧. */
101
+ snippet?: string | null;
100
102
  currentParticipant: Pick<DocumentParticipantResponseEntity, 'role' | 'employeeId' | 'fullName'> | null;
101
103
  distribution: {
102
104
  total: number;
@@ -143,6 +145,11 @@ export interface DocumentGetByIdResponseEntity {
143
145
  recipients: DocumentRecipientResponseEntity[];
144
146
  deliveries: DocumentDeliveryResponseEntity[];
145
147
  replyTo: DocumentLinkEntity | null;
148
+ /** Lote de firma al que pertenece. */
149
+ batch: {
150
+ id: string;
151
+ name: string;
152
+ } | null;
146
153
  replies: DocumentLinkEntity[];
147
154
  /** Expedientes en que está incorporado y que quien consulta puede ver. */
148
155
  caseFiles: {
@@ -195,6 +202,11 @@ export interface DocumentGetByIdResponseEntity {
195
202
  export interface DocumentGetSummaryResponseEntity {
196
203
  toVisa: number;
197
204
  toSign: number;
205
+ /** Lotes de firma con documentos en su turno (los documentos de un lote no se cuentan en `toVisa` ni `toSign`). */
206
+ batches: {
207
+ toVisa: number;
208
+ toSign: number;
209
+ };
198
210
  created: {
199
211
  drafted: number;
200
212
  inProgress: number;
@@ -220,6 +232,27 @@ export interface DocumentReviewResponseEntity {
220
232
  ok: boolean;
221
233
  status: DocumentEntity['status'];
222
234
  }
235
+ /** Resultado de un documento en una firma de varios documentos. */
236
+ export interface DocumentSignManyResultEntity {
237
+ id: DocumentEntity['id'];
238
+ ok: boolean;
239
+ /** Estado en que quedó, si se firmó. */
240
+ status?: DocumentEntity['status'];
241
+ /** Por qué no se firmó. */
242
+ message?: string;
243
+ }
244
+ /**
245
+ * Firma de varios documentos con un solo OTP. FirmaGob admite 5 MB por solicitud: los que no cupieron quedan en
246
+ * `remaining`, en el turno del firmante, para firmarlos con un OTP nuevo.
247
+ */
248
+ export interface DocumentSignManyResponseEntity {
249
+ results: DocumentSignManyResultEntity[];
250
+ signed: number;
251
+ failed: number;
252
+ remaining: DocumentEntity['id'][];
253
+ /** FirmaGob avisó que el OTP venció antes de firmar todos los documentos de la solicitud. */
254
+ otpExpired: boolean;
255
+ }
223
256
  export interface DocumentDiscardResponseEntity {
224
257
  id: DocumentEntity['id'];
225
258
  ok: boolean;
@@ -19,6 +19,7 @@ export interface DocumentTypeGetAllResponseEntity {
19
19
  nextCorrelative: DocumentTypeEntity['nextCorrelative'];
20
20
  correlativeYear: DocumentTypeEntity['correlativeYear'];
21
21
  resetsYearly: DocumentTypeEntity['resetsYearly'];
22
+ numbered: DocumentTypeEntity['numbered'];
22
23
  directorateCodeReference: DocumentTypeEntity['directorateCodeReference'];
23
24
  enabled: DocumentTypeEntity['enabled'];
24
25
  flow: {
@@ -3,3 +3,5 @@ export * from './document';
3
3
  export * from './procedure';
4
4
  export * from './caseFile';
5
5
  export * from './partsOffice';
6
+ export * from './registerBook';
7
+ export * from './signatureBatch';
@@ -19,3 +19,5 @@ __exportStar(require("./document"), exports);
19
19
  __exportStar(require("./procedure"), exports);
20
20
  __exportStar(require("./caseFile"), exports);
21
21
  __exportStar(require("./partsOffice"), exports);
22
+ __exportStar(require("./registerBook"), exports);
23
+ __exportStar(require("./signatureBatch"), exports);
@@ -0,0 +1 @@
1
+ export * from './registerBook.entity';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./registerBook.entity"), exports);
@@ -0,0 +1,42 @@
1
+ /** Libro de registro: el de un tipo documental (sus números) o el de ingresos de Oficina de Partes. */
2
+ export type RegisterBookKind = 'documentType' | 'intake';
3
+ /**
4
+ * Estado de un número en el libro: vigente, en tramitación (numerado con la primera firma, aún sin todas las firmas),
5
+ * documento anulado, número anulado por un rechazo, o número sin registro en el gestor (un salto en la numeración).
6
+ */
7
+ export type RegisterBookRowState = 'Valid' | 'InProgress' | 'Annulled' | 'NumberAnnulled' | 'Unused';
8
+ export interface RegisterBookRowEntity {
9
+ number: number;
10
+ /** Fecha del número (o del ingreso), en ISO 8601. `null` en un salto. */
11
+ date: string | null;
12
+ state: RegisterBookRowState;
13
+ documentId: string | null;
14
+ subject: string | null;
15
+ /** Quién redactó el documento (o, en el libro de ingresos, quién lo ingresó). */
16
+ author: string | null;
17
+ signers: string[];
18
+ /** Libro de ingresos: institución que lo envió y su folio. */
19
+ sender: string | null;
20
+ externalFolio: string | null;
21
+ /** Libro de ingresos: a quiénes se derivó. */
22
+ recipients: string[];
23
+ /** Despacho por DocDigital: «DocDigital N° 777001 · 14-10-2026». */
24
+ dispatch: string | null;
25
+ /** Motivo de la anulación (del documento o del número). */
26
+ observation: string | null;
27
+ }
28
+ export interface RegisterBookEntity {
29
+ kind: RegisterBookKind;
30
+ /** «Decreto alcaldicio exento» o «Ingresos de Oficina de Partes». */
31
+ title: string;
32
+ year: number;
33
+ month: number | null;
34
+ rows: RegisterBookRowEntity[];
35
+ totals: Record<RegisterBookRowState, number>;
36
+ }
37
+ /** Libro exportado, listo para descargar. */
38
+ export interface RegisterBookExportEntity {
39
+ fileName: string;
40
+ contentType: string;
41
+ contentBase64: string;
42
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './signatureBatch.entity';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./signatureBatch.entity"), exports);
@@ -0,0 +1,106 @@
1
+ import { type DocumentAccessLevel, type DocumentEntity, type DocumentParticipantRole, type DocumentStatus, type SignatureBatchEntity } from '../../base/entities';
2
+ import { type DocumentSignManyResponseEntity, type DocumentSignManyResultEntity } from '../document';
3
+ /**
4
+ * Estado de un lote, deducido del de sus documentos: en tramitación mientras alguno lo esté; devuelto si no queda
5
+ * ninguno en tramitación y alguno volvió a su redactor; finalizado si todos terminaron (o se anularon después).
6
+ */
7
+ export type SignatureBatchStatus = 'InProgress' | 'Returned' | 'Finished';
8
+ /** Lista de lotes: los que esperan al funcionario, los que redactó o todos en que participa. */
9
+ export type SignatureBatchTab = 'pending' | 'created' | 'participated';
10
+ /** Cuántos documentos del lote hay en cada situación. */
11
+ export interface SignatureBatchCountsEntity {
12
+ total: number;
13
+ inProgress: number;
14
+ finished: number;
15
+ /** Devueltos a su redactor (rechazados), para corregirlos y reenviarlos. */
16
+ returned: number;
17
+ annulled: number;
18
+ }
19
+ export interface SignatureBatchGetAllResponseEntity {
20
+ id: string;
21
+ name: string;
22
+ documentType: {
23
+ id: string;
24
+ name: string;
25
+ };
26
+ createdByEmployeeId: string;
27
+ createdByFullName: string;
28
+ createdAt: SignatureBatchEntity['createdAt'];
29
+ status: SignatureBatchStatus;
30
+ counts: SignatureBatchCountsEntity;
31
+ /** Documentos del lote que esperan al funcionario que consulta, por rol. */
32
+ myPending: {
33
+ visa: number;
34
+ signature: number;
35
+ };
36
+ }
37
+ /** Un documento del lote, con su turno vigente. */
38
+ export interface SignatureBatchDocumentEntity {
39
+ id: string;
40
+ subject: string;
41
+ status: DocumentStatus;
42
+ correlative: number | null;
43
+ correlativeYear: number | null;
44
+ numberedAt: DocumentEntity['numberedAt'];
45
+ verificationCode: string | null;
46
+ originalFileName: string;
47
+ currentTurn: {
48
+ employeeId: string;
49
+ fullName: string;
50
+ role: DocumentParticipantRole;
51
+ } | null;
52
+ /** Si el turno vigente es del funcionario que consulta, qué le toca hacer. */
53
+ myTurn: DocumentParticipantRole | null;
54
+ }
55
+ export interface SignatureBatchGetByIdResponseEntity extends SignatureBatchGetAllResponseEntity {
56
+ documentType: {
57
+ id: string;
58
+ name: string;
59
+ abbreviation: string | null;
60
+ numbered: boolean;
61
+ };
62
+ keywords: string[];
63
+ accessLevel: DocumentAccessLevel;
64
+ hasSensitiveData: boolean;
65
+ /** Visadores y firmantes del lote, en orden (los del primer documento: todos parten con el mismo flujo). */
66
+ flow: {
67
+ role: DocumentParticipantRole;
68
+ employeeId: string;
69
+ fullName: string;
70
+ position: string | null;
71
+ }[];
72
+ documents: SignatureBatchDocumentEntity[];
73
+ }
74
+ /** A quién le quedó el turno después de una operación sobre el lote: para avisarle una sola vez por lote. */
75
+ export interface SignatureBatchTurnEntity {
76
+ employeeId: string;
77
+ fullName: string;
78
+ role: DocumentParticipantRole;
79
+ count: number;
80
+ }
81
+ /** Lo que el gateway necesita para avisar: el lote, su redactor, a quién le toca ahora y cuántos terminaron. */
82
+ export interface SignatureBatchOutcomeEntity {
83
+ id: string;
84
+ name: string;
85
+ createdByEmployeeId: string;
86
+ nextTurns: SignatureBatchTurnEntity[];
87
+ /** Documentos que quedaron finalizados con esta operación. */
88
+ finished: number;
89
+ }
90
+ export interface SignatureBatchCreateResponseEntity extends SignatureBatchOutcomeEntity {
91
+ ok: boolean;
92
+ documentIds: string[];
93
+ }
94
+ export interface SignatureBatchVisaResponseEntity extends SignatureBatchOutcomeEntity {
95
+ ok: boolean;
96
+ visaed: number;
97
+ /** Los que no se pudieron visar, con el motivo. */
98
+ failures: DocumentSignManyResultEntity[];
99
+ }
100
+ export type SignatureBatchSignResponseEntity = SignatureBatchOutcomeEntity & DocumentSignManyResponseEntity;
101
+ export interface SignatureBatchRejectResponseEntity extends SignatureBatchOutcomeEntity {
102
+ ok: boolean;
103
+ /** Documentos devueltos a su redactor. */
104
+ rejected: number;
105
+ observation: string;
106
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muni-sanfer/types-gestor-documental",
3
- "version": "0.0.1-beta.5",
3
+ "version": "0.0.1-beta.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -250,11 +250,13 @@ export interface DocumentTypeEntity {
250
250
  nextCorrelative: number;
251
251
  correlativeYear?: number | null;
252
252
  resetsYearly: boolean;
253
+ numbered: boolean;
253
254
  directorateCodeReference?: number | null;
254
255
  enabled: boolean;
255
256
  documents?: DocumentEntity[];
256
257
  annulledNumbers?: DocumentAnnulledNumberEntity[];
257
258
  flowSteps?: DocumentTypeFlowStepEntity[];
259
+ signatureBatches?: SignatureBatchEntity[];
258
260
  deleted: boolean;
259
261
  createdAt: string;
260
262
  updatedAt: string;
@@ -281,6 +283,10 @@ export interface DocumentEntity {
281
283
  externalFolio?: string | null;
282
284
  externalSender?: string | null;
283
285
  externalDate?: string | null;
286
+ contentText?: string | null;
287
+ textExtractedAt?: string | null;
288
+ batch?: SignatureBatchEntity | null;
289
+ batchId?: string | null;
284
290
  replyTo?: DocumentEntity | null;
285
291
  replyToDocumentId?: string | null;
286
292
  replies?: DocumentEntity[];
@@ -311,6 +317,19 @@ export interface DocumentEntity {
311
317
  updatedAt: string;
312
318
  }
313
319
 
320
+ export interface SignatureBatchEntity {
321
+ id: string;
322
+ name: string;
323
+ createdByEmployeeId: string;
324
+ createdByFullName: string;
325
+ documentType?: DocumentTypeEntity;
326
+ documentTypeId: string;
327
+ documents?: DocumentEntity[];
328
+ deleted: boolean;
329
+ createdAt: string;
330
+ updatedAt: string;
331
+ }
332
+
314
333
  export interface DocumentParticipantEntity {
315
334
  id: string;
316
335
  role: DocumentParticipantRole;
@@ -20,6 +20,7 @@ import {
20
20
  type DocumentPublicFileResponseEntity,
21
21
  type DocumentReassignResponseEntity,
22
22
  type DocumentReviewResponseEntity,
23
+ type DocumentSignManyResponseEntity,
23
24
  type DocumentUpdateResponseEntity,
24
25
  type DocumentVerifyResponseEntity,
25
26
  } from '../entities';
@@ -34,6 +35,7 @@ export const DocumentPatterns = {
34
35
  create: 'gestorDocumental.document.create',
35
36
  update: 'gestorDocumental.document.update',
36
37
  review: 'gestorDocumental.document.review',
38
+ signMany: 'gestorDocumental.document.signMany',
37
39
  reassign: 'gestorDocumental.document.reassign',
38
40
  discard: 'gestorDocumental.document.discard',
39
41
  annul: 'gestorDocumental.document.annul',
@@ -129,6 +131,14 @@ export interface DocumentContract {
129
131
  // Rango de fechas de creación (ISO 8601).
130
132
  dateFrom?: string;
131
133
  dateTo?: string;
134
+ // Búsqueda avanzada: número (del documento o folio de ingreso) y año, firmante, redactor y unidad emisora.
135
+ number?: number;
136
+ year?: number;
137
+ signerEmployeeId?: string;
138
+ authorEmployeeId?: string;
139
+ directorateCodeReference?: number;
140
+ // Texto completo, en el asunto y en el contenido del PDF.
141
+ text?: string;
132
142
  };
133
143
  // Obligatorio en todas las bandejas salvo `all`.
134
144
  actor?: DocumentActor;
@@ -176,6 +186,21 @@ export interface DocumentContract {
176
186
  };
177
187
  response: DocumentReviewResponseEntity;
178
188
  };
189
+ /**
190
+ * Firma con un solo OTP varios documentos que el funcionario tiene en su turno de firma (los de un lote, o los que
191
+ * marcó en su bandeja). Cada uno queda firmado aparte; los que no caben en la solicitud quedan en `remaining`.
192
+ */
193
+ [DocumentPatterns.signMany]: {
194
+ payload: {
195
+ ids: DocumentEntity['id'][];
196
+ observation?: string | null;
197
+ // Datos de quien firma, para el sello de la firma (los resuelve el gateway desde la sesión).
198
+ signer: { rut: string; fullName: string; role: string; areaName: string };
199
+ otp?: string;
200
+ actor: DocumentActor;
201
+ };
202
+ response: DocumentSignManyResponseEntity;
203
+ };
179
204
  /**
180
205
  * Pasa un turno pendiente (de visación o de firma) a otro funcionario, por ausencia o por error, y lo deja en la
181
206
  * trazabilidad con su motivo. Puede hacerlo quien redactó el documento; con `anyDocument`, quien lleva el registro.
@@ -34,6 +34,8 @@ export interface DocumentTypeWritePayload {
34
34
  // Próximo número que se asignará: permite partir desde el correlativo que la municipalidad ya lleva.
35
35
  nextCorrelative?: number;
36
36
  resetsYearly?: boolean;
37
+ // Sus documentos llevan número (por omisión, sí).
38
+ numbered?: boolean;
37
39
  directorateCodeReference?: number | null;
38
40
  enabled?: boolean;
39
41
  // Flujo sugerido, en el orden en que les toca dentro de cada rol. Al editar, si no viene, el flujo no cambia.
@@ -3,6 +3,8 @@ import { DocumentPatterns, type DocumentContract } from './document.contract';
3
3
  import { DocumentTypePatterns, type DocumentTypeContract } from './documentType.contract';
4
4
  import { PartsOfficePatterns, type PartsOfficeContract } from './partsOffice.contract';
5
5
  import { ProcedurePatterns, type ProcedureContract } from './procedure.contract';
6
+ import { RegisterBookPatterns, type RegisterBookContract } from './registerBook.contract';
7
+ import { SignatureBatchPatterns, type SignatureBatchContract } from './signatureBatch.contract';
6
8
 
7
9
  export * from './contract';
8
10
  export * from './document.contract';
@@ -10,6 +12,8 @@ export * from './documentType.contract';
10
12
  export * from './procedure.contract';
11
13
  export * from './caseFile.contract';
12
14
  export * from './partsOffice.contract';
15
+ export * from './registerBook.contract';
16
+ export * from './signatureBatch.contract';
13
17
 
14
18
  /** Patrones NATS de gestor-documental-ms, por recurso: `gestorDocumental.<recurso>.<acción>`. */
15
19
  export const GestorDocumentalPatterns = {
@@ -18,6 +22,8 @@ export const GestorDocumentalPatterns = {
18
22
  procedure: ProcedurePatterns,
19
23
  caseFile: CaseFilePatterns,
20
24
  partsOffice: PartsOfficePatterns,
25
+ registerBook: RegisterBookPatterns,
26
+ signatureBatch: SignatureBatchPatterns,
21
27
  } as const;
22
28
 
23
29
  /** Contrato completo de gestor-documental-ms: la unión de los contratos de sus recursos. */
@@ -25,4 +31,6 @@ export type GestorDocumentalContract = DocumentTypeContract &
25
31
  DocumentContract &
26
32
  ProcedureContract &
27
33
  CaseFileContract &
28
- PartsOfficeContract;
34
+ PartsOfficeContract &
35
+ RegisterBookContract &
36
+ SignatureBatchContract;
@@ -0,0 +1,24 @@
1
+ import { type RegisterBookEntity, type RegisterBookExportEntity, type RegisterBookKind } from '../entities';
2
+
3
+ /** Patrones NATS de `registerBook` (libros de registro): `<servicio>.<recurso>.<acción>`. */
4
+ export const RegisterBookPatterns = {
5
+ get: 'gestorDocumental.registerBook.get',
6
+ export: 'gestorDocumental.registerBook.export',
7
+ } as const;
8
+
9
+ /** Qué libro y qué período: un año y, si se indica, un mes. El de un tipo documental exige el tipo. */
10
+ export interface RegisterBookQuery {
11
+ kind: RegisterBookKind;
12
+ documentTypeId?: string;
13
+ year: number;
14
+ month?: number | null;
15
+ }
16
+
17
+ export interface RegisterBookContract {
18
+ [RegisterBookPatterns.get]: { payload: RegisterBookQuery; response: RegisterBookEntity };
19
+ /** El libro en Excel o PDF. `generatedBy`: quién lo descarga (va en el encabezado). */
20
+ [RegisterBookPatterns.export]: {
21
+ payload: RegisterBookQuery & { format: 'xlsx' | 'pdf'; generatedBy: string };
22
+ response: RegisterBookExportEntity;
23
+ };
24
+ }
@@ -0,0 +1,94 @@
1
+ import { type DocumentAccessLevel } from '../base/entities';
2
+ import {
3
+ type SignatureBatchCreateResponseEntity,
4
+ type SignatureBatchGetAllResponseEntity,
5
+ type SignatureBatchGetByIdResponseEntity,
6
+ type SignatureBatchRejectResponseEntity,
7
+ type SignatureBatchSignResponseEntity,
8
+ type SignatureBatchTab,
9
+ type SignatureBatchVisaResponseEntity,
10
+ } from '../entities';
11
+ import { type RpcPage } from './contract';
12
+ import { type DocumentActor } from './document.contract';
13
+
14
+ /** Patrones NATS de `signatureBatch` (lotes de firma): `<servicio>.<recurso>.<acción>`. */
15
+ export const SignatureBatchPatterns = {
16
+ getAll: 'gestorDocumental.signatureBatch.getAll',
17
+ getById: 'gestorDocumental.signatureBatch.getById',
18
+ create: 'gestorDocumental.signatureBatch.create',
19
+ visa: 'gestorDocumental.signatureBatch.visa',
20
+ sign: 'gestorDocumental.signatureBatch.sign',
21
+ reject: 'gestorDocumental.signatureBatch.reject',
22
+ } as const;
23
+
24
+ /** Datos de quien firma, para el sello de la firma (los resuelve el gateway desde la sesión). */
25
+ export interface SignatureBatchSigner {
26
+ rut: string;
27
+ fullName: string;
28
+ role: string;
29
+ areaName: string;
30
+ }
31
+
32
+ export interface SignatureBatchContract {
33
+ [SignatureBatchPatterns.getAll]: {
34
+ payload: {
35
+ pagination?: { page?: number; limit?: number };
36
+ filters?: { search?: string; tab?: SignatureBatchTab };
37
+ actor: DocumentActor;
38
+ };
39
+ response: RpcPage<SignatureBatchGetAllResponseEntity[]>;
40
+ };
41
+ /** Lo ven su redactor y quienes visan o firman sus documentos; con `viewAll`, quien lleva el registro. */
42
+ [SignatureBatchPatterns.getById]: {
43
+ payload: { id: string; actor: DocumentActor; viewAll?: boolean };
44
+ response: SignatureBatchGetByIdResponseEntity;
45
+ };
46
+ /**
47
+ * Crea el lote y lo envía a tramitación: un documento por cada PDF, todos del mismo tipo y con el mismo flujo.
48
+ * Cada documento recibe su código de verificación y, con su primera firma, su número (si el tipo lo lleva).
49
+ */
50
+ [SignatureBatchPatterns.create]: {
51
+ payload: {
52
+ name: string;
53
+ documentTypeId: string;
54
+ keywords: string[];
55
+ accessLevel?: DocumentAccessLevel;
56
+ hasSensitiveData?: boolean;
57
+ directorateCodeReference?: number | null;
58
+ departmentId?: string | null;
59
+ visaEmployeeIds?: string[];
60
+ signatureEmployeeIds: string[];
61
+ signatureSheet?: boolean;
62
+ documents: { subject: string; file: { fileId: string; name: string } }[];
63
+ actor: DocumentActor;
64
+ };
65
+ response: SignatureBatchCreateResponseEntity;
66
+ };
67
+ /** Visa de una vez los documentos del lote que el funcionario tiene en su turno de visación. */
68
+ [SignatureBatchPatterns.visa]: {
69
+ payload: { id: string; observation?: string | null; actor: DocumentActor };
70
+ response: SignatureBatchVisaResponseEntity;
71
+ };
72
+ /**
73
+ * Firma con un solo OTP los documentos del lote que el funcionario tiene en su turno de firma. FirmaGob admite 5 MB
74
+ * por solicitud: los que no caben quedan en `remaining`, para firmarlos con un OTP nuevo.
75
+ */
76
+ [SignatureBatchPatterns.sign]: {
77
+ payload: {
78
+ id: string;
79
+ observation?: string | null;
80
+ signer: SignatureBatchSigner;
81
+ otp?: string;
82
+ actor: DocumentActor;
83
+ };
84
+ response: SignatureBatchSignResponseEntity;
85
+ };
86
+ /**
87
+ * Devuelve a su redactor los documentos del lote que el funcionario tiene en su turno: todos, o los indicados en
88
+ * `documentIds`. Los demás siguen su curso.
89
+ */
90
+ [SignatureBatchPatterns.reject]: {
91
+ payload: { id: string; observation: string; documentIds?: string[]; actor: DocumentActor };
92
+ response: SignatureBatchRejectResponseEntity;
93
+ };
94
+ }
@@ -117,6 +117,8 @@ export interface DocumentGetAllResponseEntity {
117
117
  intakeNumber: DocumentEntity['intakeNumber'];
118
118
  intakeYear: DocumentEntity['intakeYear'];
119
119
  origin: DocumentEntity['origin'];
120
+ /** Con búsqueda de texto completo: el fragmento donde aparece lo buscado, con lo encontrado entre ⟦ y ⟧. */
121
+ snippet?: string | null;
120
122
  // A quién le toca visar o firmar (null si el documento no está en tramitación).
121
123
  currentParticipant: Pick<DocumentParticipantResponseEntity, 'role' | 'employeeId' | 'fullName'> | null;
122
124
  // A cuántos funcionarios llegó y cuántos ya lo abrieron (null si aún no se distribuye a nadie).
@@ -174,6 +176,8 @@ export interface DocumentGetByIdResponseEntity {
174
176
  deliveries: DocumentDeliveryResponseEntity[];
175
177
  // Documento al que este responde, y los que le responden (solo los ya finalizados, más los propios de quien consulta).
176
178
  replyTo: DocumentLinkEntity | null;
179
+ /** Lote de firma al que pertenece. */
180
+ batch: { id: string; name: string } | null;
177
181
  replies: DocumentLinkEntity[];
178
182
  /** Expedientes en que está incorporado y que quien consulta puede ver. */
179
183
  caseFiles: { id: string; code: string; title: string; status: 'Open' | 'Closed' }[];
@@ -228,6 +232,8 @@ export interface DocumentGetByIdResponseEntity {
228
232
  export interface DocumentGetSummaryResponseEntity {
229
233
  toVisa: number;
230
234
  toSign: number;
235
+ /** Lotes de firma con documentos en su turno (los documentos de un lote no se cuentan en `toVisa` ni `toSign`). */
236
+ batches: { toVisa: number; toSign: number };
231
237
  created: {
232
238
  drafted: number;
233
239
  inProgress: number;
@@ -258,6 +264,29 @@ export interface DocumentReviewResponseEntity {
258
264
  status: DocumentEntity['status'];
259
265
  }
260
266
 
267
+ /** Resultado de un documento en una firma de varios documentos. */
268
+ export interface DocumentSignManyResultEntity {
269
+ id: DocumentEntity['id'];
270
+ ok: boolean;
271
+ /** Estado en que quedó, si se firmó. */
272
+ status?: DocumentEntity['status'];
273
+ /** Por qué no se firmó. */
274
+ message?: string;
275
+ }
276
+
277
+ /**
278
+ * Firma de varios documentos con un solo OTP. FirmaGob admite 5 MB por solicitud: los que no cupieron quedan en
279
+ * `remaining`, en el turno del firmante, para firmarlos con un OTP nuevo.
280
+ */
281
+ export interface DocumentSignManyResponseEntity {
282
+ results: DocumentSignManyResultEntity[];
283
+ signed: number;
284
+ failed: number;
285
+ remaining: DocumentEntity['id'][];
286
+ /** FirmaGob avisó que el OTP venció antes de firmar todos los documentos de la solicitud. */
287
+ otpExpired: boolean;
288
+ }
289
+
261
290
  export interface DocumentDiscardResponseEntity {
262
291
  id: DocumentEntity['id'];
263
292
  ok: boolean;
@@ -22,6 +22,8 @@ export interface DocumentTypeGetAllResponseEntity {
22
22
  nextCorrelative: DocumentTypeEntity['nextCorrelative'];
23
23
  correlativeYear: DocumentTypeEntity['correlativeYear'];
24
24
  resetsYearly: DocumentTypeEntity['resetsYearly'];
25
+ // Sin numeración, sus documentos solo llevan fecha, código de verificación y QR.
26
+ numbered: DocumentTypeEntity['numbered'];
25
27
  directorateCodeReference: DocumentTypeEntity['directorateCodeReference'];
26
28
  enabled: DocumentTypeEntity['enabled'];
27
29
  // Cuántos visadores y firmantes tiene su flujo sugerido.
@@ -3,3 +3,5 @@ export * from './document';
3
3
  export * from './procedure';
4
4
  export * from './caseFile';
5
5
  export * from './partsOffice';
6
+ export * from './registerBook';
7
+ export * from './signatureBatch';
@@ -0,0 +1 @@
1
+ export * from './registerBook.entity';
@@ -0,0 +1,46 @@
1
+ /** Libro de registro: el de un tipo documental (sus números) o el de ingresos de Oficina de Partes. */
2
+ export type RegisterBookKind = 'documentType' | 'intake';
3
+
4
+ /**
5
+ * Estado de un número en el libro: vigente, en tramitación (numerado con la primera firma, aún sin todas las firmas),
6
+ * documento anulado, número anulado por un rechazo, o número sin registro en el gestor (un salto en la numeración).
7
+ */
8
+ export type RegisterBookRowState = 'Valid' | 'InProgress' | 'Annulled' | 'NumberAnnulled' | 'Unused';
9
+
10
+ export interface RegisterBookRowEntity {
11
+ number: number;
12
+ /** Fecha del número (o del ingreso), en ISO 8601. `null` en un salto. */
13
+ date: string | null;
14
+ state: RegisterBookRowState;
15
+ documentId: string | null;
16
+ subject: string | null;
17
+ /** Quién redactó el documento (o, en el libro de ingresos, quién lo ingresó). */
18
+ author: string | null;
19
+ signers: string[];
20
+ /** Libro de ingresos: institución que lo envió y su folio. */
21
+ sender: string | null;
22
+ externalFolio: string | null;
23
+ /** Libro de ingresos: a quiénes se derivó. */
24
+ recipients: string[];
25
+ /** Despacho por DocDigital: «DocDigital N° 777001 · 14-10-2026». */
26
+ dispatch: string | null;
27
+ /** Motivo de la anulación (del documento o del número). */
28
+ observation: string | null;
29
+ }
30
+
31
+ export interface RegisterBookEntity {
32
+ kind: RegisterBookKind;
33
+ /** «Decreto alcaldicio exento» o «Ingresos de Oficina de Partes». */
34
+ title: string;
35
+ year: number;
36
+ month: number | null;
37
+ rows: RegisterBookRowEntity[];
38
+ totals: Record<RegisterBookRowState, number>;
39
+ }
40
+
41
+ /** Libro exportado, listo para descargar. */
42
+ export interface RegisterBookExportEntity {
43
+ fileName: string;
44
+ contentType: string;
45
+ contentBase64: string;
46
+ }
@@ -0,0 +1 @@
1
+ export * from './signatureBatch.entity';
@@ -0,0 +1,104 @@
1
+ import {
2
+ type DocumentAccessLevel,
3
+ type DocumentEntity,
4
+ type DocumentParticipantRole,
5
+ type DocumentStatus,
6
+ type SignatureBatchEntity,
7
+ } from '../../base/entities';
8
+ import { type DocumentSignManyResponseEntity, type DocumentSignManyResultEntity } from '../document';
9
+
10
+ /**
11
+ * Estado de un lote, deducido del de sus documentos: en tramitación mientras alguno lo esté; devuelto si no queda
12
+ * ninguno en tramitación y alguno volvió a su redactor; finalizado si todos terminaron (o se anularon después).
13
+ */
14
+ export type SignatureBatchStatus = 'InProgress' | 'Returned' | 'Finished';
15
+
16
+ /** Lista de lotes: los que esperan al funcionario, los que redactó o todos en que participa. */
17
+ export type SignatureBatchTab = 'pending' | 'created' | 'participated';
18
+
19
+ /** Cuántos documentos del lote hay en cada situación. */
20
+ export interface SignatureBatchCountsEntity {
21
+ total: number;
22
+ inProgress: number;
23
+ finished: number;
24
+ /** Devueltos a su redactor (rechazados), para corregirlos y reenviarlos. */
25
+ returned: number;
26
+ annulled: number;
27
+ }
28
+
29
+ export interface SignatureBatchGetAllResponseEntity {
30
+ id: string;
31
+ name: string;
32
+ documentType: { id: string; name: string };
33
+ createdByEmployeeId: string;
34
+ createdByFullName: string;
35
+ createdAt: SignatureBatchEntity['createdAt'];
36
+ status: SignatureBatchStatus;
37
+ counts: SignatureBatchCountsEntity;
38
+ /** Documentos del lote que esperan al funcionario que consulta, por rol. */
39
+ myPending: { visa: number; signature: number };
40
+ }
41
+
42
+ /** Un documento del lote, con su turno vigente. */
43
+ export interface SignatureBatchDocumentEntity {
44
+ id: string;
45
+ subject: string;
46
+ status: DocumentStatus;
47
+ correlative: number | null;
48
+ correlativeYear: number | null;
49
+ numberedAt: DocumentEntity['numberedAt'];
50
+ verificationCode: string | null;
51
+ originalFileName: string;
52
+ currentTurn: { employeeId: string; fullName: string; role: DocumentParticipantRole } | null;
53
+ /** Si el turno vigente es del funcionario que consulta, qué le toca hacer. */
54
+ myTurn: DocumentParticipantRole | null;
55
+ }
56
+
57
+ export interface SignatureBatchGetByIdResponseEntity extends SignatureBatchGetAllResponseEntity {
58
+ documentType: { id: string; name: string; abbreviation: string | null; numbered: boolean };
59
+ keywords: string[];
60
+ accessLevel: DocumentAccessLevel;
61
+ hasSensitiveData: boolean;
62
+ /** Visadores y firmantes del lote, en orden (los del primer documento: todos parten con el mismo flujo). */
63
+ flow: { role: DocumentParticipantRole; employeeId: string; fullName: string; position: string | null }[];
64
+ documents: SignatureBatchDocumentEntity[];
65
+ }
66
+
67
+ /** A quién le quedó el turno después de una operación sobre el lote: para avisarle una sola vez por lote. */
68
+ export interface SignatureBatchTurnEntity {
69
+ employeeId: string;
70
+ fullName: string;
71
+ role: DocumentParticipantRole;
72
+ count: number;
73
+ }
74
+
75
+ /** Lo que el gateway necesita para avisar: el lote, su redactor, a quién le toca ahora y cuántos terminaron. */
76
+ export interface SignatureBatchOutcomeEntity {
77
+ id: string;
78
+ name: string;
79
+ createdByEmployeeId: string;
80
+ nextTurns: SignatureBatchTurnEntity[];
81
+ /** Documentos que quedaron finalizados con esta operación. */
82
+ finished: number;
83
+ }
84
+
85
+ export interface SignatureBatchCreateResponseEntity extends SignatureBatchOutcomeEntity {
86
+ ok: boolean;
87
+ documentIds: string[];
88
+ }
89
+
90
+ export interface SignatureBatchVisaResponseEntity extends SignatureBatchOutcomeEntity {
91
+ ok: boolean;
92
+ visaed: number;
93
+ /** Los que no se pudieron visar, con el motivo. */
94
+ failures: DocumentSignManyResultEntity[];
95
+ }
96
+
97
+ export type SignatureBatchSignResponseEntity = SignatureBatchOutcomeEntity & DocumentSignManyResponseEntity;
98
+
99
+ export interface SignatureBatchRejectResponseEntity extends SignatureBatchOutcomeEntity {
100
+ ok: boolean;
101
+ /** Documentos devueltos a su redactor. */
102
+ rejected: number;
103
+ observation: string;
104
+ }
package/tsconfig.json CHANGED
@@ -9,7 +9,5 @@
9
9
  "skipLibCheck": true,
10
10
  "rootDir": "./src"
11
11
  },
12
- "include": [
13
- "src"
14
- ]
12
+ "include": ["src"]
15
13
  }