@muni-sanfer/types-gestor-documental 0.0.1-beta.1 → 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.
@@ -33,7 +33,7 @@ export declare const DocumentParticipantStatus: {
33
33
  Resolved: "Resolved";
34
34
  Rejected: "Rejected";
35
35
  };
36
- export type DocumentTrackingAction = 'Created' | 'Updated' | 'Submitted' | 'Visaed' | 'Signed' | 'Rejected' | 'Finished' | 'Discarded' | 'Numbered' | 'NumberAnnulled' | 'Annulled';
36
+ export type DocumentTrackingAction = 'Created' | 'Updated' | 'Submitted' | 'Visaed' | 'Signed' | 'Rejected' | 'Finished' | 'Discarded' | 'Numbered' | 'NumberAnnulled' | 'Annulled' | 'Delivered' | 'Derived';
37
37
  export declare const DocumentTrackingAction: {
38
38
  Created: "Created";
39
39
  Updated: "Updated";
@@ -46,12 +46,32 @@ export declare const DocumentTrackingAction: {
46
46
  Numbered: "Numbered";
47
47
  NumberAnnulled: "NumberAnnulled";
48
48
  Annulled: "Annulled";
49
+ Delivered: "Delivered";
50
+ Derived: "Derived";
49
51
  };
50
52
  export type DocumentAttachmentType = 'File' | 'Link';
51
53
  export declare const DocumentAttachmentType: {
52
54
  File: "File";
53
55
  Link: "Link";
54
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
+ };
55
75
  export interface DocumentTypeEntity {
56
76
  id: string;
57
77
  name: string;
@@ -83,6 +103,10 @@ export interface DocumentEntity {
83
103
  signatureSheet: boolean;
84
104
  annulledAt?: string | null;
85
105
  annulmentReason?: string | null;
106
+ responseDueAt?: string | null;
107
+ replyTo?: DocumentEntity | null;
108
+ replyToDocumentId?: string | null;
109
+ replies?: DocumentEntity[];
86
110
  directorateCodeReference?: number | null;
87
111
  departmentId?: string | null;
88
112
  createdByEmployeeId: string;
@@ -99,6 +123,8 @@ export interface DocumentEntity {
99
123
  attachments?: DocumentAttachmentEntity[];
100
124
  trackings?: DocumentTrackingEntity[];
101
125
  annulledNumbers?: DocumentAnnulledNumberEntity[];
126
+ recipients?: DocumentRecipientEntity[];
127
+ deliveries?: DocumentDeliveryEntity[];
102
128
  deleted: boolean;
103
129
  createdAt: string;
104
130
  updatedAt: string;
@@ -153,3 +179,35 @@ export interface DocumentAnnulledNumberEntity {
153
179
  documentId: string;
154
180
  createdAt: string;
155
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',
@@ -44,8 +44,25 @@ exports.DocumentTrackingAction = {
44
44
  Numbered: 'Numbered',
45
45
  NumberAnnulled: 'NumberAnnulled',
46
46
  Annulled: 'Annulled',
47
+ Delivered: 'Delivered',
48
+ Derived: 'Derived',
47
49
  };
48
50
  exports.DocumentAttachmentType = {
49
51
  File: 'File',
50
52
  Link: 'Link',
51
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,9 +1,10 @@
1
- import { type DocumentAccessLevel, type DocumentAttachmentEntity, type DocumentEntity, type DocumentStatus } from '../base/entities';
2
- import { type DocumentAnnulResponseEntity, type DocumentCreateResponseEntity, type DocumentDiscardResponseEntity, type DocumentGetAllResponseEntity, type DocumentGetByIdResponseEntity, type DocumentGetSummaryResponseEntity, type DocumentPublicFileResponseEntity, type DocumentReviewResponseEntity, type DocumentUpdateResponseEntity, type DocumentVerifyResponseEntity } 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";
@@ -11,6 +12,8 @@ export declare const DocumentPatterns: {
11
12
  readonly review: "gestorDocumental.document.review";
12
13
  readonly discard: "gestorDocumental.document.discard";
13
14
  readonly annul: "gestorDocumental.document.annul";
15
+ readonly derive: "gestorDocumental.document.derive";
16
+ readonly closeDelivery: "gestorDocumental.document.closeDelivery";
14
17
  readonly verify: "gestorDocumental.document.verify";
15
18
  readonly getPublicFile: "gestorDocumental.document.getPublicFile";
16
19
  readonly getFilesFolder: "gestorDocumental.document.getFilesFolder";
@@ -25,7 +28,27 @@ export interface DocumentActor {
25
28
  departmentIds: string[];
26
29
  }
27
30
  /** Bandeja desde la que se lista. Todas son del funcionario (`actor`), salvo `all`. */
28
- 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';
29
52
  /** Qué hace con el documento quien tiene el turno. */
30
53
  export type DocumentReviewAction = 'Visa' | 'Sign' | 'Reject';
31
54
  /**
@@ -46,6 +69,9 @@ export interface DocumentWritePayload extends Pick<DocumentEntity, 'subject' | '
46
69
  visaEmployeeIds: string[];
47
70
  signatureEmployeeIds: string[];
48
71
  signatureSheet?: boolean;
72
+ recipients?: DocumentRecipientInput[];
73
+ responseDueAt?: string | null;
74
+ replyToDocumentId?: string | null;
49
75
  action?: 'Submit';
50
76
  actor: DocumentActor;
51
77
  }
@@ -71,6 +97,21 @@ export interface DocumentContract {
71
97
  };
72
98
  response: RpcPage<DocumentGetAllResponseEntity[]>;
73
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
+ };
74
115
  [DocumentPatterns.getSummary]: {
75
116
  payload: {
76
117
  actor: DocumentActor;
@@ -121,6 +162,31 @@ export interface DocumentContract {
121
162
  };
122
163
  response: DocumentAnnulResponseEntity;
123
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
+ };
124
190
  /** Comprobación pública de un documento con el código que lleva impreso. No exige sesión. */
125
191
  [DocumentPatterns.verify]: {
126
192
  payload: {
@@ -4,6 +4,7 @@ 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',
@@ -11,6 +12,8 @@ exports.DocumentPatterns = {
11
12
  review: 'gestorDocumental.document.review',
12
13
  discard: 'gestorDocumental.document.discard',
13
14
  annul: 'gestorDocumental.document.annul',
15
+ derive: 'gestorDocumental.document.derive',
16
+ closeDelivery: 'gestorDocumental.document.closeDelivery',
14
17
  verify: 'gestorDocumental.document.verify',
15
18
  getPublicFile: 'gestorDocumental.document.getPublicFile',
16
19
  getFilesFolder: 'gestorDocumental.document.getFilesFolder',
@@ -14,6 +14,7 @@ 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";
@@ -21,6 +22,8 @@ export declare const GestorDocumentalPatterns: {
21
22
  readonly review: "gestorDocumental.document.review";
22
23
  readonly discard: "gestorDocumental.document.discard";
23
24
  readonly annul: "gestorDocumental.document.annul";
25
+ readonly derive: "gestorDocumental.document.derive";
26
+ readonly closeDelivery: "gestorDocumental.document.closeDelivery";
24
27
  readonly verify: "gestorDocumental.document.verify";
25
28
  readonly getPublicFile: "gestorDocumental.document.getPublicFile";
26
29
  readonly getFilesFolder: "gestorDocumental.document.getFilesFolder";
@@ -1,4 +1,4 @@
1
- import { DocumentAnnulledNumberEntity, 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'];
@@ -64,6 +111,11 @@ export interface DocumentGetByIdResponseEntity {
64
111
  employeeFullName: DocumentAnnulledNumberEntity['employeeFullName'];
65
112
  createdAt: DocumentAnnulledNumberEntity['createdAt'];
66
113
  }[];
114
+ responseDueAt: DocumentEntity['responseDueAt'];
115
+ recipients: DocumentRecipientResponseEntity[];
116
+ deliveries: DocumentDeliveryResponseEntity[];
117
+ replyTo: DocumentLinkEntity | null;
118
+ replies: DocumentLinkEntity[];
67
119
  documentType: DocumentTypeSummaryEntity;
68
120
  participants: DocumentParticipantResponseEntity[];
69
121
  attachments: {
@@ -85,6 +137,9 @@ export interface DocumentGetByIdResponseEntity {
85
137
  turn: Pick<DocumentParticipantResponseEntity, 'id' | 'role'> | null;
86
138
  canEdit: boolean;
87
139
  canDiscard: boolean;
140
+ canDerive: boolean;
141
+ canReply: boolean;
142
+ inbox: DocumentDeliveryResponseEntity[];
88
143
  };
89
144
  signatureRequiresOtp: boolean;
90
145
  }
@@ -98,6 +153,11 @@ export interface DocumentGetSummaryResponseEntity {
98
153
  rejected: number;
99
154
  finished: number;
100
155
  };
156
+ received: {
157
+ unread: number;
158
+ pending: number;
159
+ overdue: number;
160
+ };
101
161
  }
102
162
  export interface DocumentCreateResponseEntity {
103
163
  id: DocumentEntity['id'];
@@ -153,3 +213,12 @@ export interface DocumentPublicFileResponseEntity {
153
213
  fileId: string;
154
214
  fileName: string;
155
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.1",
3
+ "version": "0.0.1-beta.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -57,7 +57,9 @@ export type DocumentTrackingAction =
57
57
  | 'Discarded'
58
58
  | 'Numbered'
59
59
  | 'NumberAnnulled'
60
- | 'Annulled';
60
+ | 'Annulled'
61
+ | 'Delivered'
62
+ | 'Derived';
61
63
 
62
64
  export const DocumentTrackingAction = {
63
65
  Created: 'Created',
@@ -71,6 +73,8 @@ export const DocumentTrackingAction = {
71
73
  Numbered: 'Numbered',
72
74
  NumberAnnulled: 'NumberAnnulled',
73
75
  Annulled: 'Annulled',
76
+ Delivered: 'Delivered',
77
+ Derived: 'Derived',
74
78
  } satisfies Record<string, DocumentTrackingAction>;
75
79
 
76
80
  export type DocumentAttachmentType = 'File' | 'Link';
@@ -80,6 +84,30 @@ export const DocumentAttachmentType = {
80
84
  Link: 'Link',
81
85
  } satisfies Record<string, DocumentAttachmentType>;
82
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
+
83
111
  export interface DocumentTypeEntity {
84
112
  id: string;
85
113
  name: string;
@@ -112,6 +140,10 @@ export interface DocumentEntity {
112
140
  signatureSheet: boolean;
113
141
  annulledAt?: string | null;
114
142
  annulmentReason?: string | null;
143
+ responseDueAt?: string | null;
144
+ replyTo?: DocumentEntity | null;
145
+ replyToDocumentId?: string | null;
146
+ replies?: DocumentEntity[];
115
147
  directorateCodeReference?: number | null;
116
148
  departmentId?: string | null;
117
149
  createdByEmployeeId: string;
@@ -128,6 +160,8 @@ export interface DocumentEntity {
128
160
  attachments?: DocumentAttachmentEntity[];
129
161
  trackings?: DocumentTrackingEntity[];
130
162
  annulledNumbers?: DocumentAnnulledNumberEntity[];
163
+ recipients?: DocumentRecipientEntity[];
164
+ deliveries?: DocumentDeliveryEntity[];
131
165
  deleted: boolean;
132
166
  createdAt: string;
133
167
  updatedAt: string;
@@ -186,3 +220,37 @@ export interface DocumentAnnulledNumberEntity {
186
220
  documentId: string;
187
221
  createdAt: string;
188
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,16 +1,21 @@
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 {
8
10
  type DocumentAnnulResponseEntity,
11
+ type DocumentCloseDeliveryResponseEntity,
9
12
  type DocumentCreateResponseEntity,
13
+ type DocumentDeriveResponseEntity,
10
14
  type DocumentDiscardResponseEntity,
11
15
  type DocumentGetAllResponseEntity,
12
16
  type DocumentGetByIdResponseEntity,
13
17
  type DocumentGetSummaryResponseEntity,
18
+ type DocumentInboxItemEntity,
14
19
  type DocumentPublicFileResponseEntity,
15
20
  type DocumentReviewResponseEntity,
16
21
  type DocumentUpdateResponseEntity,
@@ -21,6 +26,7 @@ import { type RpcPage } from './contract';
21
26
  /** Patrones NATS de `document`: `<servicio>.<recurso>.<acción>`. */
22
27
  export const DocumentPatterns = {
23
28
  getAll: 'gestorDocumental.document.getAll',
29
+ getInbox: 'gestorDocumental.document.getInbox',
24
30
  getSummary: 'gestorDocumental.document.getSummary',
25
31
  getById: 'gestorDocumental.document.getById',
26
32
  create: 'gestorDocumental.document.create',
@@ -28,6 +34,8 @@ export const DocumentPatterns = {
28
34
  review: 'gestorDocumental.document.review',
29
35
  discard: 'gestorDocumental.document.discard',
30
36
  annul: 'gestorDocumental.document.annul',
37
+ derive: 'gestorDocumental.document.derive',
38
+ closeDelivery: 'gestorDocumental.document.closeDelivery',
31
39
  verify: 'gestorDocumental.document.verify',
32
40
  getPublicFile: 'gestorDocumental.document.getPublicFile',
33
41
  getFilesFolder: 'gestorDocumental.document.getFilesFolder',
@@ -46,11 +54,24 @@ export interface DocumentActor {
46
54
  /** Bandeja desde la que se lista. Todas son del funcionario (`actor`), salvo `all`. */
47
55
  export type DocumentBucket =
48
56
  | 'created' // los que redactó
57
+ | 'sent' // de los que redactó, los ya finalizados que tienen destinatarios
49
58
  | 'toVisa' // le toca visarlos
50
59
  | 'toSign' // le toca firmarlos
51
60
  | 'participated' // ya los visó, firmó o rechazó
52
61
  | 'all'; // todos los que están en tramitación o finalizados (historial)
53
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
+
54
75
  /** Qué hace con el documento quien tiene el turno. */
55
76
  export type DocumentReviewAction = 'Visa' | 'Sign' | 'Reject';
56
77
 
@@ -72,6 +93,12 @@ export interface DocumentWritePayload extends Pick<DocumentEntity, 'subject' | '
72
93
  signatureEmployeeIds: string[];
73
94
  // Firmas y visaciones en una hoja aparte al final, en vez de al pie de la última página.
74
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;
75
102
  action?: 'Submit';
76
103
  actor: DocumentActor;
77
104
  }
@@ -97,6 +124,15 @@ export interface DocumentContract {
97
124
  };
98
125
  response: RpcPage<DocumentGetAllResponseEntity[]>;
99
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
+ };
100
136
  [DocumentPatterns.getSummary]: {
101
137
  payload: { actor: DocumentActor };
102
138
  response: DocumentGetSummaryResponseEntity;
@@ -138,6 +174,28 @@ export interface DocumentContract {
138
174
  payload: Pick<DocumentEntity, 'id'> & { reason: string; actor: DocumentActor };
139
175
  response: DocumentAnnulResponseEntity;
140
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
+ };
141
199
  /** Comprobación pública de un documento con el código que lleva impreso. No exige sesión. */
142
200
  [DocumentPatterns.verify]: {
143
201
  payload: { code: string };
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  DocumentAnnulledNumberEntity,
3
3
  DocumentAttachmentEntity,
4
+ DocumentDeliveryEntity,
4
5
  DocumentEntity,
5
6
  DocumentParticipantEntity,
7
+ DocumentRecipientEntity,
6
8
  DocumentTrackingEntity,
7
9
  DocumentTypeEntity,
8
10
  } from '../../base/entities';
@@ -27,6 +29,51 @@ export interface DocumentParticipantResponseEntity {
27
29
  resolvedAt: DocumentParticipantEntity['resolvedAt'];
28
30
  }
29
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
+
30
77
  export interface DocumentGetAllResponseEntity {
31
78
  id: DocumentEntity['id'];
32
79
  subject: DocumentEntity['subject'];
@@ -42,6 +89,13 @@ export interface DocumentGetAllResponseEntity {
42
89
  documentType: DocumentTypeSummaryEntity;
43
90
  // A quién le toca visar o firmar (null si el documento no está en tramitación).
44
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;
45
99
  }
46
100
 
47
101
  export interface DocumentGetByIdResponseEntity {
@@ -82,6 +136,15 @@ export interface DocumentGetByIdResponseEntity {
82
136
  employeeFullName: DocumentAnnulledNumberEntity['employeeFullName'];
83
137
  createdAt: DocumentAnnulledNumberEntity['createdAt'];
84
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[];
85
148
  documentType: DocumentTypeSummaryEntity;
86
149
  participants: DocumentParticipantResponseEntity[];
87
150
  attachments: {
@@ -105,6 +168,11 @@ export interface DocumentGetByIdResponseEntity {
105
168
  turn: Pick<DocumentParticipantResponseEntity, 'id' | 'role'> | null;
106
169
  canEdit: boolean;
107
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[];
108
176
  };
109
177
  // Firmar exige el código OTP de quien firma (firma atendida).
110
178
  signatureRequiresOtp: boolean;
@@ -120,6 +188,12 @@ export interface DocumentGetSummaryResponseEntity {
120
188
  rejected: number;
121
189
  finished: number;
122
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
+ };
123
197
  }
124
198
 
125
199
  export interface DocumentCreateResponseEntity {
@@ -185,3 +259,15 @@ export interface DocumentPublicFileResponseEntity {
185
259
  fileId: string;
186
260
  fileName: string;
187
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
+ }