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

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.
@@ -0,0 +1,169 @@
1
+ import { CaseFileAccessEntity, CaseFileActorEntity, CaseFileEntity, CaseFileEntryEntity, CaseFileMetadataChangeEntity, CaseFileParticipantEntity, CaseFileTrackingEntity, DocumentEntity, ProcedureEntity } from '../../base/entities';
2
+ import { DocumentTypeSummaryEntity } from '../document';
3
+ /** Expediente al que se hace referencia desde otro lado: cómo se cita y en qué estado está. */
4
+ export interface CaseFileLinkEntity {
5
+ id: CaseFileEntity['id'];
6
+ code: CaseFileEntity['code'];
7
+ title: CaseFileEntity['title'];
8
+ status: CaseFileEntity['status'];
9
+ }
10
+ export interface CaseFileGetAllResponseEntity extends CaseFileLinkEntity {
11
+ subject: CaseFileEntity['subject'];
12
+ accessLevel: CaseFileEntity['accessLevel'];
13
+ hasSensitiveData: CaseFileEntity['hasSensitiveData'];
14
+ procedure: Pick<ProcedureEntity, 'id' | 'name'>;
15
+ responsibleEmployeeId: CaseFileEntity['responsibleEmployeeId'];
16
+ responsibleFullName: CaseFileEntity['responsibleFullName'];
17
+ /** Actuaciones vigentes del índice (las que quedaron sin efecto no cuentan). */
18
+ entries: number;
19
+ participants: number;
20
+ createdAt: CaseFileEntity['createdAt'];
21
+ closedAt: CaseFileEntity['closedAt'];
22
+ }
23
+ /** Documento del gestor incorporado al expediente. */
24
+ export interface CaseFileEntryDocumentEntity {
25
+ id: DocumentEntity['id'];
26
+ subject: DocumentEntity['subject'];
27
+ status: DocumentEntity['status'];
28
+ correlative: DocumentEntity['correlative'];
29
+ correlativeYear: DocumentEntity['correlativeYear'];
30
+ documentType: DocumentTypeSummaryEntity;
31
+ }
32
+ /** Entrada del índice electrónico: una actuación, en su orden de incorporación. */
33
+ export interface CaseFileEntryResponseEntity {
34
+ id: CaseFileEntryEntity['id'];
35
+ sequence: CaseFileEntryEntity['sequence'];
36
+ kind: CaseFileEntryEntity['kind'];
37
+ actuationType: CaseFileEntryEntity['actuationType'];
38
+ title: CaseFileEntryEntity['title'];
39
+ document: CaseFileEntryDocumentEntity | null;
40
+ fileName: CaseFileEntryEntity['fileName'];
41
+ documentTypeName: CaseFileEntryEntity['documentTypeName'];
42
+ originDate: CaseFileEntryEntity['originDate'];
43
+ author: CaseFileEntryEntity['author'];
44
+ keywords: CaseFileEntryEntity['keywords'];
45
+ accessLevel: CaseFileEntryEntity['accessLevel'];
46
+ hasSensitiveData: CaseFileEntryEntity['hasSensitiveData'];
47
+ linkedCaseFile: CaseFileLinkEntity | null;
48
+ /** `true` si la entrada tiene un archivo que se puede abrir (un documento o un archivo subido). */
49
+ hasFile: boolean;
50
+ sha256: CaseFileEntryEntity['sha256'];
51
+ size: CaseFileEntryEntity['size'];
52
+ hasAdvancedSignature: CaseFileEntryEntity['hasAdvancedSignature'];
53
+ incorporatedByEmployeeId: CaseFileEntryEntity['incorporatedByEmployeeId'];
54
+ incorporatedByFullName: CaseFileEntryEntity['incorporatedByFullName'];
55
+ createdAt: CaseFileEntryEntity['createdAt'];
56
+ voidedAt: CaseFileEntryEntity['voidedAt'];
57
+ voidedByFullName: CaseFileEntryEntity['voidedByFullName'];
58
+ voidReason: CaseFileEntryEntity['voidReason'];
59
+ /** `true` si quien consulta puede dejarla sin efecto: el responsable o quien la incorporó, con el expediente abierto. */
60
+ canVoid: boolean;
61
+ }
62
+ export interface CaseFileParticipantResponseEntity {
63
+ id: CaseFileParticipantEntity['id'];
64
+ employeeId: CaseFileParticipantEntity['employeeId'];
65
+ fullName: CaseFileParticipantEntity['fullName'];
66
+ position: CaseFileParticipantEntity['position'];
67
+ addedByFullName: CaseFileParticipantEntity['addedByFullName'];
68
+ createdAt: CaseFileParticipantEntity['createdAt'];
69
+ }
70
+ export interface CaseFileActorResponseEntity {
71
+ id: CaseFileActorEntity['id'];
72
+ relation: CaseFileActorEntity['relation'];
73
+ actorType: CaseFileActorEntity['actorType'];
74
+ identifier: CaseFileActorEntity['identifier'];
75
+ name: CaseFileActorEntity['name'];
76
+ }
77
+ export interface CaseFileTrackingResponseEntity {
78
+ id: CaseFileTrackingEntity['id'];
79
+ action: CaseFileTrackingEntity['action'];
80
+ observation: CaseFileTrackingEntity['observation'];
81
+ employeeFullName: CaseFileTrackingEntity['employeeFullName'];
82
+ createdAt: CaseFileTrackingEntity['createdAt'];
83
+ }
84
+ export interface CaseFileMetadataChangeResponseEntity {
85
+ id: CaseFileMetadataChangeEntity['id'];
86
+ /** Código oficial del metadato. Ej: `MGDEE1_5`. */
87
+ field: CaseFileMetadataChangeEntity['field'];
88
+ previousValue: CaseFileMetadataChangeEntity['previousValue'];
89
+ newValue: CaseFileMetadataChangeEntity['newValue'];
90
+ employeeFullName: CaseFileMetadataChangeEntity['employeeFullName'];
91
+ createdAt: CaseFileMetadataChangeEntity['createdAt'];
92
+ }
93
+ export interface CaseFileAccessResponseEntity {
94
+ id: CaseFileAccessEntity['id'];
95
+ action: CaseFileAccessEntity['action'];
96
+ entryId: CaseFileAccessEntity['entryId'];
97
+ /** Título del documento que se abrió, si el acceso fue a uno. */
98
+ entryTitle: string | null;
99
+ employeeFullName: CaseFileAccessEntity['employeeFullName'];
100
+ createdAt: CaseFileAccessEntity['createdAt'];
101
+ }
102
+ export interface CaseFileGetByIdResponseEntity extends CaseFileGetAllResponseEntity {
103
+ summary: CaseFileEntity['summary'];
104
+ procedure: Pick<ProcedureEntity, 'id' | 'name' | 'cpatId' | 'cpatCode'>;
105
+ responsiblePosition: CaseFileEntity['responsiblePosition'];
106
+ incorporationMechanism: CaseFileEntity['incorporationMechanism'];
107
+ schemaVersion: CaseFileEntity['schemaVersion'];
108
+ /** Enlace persistente del expediente (MGDEE4_2). `null` si el servicio no tiene configurada la dirección. */
109
+ uri: string | null;
110
+ closedByFullName: CaseFileEntity['closedByFullName'];
111
+ closingNote: CaseFileEntity['closingNote'];
112
+ index: CaseFileEntryResponseEntity[];
113
+ sharedWith: CaseFileParticipantResponseEntity[];
114
+ actors: CaseFileActorResponseEntity[];
115
+ trackings: CaseFileTrackingResponseEntity[];
116
+ metadataChanges: CaseFileMetadataChangeResponseEntity[];
117
+ /** Registro de accesos. Solo lo recibe el responsable y quien puede ver todos los expedientes. */
118
+ accesses: CaseFileAccessResponseEntity[];
119
+ /** Qué puede hacer con el expediente quien lo consulta. Sin `actor` en la consulta, no viene. */
120
+ actorCapabilities?: {
121
+ isResponsible: boolean;
122
+ /** Editar sus metadatos y cerrarlo: el responsable, mientras esté abierto. */
123
+ canEdit: boolean;
124
+ /** Incorporar actuaciones: el responsable y aquellos con quienes se compartió, mientras esté abierto. */
125
+ canIncorporate: boolean;
126
+ /** Compartirlo con otros funcionarios: el responsable, también después de cerrado. */
127
+ canShare: boolean;
128
+ };
129
+ }
130
+ export interface CaseFileCreateResponseEntity {
131
+ id: CaseFileEntity['id'];
132
+ code: CaseFileEntity['code'];
133
+ ok: boolean;
134
+ }
135
+ export interface CaseFileUpdateResponseEntity {
136
+ id: CaseFileEntity['id'];
137
+ ok: boolean;
138
+ }
139
+ export interface CaseFileAddEntryResponseEntity {
140
+ id: CaseFileEntity['id'];
141
+ entryId: CaseFileEntryEntity['id'];
142
+ sequence: CaseFileEntryEntity['sequence'];
143
+ ok: boolean;
144
+ }
145
+ /** Archivo de una entrada del índice, para servirlo a quien puede ver el expediente. */
146
+ export interface CaseFileEntryFileResponseEntity {
147
+ fileId: string;
148
+ fileName: string;
149
+ }
150
+ /** Archivo que va dentro del expediente exportado, con la huella que tenía al incorporarse. */
151
+ export interface CaseFileExportFileEntity {
152
+ entryId: CaseFileEntryEntity['id'];
153
+ sequence: CaseFileEntryEntity['sequence'];
154
+ /** Ruta dentro del ZIP. Ej: `documentos/001-decreto-alcaldicio-exento-590-2026.pdf`. */
155
+ path: string;
156
+ fileId: string;
157
+ sha256: string | null;
158
+ }
159
+ /**
160
+ * Expediente listo para exportar: los metadatos con sus códigos oficiales (va tal cual como `expediente.json`) y los
161
+ * archivos que hay que agregar. El ZIP lo arma el gateway.
162
+ */
163
+ export interface CaseFileExportResponseEntity {
164
+ code: CaseFileEntity['code'];
165
+ manifest: Record<string, unknown>;
166
+ files: CaseFileExportFileEntity[];
167
+ }
168
+ /** Expediente en que está incorporado un documento, visto desde el documento. */
169
+ export type DocumentCaseFileEntity = CaseFileLinkEntity;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './caseFile.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("./caseFile.entity"), exports);
@@ -116,6 +116,13 @@ export interface DocumentGetByIdResponseEntity {
116
116
  deliveries: DocumentDeliveryResponseEntity[];
117
117
  replyTo: DocumentLinkEntity | null;
118
118
  replies: DocumentLinkEntity[];
119
+ /** Expedientes en que está incorporado y que quien consulta puede ver. */
120
+ caseFiles: {
121
+ id: string;
122
+ code: string;
123
+ title: string;
124
+ status: 'Open' | 'Closed';
125
+ }[];
119
126
  documentType: DocumentTypeSummaryEntity;
120
127
  participants: DocumentParticipantResponseEntity[];
121
128
  attachments: {
@@ -1,2 +1,4 @@
1
1
  export * from './documentType';
2
2
  export * from './document';
3
+ export * from './procedure';
4
+ export * from './caseFile';
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./documentType"), exports);
18
18
  __exportStar(require("./document"), exports);
19
+ __exportStar(require("./procedure"), exports);
20
+ __exportStar(require("./caseFile"), exports);
@@ -0,0 +1 @@
1
+ export * from './procedure.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("./procedure.entity"), exports);
@@ -0,0 +1,20 @@
1
+ import { ProcedureEntity } from '../../base/entities';
2
+ export interface ProcedureGetAllResponseEntity {
3
+ id: ProcedureEntity['id'];
4
+ name: ProcedureEntity['name'];
5
+ cpatId: ProcedureEntity['cpatId'];
6
+ cpatCode: ProcedureEntity['cpatCode'];
7
+ description: ProcedureEntity['description'];
8
+ enabled: ProcedureEntity['enabled'];
9
+ /** Cuántos expedientes pertenecen a este procedimiento. */
10
+ caseFiles: number;
11
+ }
12
+ export type ProcedureGetByIdResponseEntity = ProcedureGetAllResponseEntity;
13
+ export interface ProcedureCreateResponseEntity {
14
+ id: ProcedureEntity['id'];
15
+ ok: boolean;
16
+ }
17
+ export interface ProcedureUpdateResponseEntity {
18
+ id: ProcedureEntity['id'];
19
+ ok: boolean;
20
+ }
@@ -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.3",
3
+ "version": "0.0.1-beta.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -117,6 +117,101 @@ export const DocumentInstruction = {
117
117
  Archive: 'Archive',
118
118
  } satisfies Record<string, DocumentInstruction>;
119
119
 
120
+ export type CaseFileStatus = 'Open' | 'Closed';
121
+
122
+ export const CaseFileStatus = {
123
+ Open: 'Open',
124
+ Closed: 'Closed',
125
+ } satisfies Record<string, CaseFileStatus>;
126
+
127
+ export type CaseFileIncorporationMechanism =
128
+ 'Manual' | 'WebService' | 'Mixed' | 'CitizenRepository' | 'Interoperability';
129
+
130
+ export const CaseFileIncorporationMechanism = {
131
+ Manual: 'Manual',
132
+ WebService: 'WebService',
133
+ Mixed: 'Mixed',
134
+ CitizenRepository: 'CitizenRepository',
135
+ Interoperability: 'Interoperability',
136
+ } satisfies Record<string, CaseFileIncorporationMechanism>;
137
+
138
+ export type CaseFileActuationType =
139
+ | 'AdministrativeAct'
140
+ | 'Notification'
141
+ | 'OfficialCommunication'
142
+ | 'Interoperability'
143
+ | 'RequestReception'
144
+ | 'Subfolder'
145
+ | 'PowerRegistration';
146
+
147
+ export const CaseFileActuationType = {
148
+ AdministrativeAct: 'AdministrativeAct',
149
+ Notification: 'Notification',
150
+ OfficialCommunication: 'OfficialCommunication',
151
+ Interoperability: 'Interoperability',
152
+ RequestReception: 'RequestReception',
153
+ Subfolder: 'Subfolder',
154
+ PowerRegistration: 'PowerRegistration',
155
+ } satisfies Record<string, CaseFileActuationType>;
156
+
157
+ export type CaseFileEntryKind = 'Document' | 'File' | 'CaseFile';
158
+
159
+ export const CaseFileEntryKind = {
160
+ Document: 'Document',
161
+ File: 'File',
162
+ CaseFile: 'CaseFile',
163
+ } satisfies Record<string, CaseFileEntryKind>;
164
+
165
+ export type CaseFileActorRelation =
166
+ 'Responsible' | 'Interested' | 'Author' | 'Referred' | 'Recipient' | 'MinisterOfFaith';
167
+
168
+ export const CaseFileActorRelation = {
169
+ Responsible: 'Responsible',
170
+ Interested: 'Interested',
171
+ Author: 'Author',
172
+ Referred: 'Referred',
173
+ Recipient: 'Recipient',
174
+ MinisterOfFaith: 'MinisterOfFaith',
175
+ } satisfies Record<string, CaseFileActorRelation>;
176
+
177
+ export type CaseFileActorType = 'Citizen' | 'Foreigner' | 'PrivateInstitution' | 'Official';
178
+
179
+ export const CaseFileActorType = {
180
+ Citizen: 'Citizen',
181
+ Foreigner: 'Foreigner',
182
+ PrivateInstitution: 'PrivateInstitution',
183
+ Official: 'Official',
184
+ } satisfies Record<string, CaseFileActorType>;
185
+
186
+ export type CaseFileTrackingAction =
187
+ | 'Created'
188
+ | 'Updated'
189
+ | 'EntryAdded'
190
+ | 'EntryVoided'
191
+ | 'ParticipantAdded'
192
+ | 'ParticipantRemoved'
193
+ | 'Closed'
194
+ | 'Exported';
195
+
196
+ export const CaseFileTrackingAction = {
197
+ Created: 'Created',
198
+ Updated: 'Updated',
199
+ EntryAdded: 'EntryAdded',
200
+ EntryVoided: 'EntryVoided',
201
+ ParticipantAdded: 'ParticipantAdded',
202
+ ParticipantRemoved: 'ParticipantRemoved',
203
+ Closed: 'Closed',
204
+ Exported: 'Exported',
205
+ } satisfies Record<string, CaseFileTrackingAction>;
206
+
207
+ export type CaseFileAccessAction = 'Viewed' | 'FileDownloaded' | 'Exported';
208
+
209
+ export const CaseFileAccessAction = {
210
+ Viewed: 'Viewed',
211
+ FileDownloaded: 'FileDownloaded',
212
+ Exported: 'Exported',
213
+ } satisfies Record<string, CaseFileAccessAction>;
214
+
120
215
  export interface DocumentTypeEntity {
121
216
  id: string;
122
217
  name: string;
@@ -172,6 +267,7 @@ export interface DocumentEntity {
172
267
  annulledNumbers?: DocumentAnnulledNumberEntity[];
173
268
  recipients?: DocumentRecipientEntity[];
174
269
  deliveries?: DocumentDeliveryEntity[];
270
+ caseFileEntries?: CaseFileEntryEntity[];
175
271
  deleted: boolean;
176
272
  createdAt: string;
177
273
  updatedAt: string;
@@ -278,3 +374,143 @@ export interface DocumentTypeFlowStepEntity {
278
374
  documentTypeId: string;
279
375
  createdAt: string;
280
376
  }
377
+
378
+ export interface ProcedureEntity {
379
+ id: string;
380
+ name: string;
381
+ cpatId?: string | null;
382
+ cpatCode?: string | null;
383
+ description?: string | null;
384
+ enabled: boolean;
385
+ caseFiles?: CaseFileEntity[];
386
+ deleted: boolean;
387
+ createdAt: string;
388
+ updatedAt: string;
389
+ }
390
+
391
+ export interface CaseFileSequenceEntity {
392
+ year: number;
393
+ next: number;
394
+ }
395
+
396
+ export interface CaseFileEntity {
397
+ id: string;
398
+ code: string;
399
+ year: number;
400
+ number: number;
401
+ title: string;
402
+ subject: string;
403
+ summary?: string | null;
404
+ status: CaseFileStatus;
405
+ accessLevel: DocumentAccessLevel;
406
+ hasSensitiveData: boolean;
407
+ incorporationMechanism: CaseFileIncorporationMechanism;
408
+ schemaVersion: string;
409
+ procedure?: ProcedureEntity;
410
+ procedureId: string;
411
+ responsibleEmployeeId: string;
412
+ responsibleFullName: string;
413
+ responsiblePosition?: string | null;
414
+ closedAt?: string | null;
415
+ closedByEmployeeId?: string | null;
416
+ closedByFullName?: string | null;
417
+ closingNote?: string | null;
418
+ participants?: CaseFileParticipantEntity[];
419
+ actors?: CaseFileActorEntity[];
420
+ entries?: CaseFileEntryEntity[];
421
+ linkedFrom?: CaseFileEntryEntity[];
422
+ trackings?: CaseFileTrackingEntity[];
423
+ metadataChanges?: CaseFileMetadataChangeEntity[];
424
+ accesses?: CaseFileAccessEntity[];
425
+ createdAt: string;
426
+ updatedAt: string;
427
+ }
428
+
429
+ export interface CaseFileParticipantEntity {
430
+ id: string;
431
+ employeeId: string;
432
+ fullName: string;
433
+ position?: string | null;
434
+ addedByEmployeeId: string;
435
+ addedByFullName: string;
436
+ caseFile?: CaseFileEntity;
437
+ caseFileId: string;
438
+ createdAt: string;
439
+ }
440
+
441
+ export interface CaseFileActorEntity {
442
+ id: string;
443
+ relation: CaseFileActorRelation;
444
+ actorType: CaseFileActorType;
445
+ identifier?: string | null;
446
+ name: string;
447
+ caseFile?: CaseFileEntity;
448
+ caseFileId: string;
449
+ createdAt: string;
450
+ }
451
+
452
+ export interface CaseFileEntryEntity {
453
+ id: string;
454
+ sequence: number;
455
+ kind: CaseFileEntryKind;
456
+ actuationType: CaseFileActuationType;
457
+ title: string;
458
+ document?: DocumentEntity | null;
459
+ documentId?: string | null;
460
+ fileId?: string | null;
461
+ fileName?: string | null;
462
+ documentTypeName?: string | null;
463
+ originDate?: string | null;
464
+ author?: string | null;
465
+ keywords: string[];
466
+ accessLevel?: DocumentAccessLevel | null;
467
+ hasSensitiveData?: boolean | null;
468
+ linkedCaseFile?: CaseFileEntity | null;
469
+ linkedCaseFileId?: string | null;
470
+ sha256?: string | null;
471
+ size?: number | null;
472
+ hasAdvancedSignature: boolean;
473
+ incorporatedByEmployeeId: string;
474
+ incorporatedByFullName: string;
475
+ voidedAt?: string | null;
476
+ voidedByEmployeeId?: string | null;
477
+ voidedByFullName?: string | null;
478
+ voidReason?: string | null;
479
+ caseFile?: CaseFileEntity;
480
+ caseFileId: string;
481
+ createdAt: string;
482
+ }
483
+
484
+ export interface CaseFileTrackingEntity {
485
+ id: string;
486
+ action: CaseFileTrackingAction;
487
+ observation?: string | null;
488
+ employeeId?: string | null;
489
+ employeeFullName?: string | null;
490
+ caseFile?: CaseFileEntity;
491
+ caseFileId: string;
492
+ createdAt: string;
493
+ }
494
+
495
+ export interface CaseFileMetadataChangeEntity {
496
+ id: string;
497
+ field: string;
498
+ previousValue?: string | null;
499
+ newValue?: string | null;
500
+ employeeId: string;
501
+ employeeFullName: string;
502
+ caseFile?: CaseFileEntity;
503
+ caseFileId: string;
504
+ createdAt: string;
505
+ }
506
+
507
+ export interface CaseFileAccessEntity {
508
+ id: string;
509
+ action: CaseFileAccessAction;
510
+ entryId?: string | null;
511
+ employeeId: string;
512
+ employeeFullName: string;
513
+ caseFile?: CaseFileEntity;
514
+ caseFileId: string;
515
+ createdAt: string;
516
+ }
@@ -0,0 +1,134 @@
1
+ import {
2
+ type CaseFileActorRelation,
3
+ type CaseFileActorType,
4
+ type CaseFileActuationType,
5
+ type CaseFileEntity,
6
+ type CaseFileStatus,
7
+ type DocumentAccessLevel,
8
+ } from '../base/entities';
9
+ import {
10
+ type CaseFileAddEntryResponseEntity,
11
+ type CaseFileCreateResponseEntity,
12
+ type CaseFileEntryFileResponseEntity,
13
+ type CaseFileExportResponseEntity,
14
+ type CaseFileGetAllResponseEntity,
15
+ type CaseFileGetByIdResponseEntity,
16
+ type CaseFileUpdateResponseEntity,
17
+ } from '../entities';
18
+ import { type RpcPage } from './contract';
19
+ import { type DocumentActor } from './document.contract';
20
+
21
+ /** Patrones NATS de `caseFile`: `<servicio>.<recurso>.<acción>`. */
22
+ export const CaseFilePatterns = {
23
+ getAll: 'gestorDocumental.caseFile.getAll',
24
+ getById: 'gestorDocumental.caseFile.getById',
25
+ create: 'gestorDocumental.caseFile.create',
26
+ update: 'gestorDocumental.caseFile.update',
27
+ addEntry: 'gestorDocumental.caseFile.addEntry',
28
+ voidEntry: 'gestorDocumental.caseFile.voidEntry',
29
+ share: 'gestorDocumental.caseFile.share',
30
+ unshare: 'gestorDocumental.caseFile.unshare',
31
+ close: 'gestorDocumental.caseFile.close',
32
+ getEntryFile: 'gestorDocumental.caseFile.getEntryFile',
33
+ getExport: 'gestorDocumental.caseFile.getExport',
34
+ } as const;
35
+
36
+ /** Persona u organización relacionada con el expediente (MGDEE54). */
37
+ export interface CaseFileActorInput {
38
+ relation: CaseFileActorRelation;
39
+ actorType: CaseFileActorType;
40
+ identifier?: string | null;
41
+ name: string;
42
+ }
43
+
44
+ /** Metadatos del expediente que se ingresan a mano. */
45
+ export interface CaseFileWritePayload {
46
+ title: string;
47
+ subject: string;
48
+ summary?: string | null;
49
+ procedureId: string;
50
+ accessLevel: DocumentAccessLevel;
51
+ hasSensitiveData: boolean;
52
+ actors?: CaseFileActorInput[];
53
+ }
54
+
55
+ /** Actuación que se incorpora al índice: un documento del gestor, un archivo subido u otro expediente. */
56
+ export type CaseFileEntryInput =
57
+ | { kind: 'Document'; actuationType: CaseFileActuationType; documentId: string }
58
+ | {
59
+ kind: 'File';
60
+ actuationType: CaseFileActuationType;
61
+ fileId: string;
62
+ fileName: string;
63
+ title: string;
64
+ documentTypeName?: string | null;
65
+ originDate?: string | null;
66
+ author?: string | null;
67
+ keywords: string[];
68
+ accessLevel: DocumentAccessLevel;
69
+ hasSensitiveData: boolean;
70
+ }
71
+ | { kind: 'CaseFile'; actuationType: CaseFileActuationType; linkedCaseFileId: string };
72
+
73
+ /** Quién hace la operación (de la sesión) y si puede ver todos los expedientes. */
74
+ interface CaseFileActorPayload {
75
+ actor: DocumentActor;
76
+ viewAll?: boolean;
77
+ }
78
+
79
+ /** Ámbito del listado: los expedientes del funcionario (responsable o compartidos con él) o todos. */
80
+ export type CaseFileScope = 'mine' | 'all';
81
+
82
+ export interface CaseFileContract {
83
+ [CaseFilePatterns.getAll]: {
84
+ payload: {
85
+ pagination?: { page?: number; limit?: number };
86
+ filters?: { search?: string; status?: CaseFileStatus; procedureId?: string; scope?: CaseFileScope };
87
+ } & CaseFileActorPayload;
88
+ response: RpcPage<CaseFileGetAllResponseEntity[]>;
89
+ };
90
+ /** Por id o por su identificador (`EXP-2026-00001`), que es el del enlace persistente. Queda en el registro de accesos. */
91
+ [CaseFilePatterns.getById]: {
92
+ payload: { id: string } & CaseFileActorPayload;
93
+ response: CaseFileGetByIdResponseEntity;
94
+ };
95
+ [CaseFilePatterns.create]: {
96
+ payload: CaseFileWritePayload & { actor: DocumentActor };
97
+ response: CaseFileCreateResponseEntity;
98
+ };
99
+ [CaseFilePatterns.update]: {
100
+ payload: CaseFileWritePayload & Pick<CaseFileEntity, 'id'> & { actor: DocumentActor };
101
+ response: CaseFileUpdateResponseEntity;
102
+ };
103
+ [CaseFilePatterns.addEntry]: {
104
+ payload: Pick<CaseFileEntity, 'id'> & { entry: CaseFileEntryInput } & CaseFileActorPayload;
105
+ response: CaseFileAddEntryResponseEntity;
106
+ };
107
+ /** Deja una actuación sin efecto, con su motivo. No se elimina del índice. */
108
+ [CaseFilePatterns.voidEntry]: {
109
+ payload: Pick<CaseFileEntity, 'id'> & { entryId: string; reason: string; actor: DocumentActor };
110
+ response: CaseFileUpdateResponseEntity;
111
+ };
112
+ [CaseFilePatterns.share]: {
113
+ payload: Pick<CaseFileEntity, 'id'> & { employeeIds: string[]; actor: DocumentActor };
114
+ response: CaseFileUpdateResponseEntity;
115
+ };
116
+ [CaseFilePatterns.unshare]: {
117
+ payload: Pick<CaseFileEntity, 'id'> & { participantId: string; actor: DocumentActor };
118
+ response: CaseFileUpdateResponseEntity;
119
+ };
120
+ [CaseFilePatterns.close]: {
121
+ payload: Pick<CaseFileEntity, 'id'> & { note?: string | null; actor: DocumentActor };
122
+ response: CaseFileUpdateResponseEntity;
123
+ };
124
+ /** Archivo de una actuación del índice. Queda en el registro de accesos. */
125
+ [CaseFilePatterns.getEntryFile]: {
126
+ payload: Pick<CaseFileEntity, 'id'> & { entryId: string } & CaseFileActorPayload;
127
+ response: CaseFileEntryFileResponseEntity;
128
+ };
129
+ /** Metadatos y archivos para exportar el expediente completo. Queda en la trazabilidad y en el registro de accesos. */
130
+ [CaseFilePatterns.getExport]: {
131
+ payload: Pick<CaseFileEntity, 'id'> & CaseFileActorPayload;
132
+ response: CaseFileExportResponseEntity;
133
+ };
134
+ }