@muni-sanfer/types-gestor-documental 0.0.1-beta.89 → 0.0.1-beta.90

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.
@@ -22,11 +22,13 @@ export declare const DocumentNumberingScope: {
22
22
  Type: "Type";
23
23
  Category: "Category";
24
24
  };
25
- export type DocumentStatus = 'Drafted' | 'PendingVisa' | 'PendingSignature' | 'Finished' | 'Rejected' | 'Discarded' | 'Annulled';
25
+ export type DocumentStatus = 'Drafted' | 'PendingVisa' | 'PendingSignature' | 'PendingFolio' | 'PendingDispatch' | 'Finished' | 'Rejected' | 'Discarded' | 'Annulled';
26
26
  export declare const DocumentStatus: {
27
27
  Drafted: "Drafted";
28
28
  PendingVisa: "PendingVisa";
29
29
  PendingSignature: "PendingSignature";
30
+ PendingFolio: "PendingFolio";
31
+ PendingDispatch: "PendingDispatch";
30
32
  Finished: "Finished";
31
33
  Rejected: "Rejected";
32
34
  Discarded: "Discarded";
@@ -51,7 +53,7 @@ export declare const DocumentParticipantStatus: {
51
53
  Resolved: "Resolved";
52
54
  Rejected: "Rejected";
53
55
  };
54
- export type DocumentTrackingAction = 'Created' | 'Updated' | 'Submitted' | 'Visaed' | 'Signed' | 'Rejected' | 'Finished' | 'Discarded' | 'Numbered' | 'NumberAnnulled' | 'Annulled' | 'Delivered' | 'Derived' | 'RecipientsAdded' | 'Reassigned' | 'Dispatched' | 'DispatchReturned' | 'DispatchedByContingency' | 'Received' | 'EmailCopySent' | 'EmailCopyOpened' | 'DispositionRecorded' | 'TransparencyRedacted' | 'TransparencyPublished' | 'TransparencyExcluded' | 'TransparencyWithdrawn' | 'DraftReviewRequested' | 'DraftReviewApproved' | 'DraftReviewRejected' | 'DraftReviewCancelled' | 'DraftCorrected';
56
+ export type DocumentTrackingAction = 'Created' | 'Updated' | 'Submitted' | 'Visaed' | 'Signed' | 'Rejected' | 'Finished' | 'Discarded' | 'Numbered' | 'Foliated' | 'NumberAnnulled' | 'Annulled' | 'Delivered' | 'Derived' | 'RecipientsAdded' | 'Reassigned' | 'Dispatched' | 'DispatchReturned' | 'DispatchedByContingency' | 'Received' | 'EmailCopySent' | 'EmailCopyOpened' | 'DispositionRecorded' | 'TransparencyRedacted' | 'TransparencyPublished' | 'TransparencyExcluded' | 'TransparencyWithdrawn' | 'DraftReviewRequested' | 'DraftReviewApproved' | 'DraftReviewRejected' | 'DraftReviewCancelled' | 'DraftCorrected';
55
57
  export declare const DocumentTrackingAction: {
56
58
  Created: "Created";
57
59
  Updated: "Updated";
@@ -62,6 +64,7 @@ export declare const DocumentTrackingAction: {
62
64
  Finished: "Finished";
63
65
  Discarded: "Discarded";
64
66
  Numbered: "Numbered";
67
+ Foliated: "Foliated";
65
68
  NumberAnnulled: "NumberAnnulled";
66
69
  Annulled: "Annulled";
67
70
  Delivered: "Delivered";
@@ -472,6 +475,7 @@ export interface DocumentTypeEntity {
472
475
  numberingScope: DocumentNumberingScope;
473
476
  usesPartsOffice: boolean;
474
477
  decreeKind?: DecreeKind | null;
478
+ folioFormat?: JsonValue | null;
475
479
  processingSlaDays?: number | null;
476
480
  turnSlaDays?: number | null;
477
481
  reviewSlaDays?: number | null;
@@ -509,6 +513,8 @@ export interface DocumentEntity {
509
513
  correlative?: number | null;
510
514
  correlativeYear?: number | null;
511
515
  numberedAt?: string | null;
516
+ stampedAt?: string | null;
517
+ folioStamp?: JsonValue | null;
512
518
  verificationCode?: string | null;
513
519
  annulledAt?: string | null;
514
520
  annulmentReason?: string | null;
@@ -711,6 +717,7 @@ export interface DocumentTypeVersionEntity {
711
717
  numberingScope: DocumentNumberingScope;
712
718
  usesPartsOffice: boolean;
713
719
  decreeKind?: DecreeKind | null;
720
+ folioFormat?: JsonValue | null;
714
721
  processingSlaDays?: number | null;
715
722
  turnSlaDays?: number | null;
716
723
  reviewSlaDays?: number | null;
@@ -28,6 +28,8 @@ exports.DocumentStatus = {
28
28
  Drafted: 'Drafted',
29
29
  PendingVisa: 'PendingVisa',
30
30
  PendingSignature: 'PendingSignature',
31
+ PendingFolio: 'PendingFolio',
32
+ PendingDispatch: 'PendingDispatch',
31
33
  Finished: 'Finished',
32
34
  Rejected: 'Rejected',
33
35
  Discarded: 'Discarded',
@@ -59,6 +61,7 @@ exports.DocumentTrackingAction = {
59
61
  Finished: 'Finished',
60
62
  Discarded: 'Discarded',
61
63
  Numbered: 'Numbered',
64
+ Foliated: 'Foliated',
62
65
  NumberAnnulled: 'NumberAnnulled',
63
66
  Annulled: 'Annulled',
64
67
  Delivered: 'Delivered',
@@ -1,5 +1,5 @@
1
1
  import { type DocumentAccessAction, type DocumentAccessLevel, type DocumentAttachmentEntity, type DocumentDeliveryEntity, type DocumentEntity, type DocumentInstruction, type DocumentParticipantEntity, type DocumentStatus } from '../base/entities';
2
- import { type DocumentAnnulResponseEntity, type DocumentCloseDeliveryResponseEntity, type DocumentCreateResponseEntity, type DocumentAddRecipientsResponseEntity, type DocumentDeriveResponseEntity, type DocumentDiscardResponseEntity, type DocumentEmailCopyIssuedEntity, type DocumentEmailCopyViewEntity, type DocumentReminderEntity, type DocumentSlaReminderEntity, type DocumentGetAllResponseEntity, type DocumentGetByIdResponseEntity, type DocumentGetSummaryResponseEntity, type DocumentReviewAreaEntity, type DocumentInboxItemEntity, type DocumentPublicFileResponseEntity, type DocumentReassignResponseEntity, type DocumentReviewResponseEntity, type DocumentSignManyResponseEntity, type DocumentAgendaResponseEntity, type DocumentComposeResponseEntity, type DocumentComposition, type DocumentTrailExportEntity, type DocumentUpdateResponseEntity, type DocumentVerifyResponseEntity, type DocumentCommentResponseEntity, type DocumentCommentsResponseEntity, type DocumentVersionResponseEntity, type DocumentDraftCorrectionResponseEntity, type DocumentStampPlacements, type DocumentDraftReviewResponseEntity } from '../entities';
2
+ import { type StampBox, type DocumentFolioFormat, type DocumentFolioResponseEntity, type DocumentAnnulResponseEntity, type DocumentCloseDeliveryResponseEntity, type DocumentCreateResponseEntity, type DocumentAddRecipientsResponseEntity, type DocumentDeriveResponseEntity, type DocumentDiscardResponseEntity, type DocumentEmailCopyIssuedEntity, type DocumentEmailCopyViewEntity, type DocumentReminderEntity, type DocumentSlaReminderEntity, type DocumentGetAllResponseEntity, type DocumentGetByIdResponseEntity, type DocumentGetSummaryResponseEntity, type DocumentReviewAreaEntity, type DocumentInboxItemEntity, type DocumentPublicFileResponseEntity, type DocumentReassignResponseEntity, type DocumentReviewResponseEntity, type DocumentSignManyResponseEntity, type DocumentAgendaResponseEntity, type DocumentComposeResponseEntity, type DocumentComposition, type DocumentTrailExportEntity, type DocumentUpdateResponseEntity, type DocumentVerifyResponseEntity, type DocumentCommentResponseEntity, type DocumentCommentsResponseEntity, type DocumentVersionResponseEntity, type DocumentDraftCorrectionResponseEntity, type DocumentStampPlacements, type DocumentDraftReviewResponseEntity } 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: {
@@ -11,6 +11,7 @@ export declare const DocumentPatterns: {
11
11
  readonly create: "gestorDocumental.document.create";
12
12
  readonly update: "gestorDocumental.document.update";
13
13
  readonly review: "gestorDocumental.document.review";
14
+ readonly folio: "gestorDocumental.document.folio";
14
15
  readonly signMany: "gestorDocumental.document.signMany";
15
16
  readonly reassign: "gestorDocumental.document.reassign";
16
17
  readonly requestDraftReview: "gestorDocumental.document.requestDraftReview";
@@ -65,7 +66,7 @@ export interface DocumentActor {
65
66
  inboxDepartmentIds?: string[];
66
67
  }
67
68
  /** Bandeja desde la que se lista. Todas son del funcionario (`actor`), salvo `all`. */
68
- export type DocumentBucket = 'created' | 'area' | 'sent' | 'toVisa' | 'toSign' | 'participated' | 'visaed' | 'signed' | 'reviewed' | 'toReview' | 'visaAll' | 'signAll' | 'reviewAll' | 'all';
69
+ export type DocumentBucket = 'created' | 'area' | 'sent' | 'toVisa' | 'toSign' | 'participated' | 'visaed' | 'signed' | 'reviewed' | 'toReview' | 'visaAll' | 'signAll' | 'reviewAll' | 'toFolio' | 'all';
69
70
  /**
70
71
  * Destinatario de un documento o de una derivación: una persona o un área completa. El gateway resuelve el nombre del
71
72
  * área y quiénes la integran hoy; el navegador solo indica cuál es.
@@ -264,6 +265,26 @@ export interface DocumentContract {
264
265
  payload: DocumentWritePayload & Pick<DocumentEntity, 'id'>;
265
266
  response: DocumentUpdateResponseEntity;
266
267
  };
268
+ /**
269
+ * Folia un documento firmado por todos (`PendingFolio`): le asigna su número y le agrega la estampa del folio, una
270
+ * firma con el certificado desatendido de quien folia. Folia Oficina de Partes si su tipo pasa por ella; si no, quien lo
271
+ * redactó.
272
+ */
273
+ [DocumentPatterns.folio]: {
274
+ payload: Pick<DocumentEntity, 'id'> & {
275
+ signer: {
276
+ rut: string;
277
+ fullName: string;
278
+ role: string;
279
+ areaName: string;
280
+ };
281
+ partsOffice?: boolean;
282
+ box?: StampBox;
283
+ format?: DocumentFolioFormat;
284
+ actor: DocumentActor;
285
+ };
286
+ response: DocumentFolioResponseEntity;
287
+ };
267
288
  [DocumentPatterns.review]: {
268
289
  payload: Pick<DocumentEntity, 'id'> & {
269
290
  action: DocumentReviewAction;
@@ -11,6 +11,7 @@ exports.DocumentPatterns = {
11
11
  create: 'gestorDocumental.document.create',
12
12
  update: 'gestorDocumental.document.update',
13
13
  review: 'gestorDocumental.document.review',
14
+ folio: 'gestorDocumental.document.folio',
14
15
  signMany: 'gestorDocumental.document.signMany',
15
16
  reassign: 'gestorDocumental.document.reassign',
16
17
  requestDraftReview: 'gestorDocumental.document.requestDraftReview',
@@ -1,5 +1,5 @@
1
1
  import { type DecreeKind, type DocumentCategory, type DocumentNumberingScope, type DocumentParticipantRole, type DocumentTypeEntity } from '../base/entities';
2
- import { type CategoryNumberingResponseEntity, type CategoryNumberingUpdateResponseEntity, type DocumentTemplateContent, type DocumentTypeCreateResponseEntity, type DocumentTypeGetAllResponseEntity, type DocumentTypeGetByIdResponseEntity, type DocumentTypeUpdateResponseEntity } from '../entities';
2
+ import { type CategoryNumberingResponseEntity, type CategoryNumberingUpdateResponseEntity, type DocumentFolioFormat, type DocumentTemplateContent, type DocumentTypeCreateResponseEntity, type DocumentTypeGetAllResponseEntity, type DocumentTypeGetByIdResponseEntity, type DocumentTypeUpdateResponseEntity } from '../entities';
3
3
  import { type RpcPage } from './contract';
4
4
  /** Patrones NATS de `documentType`: `<servicio>.<recurso>.<acción>`. */
5
5
  export declare const DocumentTypePatterns: {
@@ -40,6 +40,7 @@ export interface DocumentTypeWritePayload {
40
40
  numberingScope?: DocumentNumberingScope;
41
41
  usesPartsOffice?: boolean;
42
42
  decreeKind?: DecreeKind | null;
43
+ folioFormat?: DocumentFolioFormat | null;
43
44
  processingSlaDays?: number | null;
44
45
  turnSlaDays?: number | null;
45
46
  reviewSlaDays?: number | null;
@@ -81,6 +81,7 @@ export declare const GestorDocumentalPatterns: {
81
81
  readonly create: "gestorDocumental.document.create";
82
82
  readonly update: "gestorDocumental.document.update";
83
83
  readonly review: "gestorDocumental.document.review";
84
+ readonly folio: "gestorDocumental.document.folio";
84
85
  readonly signMany: "gestorDocumental.document.signMany";
85
86
  readonly reassign: "gestorDocumental.document.reassign";
86
87
  readonly requestDraftReview: "gestorDocumental.document.requestDraftReview";
@@ -154,6 +155,7 @@ export declare const GestorDocumentalPatterns: {
154
155
  readonly getDocumentTypes: "gestorDocumental.partsOffice.getDocumentTypes";
155
156
  readonly getDispatches: "gestorDocumental.partsOffice.getDispatches";
156
157
  readonly dispatch: "gestorDocumental.partsOffice.dispatch";
158
+ readonly dispatchInGestor: "gestorDocumental.partsOffice.dispatchInGestor";
157
159
  readonly returnDispatch: "gestorDocumental.partsOffice.returnDispatch";
158
160
  readonly resendDispatch: "gestorDocumental.partsOffice.resendDispatch";
159
161
  readonly getDispatchFile: "gestorDocumental.partsOffice.getDispatchFile";
@@ -12,6 +12,7 @@ export declare const PartsOfficePatterns: {
12
12
  readonly getDocumentTypes: "gestorDocumental.partsOffice.getDocumentTypes";
13
13
  readonly getDispatches: "gestorDocumental.partsOffice.getDispatches";
14
14
  readonly dispatch: "gestorDocumental.partsOffice.dispatch";
15
+ readonly dispatchInGestor: "gestorDocumental.partsOffice.dispatchInGestor";
15
16
  readonly returnDispatch: "gestorDocumental.partsOffice.returnDispatch";
16
17
  readonly resendDispatch: "gestorDocumental.partsOffice.resendDispatch";
17
18
  readonly getDispatchFile: "gestorDocumental.partsOffice.getDispatchFile";
@@ -113,7 +114,11 @@ export interface PartsOfficeContract {
113
114
  response: DocDigitalDocumentTypeEntity[];
114
115
  };
115
116
  [PartsOfficePatterns.getDispatches]: {
116
- payload: IListPayload<'Pending' | 'Dispatched' | 'Returned'>;
117
+ payload: IListPayload<'Pending' | 'Dispatched' | 'Returned'> & {
118
+ filters?: {
119
+ stage?: 'folio' | 'dispatch';
120
+ };
121
+ };
117
122
  response: RpcPage<PartsOfficeDispatchEntity[]>;
118
123
  };
119
124
  /** Despacha por DocDigital, con el número del documento como folio. `operatorRun`: RUN de quien despacha. */
@@ -128,6 +133,17 @@ export interface PartsOfficeContract {
128
133
  docDigitalDocumentId: string;
129
134
  };
130
135
  };
136
+ /**
137
+ * Despacha en el gestor, sin DocDigital: el documento queda finalizado y llega a los buzones de sus destinatarios.
138
+ * No si tiene destinatarios de otras instituciones (van por DocDigital o por contingencia).
139
+ */
140
+ [PartsOfficePatterns.dispatchInGestor]: {
141
+ payload: {
142
+ id: string;
143
+ actor: DocumentActor;
144
+ };
145
+ response: PartsOfficeOkResponseEntity;
146
+ };
131
147
  /** Devuelve el despacho al redactor, con el motivo (por ejemplo, un destinatario equivocado). */
132
148
  [PartsOfficePatterns.returnDispatch]: {
133
149
  payload: {
@@ -11,6 +11,7 @@ exports.PartsOfficePatterns = {
11
11
  getDocumentTypes: 'gestorDocumental.partsOffice.getDocumentTypes',
12
12
  getDispatches: 'gestorDocumental.partsOffice.getDispatches',
13
13
  dispatch: 'gestorDocumental.partsOffice.dispatch',
14
+ dispatchInGestor: 'gestorDocumental.partsOffice.dispatchInGestor',
14
15
  returnDispatch: 'gestorDocumental.partsOffice.returnDispatch',
15
16
  resendDispatch: 'gestorDocumental.partsOffice.resendDispatch',
16
17
  getDispatchFile: 'gestorDocumental.partsOffice.getDispatchFile',
@@ -1,3 +1,4 @@
1
+ import { type DocumentFolioDraft, type DocumentFolioStamp } from './folio';
1
2
  import { type CommunicationMeans, DocumentAnnulledNumberEntity, DocumentAttachmentEntity, DocumentDeliveryEntity, DocumentEntity, DocumentParticipantEntity, DocumentRecipientEntity, type DocumentStatus, DocumentTrackingEntity, DocumentTypeEntity } from '../../base/entities';
2
3
  import { type RichLetterhead, type RichPage, type RichSpacing, type RichTextStyle } from './richStyle';
3
4
  import { type DocumentDraftingRequestEntity } from '../draftingRequest/draftingRequest.entity';
@@ -245,6 +246,12 @@ export interface DocumentGetByIdResponseEntity {
245
246
  selfValidation: DocumentSelfValidationEntity | null;
246
247
  /** Dónde van las visaciones y las firmas, si quien redacta las ubicó; `null`, las ubica el sistema. */
247
248
  stampPlacements: DocumentStampPlacements | null;
249
+ /** La estampa del folio que se firmó (dónde quedó y con qué formato); `null` si aún no se folia o no lleva número. */
250
+ folioStamp: DocumentFolioStamp | null;
251
+ /** Si está por foliar: lo necesario para proponer la estampa del folio sobre su vista previa. */
252
+ folioDraft: DocumentFolioDraft | null;
253
+ /** Quién lo folia: Oficina de Partes (su tipo pasa por ella, y lo despacha después) o quien lo redactó. */
254
+ foliatedBy: 'PartsOffice' | 'Author';
248
255
  /** Solicitud de redacción que atiende, si se redactó a pedido de otra área. */
249
256
  draftingRequest: DocumentDraftingRequestEntity | null;
250
257
  /**
@@ -305,6 +312,8 @@ export interface DocumentGetByIdResponseEntity {
305
312
  canReassign: boolean;
306
313
  /** Quien consulta redactó el documento (o lo ingresó, si llegó por DocDigital). */
307
314
  isAuthor: boolean;
315
+ /** Le toca foliarlo: está por foliar, lo redactó y su tipo no pasa por Oficina de Partes. */
316
+ canFolio: boolean;
308
317
  /** Le toca aprobar o devolver el borrador: es la jefatura de la revisión pendiente. */
309
318
  canResolveDraftReview: boolean;
310
319
  inbox: DocumentDeliveryResponseEntity[];
@@ -321,6 +330,8 @@ export interface DocumentGetSummaryResponseEntity {
321
330
  toSign: number;
322
331
  /** Borradores que esperan su revisión (como jefatura de la dirección que los revisa). */
323
332
  toReview: number;
333
+ /** Firmados por todos que le toca foliar: los redactó y su tipo no pasa por Oficina de Partes. */
334
+ toFolio: number;
324
335
  /** Solicitudes de redacción: sin tomar dirigidas a su dirección, y tomadas por él aún sin atender. */
325
336
  draftingRequests: {
326
337
  pending: number;
@@ -353,6 +364,14 @@ export interface DocumentUpdateResponseEntity {
353
364
  /** Ya no se entrega: el borrador aprobado entra de inmediato a tramitación (queda mientras el gateway lo lea). */
354
365
  officialReview?: DocumentDraftReviewResponseEntity;
355
366
  }
367
+ /** Resultado de foliar: el número que recibió y en qué estado quedó (por despachar o finalizado). */
368
+ export interface DocumentFolioResponseEntity {
369
+ id: DocumentEntity['id'];
370
+ ok: boolean;
371
+ status: DocumentEntity['status'];
372
+ correlative: number;
373
+ correlativeYear: number;
374
+ }
356
375
  export interface DocumentReviewResponseEntity {
357
376
  id: DocumentEntity['id'];
358
377
  ok: boolean;
@@ -0,0 +1,55 @@
1
+ import { type RichNumberZone, type RichSideMargins } from './richStyle';
2
+ import { type StampBox } from './stampPlacement';
3
+ /** Qué nombra la estampa del folio antes del número: el nombre del tipo, su sigla o nada. */
4
+ export type FolioLabel = 'name' | 'abbreviation' | 'none';
5
+ /** El número solo (`N° 590`) o con su año (`N° 590/2026`). */
6
+ export type FolioNumberStyle = 'number' | 'numberYear';
7
+ /** La fecha de la foliación: sin ella, corta (18-11-2026) o larga (San Fernando, 18 de noviembre de 2026). */
8
+ export type FolioDateStyle = 'none' | 'short' | 'long';
9
+ /**
10
+ * Cómo se ve la estampa del folio, que es una firma electrónica de quien folia: qué datos lleva y cómo se alinean en su
11
+ * recuadro. Lo configura el tipo documental y se puede cambiar al foliar.
12
+ */
13
+ export interface DocumentFolioFormat {
14
+ label: FolioLabel;
15
+ number: FolioNumberStyle;
16
+ date: FolioDateStyle;
17
+ /** Un texto fijo en su propia línea, al final (por ejemplo, «Oficina de Partes»). */
18
+ text?: string | null;
19
+ align: 'left' | 'center' | 'right';
20
+ }
21
+ /** La de siempre: el nombre del tipo con su número, y la fecha larga debajo, a la derecha. */
22
+ export declare const DEFAULT_FOLIO_FORMAT: DocumentFolioFormat;
23
+ /** Largo máximo del texto fijo de la estampa. */
24
+ export declare const FOLIO_TEXT_MAX = 80;
25
+ /** La estampa del folio que se firmó en un documento: dónde quedó y con qué formato. */
26
+ export interface DocumentFolioStamp {
27
+ box: StampBox;
28
+ format: DocumentFolioFormat;
29
+ }
30
+ /**
31
+ * Lo necesario para proponer la estampa del folio de un documento por foliar, sobre su vista previa: el formato del tipo
32
+ * con que se envió, su nombre y sigla, y dónde va según su plantilla (la zona del número y los márgenes de su página;
33
+ * `null` en un PDF subido: arriba a la derecha). El recuadro se calcula con `richNumberZone`.
34
+ */
35
+ export interface DocumentFolioDraft {
36
+ format: DocumentFolioFormat;
37
+ typeName: string;
38
+ abbreviation: string | null;
39
+ numberZone: RichNumberZone | null;
40
+ margins: RichSideMargins | null;
41
+ }
42
+ /** Los datos que escribe la estampa del folio. Las fechas van ya escritas (cada lado las formatea a su modo). */
43
+ export interface FolioStampData {
44
+ typeName: string;
45
+ abbreviation?: string | null;
46
+ correlative: number;
47
+ correlativeYear: number;
48
+ shortDate: string;
49
+ longDate: string;
50
+ }
51
+ /**
52
+ * Las líneas de la estampa del folio, de arriba abajo: el tipo (o su sigla) con el número, la fecha y el texto fijo. Lo
53
+ * usan el ms al firmar la estampa y la vista previa de las pantallas, para que se vean igual.
54
+ */
55
+ export declare const folioStampLines: (format: DocumentFolioFormat, data: FolioStampData) => string[];
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.folioStampLines = exports.FOLIO_TEXT_MAX = exports.DEFAULT_FOLIO_FORMAT = void 0;
4
+ /** La de siempre: el nombre del tipo con su número, y la fecha larga debajo, a la derecha. */
5
+ exports.DEFAULT_FOLIO_FORMAT = {
6
+ label: 'name',
7
+ number: 'number',
8
+ date: 'long',
9
+ align: 'right',
10
+ };
11
+ /** Largo máximo del texto fijo de la estampa. */
12
+ exports.FOLIO_TEXT_MAX = 80;
13
+ /**
14
+ * Las líneas de la estampa del folio, de arriba abajo: el tipo (o su sigla) con el número, la fecha y el texto fijo. Lo
15
+ * usan el ms al firmar la estampa y la vista previa de las pantallas, para que se vean igual.
16
+ */
17
+ const folioStampLines = (format, data) => {
18
+ const number = `N° ${data.correlative}${format.number === 'numberYear' ? `/${data.correlativeYear}` : ''}`;
19
+ const label = format.label === 'name'
20
+ ? data.typeName.toUpperCase()
21
+ : format.label === 'abbreviation'
22
+ ? (data.abbreviation || data.typeName).trim()
23
+ : '';
24
+ return [
25
+ label ? `${label} ${number}` : number,
26
+ ...(format.date === 'short' ? [data.shortDate] : format.date === 'long' ? [data.longDate] : []),
27
+ ...(format.text?.trim() ? [format.text.trim()] : []),
28
+ ];
29
+ };
30
+ exports.folioStampLines = folioStampLines;
@@ -2,3 +2,4 @@ export * from './document.entity';
2
2
  export * from './richStyle';
3
3
  export * from './stampPlacement';
4
4
  export * from './richDistribution';
5
+ export * from './folio';
@@ -18,3 +18,4 @@ __exportStar(require("./document.entity"), exports);
18
18
  __exportStar(require("./richStyle"), exports);
19
19
  __exportStar(require("./stampPlacement"), exports);
20
20
  __exportStar(require("./richDistribution"), exports);
21
+ __exportStar(require("./folio"), exports);
@@ -1,5 +1,6 @@
1
1
  import { type DocumentCategory, DocumentTypeEntity, DocumentTypeFlowStepEntity } from '../../base/entities';
2
2
  import { type DocumentTemplateContent } from '../documentTemplate/documentTemplate.entity';
3
+ import { type DocumentFolioFormat } from '../document/folio';
3
4
  /** Paso del flujo sugerido de un tipo documental: quién visa o firma, en su orden. */
4
5
  export interface DocumentTypeFlowStepResponseEntity {
5
6
  id: DocumentTypeFlowStepEntity['id'];
@@ -26,6 +27,8 @@ export interface DocumentTypeGetAllResponseEntity {
26
27
  usesPartsOffice: DocumentTypeEntity['usesPartsOffice'];
27
28
  /** En la categoría Decreto: si sus decretos son exentos o afectos. En las demás, `null`. */
28
29
  decreeKind: DocumentTypeEntity['decreeKind'];
30
+ /** Cómo se ve la estampa del folio de sus documentos; `null`: la de siempre (`DEFAULT_FOLIO_FORMAT`). */
31
+ folioFormat: DocumentFolioFormat | null;
29
32
  processingSlaDays: DocumentTypeEntity['processingSlaDays'];
30
33
  turnSlaDays: DocumentTypeEntity['turnSlaDays'];
31
34
  reviewSlaDays: DocumentTypeEntity['reviewSlaDays'];
@@ -1,3 +1,4 @@
1
+ import { type DocumentFolioDraft } from '../document/folio';
1
2
  import { type PdfSignatureReportEntity } from '../signatureCheck';
2
3
  import { type DocumentDispatchResponseEntity, type DocumentExternalRecipientResponseEntity, type DocumentLinkEntity } from '../document';
3
4
  /** Institución del Estado en DocDigital. */
@@ -35,6 +36,8 @@ export interface PartsOfficeDispatchEntity extends DocumentDispatchResponseEntit
35
36
  externalRecipients: DocumentExternalRecipientResponseEntity[];
36
37
  /** A nombre de quién sale: la entidad emisora del tipo documental o la municipalidad. */
37
38
  issuerName: string;
39
+ /** Si está por foliar: lo necesario para proponer la estampa del folio sobre su vista previa. */
40
+ folioDraft: DocumentFolioDraft | null;
38
41
  createdAt: string;
39
42
  }
40
43
  /** Documento que llegó por DocDigital. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muni-sanfer/types-gestor-documental",
3
- "version": "0.0.1-beta.89",
3
+ "version": "0.0.1-beta.90",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -42,12 +42,22 @@ export const DocumentNumberingScope = {
42
42
  } satisfies Record<string, DocumentNumberingScope>;
43
43
 
44
44
  export type DocumentStatus =
45
- 'Drafted' | 'PendingVisa' | 'PendingSignature' | 'Finished' | 'Rejected' | 'Discarded' | 'Annulled';
45
+ | 'Drafted'
46
+ | 'PendingVisa'
47
+ | 'PendingSignature'
48
+ | 'PendingFolio'
49
+ | 'PendingDispatch'
50
+ | 'Finished'
51
+ | 'Rejected'
52
+ | 'Discarded'
53
+ | 'Annulled';
46
54
 
47
55
  export const DocumentStatus = {
48
56
  Drafted: 'Drafted',
49
57
  PendingVisa: 'PendingVisa',
50
58
  PendingSignature: 'PendingSignature',
59
+ PendingFolio: 'PendingFolio',
60
+ PendingDispatch: 'PendingDispatch',
51
61
  Finished: 'Finished',
52
62
  Rejected: 'Rejected',
53
63
  Discarded: 'Discarded',
@@ -89,6 +99,7 @@ export type DocumentTrackingAction =
89
99
  | 'Finished'
90
100
  | 'Discarded'
91
101
  | 'Numbered'
102
+ | 'Foliated'
92
103
  | 'NumberAnnulled'
93
104
  | 'Annulled'
94
105
  | 'Delivered'
@@ -122,6 +133,7 @@ export const DocumentTrackingAction = {
122
133
  Finished: 'Finished',
123
134
  Discarded: 'Discarded',
124
135
  Numbered: 'Numbered',
136
+ Foliated: 'Foliated',
125
137
  NumberAnnulled: 'NumberAnnulled',
126
138
  Annulled: 'Annulled',
127
139
  Delivered: 'Delivered',
@@ -700,6 +712,7 @@ export interface DocumentTypeEntity {
700
712
  numberingScope: DocumentNumberingScope;
701
713
  usesPartsOffice: boolean;
702
714
  decreeKind?: DecreeKind | null;
715
+ folioFormat?: JsonValue | null;
703
716
  processingSlaDays?: number | null;
704
717
  turnSlaDays?: number | null;
705
718
  reviewSlaDays?: number | null;
@@ -738,6 +751,8 @@ export interface DocumentEntity {
738
751
  correlative?: number | null;
739
752
  correlativeYear?: number | null;
740
753
  numberedAt?: string | null;
754
+ stampedAt?: string | null;
755
+ folioStamp?: JsonValue | null;
741
756
  verificationCode?: string | null;
742
757
  annulledAt?: string | null;
743
758
  annulmentReason?: string | null;
@@ -949,6 +964,7 @@ export interface DocumentTypeVersionEntity {
949
964
  numberingScope: DocumentNumberingScope;
950
965
  usesPartsOffice: boolean;
951
966
  decreeKind?: DecreeKind | null;
967
+ folioFormat?: JsonValue | null;
952
968
  processingSlaDays?: number | null;
953
969
  turnSlaDays?: number | null;
954
970
  reviewSlaDays?: number | null;
@@ -9,6 +9,9 @@ import {
9
9
  type DocumentStatus,
10
10
  } from '../base/entities';
11
11
  import {
12
+ type StampBox,
13
+ type DocumentFolioFormat,
14
+ type DocumentFolioResponseEntity,
12
15
  type DocumentAnnulResponseEntity,
13
16
  type DocumentCloseDeliveryResponseEntity,
14
17
  type DocumentCreateResponseEntity,
@@ -53,6 +56,7 @@ export const DocumentPatterns = {
53
56
  create: 'gestorDocumental.document.create',
54
57
  update: 'gestorDocumental.document.update',
55
58
  review: 'gestorDocumental.document.review',
59
+ folio: 'gestorDocumental.document.folio',
56
60
  signMany: 'gestorDocumental.document.signMany',
57
61
  reassign: 'gestorDocumental.document.reassign',
58
62
  requestDraftReview: 'gestorDocumental.document.requestDraftReview',
@@ -123,6 +127,7 @@ export type DocumentBucket =
123
127
  | 'visaAll' // los que le toca visar y los que ya visó (o rechazó como visador)
124
128
  | 'signAll' // los que le toca firmar y los que ya firmó (o rechazó como firmante)
125
129
  | 'reviewAll' // los borradores que le toca revisar y los que ya revisó
130
+ | 'toFolio' // firmados por todos que le toca foliar (los redactó y su tipo no pasa por Oficina de Partes)
126
131
  | 'all'; // todos los que están en tramitación o finalizados (historial)
127
132
 
128
133
  /**
@@ -319,6 +324,24 @@ export interface DocumentContract {
319
324
  payload: DocumentWritePayload & Pick<DocumentEntity, 'id'>;
320
325
  response: DocumentUpdateResponseEntity;
321
326
  };
327
+ /**
328
+ * Folia un documento firmado por todos (`PendingFolio`): le asigna su número y le agrega la estampa del folio, una
329
+ * firma con el certificado desatendido de quien folia. Folia Oficina de Partes si su tipo pasa por ella; si no, quien lo
330
+ * redactó.
331
+ */
332
+ [DocumentPatterns.folio]: {
333
+ payload: Pick<DocumentEntity, 'id'> & {
334
+ // Datos de quien folia, para su firma (los resuelve el gateway desde la sesión)
335
+ signer: { rut: string; fullName: string; role: string; areaName: string };
336
+ // Quien folia actúa como Oficina de Partes (lo decide el gateway con sus permisos)
337
+ partsOffice?: boolean;
338
+ // Solo para este documento: dónde va la estampa y cómo se ve (sin ellos, los del tipo y su plantilla)
339
+ box?: StampBox;
340
+ format?: DocumentFolioFormat;
341
+ actor: DocumentActor;
342
+ };
343
+ response: DocumentFolioResponseEntity;
344
+ };
322
345
  [DocumentPatterns.review]: {
323
346
  payload: Pick<DocumentEntity, 'id'> & {
324
347
  action: DocumentReviewAction;
@@ -8,6 +8,7 @@ import {
8
8
  import {
9
9
  type CategoryNumberingResponseEntity,
10
10
  type CategoryNumberingUpdateResponseEntity,
11
+ type DocumentFolioFormat,
11
12
  type DocumentTemplateContent,
12
13
  type DocumentTypeCreateResponseEntity,
13
14
  type DocumentTypeGetAllResponseEntity,
@@ -57,6 +58,8 @@ export interface DocumentTypeWritePayload {
57
58
  usesPartsOffice?: boolean;
58
59
  // En la categoría Decreto, obligatorio: sus decretos son exentos o afectos. En las demás se ignora.
59
60
  decreeKind?: DecreeKind | null;
61
+ // Cómo se ve la estampa del folio de sus documentos (`null`: la de siempre). Sin el campo, no cambia.
62
+ folioFormat?: DocumentFolioFormat | null;
60
63
  // Plazos de servicio en días hábiles (sin valor: sin plazo): de la tramitación, de cada turno y de cada revisión.
61
64
  processingSlaDays?: number | null;
62
65
  turnSlaDays?: number | null;
@@ -28,6 +28,7 @@ export const PartsOfficePatterns = {
28
28
  getDocumentTypes: 'gestorDocumental.partsOffice.getDocumentTypes',
29
29
  getDispatches: 'gestorDocumental.partsOffice.getDispatches',
30
30
  dispatch: 'gestorDocumental.partsOffice.dispatch',
31
+ dispatchInGestor: 'gestorDocumental.partsOffice.dispatchInGestor',
31
32
  returnDispatch: 'gestorDocumental.partsOffice.returnDispatch',
32
33
  resendDispatch: 'gestorDocumental.partsOffice.resendDispatch',
33
34
  getDispatchFile: 'gestorDocumental.partsOffice.getDispatchFile',
@@ -91,7 +92,10 @@ export interface PartsOfficeContract {
91
92
  };
92
93
  [PartsOfficePatterns.getDocumentTypes]: { payload: Record<string, never>; response: DocDigitalDocumentTypeEntity[] };
93
94
  [PartsOfficePatterns.getDispatches]: {
94
- payload: IListPayload<'Pending' | 'Dispatched' | 'Returned'>;
95
+ // `stage`: lo pendiente por foliar (`folio`) o ya foliado, por despachar (`dispatch`)
96
+ payload: IListPayload<'Pending' | 'Dispatched' | 'Returned'> & {
97
+ filters?: { stage?: 'folio' | 'dispatch' };
98
+ };
95
99
  response: RpcPage<PartsOfficeDispatchEntity[]>;
96
100
  };
97
101
  /** Despacha por DocDigital, con el número del documento como folio. `operatorRun`: RUN de quien despacha. */
@@ -99,6 +103,14 @@ export interface PartsOfficeContract {
99
103
  payload: { id: string; docDigitalTypeId: number; operatorRun?: string | null; actor: DocumentActor };
100
104
  response: PartsOfficeOkResponseEntity & { docDigitalDocumentId: string };
101
105
  };
106
+ /**
107
+ * Despacha en el gestor, sin DocDigital: el documento queda finalizado y llega a los buzones de sus destinatarios.
108
+ * No si tiene destinatarios de otras instituciones (van por DocDigital o por contingencia).
109
+ */
110
+ [PartsOfficePatterns.dispatchInGestor]: {
111
+ payload: { id: string; actor: DocumentActor };
112
+ response: PartsOfficeOkResponseEntity;
113
+ };
102
114
  /** Devuelve el despacho al redactor, con el motivo (por ejemplo, un destinatario equivocado). */
103
115
  [PartsOfficePatterns.returnDispatch]: {
104
116
  payload: { id: string; reason: string; actor: DocumentActor };
@@ -1,3 +1,4 @@
1
+ import { type DocumentFolioDraft, type DocumentFolioStamp } from './folio';
1
2
  import {
2
3
  type CommunicationMeans,
3
4
  DocumentAnnulledNumberEntity,
@@ -278,6 +279,12 @@ export interface DocumentGetByIdResponseEntity {
278
279
  selfValidation: DocumentSelfValidationEntity | null;
279
280
  /** Dónde van las visaciones y las firmas, si quien redacta las ubicó; `null`, las ubica el sistema. */
280
281
  stampPlacements: DocumentStampPlacements | null;
282
+ /** La estampa del folio que se firmó (dónde quedó y con qué formato); `null` si aún no se folia o no lleva número. */
283
+ folioStamp: DocumentFolioStamp | null;
284
+ /** Si está por foliar: lo necesario para proponer la estampa del folio sobre su vista previa. */
285
+ folioDraft: DocumentFolioDraft | null;
286
+ /** Quién lo folia: Oficina de Partes (su tipo pasa por ella, y lo despacha después) o quien lo redactó. */
287
+ foliatedBy: 'PartsOffice' | 'Author';
281
288
  /** Solicitud de redacción que atiende, si se redactó a pedido de otra área. */
282
289
  draftingRequest: DocumentDraftingRequestEntity | null;
283
290
  /**
@@ -340,6 +347,8 @@ export interface DocumentGetByIdResponseEntity {
340
347
  canReassign: boolean;
341
348
  /** Quien consulta redactó el documento (o lo ingresó, si llegó por DocDigital). */
342
349
  isAuthor: boolean;
350
+ /** Le toca foliarlo: está por foliar, lo redactó y su tipo no pasa por Oficina de Partes. */
351
+ canFolio: boolean;
343
352
  /** Le toca aprobar o devolver el borrador: es la jefatura de la revisión pendiente. */
344
353
  canResolveDraftReview: boolean;
345
354
  // Sus propias entregas de este documento (puede tener más de una si además se lo derivaron).
@@ -359,6 +368,8 @@ export interface DocumentGetSummaryResponseEntity {
359
368
  toSign: number;
360
369
  /** Borradores que esperan su revisión (como jefatura de la dirección que los revisa). */
361
370
  toReview: number;
371
+ /** Firmados por todos que le toca foliar: los redactó y su tipo no pasa por Oficina de Partes. */
372
+ toFolio: number;
362
373
  /** Solicitudes de redacción: sin tomar dirigidas a su dirección, y tomadas por él aún sin atender. */
363
374
  draftingRequests: { pending: number; taken: number };
364
375
  /** Lotes de firma con documentos en su turno (los documentos de un lote no se cuentan en `toVisa` ni `toSign`). */
@@ -389,6 +400,15 @@ export interface DocumentUpdateResponseEntity {
389
400
  officialReview?: DocumentDraftReviewResponseEntity;
390
401
  }
391
402
 
403
+ /** Resultado de foliar: el número que recibió y en qué estado quedó (por despachar o finalizado). */
404
+ export interface DocumentFolioResponseEntity {
405
+ id: DocumentEntity['id'];
406
+ ok: boolean;
407
+ status: DocumentEntity['status'];
408
+ correlative: number;
409
+ correlativeYear: number;
410
+ }
411
+
392
412
  export interface DocumentReviewResponseEntity {
393
413
  id: DocumentEntity['id'];
394
414
  ok: boolean;
@@ -0,0 +1,82 @@
1
+ import { type RichNumberZone, type RichSideMargins } from './richStyle';
2
+ import { type StampBox } from './stampPlacement';
3
+
4
+ /** Qué nombra la estampa del folio antes del número: el nombre del tipo, su sigla o nada. */
5
+ export type FolioLabel = 'name' | 'abbreviation' | 'none';
6
+ /** El número solo (`N° 590`) o con su año (`N° 590/2026`). */
7
+ export type FolioNumberStyle = 'number' | 'numberYear';
8
+ /** La fecha de la foliación: sin ella, corta (18-11-2026) o larga (San Fernando, 18 de noviembre de 2026). */
9
+ export type FolioDateStyle = 'none' | 'short' | 'long';
10
+
11
+ /**
12
+ * Cómo se ve la estampa del folio, que es una firma electrónica de quien folia: qué datos lleva y cómo se alinean en su
13
+ * recuadro. Lo configura el tipo documental y se puede cambiar al foliar.
14
+ */
15
+ export interface DocumentFolioFormat {
16
+ label: FolioLabel;
17
+ number: FolioNumberStyle;
18
+ date: FolioDateStyle;
19
+ /** Un texto fijo en su propia línea, al final (por ejemplo, «Oficina de Partes»). */
20
+ text?: string | null;
21
+ align: 'left' | 'center' | 'right';
22
+ }
23
+
24
+ /** La de siempre: el nombre del tipo con su número, y la fecha larga debajo, a la derecha. */
25
+ export const DEFAULT_FOLIO_FORMAT: DocumentFolioFormat = {
26
+ label: 'name',
27
+ number: 'number',
28
+ date: 'long',
29
+ align: 'right',
30
+ };
31
+
32
+ /** Largo máximo del texto fijo de la estampa. */
33
+ export const FOLIO_TEXT_MAX = 80;
34
+
35
+ /** La estampa del folio que se firmó en un documento: dónde quedó y con qué formato. */
36
+ export interface DocumentFolioStamp {
37
+ box: StampBox;
38
+ format: DocumentFolioFormat;
39
+ }
40
+
41
+ /**
42
+ * Lo necesario para proponer la estampa del folio de un documento por foliar, sobre su vista previa: el formato del tipo
43
+ * con que se envió, su nombre y sigla, y dónde va según su plantilla (la zona del número y los márgenes de su página;
44
+ * `null` en un PDF subido: arriba a la derecha). El recuadro se calcula con `richNumberZone`.
45
+ */
46
+ export interface DocumentFolioDraft {
47
+ format: DocumentFolioFormat;
48
+ typeName: string;
49
+ abbreviation: string | null;
50
+ numberZone: RichNumberZone | null;
51
+ margins: RichSideMargins | null;
52
+ }
53
+
54
+ /** Los datos que escribe la estampa del folio. Las fechas van ya escritas (cada lado las formatea a su modo). */
55
+ export interface FolioStampData {
56
+ typeName: string;
57
+ abbreviation?: string | null;
58
+ correlative: number;
59
+ correlativeYear: number;
60
+ shortDate: string;
61
+ longDate: string;
62
+ }
63
+
64
+ /**
65
+ * Las líneas de la estampa del folio, de arriba abajo: el tipo (o su sigla) con el número, la fecha y el texto fijo. Lo
66
+ * usan el ms al firmar la estampa y la vista previa de las pantallas, para que se vean igual.
67
+ */
68
+ export const folioStampLines = (format: DocumentFolioFormat, data: FolioStampData): string[] => {
69
+ const number = `N° ${data.correlative}${format.number === 'numberYear' ? `/${data.correlativeYear}` : ''}`;
70
+ const label =
71
+ format.label === 'name'
72
+ ? data.typeName.toUpperCase()
73
+ : format.label === 'abbreviation'
74
+ ? (data.abbreviation || data.typeName).trim()
75
+ : '';
76
+
77
+ return [
78
+ label ? `${label} ${number}` : number,
79
+ ...(format.date === 'short' ? [data.shortDate] : format.date === 'long' ? [data.longDate] : []),
80
+ ...(format.text?.trim() ? [format.text.trim()] : []),
81
+ ];
82
+ };
@@ -2,3 +2,4 @@ export * from './document.entity';
2
2
  export * from './richStyle';
3
3
  export * from './stampPlacement';
4
4
  export * from './richDistribution';
5
+ export * from './folio';
@@ -1,5 +1,6 @@
1
1
  import { type DocumentCategory, DocumentTypeEntity, DocumentTypeFlowStepEntity } from '../../base/entities';
2
2
  import { type DocumentTemplateContent } from '../documentTemplate/documentTemplate.entity';
3
+ import { type DocumentFolioFormat } from '../document/folio';
3
4
 
4
5
  /** Paso del flujo sugerido de un tipo documental: quién visa o firma, en su orden. */
5
6
  export interface DocumentTypeFlowStepResponseEntity {
@@ -35,6 +36,8 @@ export interface DocumentTypeGetAllResponseEntity {
35
36
  usesPartsOffice: DocumentTypeEntity['usesPartsOffice'];
36
37
  /** En la categoría Decreto: si sus decretos son exentos o afectos. En las demás, `null`. */
37
38
  decreeKind: DocumentTypeEntity['decreeKind'];
39
+ /** Cómo se ve la estampa del folio de sus documentos; `null`: la de siempre (`DEFAULT_FOLIO_FORMAT`). */
40
+ folioFormat: DocumentFolioFormat | null;
38
41
  // Plazos de servicio (SLA) en días hábiles: de la tramitación completa (desde que entra a tramitación o se aprueba
39
42
  // el oficial), de cada turno de visación o firma y de cada ronda de revisión del borrador o del oficial. `null`: sin
40
43
  // plazo.
@@ -1,3 +1,4 @@
1
+ import { type DocumentFolioDraft } from '../document/folio';
1
2
  import { type PdfSignatureReportEntity } from '../signatureCheck';
2
3
  import {
3
4
  type DocumentDispatchResponseEntity,
@@ -43,6 +44,8 @@ export interface PartsOfficeDispatchEntity extends DocumentDispatchResponseEntit
43
44
  externalRecipients: DocumentExternalRecipientResponseEntity[];
44
45
  /** A nombre de quién sale: la entidad emisora del tipo documental o la municipalidad. */
45
46
  issuerName: string;
47
+ /** Si está por foliar: lo necesario para proponer la estampa del folio sobre su vista previa. */
48
+ folioDraft: DocumentFolioDraft | null;
46
49
  createdAt: string;
47
50
  }
48
51