@muni-sanfer/types-gestor-documental 0.0.1-beta.4 → 0.0.1-beta.6

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 (32) hide show
  1. package/dist/base/entities.d.ts +103 -1
  2. package/dist/base/entities.js +18 -1
  3. package/dist/contracts/document.contract.d.ts +12 -0
  4. package/dist/contracts/index.d.ts +27 -1
  5. package/dist/contracts/index.js +6 -0
  6. package/dist/contracts/partsOffice.contract.d.ts +171 -0
  7. package/dist/contracts/partsOffice.contract.js +22 -0
  8. package/dist/contracts/registerBook.contract.d.ts +27 -0
  9. package/dist/contracts/registerBook.contract.js +8 -0
  10. package/dist/entities/document/document.entity.d.ts +42 -0
  11. package/dist/entities/index.d.ts +2 -0
  12. package/dist/entities/index.js +2 -0
  13. package/dist/entities/partsOffice/index.d.ts +1 -0
  14. package/dist/entities/partsOffice/index.js +17 -0
  15. package/dist/entities/partsOffice/partsOffice.entity.d.ts +98 -0
  16. package/dist/entities/partsOffice/partsOffice.entity.js +2 -0
  17. package/dist/entities/registerBook/index.d.ts +1 -0
  18. package/dist/entities/registerBook/index.js +17 -0
  19. package/dist/entities/registerBook/registerBook.entity.d.ts +42 -0
  20. package/dist/entities/registerBook/registerBook.entity.js +2 -0
  21. package/package.json +1 -1
  22. package/src/base/entities.ts +114 -1
  23. package/src/contracts/document.contract.ts +16 -0
  24. package/src/contracts/index.ts +12 -1
  25. package/src/contracts/partsOffice.contract.ts +120 -0
  26. package/src/contracts/registerBook.contract.ts +24 -0
  27. package/src/entities/document/document.entity.ts +44 -0
  28. package/src/entities/index.ts +2 -0
  29. package/src/entities/partsOffice/index.ts +1 -0
  30. package/src/entities/partsOffice/partsOffice.entity.ts +103 -0
  31. package/src/entities/registerBook/index.ts +1 -0
  32. package/src/entities/registerBook/registerBook.entity.ts +46 -0
@@ -0,0 +1,98 @@
1
+ import { type DocumentDispatchResponseEntity, type DocumentExternalRecipientResponseEntity, type DocumentLinkEntity } from '../document';
2
+ /** Institución del Estado en DocDigital. */
3
+ export interface DocDigitalEntityEntity {
4
+ id: number;
5
+ name: string;
6
+ /** Organismo al que pertenece (la entidad padre). */
7
+ organism: string | null;
8
+ }
9
+ /** Usuario habilitado de una institución en DocDigital. */
10
+ export interface DocDigitalUserEntity {
11
+ id: number;
12
+ name: string;
13
+ position: string | null;
14
+ }
15
+ export interface DocDigitalDocumentTypeEntity {
16
+ id: number;
17
+ name: string;
18
+ }
19
+ /** Si DocDigital está configurado en el gestor y cada cuánto se revisa lo recibido. */
20
+ export interface PartsOfficeStatusEntity {
21
+ configured: boolean;
22
+ syncMinutes: number;
23
+ }
24
+ /** Totales del Panel de Partes. */
25
+ export interface PartsOfficeSummaryEntity {
26
+ toDispatch: number;
27
+ received: number;
28
+ }
29
+ /** Documento firmado que va a otras instituciones: lo despacha Oficina de Partes. */
30
+ export interface PartsOfficeDispatchEntity extends DocumentDispatchResponseEntity {
31
+ document: DocumentLinkEntity & {
32
+ accessLevel: string;
33
+ };
34
+ externalRecipients: DocumentExternalRecipientResponseEntity[];
35
+ createdAt: string;
36
+ }
37
+ /** Documento que llegó por DocDigital. */
38
+ export interface PartsOfficeInboundEntity {
39
+ id: string;
40
+ docDigitalDocumentId: string;
41
+ status: 'Pending' | 'Registered' | 'Returned';
42
+ subject: string;
43
+ description: string | null;
44
+ folio: string | null;
45
+ folioDate: string | null;
46
+ typeName: string | null;
47
+ reserved: boolean;
48
+ senderEntityName: string | null;
49
+ senderName: string | null;
50
+ senderPosition: string | null;
51
+ fileName: string | null;
52
+ hasFile: boolean;
53
+ attachments: {
54
+ name: string;
55
+ url: string | null;
56
+ hasFile: boolean;
57
+ }[];
58
+ createdAt: string;
59
+ registeredAt: string | null;
60
+ registeredByFullName: string | null;
61
+ acknowledgedAt: string | null;
62
+ acknowledgeError: string | null;
63
+ returnedAt: string | null;
64
+ returnedByFullName: string | null;
65
+ returnReason: string | null;
66
+ /** El documento con que quedó ingresado al gestor. */
67
+ document: {
68
+ id: string;
69
+ intakeNumber: number | null;
70
+ intakeYear: number | null;
71
+ } | null;
72
+ }
73
+ export interface PartsOfficeOkResponseEntity {
74
+ id: string;
75
+ ok: boolean;
76
+ /** Documento al que corresponde el despacho (al despachar o devolver). */
77
+ documentId?: string;
78
+ }
79
+ export interface PartsOfficeSyncResponseEntity {
80
+ /** Recibidos nuevos que se trajeron. */
81
+ created: number;
82
+ /** Los que no se pudieron traer (se reintentan en la próxima revisión). */
83
+ failed: number;
84
+ }
85
+ export interface PartsOfficeRegisterResponseEntity {
86
+ id: string;
87
+ documentId: string;
88
+ intakeNumber: number;
89
+ intakeYear: number;
90
+ /** `false` si DocDigital no aceptó el acuse de recibo: se puede reintentar. */
91
+ acknowledged: boolean;
92
+ ok: boolean;
93
+ }
94
+ /** Archivo de un recibido, ya copiado al gestor. */
95
+ export interface PartsOfficeFileEntity {
96
+ fileId: string;
97
+ fileName: string;
98
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muni-sanfer/types-gestor-documental",
3
- "version": "0.0.1-beta.4",
3
+ "version": "0.0.1-beta.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -60,7 +60,10 @@ export type DocumentTrackingAction =
60
60
  | 'Annulled'
61
61
  | 'Delivered'
62
62
  | 'Derived'
63
- | 'Reassigned';
63
+ | 'Reassigned'
64
+ | 'Dispatched'
65
+ | 'DispatchReturned'
66
+ | 'Received';
64
67
 
65
68
  export const DocumentTrackingAction = {
66
69
  Created: 'Created',
@@ -77,8 +80,34 @@ export const DocumentTrackingAction = {
77
80
  Delivered: 'Delivered',
78
81
  Derived: 'Derived',
79
82
  Reassigned: 'Reassigned',
83
+ Dispatched: 'Dispatched',
84
+ DispatchReturned: 'DispatchReturned',
85
+ Received: 'Received',
80
86
  } satisfies Record<string, DocumentTrackingAction>;
81
87
 
88
+ export type DocumentOrigin = 'Internal' | 'DocDigital';
89
+
90
+ export const DocumentOrigin = {
91
+ Internal: 'Internal',
92
+ DocDigital: 'DocDigital',
93
+ } satisfies Record<string, DocumentOrigin>;
94
+
95
+ export type DocumentDispatchStatus = 'Pending' | 'Dispatched' | 'Returned';
96
+
97
+ export const DocumentDispatchStatus = {
98
+ Pending: 'Pending',
99
+ Dispatched: 'Dispatched',
100
+ Returned: 'Returned',
101
+ } satisfies Record<string, DocumentDispatchStatus>;
102
+
103
+ export type DocDigitalInboundStatus = 'Pending' | 'Registered' | 'Returned';
104
+
105
+ export const DocDigitalInboundStatus = {
106
+ Pending: 'Pending',
107
+ Registered: 'Registered',
108
+ Returned: 'Returned',
109
+ } satisfies Record<string, DocDigitalInboundStatus>;
110
+
82
111
  export type DocumentFlowStepType = 'Employee' | 'DirectorateHead';
83
112
 
84
113
  export const DocumentFlowStepType = {
@@ -246,6 +275,14 @@ export interface DocumentEntity {
246
275
  annulledAt?: string | null;
247
276
  annulmentReason?: string | null;
248
277
  responseDueAt?: string | null;
278
+ origin: DocumentOrigin;
279
+ intakeNumber?: number | null;
280
+ intakeYear?: number | null;
281
+ externalFolio?: string | null;
282
+ externalSender?: string | null;
283
+ externalDate?: string | null;
284
+ contentText?: string | null;
285
+ textExtractedAt?: string | null;
249
286
  replyTo?: DocumentEntity | null;
250
287
  replyToDocumentId?: string | null;
251
288
  replies?: DocumentEntity[];
@@ -268,6 +305,9 @@ export interface DocumentEntity {
268
305
  recipients?: DocumentRecipientEntity[];
269
306
  deliveries?: DocumentDeliveryEntity[];
270
307
  caseFileEntries?: CaseFileEntryEntity[];
308
+ externalRecipients?: DocumentExternalRecipientEntity[];
309
+ dispatch?: DocumentDispatchEntity | null;
310
+ docDigitalInbound?: DocDigitalInboundEntity | null;
271
311
  deleted: boolean;
272
312
  createdAt: string;
273
313
  updatedAt: string;
@@ -514,3 +554,76 @@ export interface CaseFileAccessEntity {
514
554
  caseFileId: string;
515
555
  createdAt: string;
516
556
  }
557
+
558
+ export interface DocumentExternalRecipientEntity {
559
+ id: string;
560
+ entityId: number;
561
+ entityName: string;
562
+ userId?: number | null;
563
+ userName?: string | null;
564
+ userPosition?: string | null;
565
+ document?: DocumentEntity;
566
+ documentId: string;
567
+ createdAt: string;
568
+ }
569
+
570
+ export interface DocumentDispatchEntity {
571
+ id: string;
572
+ status: DocumentDispatchStatus;
573
+ folio?: string | null;
574
+ docDigitalTypeId?: number | null;
575
+ docDigitalTypeName?: string | null;
576
+ docDigitalDocumentId?: string | null;
577
+ docDigitalRequestId?: string | null;
578
+ dispatchedAt?: string | null;
579
+ dispatchedByEmployeeId?: string | null;
580
+ dispatchedByFullName?: string | null;
581
+ returnedAt?: string | null;
582
+ returnedByEmployeeId?: string | null;
583
+ returnedByFullName?: string | null;
584
+ returnReason?: string | null;
585
+ document?: DocumentEntity;
586
+ documentId: string;
587
+ createdAt: string;
588
+ updatedAt: string;
589
+ }
590
+
591
+ export interface DocDigitalInboundEntity {
592
+ id: string;
593
+ docDigitalDocumentId: string;
594
+ docDigitalRequestId?: string | null;
595
+ status: DocDigitalInboundStatus;
596
+ subject: string;
597
+ description?: string | null;
598
+ folio?: string | null;
599
+ folioDate?: string | null;
600
+ typeName?: string | null;
601
+ reserved: boolean;
602
+ senderEntityId?: number | null;
603
+ senderEntityName?: string | null;
604
+ senderName?: string | null;
605
+ senderPosition?: string | null;
606
+ fileId?: string | null;
607
+ fileName?: string | null;
608
+ attachments: JsonValue;
609
+ registeredAt?: string | null;
610
+ registeredByEmployeeId?: string | null;
611
+ registeredByFullName?: string | null;
612
+ acknowledgedAt?: string | null;
613
+ acknowledgeError?: string | null;
614
+ returnedAt?: string | null;
615
+ returnedByEmployeeId?: string | null;
616
+ returnedByFullName?: string | null;
617
+ returnReason?: string | null;
618
+ document?: DocumentEntity | null;
619
+ documentId?: string | null;
620
+ createdAt: string;
621
+ updatedAt: string;
622
+ }
623
+
624
+ export interface IntakeSequenceEntity {
625
+ year: number;
626
+ next: number;
627
+ }
628
+
629
+ type JsonValue = string | number | boolean | { [key in string]?: JsonValue } | Array<JsonValue> | null;
@@ -102,10 +102,18 @@ export interface DocumentWritePayload extends Pick<DocumentEntity, 'subject' | '
102
102
  responseDueAt?: string | null;
103
103
  // Documento al que este responde.
104
104
  replyToDocumentId?: string | null;
105
+ // Instituciones (y usuarios) de DocDigital a quienes va: al terminar la firma pasa a Oficina de Partes.
106
+ externalRecipients?: DocumentExternalRecipientInput[];
105
107
  action?: 'Submit';
106
108
  actor: DocumentActor;
107
109
  }
108
110
 
111
+ /** Destinatario externo: una institución de DocDigital y, si se indica, uno de sus usuarios. */
112
+ export interface DocumentExternalRecipientInput {
113
+ entityId: number;
114
+ userId?: number | null;
115
+ }
116
+
109
117
  /**
110
118
  * Qué se envía y qué se responde en cada patrón. Generado desde los handlers y los DTO del microservicio.
111
119
  */
@@ -121,6 +129,14 @@ export interface DocumentContract {
121
129
  // Rango de fechas de creación (ISO 8601).
122
130
  dateFrom?: string;
123
131
  dateTo?: string;
132
+ // Búsqueda avanzada: número (del documento o folio de ingreso) y año, firmante, redactor y unidad emisora.
133
+ number?: number;
134
+ year?: number;
135
+ signerEmployeeId?: string;
136
+ authorEmployeeId?: string;
137
+ directorateCodeReference?: number;
138
+ // Texto completo, en el asunto y en el contenido del PDF.
139
+ text?: string;
124
140
  };
125
141
  // Obligatorio en todas las bandejas salvo `all`.
126
142
  actor?: DocumentActor;
@@ -1,13 +1,17 @@
1
1
  import { CaseFilePatterns, type CaseFileContract } from './caseFile.contract';
2
2
  import { DocumentPatterns, type DocumentContract } from './document.contract';
3
3
  import { DocumentTypePatterns, type DocumentTypeContract } from './documentType.contract';
4
+ import { PartsOfficePatterns, type PartsOfficeContract } from './partsOffice.contract';
4
5
  import { ProcedurePatterns, type ProcedureContract } from './procedure.contract';
6
+ import { RegisterBookPatterns, type RegisterBookContract } from './registerBook.contract';
5
7
 
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';
13
+ export * from './partsOffice.contract';
14
+ export * from './registerBook.contract';
11
15
 
12
16
  /** Patrones NATS de gestor-documental-ms, por recurso: `gestorDocumental.<recurso>.<acción>`. */
13
17
  export const GestorDocumentalPatterns = {
@@ -15,7 +19,14 @@ export const GestorDocumentalPatterns = {
15
19
  document: DocumentPatterns,
16
20
  procedure: ProcedurePatterns,
17
21
  caseFile: CaseFilePatterns,
22
+ partsOffice: PartsOfficePatterns,
23
+ registerBook: RegisterBookPatterns,
18
24
  } as const;
19
25
 
20
26
  /** Contrato completo de gestor-documental-ms: la unión de los contratos de sus recursos. */
21
- export type GestorDocumentalContract = DocumentTypeContract & DocumentContract & ProcedureContract & CaseFileContract;
27
+ export type GestorDocumentalContract = DocumentTypeContract &
28
+ DocumentContract &
29
+ ProcedureContract &
30
+ CaseFileContract &
31
+ PartsOfficeContract &
32
+ RegisterBookContract;
@@ -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,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
+ }
@@ -72,6 +72,33 @@ export interface DocumentLinkEntity {
72
72
  createdByFullName: DocumentEntity['createdByFullName'];
73
73
  finishedAt: DocumentEntity['finishedAt'];
74
74
  documentType: DocumentTypeSummaryEntity;
75
+ /** Folio de ingreso de Oficina de Partes, si llegó por DocDigital. */
76
+ intakeNumber: DocumentEntity['intakeNumber'];
77
+ intakeYear: DocumentEntity['intakeYear'];
78
+ }
79
+
80
+ /** Institución (y usuario) de DocDigital a la que va dirigido un documento. */
81
+ export interface DocumentExternalRecipientResponseEntity {
82
+ id: string;
83
+ entityId: number;
84
+ entityName: string;
85
+ userId: number | null;
86
+ userName: string | null;
87
+ userPosition: string | null;
88
+ }
89
+
90
+ /** Despacho de un documento por DocDigital. */
91
+ export interface DocumentDispatchResponseEntity {
92
+ id: string;
93
+ status: 'Pending' | 'Dispatched' | 'Returned';
94
+ folio: string | null;
95
+ docDigitalTypeName: string | null;
96
+ docDigitalDocumentId: string | null;
97
+ dispatchedAt: string | null;
98
+ dispatchedByFullName: string | null;
99
+ returnedAt: string | null;
100
+ returnedByFullName: string | null;
101
+ returnReason: string | null;
75
102
  }
76
103
 
77
104
  export interface DocumentGetAllResponseEntity {
@@ -87,6 +114,11 @@ export interface DocumentGetAllResponseEntity {
87
114
  createdByEmployeeId: DocumentEntity['createdByEmployeeId'];
88
115
  createdByFullName: DocumentEntity['createdByFullName'];
89
116
  documentType: DocumentTypeSummaryEntity;
117
+ intakeNumber: DocumentEntity['intakeNumber'];
118
+ intakeYear: DocumentEntity['intakeYear'];
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;
90
122
  // A quién le toca visar o firmar (null si el documento no está en tramitación).
91
123
  currentParticipant: Pick<DocumentParticipantResponseEntity, 'role' | 'employeeId' | 'fullName'> | null;
92
124
  // A cuántos funcionarios llegó y cuántos ya lo abrieron (null si aún no se distribuye a nadie).
@@ -147,6 +179,16 @@ export interface DocumentGetByIdResponseEntity {
147
179
  replies: DocumentLinkEntity[];
148
180
  /** Expedientes en que está incorporado y que quien consulta puede ver. */
149
181
  caseFiles: { id: string; code: string; title: string; status: 'Open' | 'Closed' }[];
182
+ /** De dónde viene: del gestor o recibido por DocDigital, con su folio de ingreso y los datos de quien lo envió. */
183
+ origin: DocumentEntity['origin'];
184
+ intakeNumber: DocumentEntity['intakeNumber'];
185
+ intakeYear: DocumentEntity['intakeYear'];
186
+ externalFolio: DocumentEntity['externalFolio'];
187
+ externalSender: DocumentEntity['externalSender'];
188
+ externalDate: DocumentEntity['externalDate'];
189
+ /** Instituciones de DocDigital a quienes va dirigido, y su despacho por Oficina de Partes. */
190
+ externalRecipients: DocumentExternalRecipientResponseEntity[];
191
+ dispatch: DocumentDispatchResponseEntity | null;
150
192
  documentType: DocumentTypeSummaryEntity;
151
193
  participants: DocumentParticipantResponseEntity[];
152
194
  attachments: {
@@ -175,6 +217,8 @@ export interface DocumentGetByIdResponseEntity {
175
217
  canReply: boolean;
176
218
  // Es quien redactó un documento en tramitación: puede pasar un turno pendiente a otro funcionario.
177
219
  canReassign: boolean;
220
+ /** Quien consulta redactó el documento (o lo ingresó, si llegó por DocDigital). */
221
+ isAuthor: boolean;
178
222
  // Sus propias entregas de este documento (puede tener más de una si además se lo derivaron).
179
223
  inbox: DocumentDeliveryResponseEntity[];
180
224
  };
@@ -2,3 +2,5 @@ export * from './documentType';
2
2
  export * from './document';
3
3
  export * from './procedure';
4
4
  export * from './caseFile';
5
+ export * from './partsOffice';
6
+ export * from './registerBook';
@@ -0,0 +1 @@
1
+ export * from './partsOffice.entity';