@muni-sanfer/types-gestor-documental 0.0.1-beta.1 → 0.0.1-beta.11

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 (74) hide show
  1. package/dist/base/entities.d.ts +436 -1
  2. package/dist/base/entities.js +98 -1
  3. package/dist/contracts/caseFile.contract.d.ts +159 -0
  4. package/dist/contracts/caseFile.contract.js +18 -0
  5. package/dist/contracts/document.contract.d.ts +163 -3
  6. package/dist/contracts/document.contract.js +8 -0
  7. package/dist/contracts/documentType.contract.d.ts +18 -1
  8. package/dist/contracts/index.d.ts +84 -1
  9. package/dist/contracts/index.js +18 -0
  10. package/dist/contracts/partsOffice.contract.d.ts +171 -0
  11. package/dist/contracts/partsOffice.contract.js +22 -0
  12. package/dist/contracts/procedure.contract.d.ts +50 -0
  13. package/dist/contracts/procedure.contract.js +11 -0
  14. package/dist/contracts/registerBook.contract.d.ts +27 -0
  15. package/dist/contracts/registerBook.contract.js +8 -0
  16. package/dist/contracts/signatureBatch.contract.d.ts +109 -0
  17. package/dist/contracts/signatureBatch.contract.js +12 -0
  18. package/dist/contracts/workFolder.contract.d.ts +114 -0
  19. package/dist/contracts/workFolder.contract.js +16 -0
  20. package/dist/entities/caseFile/caseFile.entity.d.ts +176 -0
  21. package/dist/entities/caseFile/caseFile.entity.js +2 -0
  22. package/dist/entities/caseFile/index.d.ts +1 -0
  23. package/dist/entities/caseFile/index.js +17 -0
  24. package/dist/entities/document/document.entity.d.ts +248 -1
  25. package/dist/entities/documentType/documentType.entity.d.ts +18 -1
  26. package/dist/entities/index.d.ts +6 -0
  27. package/dist/entities/index.js +6 -0
  28. package/dist/entities/partsOffice/index.d.ts +1 -0
  29. package/dist/entities/partsOffice/index.js +17 -0
  30. package/dist/entities/partsOffice/partsOffice.entity.d.ts +98 -0
  31. package/dist/entities/partsOffice/partsOffice.entity.js +2 -0
  32. package/dist/entities/procedure/index.d.ts +1 -0
  33. package/dist/entities/procedure/index.js +17 -0
  34. package/dist/entities/procedure/procedure.entity.d.ts +20 -0
  35. package/dist/entities/procedure/procedure.entity.js +2 -0
  36. package/dist/entities/registerBook/index.d.ts +1 -0
  37. package/dist/entities/registerBook/index.js +17 -0
  38. package/dist/entities/registerBook/registerBook.entity.d.ts +42 -0
  39. package/dist/entities/registerBook/registerBook.entity.js +2 -0
  40. package/dist/entities/signatureBatch/index.d.ts +1 -0
  41. package/dist/entities/signatureBatch/index.js +17 -0
  42. package/dist/entities/signatureBatch/signatureBatch.entity.d.ts +107 -0
  43. package/dist/entities/signatureBatch/signatureBatch.entity.js +2 -0
  44. package/dist/entities/workFolder/index.d.ts +1 -0
  45. package/dist/entities/workFolder/index.js +17 -0
  46. package/dist/entities/workFolder/workFolder.entity.d.ts +83 -0
  47. package/dist/entities/workFolder/workFolder.entity.js +2 -0
  48. package/package.json +1 -1
  49. package/src/base/entities.ts +509 -1
  50. package/src/contracts/caseFile.contract.ts +141 -0
  51. package/src/contracts/document.contract.ts +155 -0
  52. package/src/contracts/documentType.contract.ts +14 -1
  53. package/src/contracts/index.ts +26 -1
  54. package/src/contracts/partsOffice.contract.ts +120 -0
  55. package/src/contracts/procedure.contract.ts +53 -0
  56. package/src/contracts/registerBook.contract.ts +24 -0
  57. package/src/contracts/signatureBatch.contract.ts +96 -0
  58. package/src/contracts/workFolder.contract.ts +75 -0
  59. package/src/entities/caseFile/caseFile.entity.ts +204 -0
  60. package/src/entities/caseFile/index.ts +1 -0
  61. package/src/entities/document/document.entity.ts +259 -0
  62. package/src/entities/documentType/documentType.entity.ts +20 -1
  63. package/src/entities/index.ts +6 -0
  64. package/src/entities/partsOffice/index.ts +1 -0
  65. package/src/entities/partsOffice/partsOffice.entity.ts +103 -0
  66. package/src/entities/procedure/index.ts +1 -0
  67. package/src/entities/procedure/procedure.entity.ts +24 -0
  68. package/src/entities/registerBook/index.ts +1 -0
  69. package/src/entities/registerBook/registerBook.entity.ts +46 -0
  70. package/src/entities/signatureBatch/index.ts +1 -0
  71. package/src/entities/signatureBatch/signatureBatch.entity.ts +110 -0
  72. package/src/entities/workFolder/index.ts +1 -0
  73. package/src/entities/workFolder/workFolder.entity.ts +84 -0
  74. package/tsconfig.json +1 -3
@@ -1,18 +1,30 @@
1
1
  import {
2
2
  type DocumentAccessLevel,
3
3
  type DocumentAttachmentEntity,
4
+ type DocumentDeliveryEntity,
4
5
  type DocumentEntity,
6
+ type DocumentInstruction,
7
+ type DocumentParticipantEntity,
5
8
  type DocumentStatus,
6
9
  } from '../base/entities';
7
10
  import {
8
11
  type DocumentAnnulResponseEntity,
12
+ type DocumentCloseDeliveryResponseEntity,
9
13
  type DocumentCreateResponseEntity,
14
+ type DocumentDeriveResponseEntity,
10
15
  type DocumentDiscardResponseEntity,
11
16
  type DocumentGetAllResponseEntity,
12
17
  type DocumentGetByIdResponseEntity,
13
18
  type DocumentGetSummaryResponseEntity,
19
+ type DocumentInboxItemEntity,
14
20
  type DocumentPublicFileResponseEntity,
21
+ type DocumentReassignResponseEntity,
15
22
  type DocumentReviewResponseEntity,
23
+ type DocumentSignManyResponseEntity,
24
+ type DocumentAgendaResponseEntity,
25
+ type DocumentComposeResponseEntity,
26
+ type DocumentComposition,
27
+ type DocumentTrailExportEntity,
16
28
  type DocumentUpdateResponseEntity,
17
29
  type DocumentVerifyResponseEntity,
18
30
  } from '../entities';
@@ -21,16 +33,24 @@ import { type RpcPage } from './contract';
21
33
  /** Patrones NATS de `document`: `<servicio>.<recurso>.<acción>`. */
22
34
  export const DocumentPatterns = {
23
35
  getAll: 'gestorDocumental.document.getAll',
36
+ getInbox: 'gestorDocumental.document.getInbox',
24
37
  getSummary: 'gestorDocumental.document.getSummary',
25
38
  getById: 'gestorDocumental.document.getById',
26
39
  create: 'gestorDocumental.document.create',
27
40
  update: 'gestorDocumental.document.update',
28
41
  review: 'gestorDocumental.document.review',
42
+ signMany: 'gestorDocumental.document.signMany',
43
+ reassign: 'gestorDocumental.document.reassign',
29
44
  discard: 'gestorDocumental.document.discard',
30
45
  annul: 'gestorDocumental.document.annul',
46
+ derive: 'gestorDocumental.document.derive',
47
+ closeDelivery: 'gestorDocumental.document.closeDelivery',
31
48
  verify: 'gestorDocumental.document.verify',
32
49
  getPublicFile: 'gestorDocumental.document.getPublicFile',
33
50
  getFilesFolder: 'gestorDocumental.document.getFilesFolder',
51
+ getAgenda: 'gestorDocumental.document.getAgenda',
52
+ exportTrail: 'gestorDocumental.document.exportTrail',
53
+ compose: 'gestorDocumental.document.compose',
34
54
  } as const;
35
55
 
36
56
  /**
@@ -46,11 +66,24 @@ export interface DocumentActor {
46
66
  /** Bandeja desde la que se lista. Todas son del funcionario (`actor`), salvo `all`. */
47
67
  export type DocumentBucket =
48
68
  | 'created' // los que redactó
69
+ | 'sent' // de los que redactó, los ya finalizados que tienen destinatarios
49
70
  | 'toVisa' // le toca visarlos
50
71
  | 'toSign' // le toca firmarlos
51
72
  | 'participated' // ya los visó, firmó o rechazó
52
73
  | 'all'; // todos los que están en tramitación o finalizados (historial)
53
74
 
75
+ /**
76
+ * Destinatario de un documento o de una derivación: una persona o un área completa. El gateway resuelve el nombre del
77
+ * área y quiénes la integran hoy; el navegador solo indica cuál es.
78
+ */
79
+ export type DocumentRecipientInput =
80
+ | { type: 'Employee'; employeeId: string }
81
+ | { type: 'Directorate'; directorateCodeReference: number; name: string; memberEmployeeIds: string[] }
82
+ | { type: 'Department'; departmentId: string; name: string; memberEmployeeIds: string[] };
83
+
84
+ /** Qué parte de la bandeja de recibidos se lista: lo que falta atender, lo ya atendido, o todo. */
85
+ export type DocumentInboxState = 'pending' | 'closed' | 'all';
86
+
54
87
  /** Qué hace con el documento quien tiene el turno. */
55
88
  export type DocumentReviewAction = 'Visa' | 'Sign' | 'Reject';
56
89
 
@@ -69,17 +102,70 @@ export interface DocumentWritePayload extends Pick<DocumentEntity, 'subject' | '
69
102
  attachments?: Pick<DocumentAttachmentEntity, 'name' | 'type' | 'fileId' | 'url'>[];
70
103
  // Funcionarios que visan y que firman, en el orden en que les toca. Primero visan todos y después firman.
71
104
  visaEmployeeIds: string[];
105
+ // Etapa de cada visador, en su orden ([1, 1, 2]: los dos primeros visan a la vez). Sin etapas, visan en cadena.
106
+ visaStages?: number[] | null;
107
+ // Al reenviar un documento rechazado, pedir de nuevo las visaciones ya hechas en vez de seguir donde quedó.
108
+ restartFlow?: boolean;
109
+ // Contenido redactado con una plantilla (el PDF ya armado va en `file`): se guarda para volver a editarlo.
110
+ composition?: DocumentComposition | null;
72
111
  signatureEmployeeIds: string[];
73
112
  // Firmas y visaciones en una hoja aparte al final, en vez de al pie de la última página.
74
113
  signatureSheet?: boolean;
114
+ // A quién va dirigido: le llega a su bandeja cuando el documento termina su tramitación.
115
+ recipients?: DocumentRecipientInput[];
116
+ // Plazo en que se espera respuesta de los destinatarios (ISO 8601).
117
+ responseDueAt?: string | null;
118
+ // Documento al que este responde.
119
+ replyToDocumentId?: string | null;
120
+ // Instituciones (y usuarios) de DocDigital a quienes va: al terminar la firma pasa a Oficina de Partes.
121
+ externalRecipients?: DocumentExternalRecipientInput[];
75
122
  action?: 'Submit';
76
123
  actor: DocumentActor;
77
124
  }
78
125
 
126
+ /** Destinatario externo: una institución de DocDigital y, si se indica, uno de sus usuarios. */
127
+ export interface DocumentExternalRecipientInput {
128
+ entityId: number;
129
+ userId?: number | null;
130
+ }
131
+
79
132
  /**
80
133
  * Qué se envía y qué se responde en cada patrón. Generado desde los handlers y los DTO del microservicio.
81
134
  */
82
135
  export interface DocumentContract {
136
+ /**
137
+ * Arma el PDF de un documento redactado con una plantilla oficial: membrete, estructura y espacio libre para el
138
+ * número, las visaciones, las firmas y el QR. Con `preview` lo entrega para verlo; si no, lo sube y entrega su
139
+ * `fileId` para guardarlo como el PDF del documento.
140
+ */
141
+ [DocumentPatterns.compose]: {
142
+ payload: {
143
+ documentTypeId: string;
144
+ subject: string;
145
+ composition: DocumentComposition;
146
+ visaCount: number;
147
+ signatureCount: number;
148
+ signatureSheet?: boolean;
149
+ /** Unidad que emite, para el membrete. */
150
+ issuingUnitName?: string | null;
151
+ preview?: boolean;
152
+ actor: DocumentActor;
153
+ };
154
+ response: DocumentComposeResponseEntity;
155
+ };
156
+ /** Plazos del funcionario entre `from` y `to` (hasta 62 días), y lo que tiene vencido sin atender. */
157
+ [DocumentPatterns.getAgenda]: {
158
+ payload: { from: string; to: string; actor: DocumentActor };
159
+ response: DocumentAgendaResponseEntity;
160
+ };
161
+ /**
162
+ * Trazabilidad del documento en PDF: datos, flujo, hechos y huella de sus archivos. Con las mismas reglas de acceso
163
+ * del detalle. `generatedBy`: quién la descarga (va al pie).
164
+ */
165
+ [DocumentPatterns.exportTrail]: {
166
+ payload: Pick<DocumentEntity, 'id'> & { actor?: DocumentActor; viewAll?: boolean; generatedBy: string };
167
+ response: DocumentTrailExportEntity;
168
+ };
83
169
  [DocumentPatterns.getAll]: {
84
170
  payload: {
85
171
  pagination?: { page?: number; limit?: number };
@@ -91,12 +177,29 @@ export interface DocumentContract {
91
177
  // Rango de fechas de creación (ISO 8601).
92
178
  dateFrom?: string;
93
179
  dateTo?: string;
180
+ // Búsqueda avanzada: número (del documento o folio de ingreso) y año, firmante, redactor y unidad emisora.
181
+ number?: number;
182
+ year?: number;
183
+ signerEmployeeId?: string;
184
+ authorEmployeeId?: string;
185
+ directorateCodeReference?: number;
186
+ // Texto completo, en el asunto y en el contenido del PDF.
187
+ text?: string;
94
188
  };
95
189
  // Obligatorio en todas las bandejas salvo `all`.
96
190
  actor?: DocumentActor;
97
191
  };
98
192
  response: RpcPage<DocumentGetAllResponseEntity[]>;
99
193
  };
194
+ /** Bandeja de recibidos de un funcionario: lo que le llegó como destinatario o por derivación. */
195
+ [DocumentPatterns.getInbox]: {
196
+ payload: {
197
+ pagination?: { page?: number; limit?: number };
198
+ filters?: { search?: string; state?: DocumentInboxState };
199
+ actor: DocumentActor;
200
+ };
201
+ response: RpcPage<DocumentInboxItemEntity[]>;
202
+ };
100
203
  [DocumentPatterns.getSummary]: {
101
204
  payload: { actor: DocumentActor };
102
205
  response: DocumentGetSummaryResponseEntity;
@@ -129,6 +232,36 @@ export interface DocumentContract {
129
232
  };
130
233
  response: DocumentReviewResponseEntity;
131
234
  };
235
+ /**
236
+ * Firma con un solo OTP varios documentos que el funcionario tiene en su turno de firma (los de un lote, o los que
237
+ * marcó en su bandeja). Cada uno queda firmado aparte; los que no caben en la solicitud quedan en `remaining`.
238
+ */
239
+ [DocumentPatterns.signMany]: {
240
+ payload: {
241
+ ids: DocumentEntity['id'][];
242
+ observation?: string | null;
243
+ // Datos de quien firma, para el sello de la firma (los resuelve el gateway desde la sesión).
244
+ signer: { rut: string; fullName: string; role: string; areaName: string };
245
+ otp?: string;
246
+ actor: DocumentActor;
247
+ };
248
+ response: DocumentSignManyResponseEntity;
249
+ };
250
+ /**
251
+ * Pasa un turno pendiente (de visación o de firma) a otro funcionario, por ausencia o por error, y lo deja en la
252
+ * trazabilidad con su motivo. Puede hacerlo quien redactó el documento; con `anyDocument`, quien lleva el registro.
253
+ */
254
+ [DocumentPatterns.reassign]: {
255
+ payload: Pick<DocumentEntity, 'id'> & {
256
+ participantId: DocumentParticipantEntity['id'];
257
+ // Funcionario que toma el turno.
258
+ employeeId: string;
259
+ reason: string;
260
+ actor: DocumentActor;
261
+ anyDocument?: boolean;
262
+ };
263
+ response: DocumentReassignResponseEntity;
264
+ };
132
265
  [DocumentPatterns.discard]: {
133
266
  payload: Pick<DocumentEntity, 'id'> & { actor: DocumentActor };
134
267
  response: DocumentDiscardResponseEntity;
@@ -138,6 +271,28 @@ export interface DocumentContract {
138
271
  payload: Pick<DocumentEntity, 'id'> & { reason: string; actor: DocumentActor };
139
272
  response: DocumentAnnulResponseEntity;
140
273
  };
274
+ /**
275
+ * Deriva un documento finalizado a otros funcionarios o áreas, con su providencia (qué se espera de ellos) y,
276
+ * si corresponde, un plazo. Puede hacerlo quien lo tiene a su alcance: su redactor, quien lo visó o firmó, quien lo
277
+ * recibió y, con `viewAll`, quien consulta el historial.
278
+ */
279
+ [DocumentPatterns.derive]: {
280
+ payload: Pick<DocumentEntity, 'id'> & {
281
+ recipients: DocumentRecipientInput[];
282
+ instruction: DocumentInstruction;
283
+ note?: string | null;
284
+ // Plazo para atenderlo (ISO 8601).
285
+ dueAt?: string | null;
286
+ actor: DocumentActor;
287
+ viewAll?: boolean;
288
+ };
289
+ response: DocumentDeriveResponseEntity;
290
+ };
291
+ /** Quien recibió un documento lo marca como atendido, con una nota opcional. */
292
+ [DocumentPatterns.closeDelivery]: {
293
+ payload: { deliveryId: DocumentDeliveryEntity['id']; note?: string | null; actor: DocumentActor };
294
+ response: DocumentCloseDeliveryResponseEntity;
295
+ };
141
296
  /** Comprobación pública de un documento con el código que lleva impreso. No exige sesión. */
142
297
  [DocumentPatterns.verify]: {
143
298
  payload: { code: string };
@@ -1,4 +1,4 @@
1
- import { type DocumentCategory, type DocumentTypeEntity } from '../base/entities';
1
+ import { type DocumentCategory, type DocumentParticipantRole, type DocumentTypeEntity } from '../base/entities';
2
2
  import {
3
3
  type DocumentTypeCreateResponseEntity,
4
4
  type DocumentTypeGetAllResponseEntity,
@@ -16,6 +16,15 @@ export const DocumentTypePatterns = {
16
16
  setEnabled: 'gestorDocumental.documentType.setEnabled',
17
17
  } as const;
18
18
 
19
+ /**
20
+ * Paso del flujo sugerido de un tipo documental: un funcionario en particular, o quien dirija una dirección al
21
+ * momento de redactar (su jefatura o, con subrogancia activa, el subrogante). El nombre de la dirección lo resuelve
22
+ * el gateway; el navegador solo indica cuál es.
23
+ */
24
+ export type DocumentFlowStepInput =
25
+ | { role: DocumentParticipantRole; type: 'Employee'; employeeId: string }
26
+ | { role: DocumentParticipantRole; type: 'DirectorateHead'; directorateCodeReference: number; name: string };
27
+
19
28
  /** Datos de un tipo documental al crearlo o editarlo. */
20
29
  export interface DocumentTypeWritePayload {
21
30
  name: string;
@@ -25,8 +34,12 @@ export interface DocumentTypeWritePayload {
25
34
  // Próximo número que se asignará: permite partir desde el correlativo que la municipalidad ya lleva.
26
35
  nextCorrelative?: number;
27
36
  resetsYearly?: boolean;
37
+ // Sus documentos llevan número (por omisión, sí).
38
+ numbered?: boolean;
28
39
  directorateCodeReference?: number | null;
29
40
  enabled?: boolean;
41
+ // Flujo sugerido, en el orden en que les toca dentro de cada rol. Al editar, si no viene, el flujo no cambia.
42
+ flowSteps?: DocumentFlowStepInput[];
30
43
  }
31
44
 
32
45
  /**
@@ -1,15 +1,40 @@
1
+ import { CaseFilePatterns, type CaseFileContract } from './caseFile.contract';
1
2
  import { DocumentPatterns, type DocumentContract } from './document.contract';
2
3
  import { DocumentTypePatterns, type DocumentTypeContract } from './documentType.contract';
4
+ import { PartsOfficePatterns, type PartsOfficeContract } from './partsOffice.contract';
5
+ import { ProcedurePatterns, type ProcedureContract } from './procedure.contract';
6
+ import { RegisterBookPatterns, type RegisterBookContract } from './registerBook.contract';
7
+ import { SignatureBatchPatterns, type SignatureBatchContract } from './signatureBatch.contract';
8
+ import { WorkFolderPatterns, type WorkFolderContract } from './workFolder.contract';
3
9
 
4
10
  export * from './contract';
5
11
  export * from './document.contract';
6
12
  export * from './documentType.contract';
13
+ export * from './procedure.contract';
14
+ export * from './caseFile.contract';
15
+ export * from './partsOffice.contract';
16
+ export * from './registerBook.contract';
17
+ export * from './signatureBatch.contract';
18
+ export * from './workFolder.contract';
7
19
 
8
20
  /** Patrones NATS de gestor-documental-ms, por recurso: `gestorDocumental.<recurso>.<acción>`. */
9
21
  export const GestorDocumentalPatterns = {
10
22
  documentType: DocumentTypePatterns,
11
23
  document: DocumentPatterns,
24
+ procedure: ProcedurePatterns,
25
+ caseFile: CaseFilePatterns,
26
+ partsOffice: PartsOfficePatterns,
27
+ registerBook: RegisterBookPatterns,
28
+ signatureBatch: SignatureBatchPatterns,
29
+ workFolder: WorkFolderPatterns,
12
30
  } as const;
13
31
 
14
32
  /** Contrato completo de gestor-documental-ms: la unión de los contratos de sus recursos. */
15
- export type GestorDocumentalContract = DocumentTypeContract & DocumentContract;
33
+ export type GestorDocumentalContract = DocumentTypeContract &
34
+ DocumentContract &
35
+ ProcedureContract &
36
+ CaseFileContract &
37
+ PartsOfficeContract &
38
+ RegisterBookContract &
39
+ SignatureBatchContract &
40
+ WorkFolderContract;
@@ -0,0 +1,120 @@
1
+ import { type DocumentAccessLevel, type DocumentInstruction } from '../base/entities';
2
+ import {
3
+ type DocDigitalDocumentTypeEntity,
4
+ type DocDigitalEntityEntity,
5
+ type PartsOfficeInboundEntity,
6
+ type DocDigitalUserEntity,
7
+ type PartsOfficeDispatchEntity,
8
+ type PartsOfficeFileEntity,
9
+ type PartsOfficeOkResponseEntity,
10
+ type PartsOfficeRegisterResponseEntity,
11
+ type PartsOfficeStatusEntity,
12
+ type PartsOfficeSummaryEntity,
13
+ type PartsOfficeSyncResponseEntity,
14
+ } from '../entities';
15
+ import { type RpcPage } from './contract';
16
+ import { type DocumentActor, type DocumentExternalRecipientInput } from './document.contract';
17
+
18
+ /** Patrones NATS de `partsOffice` (Oficina de Partes y DocDigital): `<servicio>.<recurso>.<acción>`. */
19
+ export const PartsOfficePatterns = {
20
+ getStatus: 'gestorDocumental.partsOffice.getStatus',
21
+ getSummary: 'gestorDocumental.partsOffice.getSummary',
22
+ getEntities: 'gestorDocumental.partsOffice.getEntities',
23
+ getUsers: 'gestorDocumental.partsOffice.getUsers',
24
+ getDocumentTypes: 'gestorDocumental.partsOffice.getDocumentTypes',
25
+ getDispatches: 'gestorDocumental.partsOffice.getDispatches',
26
+ dispatch: 'gestorDocumental.partsOffice.dispatch',
27
+ returnDispatch: 'gestorDocumental.partsOffice.returnDispatch',
28
+ resendDispatch: 'gestorDocumental.partsOffice.resendDispatch',
29
+ getDispatchFile: 'gestorDocumental.partsOffice.getDispatchFile',
30
+ getInbound: 'gestorDocumental.partsOffice.getInbound',
31
+ syncInbound: 'gestorDocumental.partsOffice.syncInbound',
32
+ registerInbound: 'gestorDocumental.partsOffice.registerInbound',
33
+ acknowledgeInbound: 'gestorDocumental.partsOffice.acknowledgeInbound',
34
+ returnInbound: 'gestorDocumental.partsOffice.returnInbound',
35
+ getInboundFile: 'gestorDocumental.partsOffice.getInboundFile',
36
+ } as const;
37
+
38
+ /** Destinatario interno de un ingreso, ya resuelto por el gateway (las áreas con sus integrantes). */
39
+ export type PartsOfficeRecipientInput =
40
+ | { type: 'Employee'; employeeId: string }
41
+ | { type: 'Directorate'; directorateCodeReference: number; name: string; memberEmployeeIds: string[] }
42
+ | { type: 'Department'; departmentId: string; name: string; memberEmployeeIds: string[] };
43
+
44
+ interface IListPayload<S> {
45
+ pagination?: { page?: number; limit?: number };
46
+ filters?: { search?: string; status?: S };
47
+ }
48
+
49
+ export interface PartsOfficeContract {
50
+ [PartsOfficePatterns.getStatus]: { payload: Record<string, never>; response: PartsOfficeStatusEntity };
51
+ [PartsOfficePatterns.getSummary]: { payload: Record<string, never>; response: PartsOfficeSummaryEntity };
52
+ /** Directorio de DocDigital: instituciones por nombre. */
53
+ [PartsOfficePatterns.getEntities]: { payload: { search?: string }; response: DocDigitalEntityEntity[] };
54
+ [PartsOfficePatterns.getUsers]: {
55
+ payload: { entityId: number; search?: string };
56
+ response: DocDigitalUserEntity[];
57
+ };
58
+ [PartsOfficePatterns.getDocumentTypes]: { payload: Record<string, never>; response: DocDigitalDocumentTypeEntity[] };
59
+ [PartsOfficePatterns.getDispatches]: {
60
+ payload: IListPayload<'Pending' | 'Dispatched' | 'Returned'>;
61
+ response: RpcPage<PartsOfficeDispatchEntity[]>;
62
+ };
63
+ /** Despacha por DocDigital, con el número del documento como folio. `operatorRun`: RUN de quien despacha. */
64
+ [PartsOfficePatterns.dispatch]: {
65
+ payload: { id: string; docDigitalTypeId: number; operatorRun?: string | null; actor: DocumentActor };
66
+ response: PartsOfficeOkResponseEntity & { docDigitalDocumentId: string };
67
+ };
68
+ /** Devuelve el despacho al redactor, con el motivo (por ejemplo, un destinatario equivocado). */
69
+ [PartsOfficePatterns.returnDispatch]: {
70
+ payload: { id: string; reason: string; actor: DocumentActor };
71
+ response: PartsOfficeOkResponseEntity;
72
+ };
73
+ /** El redactor corrige las instituciones de destino de un despacho devuelto y lo envía de nuevo a Partes. */
74
+ [PartsOfficePatterns.resendDispatch]: {
75
+ payload: { id: string; externalRecipients: DocumentExternalRecipientInput[]; actor: DocumentActor };
76
+ response: PartsOfficeOkResponseEntity;
77
+ };
78
+ /** PDF firmado de un documento por despachar, para que Oficina de Partes lo revise. */
79
+ [PartsOfficePatterns.getDispatchFile]: { payload: { id: string }; response: PartsOfficeFileEntity };
80
+ [PartsOfficePatterns.getInbound]: {
81
+ payload: IListPayload<'Pending' | 'Registered' | 'Returned'>;
82
+ response: RpcPage<PartsOfficeInboundEntity[]>;
83
+ };
84
+ /** Trae de DocDigital lo recibido que aún no tiene acuse de recibo. */
85
+ [PartsOfficePatterns.syncInbound]: { payload: Record<string, never>; response: PartsOfficeSyncResponseEntity };
86
+ /**
87
+ * Ingresa un recibido al gestor: le da folio de ingreso, lo deriva a quienes corresponda y da el acuse de recibo
88
+ * en DocDigital.
89
+ */
90
+ [PartsOfficePatterns.registerInbound]: {
91
+ payload: {
92
+ id: string;
93
+ documentTypeId: string;
94
+ keywords: string[];
95
+ accessLevel: DocumentAccessLevel;
96
+ hasSensitiveData: boolean;
97
+ recipients: PartsOfficeRecipientInput[];
98
+ instruction: DocumentInstruction;
99
+ note?: string | null;
100
+ dueAt?: string | null;
101
+ actor: DocumentActor;
102
+ };
103
+ response: PartsOfficeRegisterResponseEntity;
104
+ };
105
+ /** Reintenta el acuse de recibo de un recibido ya ingresado. */
106
+ [PartsOfficePatterns.acknowledgeInbound]: {
107
+ payload: { id: string; actor: DocumentActor };
108
+ response: PartsOfficeOkResponseEntity;
109
+ };
110
+ /** Devuelve el recibido a la institución que lo envió, con el motivo (entre 3 y 255 caracteres). */
111
+ [PartsOfficePatterns.returnInbound]: {
112
+ payload: { id: string; reason: string; actor: DocumentActor };
113
+ response: PartsOfficeOkResponseEntity;
114
+ };
115
+ /** Archivo de un recibido: el principal o, con `attachment`, uno de sus anexos (por su posición). */
116
+ [PartsOfficePatterns.getInboundFile]: {
117
+ payload: { id: string; attachment?: number };
118
+ response: PartsOfficeFileEntity;
119
+ };
120
+ }
@@ -0,0 +1,53 @@
1
+ import { type ProcedureEntity } from '../base/entities';
2
+ import {
3
+ type ProcedureCreateResponseEntity,
4
+ type ProcedureGetAllResponseEntity,
5
+ type ProcedureGetByIdResponseEntity,
6
+ type ProcedureUpdateResponseEntity,
7
+ } from '../entities';
8
+ import { type RpcPage } from './contract';
9
+
10
+ /** Patrones NATS de `procedure`: `<servicio>.<recurso>.<acción>`. */
11
+ export const ProcedurePatterns = {
12
+ getAll: 'gestorDocumental.procedure.getAll',
13
+ getById: 'gestorDocumental.procedure.getById',
14
+ create: 'gestorDocumental.procedure.create',
15
+ update: 'gestorDocumental.procedure.update',
16
+ setEnabled: 'gestorDocumental.procedure.setEnabled',
17
+ } as const;
18
+
19
+ /** Datos de un procedimiento administrativo al crearlo o editarlo. */
20
+ export interface ProcedureWritePayload {
21
+ name: string;
22
+ cpatId?: string | null;
23
+ cpatCode?: string | null;
24
+ description?: string | null;
25
+ enabled?: boolean;
26
+ }
27
+
28
+ export interface ProcedureContract {
29
+ [ProcedurePatterns.getAll]: {
30
+ // sin `page` y `limit` responde todos en una sola página
31
+ payload: {
32
+ pagination?: { page?: number; limit?: number };
33
+ filters?: { search?: string; enabled?: boolean };
34
+ };
35
+ response: RpcPage<ProcedureGetAllResponseEntity[]>;
36
+ };
37
+ [ProcedurePatterns.getById]: {
38
+ payload: Pick<ProcedureEntity, 'id'>;
39
+ response: ProcedureGetByIdResponseEntity;
40
+ };
41
+ [ProcedurePatterns.create]: {
42
+ payload: ProcedureWritePayload;
43
+ response: ProcedureCreateResponseEntity;
44
+ };
45
+ [ProcedurePatterns.update]: {
46
+ payload: ProcedureWritePayload & Pick<ProcedureEntity, 'id'>;
47
+ response: ProcedureUpdateResponseEntity;
48
+ };
49
+ [ProcedurePatterns.setEnabled]: {
50
+ payload: Pick<ProcedureEntity, 'id' | 'enabled'>;
51
+ response: ProcedureUpdateResponseEntity;
52
+ };
53
+ }
@@ -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,96 @@
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
+ // Etapa de cada visador: los de una misma etapa visan a la vez.
61
+ visaStages?: number[] | null;
62
+ signatureEmployeeIds: string[];
63
+ signatureSheet?: boolean;
64
+ documents: { subject: string; file: { fileId: string; name: string } }[];
65
+ actor: DocumentActor;
66
+ };
67
+ response: SignatureBatchCreateResponseEntity;
68
+ };
69
+ /** Visa de una vez los documentos del lote que el funcionario tiene en su turno de visación. */
70
+ [SignatureBatchPatterns.visa]: {
71
+ payload: { id: string; observation?: string | null; actor: DocumentActor };
72
+ response: SignatureBatchVisaResponseEntity;
73
+ };
74
+ /**
75
+ * Firma con un solo OTP los documentos del lote que el funcionario tiene en su turno de firma. FirmaGob admite 5 MB
76
+ * por solicitud: los que no caben quedan en `remaining`, para firmarlos con un OTP nuevo.
77
+ */
78
+ [SignatureBatchPatterns.sign]: {
79
+ payload: {
80
+ id: string;
81
+ observation?: string | null;
82
+ signer: SignatureBatchSigner;
83
+ otp?: string;
84
+ actor: DocumentActor;
85
+ };
86
+ response: SignatureBatchSignResponseEntity;
87
+ };
88
+ /**
89
+ * Devuelve a su redactor los documentos del lote que el funcionario tiene en su turno: todos, o los indicados en
90
+ * `documentIds`. Los demás siguen su curso.
91
+ */
92
+ [SignatureBatchPatterns.reject]: {
93
+ payload: { id: string; observation: string; documentIds?: string[]; actor: DocumentActor };
94
+ response: SignatureBatchRejectResponseEntity;
95
+ };
96
+ }