@mdgf11/filesystem-lib 2.2.7 → 2.2.9
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.
- package/dist/filesystemUpdateMethods.js +6 -5
- package/dist/types.d.ts +3 -2
- package/dist/types.js +3 -2
- package/package.json +2 -2
- package/src/filesystemUpdateMethods.ts +7 -5
- package/src/types.ts +4 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import {
|
|
3
|
+
import { SOURCE_TO_PATH } from "./types.js";
|
|
4
4
|
export function logDocumentProcessingError(update, err) {
|
|
5
5
|
update.file_errors.push(err);
|
|
6
6
|
}
|
|
@@ -19,7 +19,7 @@ export function addFileToUpdate(update, filesystem_document) {
|
|
|
19
19
|
}
|
|
20
20
|
export function writeFilesystemUpdate(update, source) {
|
|
21
21
|
update.date_end = new Date();
|
|
22
|
-
let log_path = source
|
|
22
|
+
let log_path = SOURCE_TO_PATH[source];
|
|
23
23
|
fs.mkdirSync(log_path, { recursive: true });
|
|
24
24
|
const updates_file_path = `${log_path}/log_${formatUpdateDate(update.date_end)}.json`;
|
|
25
25
|
const drive_dir_path = `${log_path}/All`;
|
|
@@ -35,11 +35,12 @@ export function loadLastFilesystemUpdate(source) {
|
|
|
35
35
|
file_errors: [],
|
|
36
36
|
date_start: new Date()
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
const old_log_path = SOURCE_TO_PATH[source];
|
|
39
|
+
if (!fs.existsSync(old_log_path))
|
|
39
40
|
return empty_update;
|
|
40
|
-
const files = fs.readdirSync(
|
|
41
|
+
const files = fs.readdirSync(old_log_path);
|
|
41
42
|
for (const file of files) {
|
|
42
|
-
const fullPath = path.join(
|
|
43
|
+
const fullPath = path.join(old_log_path, file);
|
|
43
44
|
if (fs.statSync(fullPath).isFile() && file.toLowerCase().includes("log")) {
|
|
44
45
|
const jsonString = fs.readFileSync(fullPath, 'utf-8');
|
|
45
46
|
const parsed = JSON.parse(jsonString);
|
package/dist/types.d.ts
CHANGED
|
@@ -8,9 +8,10 @@ export declare const DETAILS_NAME = "Detalhes";
|
|
|
8
8
|
export declare const ORIGINAL_NAME = "Original";
|
|
9
9
|
export declare const LOGS_PATH = "/Updates";
|
|
10
10
|
export declare const SHAREPOINT_LOGS_PATH = "/Updates/Sharepoint";
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const DGSI_LOGS_PATH = "/Updates/Juris";
|
|
12
12
|
export declare const SHAREPOINT_UPDATE_DIR: string;
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const DGSI_UPDATE_DIR: string;
|
|
14
|
+
export declare const SOURCE_TO_PATH: Record<SupportedUpdateSources, string>;
|
|
14
15
|
export type FilesystemUpdate = {
|
|
15
16
|
updateSource: SupportedUpdateSources;
|
|
16
17
|
date_start: Date;
|
package/dist/types.js
CHANGED
|
@@ -8,9 +8,10 @@ export const DETAILS_NAME = "Detalhes";
|
|
|
8
8
|
export const ORIGINAL_NAME = "Original";
|
|
9
9
|
export const LOGS_PATH = "/Updates";
|
|
10
10
|
export const SHAREPOINT_LOGS_PATH = `${LOGS_PATH}/Sharepoint`;
|
|
11
|
-
export const
|
|
11
|
+
export const DGSI_LOGS_PATH = `${LOGS_PATH}/Juris`;
|
|
12
12
|
export const SHAREPOINT_UPDATE_DIR = `${ROOT_PATH}${SHAREPOINT_LOGS_PATH}`;
|
|
13
|
-
export const
|
|
13
|
+
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 };
|
|
14
15
|
export const SUPPORTED_EXTENSIONS = ["txt", "pdf", "docx", "html"];
|
|
15
16
|
export function isSupportedExtension(ext) {
|
|
16
17
|
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.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"description": "Library to extend usage of jurisprudencia-document",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "Miguel Fonseca",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"start": "npm run build && npm run run"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@stjiris/jurisprudencia-document": "npm:@mdgf11/jurisprudencia-document@^13.2.
|
|
16
|
+
"@stjiris/jurisprudencia-document": "npm:@mdgf11/jurisprudencia-document@^13.2.5",
|
|
17
17
|
"axios": "^1.13.1",
|
|
18
18
|
"body-parser": "^2.2.0",
|
|
19
19
|
"canvas": "^2.11.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import {
|
|
3
|
+
import { DGSI_LOGS_PATH, DGSI_UPDATE_DIR, FilesystemDocument, FilesystemUpdate, SHAREPOINT_UPDATE_DIR, 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);
|
|
@@ -25,7 +25,7 @@ export function addFileToUpdate(update: FilesystemUpdate, filesystem_document: F
|
|
|
25
25
|
export function writeFilesystemUpdate(update: FilesystemUpdate, source: SupportedUpdateSources): void {
|
|
26
26
|
update.date_end = new Date();
|
|
27
27
|
|
|
28
|
-
let log_path: string = source
|
|
28
|
+
let log_path: string = SOURCE_TO_PATH[source];
|
|
29
29
|
|
|
30
30
|
fs.mkdirSync(log_path, { recursive: true });
|
|
31
31
|
const updates_file_path = `${log_path}/log_${formatUpdateDate(update.date_end)}.json`;
|
|
@@ -47,12 +47,14 @@ export function loadLastFilesystemUpdate(source: SupportedUpdateSources): Filesy
|
|
|
47
47
|
date_start: new Date()
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
const old_log_path = SOURCE_TO_PATH[source];
|
|
51
|
+
|
|
52
|
+
if (!fs.existsSync(old_log_path))
|
|
51
53
|
return empty_update;
|
|
52
54
|
|
|
53
|
-
const files = fs.readdirSync(
|
|
55
|
+
const files = fs.readdirSync(old_log_path);
|
|
54
56
|
for (const file of files) {
|
|
55
|
-
const fullPath = path.join(
|
|
57
|
+
const fullPath = path.join(old_log_path, file);
|
|
56
58
|
if (fs.statSync(fullPath).isFile() && file.toLowerCase().includes("log")) {
|
|
57
59
|
const jsonString = fs.readFileSync(fullPath, 'utf-8');
|
|
58
60
|
const parsed: FilesystemUpdate = JSON.parse(jsonString);
|
package/src/types.ts
CHANGED
|
@@ -13,10 +13,12 @@ export const ORIGINAL_NAME = "Original"
|
|
|
13
13
|
export const LOGS_PATH = "/Updates"
|
|
14
14
|
|
|
15
15
|
export const SHAREPOINT_LOGS_PATH = `${LOGS_PATH}/Sharepoint`
|
|
16
|
-
export const
|
|
16
|
+
export const DGSI_LOGS_PATH = `${LOGS_PATH}/Juris`
|
|
17
17
|
|
|
18
18
|
export const SHAREPOINT_UPDATE_DIR = `${ROOT_PATH}${SHAREPOINT_LOGS_PATH}`;
|
|
19
|
-
export const
|
|
19
|
+
export const DGSI_UPDATE_DIR = `${ROOT_PATH}${DGSI_LOGS_PATH}`;
|
|
20
|
+
|
|
21
|
+
export const SOURCE_TO_PATH: Record<SupportedUpdateSources, string> = { "STJ (Sharepoint)": SHAREPOINT_UPDATE_DIR, "DGSI": DGSI_UPDATE_DIR };
|
|
20
22
|
|
|
21
23
|
export type FilesystemUpdate = {
|
|
22
24
|
updateSource: SupportedUpdateSources,
|