@mdgf11/filesystem-lib 2.2.21 → 2.2.23
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.
|
@@ -5,7 +5,13 @@ export declare function loadFilesystemDocument(jsonPath: string): FilesystemDocu
|
|
|
5
5
|
export type DocumentFileType = "nlp" | "details" | "pdf" | "docx" | "txt";
|
|
6
6
|
export declare function loadDocumentFile(doc: PartialJurisprudenciaDocument, type: "nlp" | "details"): string;
|
|
7
7
|
export declare function loadDocumentFile(doc: PartialJurisprudenciaDocument, type: "pdf" | "docx" | "txt"): Buffer;
|
|
8
|
+
export declare function writeContentToDocument(doc: PartialJurisprudenciaDocument, content: ContentType, isSumario: boolean): void;
|
|
8
9
|
export declare const ANONIMIZADO_NAME = "Anonimizado";
|
|
10
|
+
/**
|
|
11
|
+
* Saves the anonymized entities JSON as Anonimizado.json in the document's filesystem directory.
|
|
12
|
+
* This file is separate from the NLP Entities.json and records the final entities after anonymization.
|
|
13
|
+
*/
|
|
14
|
+
export declare function saveAnonimizedEntities(doc: PartialJurisprudenciaDocument, entities: Record<string, string[]>): void;
|
|
9
15
|
/**
|
|
10
16
|
* Converts the anonymized HTML text (and optionally summary) to DOCX and PDF files
|
|
11
17
|
* saved as Anonimizado.docx / Anonimizado.pdf in the document's filesystem directory.
|
|
@@ -2,7 +2,7 @@ import { execFileSync } from "child_process";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import mammoth from "mammoth";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { DETAILS_NAME, ENTITIES_NAME, FILESYSTEM_PATH,
|
|
5
|
+
import { DETAILS_NAME, ENTITIES_NAME, FILESYSTEM_PATH, ROOT_PATH, SHAREPOINT_COPY_PATH, SUMARIO_NAME, TEXTO_NAME } from "./types.js";
|
|
6
6
|
import { writeDocumentEvent } from "./filesystemUpdateMethods.js";
|
|
7
7
|
import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
8
8
|
export function writeFilesystemDocument(filesystem_document) {
|
|
@@ -20,7 +20,7 @@ export function writeFilesystemDocument(filesystem_document) {
|
|
|
20
20
|
fs.mkdirSync(filesystem_dir_path, { recursive: true });
|
|
21
21
|
fs.writeFileSync(filesystem_metadata_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
|
|
22
22
|
for (const content_i of content) {
|
|
23
|
-
const name = content_i.extension === "json" ? ENTITIES_NAME :
|
|
23
|
+
const name = content_i.extension === "json" ? ENTITIES_NAME : TEXTO_NAME;
|
|
24
24
|
const filesystem_original_path = `${filesystem_dir_path}/${name}.${content_i.extension}`;
|
|
25
25
|
fs.writeFileSync(filesystem_original_path, content_i.data, { encoding: "utf-8" });
|
|
26
26
|
}
|
|
@@ -39,7 +39,7 @@ export function writeFilesystemDocument(filesystem_document) {
|
|
|
39
39
|
fs.mkdirSync(filesystem_sharepoint_dir_path, { recursive: true });
|
|
40
40
|
fs.writeFileSync(filesystem_sharepoint_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
|
|
41
41
|
for (const content_i of content) {
|
|
42
|
-
const name = content_i.extension === "json" ? ENTITIES_NAME :
|
|
42
|
+
const name = content_i.extension === "json" ? ENTITIES_NAME : TEXTO_NAME;
|
|
43
43
|
const filesystem_original_path = `${filesystem_sharepoint_dir_path}/${name}.${content_i.extension}`;
|
|
44
44
|
fs.writeFileSync(filesystem_original_path, content_i.data, { encoding: "utf-8" });
|
|
45
45
|
}
|
|
@@ -67,9 +67,25 @@ export function loadDocumentFile(doc, type) {
|
|
|
67
67
|
if (type === "details") {
|
|
68
68
|
return fs.readFileSync(`${dirPath}/${DETAILS_NAME}.json`, "utf-8");
|
|
69
69
|
}
|
|
70
|
-
return fs.readFileSync(`${dirPath}/${
|
|
70
|
+
return fs.readFileSync(`${dirPath}/${TEXTO_NAME}.${type}`);
|
|
71
|
+
}
|
|
72
|
+
export function writeContentToDocument(doc, content, isSumario) {
|
|
73
|
+
const filePath = generateFilePath(doc);
|
|
74
|
+
const dirPath = `${ROOT_PATH}${FILESYSTEM_PATH}${filePath}`;
|
|
75
|
+
const name = isSumario ? SUMARIO_NAME : TEXTO_NAME;
|
|
76
|
+
fs.writeFileSync(`${dirPath}/${name}.${content.extension}`, content.data);
|
|
71
77
|
}
|
|
72
78
|
export const ANONIMIZADO_NAME = "Anonimizado";
|
|
79
|
+
/**
|
|
80
|
+
* Saves the anonymized entities JSON as Anonimizado.json in the document's filesystem directory.
|
|
81
|
+
* This file is separate from the NLP Entities.json and records the final entities after anonymization.
|
|
82
|
+
*/
|
|
83
|
+
export function saveAnonimizedEntities(doc, entities) {
|
|
84
|
+
const dirPath = `${ROOT_PATH}${FILESYSTEM_PATH}${generateFilePath(doc)}`;
|
|
85
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
86
|
+
const jsonPath = path.join(dirPath, `${ANONIMIZADO_NAME}.json`);
|
|
87
|
+
fs.writeFileSync(jsonPath, JSON.stringify(entities, null, 2), { encoding: "utf-8" });
|
|
88
|
+
}
|
|
73
89
|
/**
|
|
74
90
|
* Converts the anonymized HTML text (and optionally summary) to DOCX and PDF files
|
|
75
91
|
* saved as Anonimizado.docx / Anonimizado.pdf in the document's filesystem directory.
|
package/dist/types.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export declare const ROOT_PATH: string;
|
|
|
4
4
|
export declare const FILESYSTEM_PATH = "/FileSystem";
|
|
5
5
|
export declare const SHAREPOINT_COPY_PATH = "/Sharepoint";
|
|
6
6
|
export declare const DETAILS_NAME = "Detalhes";
|
|
7
|
-
export declare const ORIGINAL_NAME = "Original";
|
|
8
7
|
export declare const ENTITIES_NAME = "Entities";
|
|
8
|
+
export declare const TEXTO_NAME = "Texto";
|
|
9
|
+
export declare const SUMARIO_NAME = "Sum\u00E1rio";
|
|
9
10
|
export declare const LOGS_PATH = "/Updates";
|
|
10
11
|
export declare const SHAREPOINT_LOGS_PATH = "/Updates/Sharepoint";
|
|
11
12
|
export declare const DGSI_LOGS_PATH = "/Updates/DGSI";
|
package/dist/types.js
CHANGED
|
@@ -5,8 +5,9 @@ export const ROOT_PATH = process.env['LOCAL_ROOT'] || 'results';
|
|
|
5
5
|
export const FILESYSTEM_PATH = `/FileSystem`;
|
|
6
6
|
export const SHAREPOINT_COPY_PATH = `/Sharepoint`;
|
|
7
7
|
export const DETAILS_NAME = "Detalhes";
|
|
8
|
-
export const ORIGINAL_NAME = "Original";
|
|
9
8
|
export const ENTITIES_NAME = "Entities";
|
|
9
|
+
export const TEXTO_NAME = "Texto";
|
|
10
|
+
export const SUMARIO_NAME = "Sumário";
|
|
10
11
|
export const LOGS_PATH = "/Updates";
|
|
11
12
|
export const SHAREPOINT_LOGS_PATH = `${LOGS_PATH}/Sharepoint`;
|
|
12
13
|
export const DGSI_LOGS_PATH = `${LOGS_PATH}/DGSI`;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ 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, DocumentUpdateEvent, ENTITIES_NAME, FILESYSTEM_PATH, FilesystemDocument,
|
|
6
|
+
import { ContentType, Date_Area_Section, DETAILS_NAME, DocumentUpdateEvent, ENTITIES_NAME, FILESYSTEM_PATH, FilesystemDocument, Retrievable_Metadata, ROOT_PATH, SHAREPOINT_COPY_PATH, Sharepoint_Metadata, SUMARIO_NAME, SupportedUpdateSources, TEXTO_NAME } from "./types.js";
|
|
7
7
|
import { writeDocumentEvent } from "./filesystemUpdateMethods.js";
|
|
8
8
|
import { DescritorOficial } from "./descritores.js";
|
|
9
9
|
import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
@@ -26,7 +26,7 @@ export function writeFilesystemDocument(filesystem_document: FilesystemDocument)
|
|
|
26
26
|
fs.mkdirSync(filesystem_dir_path, { recursive: true });
|
|
27
27
|
fs.writeFileSync(filesystem_metadata_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
|
|
28
28
|
for (const content_i of content) {
|
|
29
|
-
const name = content_i.extension === "json" ? ENTITIES_NAME :
|
|
29
|
+
const name = content_i.extension === "json" ? ENTITIES_NAME : TEXTO_NAME;
|
|
30
30
|
const filesystem_original_path = `${filesystem_dir_path}/${name}.${content_i.extension}`;
|
|
31
31
|
fs.writeFileSync(filesystem_original_path, content_i.data, { encoding: "utf-8" });
|
|
32
32
|
}
|
|
@@ -45,7 +45,7 @@ export function writeFilesystemDocument(filesystem_document: FilesystemDocument)
|
|
|
45
45
|
fs.mkdirSync(filesystem_sharepoint_dir_path, { recursive: true });
|
|
46
46
|
fs.writeFileSync(filesystem_sharepoint_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
|
|
47
47
|
for (const content_i of content) {
|
|
48
|
-
const name = content_i.extension === "json" ? ENTITIES_NAME :
|
|
48
|
+
const name = content_i.extension === "json" ? ENTITIES_NAME : TEXTO_NAME;
|
|
49
49
|
const filesystem_original_path = `${filesystem_sharepoint_dir_path}/${name}.${content_i.extension}`;
|
|
50
50
|
fs.writeFileSync(filesystem_original_path, content_i.data, { encoding: "utf-8" });
|
|
51
51
|
}
|
|
@@ -80,11 +80,36 @@ export function loadDocumentFile(doc: PartialJurisprudenciaDocument, type: Docum
|
|
|
80
80
|
if (type === "details") {
|
|
81
81
|
return fs.readFileSync(`${dirPath}/${DETAILS_NAME}.json`, "utf-8");
|
|
82
82
|
}
|
|
83
|
-
return fs.readFileSync(`${dirPath}/${
|
|
83
|
+
return fs.readFileSync(`${dirPath}/${TEXTO_NAME}.${type}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function writeContentToDocument(
|
|
87
|
+
doc: PartialJurisprudenciaDocument,
|
|
88
|
+
content: ContentType,
|
|
89
|
+
isSumario: boolean
|
|
90
|
+
): void {
|
|
91
|
+
const filePath = generateFilePath(doc);
|
|
92
|
+
const dirPath = `${ROOT_PATH}${FILESYSTEM_PATH}${filePath}`;
|
|
93
|
+
const name = isSumario ? SUMARIO_NAME : TEXTO_NAME;
|
|
94
|
+
fs.writeFileSync(`${dirPath}/${name}.${content.extension}`, content.data);
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
export const ANONIMIZADO_NAME = "Anonimizado";
|
|
87
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Saves the anonymized entities JSON as Anonimizado.json in the document's filesystem directory.
|
|
101
|
+
* This file is separate from the NLP Entities.json and records the final entities after anonymization.
|
|
102
|
+
*/
|
|
103
|
+
export function saveAnonimizedEntities(
|
|
104
|
+
doc: PartialJurisprudenciaDocument,
|
|
105
|
+
entities: Record<string, string[]>
|
|
106
|
+
): void {
|
|
107
|
+
const dirPath = `${ROOT_PATH}${FILESYSTEM_PATH}${generateFilePath(doc)}`;
|
|
108
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
109
|
+
const jsonPath = path.join(dirPath, `${ANONIMIZADO_NAME}.json`);
|
|
110
|
+
fs.writeFileSync(jsonPath, JSON.stringify(entities, null, 2), { encoding: "utf-8" });
|
|
111
|
+
}
|
|
112
|
+
|
|
88
113
|
/**
|
|
89
114
|
* Converts the anonymized HTML text (and optionally summary) to DOCX and PDF files
|
|
90
115
|
* saved as Anonimizado.docx / Anonimizado.pdf in the document's filesystem directory.
|
package/src/types.ts
CHANGED
|
@@ -8,8 +8,9 @@ export const ROOT_PATH = process.env['LOCAL_ROOT'] || 'results';
|
|
|
8
8
|
export const FILESYSTEM_PATH = `/FileSystem`;
|
|
9
9
|
export const SHAREPOINT_COPY_PATH = `/Sharepoint`;
|
|
10
10
|
export const DETAILS_NAME = "Detalhes";
|
|
11
|
-
export const ORIGINAL_NAME = "Original";
|
|
12
11
|
export const ENTITIES_NAME = "Entities";
|
|
12
|
+
export const TEXTO_NAME = "Texto";
|
|
13
|
+
export const SUMARIO_NAME = "Sumário";
|
|
13
14
|
export const LOGS_PATH = "/Updates";
|
|
14
15
|
|
|
15
16
|
export const SHAREPOINT_LOGS_PATH = `${LOGS_PATH}/Sharepoint`;
|