@mdgf11/filesystem-lib 2.2.18 → 2.2.20

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.
@@ -12,6 +12,12 @@ export declare const ANONIMIZADO_NAME = "Anonimizado";
12
12
  * Requires pandoc (and xelatex for PDF) to be available on PATH.
13
13
  */
14
14
  export declare function saveAnonimizedDocument(doc: PartialJurisprudenciaDocument, textoHtml: string, sumarioHtml?: string): Promise<void>;
15
+ /**
16
+ * Moves the filesystem directory of a document when Área or Data changes.
17
+ * Must be called BEFORE updating the document in Elasticsearch.
18
+ * Also updates Detalhes.json inside the directory and writes a Juris update event.
19
+ */
20
+ export declare function moveDecision(currentDoc: PartialJurisprudenciaDocument, updateObject: PartialJurisprudenciaDocument): void;
15
21
  /** @deprecated use loadDocumentFile(doc, "nlp") instead */
16
22
  export declare function loadNlpDocument(jurisprudencia_document: JurisprudenciaDocument): string;
17
23
  export declare function hasSelectableText(buffer: Buffer): Promise<boolean>;
@@ -3,6 +3,7 @@ import fs from "fs";
3
3
  import mammoth from "mammoth";
4
4
  import path from "path";
5
5
  import { DETAILS_NAME, FILESYSTEM_PATH, ORIGINAL_NAME, ROOT_PATH, SHAREPOINT_COPY_PATH } from "./types.js";
6
+ import { writeDocumentEvent } from "./filesystemUpdateMethods.js";
6
7
  import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";
7
8
  export function writeFilesystemDocument(filesystem_document) {
8
9
  if (!filesystem_document.content)
@@ -103,6 +104,82 @@ export async function saveAnonimizedDocument(doc, textoHtml, sumarioHtml) {
103
104
  }
104
105
  catch { /* ignore */ }
105
106
  }
107
+ if (doc.UUID) {
108
+ writeDocumentEvent({
109
+ source: "Juris",
110
+ date: new Date().toISOString(),
111
+ uuid: doc.UUID,
112
+ event: "anonimize",
113
+ new_path: dirPath,
114
+ });
115
+ }
116
+ }
117
+ /**
118
+ * Moves the filesystem directory of a document when Área or Data changes.
119
+ * Must be called BEFORE updating the document in Elasticsearch.
120
+ * Also updates Detalhes.json inside the directory and writes a Juris update event.
121
+ */
122
+ export function moveDecision(currentDoc, updateObject) {
123
+ if (!currentDoc.UUID)
124
+ return;
125
+ const newArea = updateObject.Área;
126
+ const newData = updateObject.Data;
127
+ const areaChanged = newArea?.Show && JSON.stringify(newArea.Show) !== JSON.stringify(currentDoc.Área?.Show);
128
+ const dataChanged = newData && newData !== currentDoc.Data;
129
+ if (!areaChanged && !dataChanged)
130
+ return;
131
+ let oldRelPath;
132
+ try {
133
+ oldRelPath = generateFilePath(currentDoc);
134
+ }
135
+ catch {
136
+ return; // doc missing required metadata
137
+ }
138
+ const oldPath = `${ROOT_PATH}${FILESYSTEM_PATH}${oldRelPath}`;
139
+ if (!fs.existsSync(oldPath))
140
+ return;
141
+ const mergedDoc = {
142
+ ...currentDoc,
143
+ ...(areaChanged ? { Área: newArea } : {}),
144
+ ...(dataChanged ? { Data: newData } : {}),
145
+ };
146
+ let newRelPath;
147
+ try {
148
+ newRelPath = generateFilePath(mergedDoc);
149
+ }
150
+ catch {
151
+ return;
152
+ }
153
+ const newPath = `${ROOT_PATH}${FILESYSTEM_PATH}${newRelPath}`;
154
+ if (oldPath === newPath)
155
+ return;
156
+ fs.mkdirSync(path.dirname(newPath), { recursive: true });
157
+ fs.renameSync(oldPath, newPath);
158
+ // Update Detalhes.json with the new path
159
+ const detalhesPath = path.join(newPath, `${DETAILS_NAME}.json`);
160
+ if (fs.existsSync(detalhesPath)) {
161
+ try {
162
+ const detalhes = JSON.parse(fs.readFileSync(detalhesPath, "utf-8"));
163
+ detalhes.file_path = newRelPath;
164
+ detalhes.last_update_date = new Date().toISOString();
165
+ fs.writeFileSync(detalhesPath, JSON.stringify(detalhes, null, 2), { encoding: "utf-8" });
166
+ }
167
+ catch (err) {
168
+ console.error("moveDecision: failed to update Detalhes.json:", err);
169
+ }
170
+ }
171
+ writeDocumentEvent({
172
+ source: "Juris",
173
+ date: new Date().toISOString(),
174
+ uuid: currentDoc.UUID,
175
+ event: "move",
176
+ old_path: oldPath,
177
+ new_path: newPath,
178
+ changes: {
179
+ ...(areaChanged ? { Área: { from: currentDoc.Área?.Show, to: newArea.Show } } : {}),
180
+ ...(dataChanged ? { Data: { from: currentDoc.Data, to: newData } } : {}),
181
+ }
182
+ });
106
183
  }
107
184
  /** @deprecated use loadDocumentFile(doc, "nlp") instead */
108
185
  export function loadNlpDocument(jurisprudencia_document) {
@@ -1,5 +1,6 @@
1
- import { FilesystemDocument, FilesystemUpdate, SupportedUpdateSources } from "./types.js";
1
+ import { DocumentUpdateEvent, FilesystemDocument, FilesystemUpdate, SupportedUpdateSources } from "./types.js";
2
2
  export declare function logDocumentProcessingError(update: FilesystemUpdate, err: string): void;
3
3
  export declare function addFileToUpdate(update: FilesystemUpdate, filesystem_document: FilesystemDocument): void;
4
4
  export declare function writeFilesystemUpdate(update: FilesystemUpdate, source: SupportedUpdateSources): void;
5
+ export declare function writeDocumentEvent(event: DocumentUpdateEvent): void;
5
6
  export declare function loadLastFilesystemUpdate(source: SupportedUpdateSources): FilesystemUpdate;
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
- import { SOURCE_TO_PATH } from "./types.js";
3
+ import { ALL_UPDATE_DIR, SOURCE_TO_PATH } from "./types.js";
4
4
  export function logDocumentProcessingError(update, err) {
5
5
  update.file_errors.push(err);
6
6
  }
@@ -20,14 +20,26 @@ export function addFileToUpdate(update, filesystem_document) {
20
20
  export function writeFilesystemUpdate(update, source) {
21
21
  update.date_end = new Date();
22
22
  let log_path = SOURCE_TO_PATH[source];
23
+ const timestamp = formatUpdateDate(update.date_end);
23
24
  fs.mkdirSync(log_path, { recursive: true });
24
- const updates_file_path = `${log_path}/log_${formatUpdateDate(update.date_end)}.json`;
25
- const drive_dir_path = `${log_path}/All`;
26
- fs.mkdirSync(drive_dir_path, { recursive: true });
27
- const drive_file_path = `${drive_dir_path}/log_${formatUpdateDate(update.date_end)}.json`;
25
+ const updates_file_path = `${log_path}/${timestamp}_log.json`;
28
26
  removeOldUpdate(log_path);
29
- fs.writeFileSync(drive_file_path, JSON.stringify(update, null, 2), { encoding: "utf-8" });
30
27
  fs.writeFileSync(updates_file_path, JSON.stringify(update, null, 2), { encoding: "utf-8" });
28
+ // Write to global All dir (never deleted — full history of all sources)
29
+ fs.mkdirSync(ALL_UPDATE_DIR, { recursive: true });
30
+ fs.writeFileSync(`${ALL_UPDATE_DIR}/${timestamp}_log_${source.replace(/[^a-zA-Z0-9]/g, "_")}.json`, JSON.stringify(update, null, 2), { encoding: "utf-8" });
31
+ }
32
+ export function writeDocumentEvent(event) {
33
+ const timestamp = formatUpdateDate(new Date(event.date));
34
+ const filename = `${timestamp}_event_${event.event}_${event.uuid}.json`;
35
+ const content = JSON.stringify(event, null, 2);
36
+ // Write to source-specific dir (e.g. Updates/Juris/) — keeps all individual events
37
+ const sourceDir = SOURCE_TO_PATH[event.source];
38
+ fs.mkdirSync(sourceDir, { recursive: true });
39
+ fs.writeFileSync(path.join(sourceDir, filename), content, { encoding: "utf-8" });
40
+ // Write to global All dir (full cross-source history)
41
+ fs.mkdirSync(ALL_UPDATE_DIR, { recursive: true });
42
+ fs.writeFileSync(path.join(ALL_UPDATE_DIR, filename), content, { encoding: "utf-8" });
31
43
  }
32
44
  export function loadLastFilesystemUpdate(source) {
33
45
  const empty_update = {
@@ -38,16 +50,14 @@ export function loadLastFilesystemUpdate(source) {
38
50
  const old_log_path = SOURCE_TO_PATH[source];
39
51
  if (!fs.existsSync(old_log_path))
40
52
  return empty_update;
41
- const files = fs.readdirSync(old_log_path);
42
- for (const file of files) {
43
- const fullPath = path.join(old_log_path, file);
44
- if (fs.statSync(fullPath).isFile() && file.toLowerCase().includes("log")) {
45
- const jsonString = fs.readFileSync(fullPath, 'utf-8');
46
- const parsed = JSON.parse(jsonString);
47
- return parsed;
48
- }
49
- }
50
- return empty_update;
53
+ const files = fs.readdirSync(old_log_path)
54
+ .filter(f => fs.statSync(path.join(old_log_path, f)).isFile() && f.toLowerCase().includes("log"))
55
+ .sort();
56
+ if (files.length === 0)
57
+ return empty_update;
58
+ const fullPath = path.join(old_log_path, files[files.length - 1]);
59
+ const jsonString = fs.readFileSync(fullPath, 'utf-8');
60
+ return JSON.parse(jsonString);
51
61
  }
52
62
  function formatUpdateDate(d = new Date()) {
53
63
  const pad = (n) => n.toString().padStart(2, "0");
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const UpdateSources: readonly ["STJ (Sharepoint)", "DGSI"];
1
+ export declare const UpdateSources: readonly ["STJ (Sharepoint)", "DGSI", "Juris"];
2
2
  export type SupportedUpdateSources = typeof UpdateSources[number];
3
3
  export declare const ROOT_PATH: string;
4
4
  export declare const FILESYSTEM_PATH = "/FileSystem";
@@ -8,8 +8,12 @@ export declare const ORIGINAL_NAME = "Original";
8
8
  export declare const LOGS_PATH = "/Updates";
9
9
  export declare const SHAREPOINT_LOGS_PATH = "/Updates/Sharepoint";
10
10
  export declare const DGSI_LOGS_PATH = "/Updates/DGSI";
11
+ export declare const JURIS_LOGS_PATH = "/Updates/Juris";
12
+ export declare const ALL_LOGS_PATH = "/Updates/All";
11
13
  export declare const SHAREPOINT_UPDATE_DIR: string;
12
14
  export declare const DGSI_UPDATE_DIR: string;
15
+ export declare const JURIS_UPDATE_DIR: string;
16
+ export declare const ALL_UPDATE_DIR: string;
13
17
  export declare const SOURCE_TO_PATH: Record<SupportedUpdateSources, string>;
14
18
  export type FilesystemUpdate = {
15
19
  updateSource: SupportedUpdateSources;
@@ -63,3 +67,12 @@ export type FilesystemDocument = {
63
67
  content?: ContentType[];
64
68
  };
65
69
  export declare function isSupportedExtension(ext: string): ext is Supported_Content_Extensions;
70
+ export type DocumentUpdateEvent = {
71
+ source: SupportedUpdateSources;
72
+ date: string;
73
+ uuid: string;
74
+ event: "move" | "anonimize" | "edit";
75
+ old_path?: string;
76
+ new_path?: string;
77
+ changes?: Record<string, unknown>;
78
+ };
package/dist/types.js CHANGED
@@ -1,4 +1,4 @@
1
- export const UpdateSources = ["STJ (Sharepoint)", "DGSI"];
1
+ export const UpdateSources = ["STJ (Sharepoint)", "DGSI", "Juris"];
2
2
  import dotenv from 'dotenv';
3
3
  dotenv.config();
4
4
  export const ROOT_PATH = process.env['LOCAL_ROOT'] || 'results';
@@ -9,9 +9,13 @@ export const ORIGINAL_NAME = "Original";
9
9
  export const LOGS_PATH = "/Updates";
10
10
  export const SHAREPOINT_LOGS_PATH = `${LOGS_PATH}/Sharepoint`;
11
11
  export const DGSI_LOGS_PATH = `${LOGS_PATH}/DGSI`;
12
+ export const JURIS_LOGS_PATH = `${LOGS_PATH}/Juris`;
13
+ export const ALL_LOGS_PATH = `${LOGS_PATH}/All`;
12
14
  export const SHAREPOINT_UPDATE_DIR = `${ROOT_PATH}${SHAREPOINT_LOGS_PATH}`;
13
15
  export const DGSI_UPDATE_DIR = `${ROOT_PATH}${DGSI_LOGS_PATH}`;
14
- export const SOURCE_TO_PATH = { "STJ (Sharepoint)": SHAREPOINT_UPDATE_DIR, "DGSI": DGSI_UPDATE_DIR };
16
+ export const JURIS_UPDATE_DIR = `${ROOT_PATH}${JURIS_LOGS_PATH}`;
17
+ export const ALL_UPDATE_DIR = `${ROOT_PATH}${ALL_LOGS_PATH}`;
18
+ export const SOURCE_TO_PATH = { "STJ (Sharepoint)": SHAREPOINT_UPDATE_DIR, "DGSI": DGSI_UPDATE_DIR, "Juris": JURIS_UPDATE_DIR };
15
19
  export const SUPPORTED_EXTENSIONS = ["txt", "pdf", "docx", "html", "json"];
16
20
  export function isSupportedExtension(ext) {
17
21
  return SUPPORTED_EXTENSIONS.includes(ext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdgf11/filesystem-lib",
3
- "version": "2.2.18",
3
+ "version": "2.2.20",
4
4
  "description": "Library to extend usage of jurisprudencia-document",
5
5
  "license": "ISC",
6
6
  "author": "Miguel Fonseca",
@@ -3,7 +3,8 @@ import { execFileSync } from "child_process";
3
3
  import fs from "fs";
4
4
  import mammoth from "mammoth";
5
5
  import path from "path";
6
- import { ContentType, Date_Area_Section, DETAILS_NAME, FILESYSTEM_PATH, FilesystemDocument, ORIGINAL_NAME, Retrievable_Metadata, ROOT_PATH, SHAREPOINT_COPY_PATH, Sharepoint_Metadata, SupportedUpdateSources } from "./types.js";
6
+ import { ContentType, Date_Area_Section, DETAILS_NAME, DocumentUpdateEvent, FILESYSTEM_PATH, FilesystemDocument, ORIGINAL_NAME, Retrievable_Metadata, ROOT_PATH, SHAREPOINT_COPY_PATH, Sharepoint_Metadata, SupportedUpdateSources } from "./types.js";
7
+ import { writeDocumentEvent } from "./filesystemUpdateMethods.js";
7
8
  import { DescritorOficial } from "./descritores.js";
8
9
  import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";
9
10
 
@@ -122,6 +123,91 @@ export async function saveAnonimizedDocument(
122
123
  } finally {
123
124
  try { fs.unlinkSync(tmpHtml); } catch { /* ignore */ }
124
125
  }
126
+
127
+ if (doc.UUID) {
128
+ writeDocumentEvent({
129
+ source: "Juris",
130
+ date: new Date().toISOString(),
131
+ uuid: doc.UUID,
132
+ event: "anonimize",
133
+ new_path: dirPath,
134
+ });
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Moves the filesystem directory of a document when Área or Data changes.
140
+ * Must be called BEFORE updating the document in Elasticsearch.
141
+ * Also updates Detalhes.json inside the directory and writes a Juris update event.
142
+ */
143
+ export function moveDecision(
144
+ currentDoc: PartialJurisprudenciaDocument,
145
+ updateObject: PartialJurisprudenciaDocument
146
+ ): void {
147
+ if (!currentDoc.UUID) return;
148
+
149
+ const newArea = updateObject.Área as any;
150
+ const newData = updateObject.Data;
151
+
152
+ const areaChanged = newArea?.Show && JSON.stringify(newArea.Show) !== JSON.stringify((currentDoc as any).Área?.Show);
153
+ const dataChanged = newData && newData !== currentDoc.Data;
154
+
155
+ if (!areaChanged && !dataChanged) return;
156
+
157
+ let oldRelPath: string;
158
+ try {
159
+ oldRelPath = generateFilePath(currentDoc);
160
+ } catch {
161
+ return; // doc missing required metadata
162
+ }
163
+
164
+ const oldPath = `${ROOT_PATH}${FILESYSTEM_PATH}${oldRelPath}`;
165
+ if (!fs.existsSync(oldPath)) return;
166
+
167
+ const mergedDoc = {
168
+ ...currentDoc,
169
+ ...(areaChanged ? { Área: newArea } : {}),
170
+ ...(dataChanged ? { Data: newData } : {}),
171
+ } as PartialJurisprudenciaDocument;
172
+
173
+ let newRelPath: string;
174
+ try {
175
+ newRelPath = generateFilePath(mergedDoc);
176
+ } catch {
177
+ return;
178
+ }
179
+
180
+ const newPath = `${ROOT_PATH}${FILESYSTEM_PATH}${newRelPath}`;
181
+ if (oldPath === newPath) return;
182
+
183
+ fs.mkdirSync(path.dirname(newPath), { recursive: true });
184
+ fs.renameSync(oldPath, newPath);
185
+
186
+ // Update Detalhes.json with the new path
187
+ const detalhesPath = path.join(newPath, `${DETAILS_NAME}.json`);
188
+ if (fs.existsSync(detalhesPath)) {
189
+ try {
190
+ const detalhes = JSON.parse(fs.readFileSync(detalhesPath, "utf-8"));
191
+ detalhes.file_path = newRelPath;
192
+ detalhes.last_update_date = new Date().toISOString();
193
+ fs.writeFileSync(detalhesPath, JSON.stringify(detalhes, null, 2), { encoding: "utf-8" });
194
+ } catch (err) {
195
+ console.error("moveDecision: failed to update Detalhes.json:", err);
196
+ }
197
+ }
198
+
199
+ writeDocumentEvent({
200
+ source: "Juris",
201
+ date: new Date().toISOString(),
202
+ uuid: currentDoc.UUID,
203
+ event: "move",
204
+ old_path: oldPath,
205
+ new_path: newPath,
206
+ changes: {
207
+ ...(areaChanged ? { Área: { from: (currentDoc as any).Área?.Show, to: newArea.Show } } : {}),
208
+ ...(dataChanged ? { Data: { from: currentDoc.Data, to: newData } } : {}),
209
+ }
210
+ });
125
211
  }
126
212
 
127
213
  /** @deprecated use loadDocumentFile(doc, "nlp") instead */
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
- import { FilesystemDocument, FilesystemUpdate, SHAREPOINT_UPDATE_DIR, SOURCE_TO_PATH, SupportedUpdateSources } from "./types.js";
3
+ import { ALL_UPDATE_DIR, DocumentUpdateEvent, FilesystemDocument, FilesystemUpdate, SOURCE_TO_PATH, SupportedUpdateSources } from "./types.js";
4
4
 
5
5
  export function logDocumentProcessingError(update: FilesystemUpdate, err: string) {
6
6
  update.file_errors.push(err);
@@ -26,18 +26,32 @@ export function writeFilesystemUpdate(update: FilesystemUpdate, source: Supporte
26
26
  update.date_end = new Date();
27
27
 
28
28
  let log_path: string = SOURCE_TO_PATH[source];
29
+ const timestamp = formatUpdateDate(update.date_end);
29
30
 
30
31
  fs.mkdirSync(log_path, { recursive: true });
31
- const updates_file_path = `${log_path}/log_${formatUpdateDate(update.date_end)}.json`;
32
-
33
- const drive_dir_path = `${log_path}/All`
34
- fs.mkdirSync(drive_dir_path, { recursive: true });
35
- const drive_file_path = `${drive_dir_path}/log_${formatUpdateDate(update.date_end)}.json`;
32
+ const updates_file_path = `${log_path}/${timestamp}_log.json`;
36
33
 
37
34
  removeOldUpdate(log_path);
38
-
39
- fs.writeFileSync(drive_file_path, JSON.stringify(update, null, 2), { encoding: "utf-8" });
40
35
  fs.writeFileSync(updates_file_path, JSON.stringify(update, null, 2), { encoding: "utf-8" });
36
+
37
+ // Write to global All dir (never deleted — full history of all sources)
38
+ fs.mkdirSync(ALL_UPDATE_DIR, { recursive: true });
39
+ fs.writeFileSync(`${ALL_UPDATE_DIR}/${timestamp}_log_${source.replace(/[^a-zA-Z0-9]/g, "_")}.json`, JSON.stringify(update, null, 2), { encoding: "utf-8" });
40
+ }
41
+
42
+ export function writeDocumentEvent(event: DocumentUpdateEvent): void {
43
+ const timestamp = formatUpdateDate(new Date(event.date));
44
+ const filename = `${timestamp}_event_${event.event}_${event.uuid}.json`;
45
+ const content = JSON.stringify(event, null, 2);
46
+
47
+ // Write to source-specific dir (e.g. Updates/Juris/) — keeps all individual events
48
+ const sourceDir = SOURCE_TO_PATH[event.source];
49
+ fs.mkdirSync(sourceDir, { recursive: true });
50
+ fs.writeFileSync(path.join(sourceDir, filename), content, { encoding: "utf-8" });
51
+
52
+ // Write to global All dir (full cross-source history)
53
+ fs.mkdirSync(ALL_UPDATE_DIR, { recursive: true });
54
+ fs.writeFileSync(path.join(ALL_UPDATE_DIR, filename), content, { encoding: "utf-8" });
41
55
  }
42
56
 
43
57
  export function loadLastFilesystemUpdate(source: SupportedUpdateSources): FilesystemUpdate {
@@ -52,16 +66,15 @@ export function loadLastFilesystemUpdate(source: SupportedUpdateSources): Filesy
52
66
  if (!fs.existsSync(old_log_path))
53
67
  return empty_update;
54
68
 
55
- const files = fs.readdirSync(old_log_path);
56
- for (const file of files) {
57
- const fullPath = path.join(old_log_path, file);
58
- if (fs.statSync(fullPath).isFile() && file.toLowerCase().includes("log")) {
59
- const jsonString = fs.readFileSync(fullPath, 'utf-8');
60
- const parsed: FilesystemUpdate = JSON.parse(jsonString);
61
- return parsed;
62
- }
63
- }
64
- return empty_update;
69
+ const files = fs.readdirSync(old_log_path)
70
+ .filter(f => fs.statSync(path.join(old_log_path, f)).isFile() && f.toLowerCase().includes("log"))
71
+ .sort();
72
+
73
+ if (files.length === 0) return empty_update;
74
+
75
+ const fullPath = path.join(old_log_path, files[files.length - 1]);
76
+ const jsonString = fs.readFileSync(fullPath, 'utf-8');
77
+ return JSON.parse(jsonString) as FilesystemUpdate;
65
78
  }
66
79
 
67
80
  function formatUpdateDate(d: Date = new Date()): string {
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- export const UpdateSources = ["STJ (Sharepoint)", "DGSI"] as const;
2
+ export const UpdateSources = ["STJ (Sharepoint)", "DGSI", "Juris"] as const;
3
3
  export type SupportedUpdateSources = typeof UpdateSources[number];
4
4
  import dotenv from 'dotenv';
5
5
 
@@ -13,11 +13,15 @@ export const LOGS_PATH = "/Updates";
13
13
 
14
14
  export const SHAREPOINT_LOGS_PATH = `${LOGS_PATH}/Sharepoint`;
15
15
  export const DGSI_LOGS_PATH = `${LOGS_PATH}/DGSI`;
16
+ export const JURIS_LOGS_PATH = `${LOGS_PATH}/Juris`;
17
+ export const ALL_LOGS_PATH = `${LOGS_PATH}/All`;
16
18
 
17
19
  export const SHAREPOINT_UPDATE_DIR = `${ROOT_PATH}${SHAREPOINT_LOGS_PATH}`;
18
20
  export const DGSI_UPDATE_DIR = `${ROOT_PATH}${DGSI_LOGS_PATH}`;
21
+ export const JURIS_UPDATE_DIR = `${ROOT_PATH}${JURIS_LOGS_PATH}`;
22
+ export const ALL_UPDATE_DIR = `${ROOT_PATH}${ALL_LOGS_PATH}`;
19
23
 
20
- export const SOURCE_TO_PATH: Record<SupportedUpdateSources, string> = { "STJ (Sharepoint)": SHAREPOINT_UPDATE_DIR, "DGSI": DGSI_UPDATE_DIR };
24
+ export const SOURCE_TO_PATH: Record<SupportedUpdateSources, string> = { "STJ (Sharepoint)": SHAREPOINT_UPDATE_DIR, "DGSI": DGSI_UPDATE_DIR, "Juris": JURIS_UPDATE_DIR };
21
25
 
22
26
  export type FilesystemUpdate = {
23
27
  updateSource: SupportedUpdateSources,
@@ -65,3 +69,13 @@ export type FilesystemDocument = {
65
69
  export function isSupportedExtension(ext: string): ext is Supported_Content_Extensions {
66
70
  return (SUPPORTED_EXTENSIONS as readonly string[]).includes(ext);
67
71
  };
72
+
73
+ export type DocumentUpdateEvent = {
74
+ source: SupportedUpdateSources,
75
+ date: string,
76
+ uuid: string,
77
+ event: "move" | "anonimize" | "edit",
78
+ old_path?: string,
79
+ new_path?: string,
80
+ changes?: Record<string, unknown>
81
+ };