@muni-sanfer/types-gestor-documental 0.0.1-beta.0 → 0.0.1-beta.2

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.
@@ -4,7 +4,7 @@ export declare const DocumentCategory: {
4
4
  Communication: "Communication";
5
5
  Other: "Other";
6
6
  };
7
- export type DocumentStatus = 'Drafted' | 'PendingVisa' | 'PendingSignature' | 'Finished' | 'Rejected' | 'Discarded';
7
+ export type DocumentStatus = 'Drafted' | 'PendingVisa' | 'PendingSignature' | 'Finished' | 'Rejected' | 'Discarded' | 'Annulled';
8
8
  export declare const DocumentStatus: {
9
9
  Drafted: "Drafted";
10
10
  PendingVisa: "PendingVisa";
@@ -12,6 +12,7 @@ export declare const DocumentStatus: {
12
12
  Finished: "Finished";
13
13
  Rejected: "Rejected";
14
14
  Discarded: "Discarded";
15
+ Annulled: "Annulled";
15
16
  };
16
17
  export type DocumentAccessLevel = 'Public' | 'Restricted' | 'Secret' | 'Reserved';
17
18
  export declare const DocumentAccessLevel: {
@@ -32,7 +33,7 @@ export declare const DocumentParticipantStatus: {
32
33
  Resolved: "Resolved";
33
34
  Rejected: "Rejected";
34
35
  };
35
- export type DocumentTrackingAction = 'Created' | 'Updated' | 'Submitted' | 'Visaed' | 'Signed' | 'Rejected' | 'Finished' | 'Discarded';
36
+ export type DocumentTrackingAction = 'Created' | 'Updated' | 'Submitted' | 'Visaed' | 'Signed' | 'Rejected' | 'Finished' | 'Discarded' | 'Numbered' | 'NumberAnnulled' | 'Annulled' | 'Delivered' | 'Derived';
36
37
  export declare const DocumentTrackingAction: {
37
38
  Created: "Created";
38
39
  Updated: "Updated";
@@ -42,12 +43,35 @@ export declare const DocumentTrackingAction: {
42
43
  Rejected: "Rejected";
43
44
  Finished: "Finished";
44
45
  Discarded: "Discarded";
46
+ Numbered: "Numbered";
47
+ NumberAnnulled: "NumberAnnulled";
48
+ Annulled: "Annulled";
49
+ Delivered: "Delivered";
50
+ Derived: "Derived";
45
51
  };
46
52
  export type DocumentAttachmentType = 'File' | 'Link';
47
53
  export declare const DocumentAttachmentType: {
48
54
  File: "File";
49
55
  Link: "Link";
50
56
  };
57
+ export type DocumentRecipientType = 'Employee' | 'Directorate' | 'Department';
58
+ export declare const DocumentRecipientType: {
59
+ Employee: "Employee";
60
+ Directorate: "Directorate";
61
+ Department: "Department";
62
+ };
63
+ export type DocumentDeliveryOrigin = 'Recipient' | 'Derivation';
64
+ export declare const DocumentDeliveryOrigin: {
65
+ Recipient: "Recipient";
66
+ Derivation: "Derivation";
67
+ };
68
+ export type DocumentInstruction = 'Knowledge' | 'Inform' | 'Respond' | 'Archive';
69
+ export declare const DocumentInstruction: {
70
+ Knowledge: "Knowledge";
71
+ Inform: "Inform";
72
+ Respond: "Respond";
73
+ Archive: "Archive";
74
+ };
51
75
  export interface DocumentTypeEntity {
52
76
  id: string;
53
77
  name: string;
@@ -60,6 +84,7 @@ export interface DocumentTypeEntity {
60
84
  directorateCodeReference?: number | null;
61
85
  enabled: boolean;
62
86
  documents?: DocumentEntity[];
87
+ annulledNumbers?: DocumentAnnulledNumberEntity[];
63
88
  deleted: boolean;
64
89
  createdAt: string;
65
90
  updatedAt: string;
@@ -74,6 +99,14 @@ export interface DocumentEntity {
74
99
  correlative?: number | null;
75
100
  correlativeYear?: number | null;
76
101
  numberedAt?: string | null;
102
+ verificationCode?: string | null;
103
+ signatureSheet: boolean;
104
+ annulledAt?: string | null;
105
+ annulmentReason?: string | null;
106
+ responseDueAt?: string | null;
107
+ replyTo?: DocumentEntity | null;
108
+ replyToDocumentId?: string | null;
109
+ replies?: DocumentEntity[];
77
110
  directorateCodeReference?: number | null;
78
111
  departmentId?: string | null;
79
112
  createdByEmployeeId: string;
@@ -89,6 +122,9 @@ export interface DocumentEntity {
89
122
  participants?: DocumentParticipantEntity[];
90
123
  attachments?: DocumentAttachmentEntity[];
91
124
  trackings?: DocumentTrackingEntity[];
125
+ annulledNumbers?: DocumentAnnulledNumberEntity[];
126
+ recipients?: DocumentRecipientEntity[];
127
+ deliveries?: DocumentDeliveryEntity[];
92
128
  deleted: boolean;
93
129
  createdAt: string;
94
130
  updatedAt: string;
@@ -130,3 +166,48 @@ export interface DocumentTrackingEntity {
130
166
  documentId: string;
131
167
  createdAt: string;
132
168
  }
169
+ export interface DocumentAnnulledNumberEntity {
170
+ id: string;
171
+ correlative: number;
172
+ correlativeYear: number;
173
+ reason: string;
174
+ employeeId: string;
175
+ employeeFullName: string;
176
+ documentType?: DocumentTypeEntity;
177
+ documentTypeId: string;
178
+ document?: DocumentEntity;
179
+ documentId: string;
180
+ createdAt: string;
181
+ }
182
+ export interface DocumentRecipientEntity {
183
+ id: string;
184
+ type: DocumentRecipientType;
185
+ employeeId?: string | null;
186
+ directorateCodeReference?: number | null;
187
+ departmentId?: string | null;
188
+ name: string;
189
+ position?: string | null;
190
+ document?: DocumentEntity;
191
+ documentId: string;
192
+ createdAt: string;
193
+ }
194
+ export interface DocumentDeliveryEntity {
195
+ id: string;
196
+ origin: DocumentDeliveryOrigin;
197
+ employeeId: string;
198
+ fullName: string;
199
+ position?: string | null;
200
+ areaName?: string | null;
201
+ sentByEmployeeId?: string | null;
202
+ sentByFullName?: string | null;
203
+ instruction?: DocumentInstruction | null;
204
+ note?: string | null;
205
+ dueAt?: string | null;
206
+ deliveredAt?: string | null;
207
+ readAt?: string | null;
208
+ closedAt?: string | null;
209
+ closingNote?: string | null;
210
+ document?: DocumentEntity;
211
+ documentId: string;
212
+ createdAt: string;
213
+ }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by prisma-generator-typescript-interfaces
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.DocumentAttachmentType = exports.DocumentTrackingAction = exports.DocumentParticipantStatus = exports.DocumentParticipantRole = exports.DocumentAccessLevel = exports.DocumentStatus = exports.DocumentCategory = void 0;
4
+ exports.DocumentInstruction = exports.DocumentDeliveryOrigin = exports.DocumentRecipientType = exports.DocumentAttachmentType = exports.DocumentTrackingAction = exports.DocumentParticipantStatus = exports.DocumentParticipantRole = exports.DocumentAccessLevel = exports.DocumentStatus = exports.DocumentCategory = void 0;
5
5
  exports.DocumentCategory = {
6
6
  Decree: 'Decree',
7
7
  Communication: 'Communication',
@@ -14,6 +14,7 @@ exports.DocumentStatus = {
14
14
  Finished: 'Finished',
15
15
  Rejected: 'Rejected',
16
16
  Discarded: 'Discarded',
17
+ Annulled: 'Annulled',
17
18
  };
18
19
  exports.DocumentAccessLevel = {
19
20
  Public: 'Public',
@@ -40,8 +41,28 @@ exports.DocumentTrackingAction = {
40
41
  Rejected: 'Rejected',
41
42
  Finished: 'Finished',
42
43
  Discarded: 'Discarded',
44
+ Numbered: 'Numbered',
45
+ NumberAnnulled: 'NumberAnnulled',
46
+ Annulled: 'Annulled',
47
+ Delivered: 'Delivered',
48
+ Derived: 'Derived',
43
49
  };
44
50
  exports.DocumentAttachmentType = {
45
51
  File: 'File',
46
52
  Link: 'Link',
47
53
  };
54
+ exports.DocumentRecipientType = {
55
+ Employee: 'Employee',
56
+ Directorate: 'Directorate',
57
+ Department: 'Department',
58
+ };
59
+ exports.DocumentDeliveryOrigin = {
60
+ Recipient: 'Recipient',
61
+ Derivation: 'Derivation',
62
+ };
63
+ exports.DocumentInstruction = {
64
+ Knowledge: 'Knowledge',
65
+ Inform: 'Inform',
66
+ Respond: 'Respond',
67
+ Archive: 'Archive',
68
+ };
@@ -1,15 +1,21 @@
1
- import { type DocumentAccessLevel, type DocumentAttachmentEntity, type DocumentEntity, type DocumentStatus } from '../base/entities';
2
- import { type DocumentCreateResponseEntity, type DocumentDiscardResponseEntity, type DocumentGetAllResponseEntity, type DocumentGetByIdResponseEntity, type DocumentGetSummaryResponseEntity, type DocumentReviewResponseEntity, type DocumentUpdateResponseEntity } from '../entities';
1
+ import { type DocumentAccessLevel, type DocumentAttachmentEntity, type DocumentDeliveryEntity, type DocumentEntity, type DocumentInstruction, 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 DocumentReviewResponseEntity, 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: {
6
6
  readonly getAll: "gestorDocumental.document.getAll";
7
+ readonly getInbox: "gestorDocumental.document.getInbox";
7
8
  readonly getSummary: "gestorDocumental.document.getSummary";
8
9
  readonly getById: "gestorDocumental.document.getById";
9
10
  readonly create: "gestorDocumental.document.create";
10
11
  readonly update: "gestorDocumental.document.update";
11
12
  readonly review: "gestorDocumental.document.review";
12
13
  readonly discard: "gestorDocumental.document.discard";
14
+ readonly annul: "gestorDocumental.document.annul";
15
+ readonly derive: "gestorDocumental.document.derive";
16
+ readonly closeDelivery: "gestorDocumental.document.closeDelivery";
17
+ readonly verify: "gestorDocumental.document.verify";
18
+ readonly getPublicFile: "gestorDocumental.document.getPublicFile";
13
19
  readonly getFilesFolder: "gestorDocumental.document.getFilesFolder";
14
20
  };
15
21
  /**
@@ -22,7 +28,27 @@ export interface DocumentActor {
22
28
  departmentIds: string[];
23
29
  }
24
30
  /** Bandeja desde la que se lista. Todas son del funcionario (`actor`), salvo `all`. */
25
- export type DocumentBucket = 'created' | 'toVisa' | 'toSign' | 'participated' | 'all';
31
+ export type DocumentBucket = 'created' | 'sent' | 'toVisa' | 'toSign' | 'participated' | 'all';
32
+ /**
33
+ * Destinatario de un documento o de una derivación: una persona o un área completa. El gateway resuelve el nombre del
34
+ * área y quiénes la integran hoy; el navegador solo indica cuál es.
35
+ */
36
+ export type DocumentRecipientInput = {
37
+ type: 'Employee';
38
+ employeeId: string;
39
+ } | {
40
+ type: 'Directorate';
41
+ directorateCodeReference: number;
42
+ name: string;
43
+ memberEmployeeIds: string[];
44
+ } | {
45
+ type: 'Department';
46
+ departmentId: string;
47
+ name: string;
48
+ memberEmployeeIds: string[];
49
+ };
50
+ /** Qué parte de la bandeja de recibidos se lista: lo que falta atender, lo ya atendido, o todo. */
51
+ export type DocumentInboxState = 'pending' | 'closed' | 'all';
26
52
  /** Qué hace con el documento quien tiene el turno. */
27
53
  export type DocumentReviewAction = 'Visa' | 'Sign' | 'Reject';
28
54
  /**
@@ -42,6 +68,10 @@ export interface DocumentWritePayload extends Pick<DocumentEntity, 'subject' | '
42
68
  attachments?: Pick<DocumentAttachmentEntity, 'name' | 'type' | 'fileId' | 'url'>[];
43
69
  visaEmployeeIds: string[];
44
70
  signatureEmployeeIds: string[];
71
+ signatureSheet?: boolean;
72
+ recipients?: DocumentRecipientInput[];
73
+ responseDueAt?: string | null;
74
+ replyToDocumentId?: string | null;
45
75
  action?: 'Submit';
46
76
  actor: DocumentActor;
47
77
  }
@@ -67,6 +97,21 @@ export interface DocumentContract {
67
97
  };
68
98
  response: RpcPage<DocumentGetAllResponseEntity[]>;
69
99
  };
100
+ /** Bandeja de recibidos de un funcionario: lo que le llegó como destinatario o por derivación. */
101
+ [DocumentPatterns.getInbox]: {
102
+ payload: {
103
+ pagination?: {
104
+ page?: number;
105
+ limit?: number;
106
+ };
107
+ filters?: {
108
+ search?: string;
109
+ state?: DocumentInboxState;
110
+ };
111
+ actor: DocumentActor;
112
+ };
113
+ response: RpcPage<DocumentInboxItemEntity[]>;
114
+ };
70
115
  [DocumentPatterns.getSummary]: {
71
116
  payload: {
72
117
  actor: DocumentActor;
@@ -109,6 +154,53 @@ export interface DocumentContract {
109
154
  };
110
155
  response: DocumentDiscardResponseEntity;
111
156
  };
157
+ /** Deja sin efecto un documento ya finalizado. Conserva su número, que no se reutiliza. */
158
+ [DocumentPatterns.annul]: {
159
+ payload: Pick<DocumentEntity, 'id'> & {
160
+ reason: string;
161
+ actor: DocumentActor;
162
+ };
163
+ response: DocumentAnnulResponseEntity;
164
+ };
165
+ /**
166
+ * Deriva un documento finalizado a otros funcionarios o áreas, con su providencia (qué se espera de ellos) y,
167
+ * si corresponde, un plazo. Puede hacerlo quien lo tiene a su alcance: su redactor, quien lo visó o firmó, quien lo
168
+ * recibió y, con `viewAll`, quien consulta el historial.
169
+ */
170
+ [DocumentPatterns.derive]: {
171
+ payload: Pick<DocumentEntity, 'id'> & {
172
+ recipients: DocumentRecipientInput[];
173
+ instruction: DocumentInstruction;
174
+ note?: string | null;
175
+ dueAt?: string | null;
176
+ actor: DocumentActor;
177
+ viewAll?: boolean;
178
+ };
179
+ response: DocumentDeriveResponseEntity;
180
+ };
181
+ /** Quien recibió un documento lo marca como atendido, con una nota opcional. */
182
+ [DocumentPatterns.closeDelivery]: {
183
+ payload: {
184
+ deliveryId: DocumentDeliveryEntity['id'];
185
+ note?: string | null;
186
+ actor: DocumentActor;
187
+ };
188
+ response: DocumentCloseDeliveryResponseEntity;
189
+ };
190
+ /** Comprobación pública de un documento con el código que lleva impreso. No exige sesión. */
191
+ [DocumentPatterns.verify]: {
192
+ payload: {
193
+ code: string;
194
+ };
195
+ response: DocumentVerifyResponseEntity;
196
+ };
197
+ /** Archivo de un documento finalizado y de acceso público, para quien lo verificó con su código. */
198
+ [DocumentPatterns.getPublicFile]: {
199
+ payload: {
200
+ code: string;
201
+ };
202
+ response: DocumentPublicFileResponseEntity;
203
+ };
112
204
  /** Carpeta de Drive de los documentos y sus anexos: el gateway la pide antes de subir cada archivo. */
113
205
  [DocumentPatterns.getFilesFolder]: {
114
206
  payload: Record<string, never>;
@@ -4,11 +4,17 @@ exports.DocumentPatterns = void 0;
4
4
  /** Patrones NATS de `document`: `<servicio>.<recurso>.<acción>`. */
5
5
  exports.DocumentPatterns = {
6
6
  getAll: 'gestorDocumental.document.getAll',
7
+ getInbox: 'gestorDocumental.document.getInbox',
7
8
  getSummary: 'gestorDocumental.document.getSummary',
8
9
  getById: 'gestorDocumental.document.getById',
9
10
  create: 'gestorDocumental.document.create',
10
11
  update: 'gestorDocumental.document.update',
11
12
  review: 'gestorDocumental.document.review',
12
13
  discard: 'gestorDocumental.document.discard',
14
+ annul: 'gestorDocumental.document.annul',
15
+ derive: 'gestorDocumental.document.derive',
16
+ closeDelivery: 'gestorDocumental.document.closeDelivery',
17
+ verify: 'gestorDocumental.document.verify',
18
+ getPublicFile: 'gestorDocumental.document.getPublicFile',
13
19
  getFilesFolder: 'gestorDocumental.document.getFilesFolder',
14
20
  };
@@ -14,12 +14,18 @@ export declare const GestorDocumentalPatterns: {
14
14
  };
15
15
  readonly document: {
16
16
  readonly getAll: "gestorDocumental.document.getAll";
17
+ readonly getInbox: "gestorDocumental.document.getInbox";
17
18
  readonly getSummary: "gestorDocumental.document.getSummary";
18
19
  readonly getById: "gestorDocumental.document.getById";
19
20
  readonly create: "gestorDocumental.document.create";
20
21
  readonly update: "gestorDocumental.document.update";
21
22
  readonly review: "gestorDocumental.document.review";
22
23
  readonly discard: "gestorDocumental.document.discard";
24
+ readonly annul: "gestorDocumental.document.annul";
25
+ readonly derive: "gestorDocumental.document.derive";
26
+ readonly closeDelivery: "gestorDocumental.document.closeDelivery";
27
+ readonly verify: "gestorDocumental.document.verify";
28
+ readonly getPublicFile: "gestorDocumental.document.getPublicFile";
23
29
  readonly getFilesFolder: "gestorDocumental.document.getFilesFolder";
24
30
  };
25
31
  };
@@ -1,4 +1,4 @@
1
- import { DocumentAttachmentEntity, DocumentEntity, DocumentParticipantEntity, DocumentTrackingEntity, DocumentTypeEntity } from '../../base/entities';
1
+ import { DocumentAnnulledNumberEntity, DocumentAttachmentEntity, DocumentDeliveryEntity, DocumentEntity, DocumentParticipantEntity, DocumentRecipientEntity, DocumentTrackingEntity, DocumentTypeEntity } from '../../base/entities';
2
2
  /** Tipo documental de un documento, con lo necesario para citarlo. */
3
3
  export interface DocumentTypeSummaryEntity {
4
4
  id: DocumentTypeEntity['id'];
@@ -17,6 +17,45 @@ export interface DocumentParticipantResponseEntity {
17
17
  observation: DocumentParticipantEntity['observation'];
18
18
  resolvedAt: DocumentParticipantEntity['resolvedAt'];
19
19
  }
20
+ /** Destinatario de un documento, como lo eligió el redactor: una persona o un área completa. */
21
+ export interface DocumentRecipientResponseEntity {
22
+ id: DocumentRecipientEntity['id'];
23
+ type: DocumentRecipientEntity['type'];
24
+ employeeId: DocumentRecipientEntity['employeeId'];
25
+ directorateCodeReference: DocumentRecipientEntity['directorateCodeReference'];
26
+ departmentId: DocumentRecipientEntity['departmentId'];
27
+ name: DocumentRecipientEntity['name'];
28
+ position: DocumentRecipientEntity['position'];
29
+ }
30
+ /** Un documento en la bandeja de un funcionario: como destinatario o porque se lo derivaron. */
31
+ export interface DocumentDeliveryResponseEntity {
32
+ id: DocumentDeliveryEntity['id'];
33
+ origin: DocumentDeliveryEntity['origin'];
34
+ employeeId: DocumentDeliveryEntity['employeeId'];
35
+ fullName: DocumentDeliveryEntity['fullName'];
36
+ position: DocumentDeliveryEntity['position'];
37
+ areaName: DocumentDeliveryEntity['areaName'];
38
+ sentByEmployeeId: DocumentDeliveryEntity['sentByEmployeeId'];
39
+ sentByFullName: DocumentDeliveryEntity['sentByFullName'];
40
+ instruction: DocumentDeliveryEntity['instruction'];
41
+ note: DocumentDeliveryEntity['note'];
42
+ dueAt: DocumentDeliveryEntity['dueAt'];
43
+ deliveredAt: DocumentDeliveryEntity['deliveredAt'];
44
+ readAt: DocumentDeliveryEntity['readAt'];
45
+ closedAt: DocumentDeliveryEntity['closedAt'];
46
+ closingNote: DocumentDeliveryEntity['closingNote'];
47
+ }
48
+ /** Lo necesario para citar otro documento y enlazarlo (el que se responde, o las respuestas). */
49
+ export interface DocumentLinkEntity {
50
+ id: DocumentEntity['id'];
51
+ subject: DocumentEntity['subject'];
52
+ status: DocumentEntity['status'];
53
+ correlative: DocumentEntity['correlative'];
54
+ correlativeYear: DocumentEntity['correlativeYear'];
55
+ createdByFullName: DocumentEntity['createdByFullName'];
56
+ finishedAt: DocumentEntity['finishedAt'];
57
+ documentType: DocumentTypeSummaryEntity;
58
+ }
20
59
  export interface DocumentGetAllResponseEntity {
21
60
  id: DocumentEntity['id'];
22
61
  subject: DocumentEntity['subject'];
@@ -31,6 +70,14 @@ export interface DocumentGetAllResponseEntity {
31
70
  createdByFullName: DocumentEntity['createdByFullName'];
32
71
  documentType: DocumentTypeSummaryEntity;
33
72
  currentParticipant: Pick<DocumentParticipantResponseEntity, 'role' | 'employeeId' | 'fullName'> | null;
73
+ distribution: {
74
+ total: number;
75
+ read: number;
76
+ } | null;
77
+ }
78
+ /** Una entrada de la bandeja de recibidos: la entrega y el documento al que corresponde. */
79
+ export interface DocumentInboxItemEntity extends DocumentDeliveryResponseEntity {
80
+ document: DocumentLinkEntity;
34
81
  }
35
82
  export interface DocumentGetByIdResponseEntity {
36
83
  id: DocumentEntity['id'];
@@ -52,6 +99,23 @@ export interface DocumentGetByIdResponseEntity {
52
99
  createdAt: DocumentEntity['createdAt'];
53
100
  submittedAt: DocumentEntity['submittedAt'];
54
101
  finishedAt: DocumentEntity['finishedAt'];
102
+ verificationCode: DocumentEntity['verificationCode'];
103
+ verificationUrl: string | null;
104
+ signatureSheet: DocumentEntity['signatureSheet'];
105
+ annulledAt: DocumentEntity['annulledAt'];
106
+ annulmentReason: DocumentEntity['annulmentReason'];
107
+ annulledNumbers: {
108
+ correlative: DocumentAnnulledNumberEntity['correlative'];
109
+ correlativeYear: DocumentAnnulledNumberEntity['correlativeYear'];
110
+ reason: DocumentAnnulledNumberEntity['reason'];
111
+ employeeFullName: DocumentAnnulledNumberEntity['employeeFullName'];
112
+ createdAt: DocumentAnnulledNumberEntity['createdAt'];
113
+ }[];
114
+ responseDueAt: DocumentEntity['responseDueAt'];
115
+ recipients: DocumentRecipientResponseEntity[];
116
+ deliveries: DocumentDeliveryResponseEntity[];
117
+ replyTo: DocumentLinkEntity | null;
118
+ replies: DocumentLinkEntity[];
55
119
  documentType: DocumentTypeSummaryEntity;
56
120
  participants: DocumentParticipantResponseEntity[];
57
121
  attachments: {
@@ -73,6 +137,9 @@ export interface DocumentGetByIdResponseEntity {
73
137
  turn: Pick<DocumentParticipantResponseEntity, 'id' | 'role'> | null;
74
138
  canEdit: boolean;
75
139
  canDiscard: boolean;
140
+ canDerive: boolean;
141
+ canReply: boolean;
142
+ inbox: DocumentDeliveryResponseEntity[];
76
143
  };
77
144
  signatureRequiresOtp: boolean;
78
145
  }
@@ -86,6 +153,11 @@ export interface DocumentGetSummaryResponseEntity {
86
153
  rejected: number;
87
154
  finished: number;
88
155
  };
156
+ received: {
157
+ unread: number;
158
+ pending: number;
159
+ overdue: number;
160
+ };
89
161
  }
90
162
  export interface DocumentCreateResponseEntity {
91
163
  id: DocumentEntity['id'];
@@ -104,3 +176,49 @@ export interface DocumentDiscardResponseEntity {
104
176
  id: DocumentEntity['id'];
105
177
  ok: boolean;
106
178
  }
179
+ export interface DocumentAnnulResponseEntity {
180
+ id: DocumentEntity['id'];
181
+ ok: boolean;
182
+ }
183
+ /**
184
+ * Qué se le dice a quien comprueba un documento con su código, sin sesión:
185
+ * - `Finished`: es un documento oficial vigente;
186
+ * - `Annulled`: lo fue, pero quedó sin efecto;
187
+ * - `InProgress`: todavía se está firmando, así que la copia que tiene no es el documento oficial.
188
+ */
189
+ export type DocumentVerificationState = 'Finished' | 'Annulled' | 'InProgress';
190
+ /**
191
+ * Respuesta pública de la verificación. Dice lo necesario para comprobar la autenticidad (tipo, número, fecha y
192
+ * quiénes firmaron); la materia y la descarga solo se entregan si el documento es de acceso público.
193
+ */
194
+ export interface DocumentVerifyResponseEntity {
195
+ state: DocumentVerificationState;
196
+ verificationCode: string;
197
+ documentType: Pick<DocumentTypeSummaryEntity, 'name' | 'abbreviation'>;
198
+ correlative: DocumentEntity['correlative'];
199
+ correlativeYear: DocumentEntity['correlativeYear'];
200
+ numberedAt: DocumentEntity['numberedAt'];
201
+ finishedAt: DocumentEntity['finishedAt'];
202
+ annulledAt: DocumentEntity['annulledAt'];
203
+ signers: {
204
+ fullName: DocumentParticipantEntity['fullName'];
205
+ position: DocumentParticipantEntity['position'];
206
+ signedAt: DocumentParticipantEntity['resolvedAt'];
207
+ }[];
208
+ subject: DocumentEntity['subject'] | null;
209
+ canDownload: boolean;
210
+ }
211
+ /** Archivo de un documento público, para que el gateway lo entregue a quien lo verifica. */
212
+ export interface DocumentPublicFileResponseEntity {
213
+ fileId: string;
214
+ fileName: string;
215
+ }
216
+ export interface DocumentDeriveResponseEntity {
217
+ id: DocumentEntity['id'];
218
+ ok: boolean;
219
+ delivered: number;
220
+ }
221
+ export interface DocumentCloseDeliveryResponseEntity {
222
+ id: DocumentDeliveryEntity['id'];
223
+ ok: boolean;
224
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muni-sanfer/types-gestor-documental",
3
- "version": "0.0.1-beta.0",
3
+ "version": "0.0.1-beta.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -8,7 +8,8 @@ export const DocumentCategory = {
8
8
  Other: 'Other',
9
9
  } satisfies Record<string, DocumentCategory>;
10
10
 
11
- export type DocumentStatus = 'Drafted' | 'PendingVisa' | 'PendingSignature' | 'Finished' | 'Rejected' | 'Discarded';
11
+ export type DocumentStatus =
12
+ 'Drafted' | 'PendingVisa' | 'PendingSignature' | 'Finished' | 'Rejected' | 'Discarded' | 'Annulled';
12
13
 
13
14
  export const DocumentStatus = {
14
15
  Drafted: 'Drafted',
@@ -17,6 +18,7 @@ export const DocumentStatus = {
17
18
  Finished: 'Finished',
18
19
  Rejected: 'Rejected',
19
20
  Discarded: 'Discarded',
21
+ Annulled: 'Annulled',
20
22
  } satisfies Record<string, DocumentStatus>;
21
23
 
22
24
  export type DocumentAccessLevel = 'Public' | 'Restricted' | 'Secret' | 'Reserved';
@@ -45,7 +47,19 @@ export const DocumentParticipantStatus = {
45
47
  } satisfies Record<string, DocumentParticipantStatus>;
46
48
 
47
49
  export type DocumentTrackingAction =
48
- 'Created' | 'Updated' | 'Submitted' | 'Visaed' | 'Signed' | 'Rejected' | 'Finished' | 'Discarded';
50
+ | 'Created'
51
+ | 'Updated'
52
+ | 'Submitted'
53
+ | 'Visaed'
54
+ | 'Signed'
55
+ | 'Rejected'
56
+ | 'Finished'
57
+ | 'Discarded'
58
+ | 'Numbered'
59
+ | 'NumberAnnulled'
60
+ | 'Annulled'
61
+ | 'Delivered'
62
+ | 'Derived';
49
63
 
50
64
  export const DocumentTrackingAction = {
51
65
  Created: 'Created',
@@ -56,6 +70,11 @@ export const DocumentTrackingAction = {
56
70
  Rejected: 'Rejected',
57
71
  Finished: 'Finished',
58
72
  Discarded: 'Discarded',
73
+ Numbered: 'Numbered',
74
+ NumberAnnulled: 'NumberAnnulled',
75
+ Annulled: 'Annulled',
76
+ Delivered: 'Delivered',
77
+ Derived: 'Derived',
59
78
  } satisfies Record<string, DocumentTrackingAction>;
60
79
 
61
80
  export type DocumentAttachmentType = 'File' | 'Link';
@@ -65,6 +84,30 @@ export const DocumentAttachmentType = {
65
84
  Link: 'Link',
66
85
  } satisfies Record<string, DocumentAttachmentType>;
67
86
 
87
+ export type DocumentRecipientType = 'Employee' | 'Directorate' | 'Department';
88
+
89
+ export const DocumentRecipientType = {
90
+ Employee: 'Employee',
91
+ Directorate: 'Directorate',
92
+ Department: 'Department',
93
+ } satisfies Record<string, DocumentRecipientType>;
94
+
95
+ export type DocumentDeliveryOrigin = 'Recipient' | 'Derivation';
96
+
97
+ export const DocumentDeliveryOrigin = {
98
+ Recipient: 'Recipient',
99
+ Derivation: 'Derivation',
100
+ } satisfies Record<string, DocumentDeliveryOrigin>;
101
+
102
+ export type DocumentInstruction = 'Knowledge' | 'Inform' | 'Respond' | 'Archive';
103
+
104
+ export const DocumentInstruction = {
105
+ Knowledge: 'Knowledge',
106
+ Inform: 'Inform',
107
+ Respond: 'Respond',
108
+ Archive: 'Archive',
109
+ } satisfies Record<string, DocumentInstruction>;
110
+
68
111
  export interface DocumentTypeEntity {
69
112
  id: string;
70
113
  name: string;
@@ -77,6 +120,7 @@ export interface DocumentTypeEntity {
77
120
  directorateCodeReference?: number | null;
78
121
  enabled: boolean;
79
122
  documents?: DocumentEntity[];
123
+ annulledNumbers?: DocumentAnnulledNumberEntity[];
80
124
  deleted: boolean;
81
125
  createdAt: string;
82
126
  updatedAt: string;
@@ -92,6 +136,14 @@ export interface DocumentEntity {
92
136
  correlative?: number | null;
93
137
  correlativeYear?: number | null;
94
138
  numberedAt?: string | null;
139
+ verificationCode?: string | null;
140
+ signatureSheet: boolean;
141
+ annulledAt?: string | null;
142
+ annulmentReason?: string | null;
143
+ responseDueAt?: string | null;
144
+ replyTo?: DocumentEntity | null;
145
+ replyToDocumentId?: string | null;
146
+ replies?: DocumentEntity[];
95
147
  directorateCodeReference?: number | null;
96
148
  departmentId?: string | null;
97
149
  createdByEmployeeId: string;
@@ -107,6 +159,9 @@ export interface DocumentEntity {
107
159
  participants?: DocumentParticipantEntity[];
108
160
  attachments?: DocumentAttachmentEntity[];
109
161
  trackings?: DocumentTrackingEntity[];
162
+ annulledNumbers?: DocumentAnnulledNumberEntity[];
163
+ recipients?: DocumentRecipientEntity[];
164
+ deliveries?: DocumentDeliveryEntity[];
110
165
  deleted: boolean;
111
166
  createdAt: string;
112
167
  updatedAt: string;
@@ -151,3 +206,51 @@ export interface DocumentTrackingEntity {
151
206
  documentId: string;
152
207
  createdAt: string;
153
208
  }
209
+
210
+ export interface DocumentAnnulledNumberEntity {
211
+ id: string;
212
+ correlative: number;
213
+ correlativeYear: number;
214
+ reason: string;
215
+ employeeId: string;
216
+ employeeFullName: string;
217
+ documentType?: DocumentTypeEntity;
218
+ documentTypeId: string;
219
+ document?: DocumentEntity;
220
+ documentId: string;
221
+ createdAt: string;
222
+ }
223
+
224
+ export interface DocumentRecipientEntity {
225
+ id: string;
226
+ type: DocumentRecipientType;
227
+ employeeId?: string | null;
228
+ directorateCodeReference?: number | null;
229
+ departmentId?: string | null;
230
+ name: string;
231
+ position?: string | null;
232
+ document?: DocumentEntity;
233
+ documentId: string;
234
+ createdAt: string;
235
+ }
236
+
237
+ export interface DocumentDeliveryEntity {
238
+ id: string;
239
+ origin: DocumentDeliveryOrigin;
240
+ employeeId: string;
241
+ fullName: string;
242
+ position?: string | null;
243
+ areaName?: string | null;
244
+ sentByEmployeeId?: string | null;
245
+ sentByFullName?: string | null;
246
+ instruction?: DocumentInstruction | null;
247
+ note?: string | null;
248
+ dueAt?: string | null;
249
+ deliveredAt?: string | null;
250
+ readAt?: string | null;
251
+ closedAt?: string | null;
252
+ closingNote?: string | null;
253
+ document?: DocumentEntity;
254
+ documentId: string;
255
+ createdAt: string;
256
+ }
@@ -1,29 +1,43 @@
1
1
  import {
2
2
  type DocumentAccessLevel,
3
3
  type DocumentAttachmentEntity,
4
+ type DocumentDeliveryEntity,
4
5
  type DocumentEntity,
6
+ type DocumentInstruction,
5
7
  type DocumentStatus,
6
8
  } from '../base/entities';
7
9
  import {
10
+ type DocumentAnnulResponseEntity,
11
+ type DocumentCloseDeliveryResponseEntity,
8
12
  type DocumentCreateResponseEntity,
13
+ type DocumentDeriveResponseEntity,
9
14
  type DocumentDiscardResponseEntity,
10
15
  type DocumentGetAllResponseEntity,
11
16
  type DocumentGetByIdResponseEntity,
12
17
  type DocumentGetSummaryResponseEntity,
18
+ type DocumentInboxItemEntity,
19
+ type DocumentPublicFileResponseEntity,
13
20
  type DocumentReviewResponseEntity,
14
21
  type DocumentUpdateResponseEntity,
22
+ type DocumentVerifyResponseEntity,
15
23
  } from '../entities';
16
24
  import { type RpcPage } from './contract';
17
25
 
18
26
  /** Patrones NATS de `document`: `<servicio>.<recurso>.<acción>`. */
19
27
  export const DocumentPatterns = {
20
28
  getAll: 'gestorDocumental.document.getAll',
29
+ getInbox: 'gestorDocumental.document.getInbox',
21
30
  getSummary: 'gestorDocumental.document.getSummary',
22
31
  getById: 'gestorDocumental.document.getById',
23
32
  create: 'gestorDocumental.document.create',
24
33
  update: 'gestorDocumental.document.update',
25
34
  review: 'gestorDocumental.document.review',
26
35
  discard: 'gestorDocumental.document.discard',
36
+ annul: 'gestorDocumental.document.annul',
37
+ derive: 'gestorDocumental.document.derive',
38
+ closeDelivery: 'gestorDocumental.document.closeDelivery',
39
+ verify: 'gestorDocumental.document.verify',
40
+ getPublicFile: 'gestorDocumental.document.getPublicFile',
27
41
  getFilesFolder: 'gestorDocumental.document.getFilesFolder',
28
42
  } as const;
29
43
 
@@ -40,11 +54,24 @@ export interface DocumentActor {
40
54
  /** Bandeja desde la que se lista. Todas son del funcionario (`actor`), salvo `all`. */
41
55
  export type DocumentBucket =
42
56
  | 'created' // los que redactó
57
+ | 'sent' // de los que redactó, los ya finalizados que tienen destinatarios
43
58
  | 'toVisa' // le toca visarlos
44
59
  | 'toSign' // le toca firmarlos
45
60
  | 'participated' // ya los visó, firmó o rechazó
46
61
  | 'all'; // todos los que están en tramitación o finalizados (historial)
47
62
 
63
+ /**
64
+ * Destinatario de un documento o de una derivación: una persona o un área completa. El gateway resuelve el nombre del
65
+ * área y quiénes la integran hoy; el navegador solo indica cuál es.
66
+ */
67
+ export type DocumentRecipientInput =
68
+ | { type: 'Employee'; employeeId: string }
69
+ | { type: 'Directorate'; directorateCodeReference: number; name: string; memberEmployeeIds: string[] }
70
+ | { type: 'Department'; departmentId: string; name: string; memberEmployeeIds: string[] };
71
+
72
+ /** Qué parte de la bandeja de recibidos se lista: lo que falta atender, lo ya atendido, o todo. */
73
+ export type DocumentInboxState = 'pending' | 'closed' | 'all';
74
+
48
75
  /** Qué hace con el documento quien tiene el turno. */
49
76
  export type DocumentReviewAction = 'Visa' | 'Sign' | 'Reject';
50
77
 
@@ -64,6 +91,14 @@ export interface DocumentWritePayload extends Pick<DocumentEntity, 'subject' | '
64
91
  // Funcionarios que visan y que firman, en el orden en que les toca. Primero visan todos y después firman.
65
92
  visaEmployeeIds: string[];
66
93
  signatureEmployeeIds: string[];
94
+ // Firmas y visaciones en una hoja aparte al final, en vez de al pie de la última página.
95
+ signatureSheet?: boolean;
96
+ // A quién va dirigido: le llega a su bandeja cuando el documento termina su tramitación.
97
+ recipients?: DocumentRecipientInput[];
98
+ // Plazo en que se espera respuesta de los destinatarios (ISO 8601).
99
+ responseDueAt?: string | null;
100
+ // Documento al que este responde.
101
+ replyToDocumentId?: string | null;
67
102
  action?: 'Submit';
68
103
  actor: DocumentActor;
69
104
  }
@@ -89,6 +124,15 @@ export interface DocumentContract {
89
124
  };
90
125
  response: RpcPage<DocumentGetAllResponseEntity[]>;
91
126
  };
127
+ /** Bandeja de recibidos de un funcionario: lo que le llegó como destinatario o por derivación. */
128
+ [DocumentPatterns.getInbox]: {
129
+ payload: {
130
+ pagination?: { page?: number; limit?: number };
131
+ filters?: { search?: string; state?: DocumentInboxState };
132
+ actor: DocumentActor;
133
+ };
134
+ response: RpcPage<DocumentInboxItemEntity[]>;
135
+ };
92
136
  [DocumentPatterns.getSummary]: {
93
137
  payload: { actor: DocumentActor };
94
138
  response: DocumentGetSummaryResponseEntity;
@@ -125,6 +169,43 @@ export interface DocumentContract {
125
169
  payload: Pick<DocumentEntity, 'id'> & { actor: DocumentActor };
126
170
  response: DocumentDiscardResponseEntity;
127
171
  };
172
+ /** Deja sin efecto un documento ya finalizado. Conserva su número, que no se reutiliza. */
173
+ [DocumentPatterns.annul]: {
174
+ payload: Pick<DocumentEntity, 'id'> & { reason: string; actor: DocumentActor };
175
+ response: DocumentAnnulResponseEntity;
176
+ };
177
+ /**
178
+ * Deriva un documento finalizado a otros funcionarios o áreas, con su providencia (qué se espera de ellos) y,
179
+ * si corresponde, un plazo. Puede hacerlo quien lo tiene a su alcance: su redactor, quien lo visó o firmó, quien lo
180
+ * recibió y, con `viewAll`, quien consulta el historial.
181
+ */
182
+ [DocumentPatterns.derive]: {
183
+ payload: Pick<DocumentEntity, 'id'> & {
184
+ recipients: DocumentRecipientInput[];
185
+ instruction: DocumentInstruction;
186
+ note?: string | null;
187
+ // Plazo para atenderlo (ISO 8601).
188
+ dueAt?: string | null;
189
+ actor: DocumentActor;
190
+ viewAll?: boolean;
191
+ };
192
+ response: DocumentDeriveResponseEntity;
193
+ };
194
+ /** Quien recibió un documento lo marca como atendido, con una nota opcional. */
195
+ [DocumentPatterns.closeDelivery]: {
196
+ payload: { deliveryId: DocumentDeliveryEntity['id']; note?: string | null; actor: DocumentActor };
197
+ response: DocumentCloseDeliveryResponseEntity;
198
+ };
199
+ /** Comprobación pública de un documento con el código que lleva impreso. No exige sesión. */
200
+ [DocumentPatterns.verify]: {
201
+ payload: { code: string };
202
+ response: DocumentVerifyResponseEntity;
203
+ };
204
+ /** Archivo de un documento finalizado y de acceso público, para quien lo verificó con su código. */
205
+ [DocumentPatterns.getPublicFile]: {
206
+ payload: { code: string };
207
+ response: DocumentPublicFileResponseEntity;
208
+ };
128
209
  /** Carpeta de Drive de los documentos y sus anexos: el gateway la pide antes de subir cada archivo. */
129
210
  [DocumentPatterns.getFilesFolder]: {
130
211
  payload: Record<string, never>;
@@ -1,7 +1,10 @@
1
1
  import {
2
+ DocumentAnnulledNumberEntity,
2
3
  DocumentAttachmentEntity,
4
+ DocumentDeliveryEntity,
3
5
  DocumentEntity,
4
6
  DocumentParticipantEntity,
7
+ DocumentRecipientEntity,
5
8
  DocumentTrackingEntity,
6
9
  DocumentTypeEntity,
7
10
  } from '../../base/entities';
@@ -26,6 +29,51 @@ export interface DocumentParticipantResponseEntity {
26
29
  resolvedAt: DocumentParticipantEntity['resolvedAt'];
27
30
  }
28
31
 
32
+ /** Destinatario de un documento, como lo eligió el redactor: una persona o un área completa. */
33
+ export interface DocumentRecipientResponseEntity {
34
+ id: DocumentRecipientEntity['id'];
35
+ type: DocumentRecipientEntity['type'];
36
+ employeeId: DocumentRecipientEntity['employeeId'];
37
+ directorateCodeReference: DocumentRecipientEntity['directorateCodeReference'];
38
+ departmentId: DocumentRecipientEntity['departmentId'];
39
+ name: DocumentRecipientEntity['name'];
40
+ position: DocumentRecipientEntity['position'];
41
+ }
42
+
43
+ /** Un documento en la bandeja de un funcionario: como destinatario o porque se lo derivaron. */
44
+ export interface DocumentDeliveryResponseEntity {
45
+ id: DocumentDeliveryEntity['id'];
46
+ origin: DocumentDeliveryEntity['origin'];
47
+ employeeId: DocumentDeliveryEntity['employeeId'];
48
+ fullName: DocumentDeliveryEntity['fullName'];
49
+ position: DocumentDeliveryEntity['position'];
50
+ // Área por la que le llegó, si el documento iba dirigido a un área.
51
+ areaName: DocumentDeliveryEntity['areaName'];
52
+ // Quién se lo derivó. Null si es uno de los destinatarios originales.
53
+ sentByEmployeeId: DocumentDeliveryEntity['sentByEmployeeId'];
54
+ sentByFullName: DocumentDeliveryEntity['sentByFullName'];
55
+ instruction: DocumentDeliveryEntity['instruction'];
56
+ note: DocumentDeliveryEntity['note'];
57
+ dueAt: DocumentDeliveryEntity['dueAt'];
58
+ // Null mientras el documento no termina su tramitación.
59
+ deliveredAt: DocumentDeliveryEntity['deliveredAt'];
60
+ readAt: DocumentDeliveryEntity['readAt'];
61
+ closedAt: DocumentDeliveryEntity['closedAt'];
62
+ closingNote: DocumentDeliveryEntity['closingNote'];
63
+ }
64
+
65
+ /** Lo necesario para citar otro documento y enlazarlo (el que se responde, o las respuestas). */
66
+ export interface DocumentLinkEntity {
67
+ id: DocumentEntity['id'];
68
+ subject: DocumentEntity['subject'];
69
+ status: DocumentEntity['status'];
70
+ correlative: DocumentEntity['correlative'];
71
+ correlativeYear: DocumentEntity['correlativeYear'];
72
+ createdByFullName: DocumentEntity['createdByFullName'];
73
+ finishedAt: DocumentEntity['finishedAt'];
74
+ documentType: DocumentTypeSummaryEntity;
75
+ }
76
+
29
77
  export interface DocumentGetAllResponseEntity {
30
78
  id: DocumentEntity['id'];
31
79
  subject: DocumentEntity['subject'];
@@ -41,6 +89,13 @@ export interface DocumentGetAllResponseEntity {
41
89
  documentType: DocumentTypeSummaryEntity;
42
90
  // A quién le toca visar o firmar (null si el documento no está en tramitación).
43
91
  currentParticipant: Pick<DocumentParticipantResponseEntity, 'role' | 'employeeId' | 'fullName'> | null;
92
+ // A cuántos funcionarios llegó y cuántos ya lo abrieron (null si aún no se distribuye a nadie).
93
+ distribution: { total: number; read: number } | null;
94
+ }
95
+
96
+ /** Una entrada de la bandeja de recibidos: la entrega y el documento al que corresponde. */
97
+ export interface DocumentInboxItemEntity extends DocumentDeliveryResponseEntity {
98
+ document: DocumentLinkEntity;
44
99
  }
45
100
 
46
101
  export interface DocumentGetByIdResponseEntity {
@@ -64,6 +119,32 @@ export interface DocumentGetByIdResponseEntity {
64
119
  createdAt: DocumentEntity['createdAt'];
65
120
  submittedAt: DocumentEntity['submittedAt'];
66
121
  finishedAt: DocumentEntity['finishedAt'];
122
+ // Código con que se comprueba el documento en la página pública. Null mientras no se envía a tramitación.
123
+ verificationCode: DocumentEntity['verificationCode'];
124
+ // Dirección de esa página para este documento. Null si el servicio no la tiene configurada.
125
+ verificationUrl: string | null;
126
+ // El redactor pidió una hoja aparte para firmas y visaciones.
127
+ signatureSheet: DocumentEntity['signatureSheet'];
128
+ // Anulación de un documento ya finalizado.
129
+ annulledAt: DocumentEntity['annulledAt'];
130
+ annulmentReason: DocumentEntity['annulmentReason'];
131
+ // Números que el documento tuvo y perdió: lo rechazaron cuando ya estaba numerado.
132
+ annulledNumbers: {
133
+ correlative: DocumentAnnulledNumberEntity['correlative'];
134
+ correlativeYear: DocumentAnnulledNumberEntity['correlativeYear'];
135
+ reason: DocumentAnnulledNumberEntity['reason'];
136
+ employeeFullName: DocumentAnnulledNumberEntity['employeeFullName'];
137
+ createdAt: DocumentAnnulledNumberEntity['createdAt'];
138
+ }[];
139
+ // Plazo en que el redactor espera respuesta de los destinatarios.
140
+ responseDueAt: DocumentEntity['responseDueAt'];
141
+ // A quién va dirigido, como lo indicó el redactor (personas y áreas).
142
+ recipients: DocumentRecipientResponseEntity[];
143
+ // En la bandeja de quién está: destinatarios y derivaciones, con su lectura y atención.
144
+ deliveries: DocumentDeliveryResponseEntity[];
145
+ // Documento al que este responde, y los que le responden (solo los ya finalizados, más los propios de quien consulta).
146
+ replyTo: DocumentLinkEntity | null;
147
+ replies: DocumentLinkEntity[];
67
148
  documentType: DocumentTypeSummaryEntity;
68
149
  participants: DocumentParticipantResponseEntity[];
69
150
  attachments: {
@@ -87,6 +168,11 @@ export interface DocumentGetByIdResponseEntity {
87
168
  turn: Pick<DocumentParticipantResponseEntity, 'id' | 'role'> | null;
88
169
  canEdit: boolean;
89
170
  canDiscard: boolean;
171
+ // Puede derivarlo a otros funcionarios y responderlo: el documento ya es oficial y está a su alcance.
172
+ canDerive: boolean;
173
+ canReply: boolean;
174
+ // Sus propias entregas de este documento (puede tener más de una si además se lo derivaron).
175
+ inbox: DocumentDeliveryResponseEntity[];
90
176
  };
91
177
  // Firmar exige el código OTP de quien firma (firma atendida).
92
178
  signatureRequiresOtp: boolean;
@@ -102,6 +188,12 @@ export interface DocumentGetSummaryResponseEntity {
102
188
  rejected: number;
103
189
  finished: number;
104
190
  };
191
+ // Su bandeja de recibidos: sin abrir, sin atender y, de estos, con el plazo vencido.
192
+ received: {
193
+ unread: number;
194
+ pending: number;
195
+ overdue: number;
196
+ };
105
197
  }
106
198
 
107
199
  export interface DocumentCreateResponseEntity {
@@ -124,3 +216,58 @@ export interface DocumentDiscardResponseEntity {
124
216
  id: DocumentEntity['id'];
125
217
  ok: boolean;
126
218
  }
219
+
220
+ export interface DocumentAnnulResponseEntity {
221
+ id: DocumentEntity['id'];
222
+ ok: boolean;
223
+ }
224
+
225
+ /**
226
+ * Qué se le dice a quien comprueba un documento con su código, sin sesión:
227
+ * - `Finished`: es un documento oficial vigente;
228
+ * - `Annulled`: lo fue, pero quedó sin efecto;
229
+ * - `InProgress`: todavía se está firmando, así que la copia que tiene no es el documento oficial.
230
+ */
231
+ export type DocumentVerificationState = 'Finished' | 'Annulled' | 'InProgress';
232
+
233
+ /**
234
+ * Respuesta pública de la verificación. Dice lo necesario para comprobar la autenticidad (tipo, número, fecha y
235
+ * quiénes firmaron); la materia y la descarga solo se entregan si el documento es de acceso público.
236
+ */
237
+ export interface DocumentVerifyResponseEntity {
238
+ state: DocumentVerificationState;
239
+ verificationCode: string;
240
+ documentType: Pick<DocumentTypeSummaryEntity, 'name' | 'abbreviation'>;
241
+ correlative: DocumentEntity['correlative'];
242
+ correlativeYear: DocumentEntity['correlativeYear'];
243
+ numberedAt: DocumentEntity['numberedAt'];
244
+ finishedAt: DocumentEntity['finishedAt'];
245
+ annulledAt: DocumentEntity['annulledAt'];
246
+ // Quiénes firmaron (o deben firmar, si aún está en tramitación), en su orden.
247
+ signers: {
248
+ fullName: DocumentParticipantEntity['fullName'];
249
+ position: DocumentParticipantEntity['position'];
250
+ signedAt: DocumentParticipantEntity['resolvedAt'];
251
+ }[];
252
+ // Solo en documentos de acceso público y sin datos sensibles.
253
+ subject: DocumentEntity['subject'] | null;
254
+ canDownload: boolean;
255
+ }
256
+
257
+ /** Archivo de un documento público, para que el gateway lo entregue a quien lo verifica. */
258
+ export interface DocumentPublicFileResponseEntity {
259
+ fileId: string;
260
+ fileName: string;
261
+ }
262
+
263
+ export interface DocumentDeriveResponseEntity {
264
+ id: DocumentEntity['id'];
265
+ ok: boolean;
266
+ // A cuántos funcionarios llegó la derivación.
267
+ delivered: number;
268
+ }
269
+
270
+ export interface DocumentCloseDeliveryResponseEntity {
271
+ id: DocumentDeliveryEntity['id'];
272
+ ok: boolean;
273
+ }