@mdgf11/filesystem-lib 2.0.1 → 2.0.3

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.
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DescritorOficial = void 0;
4
1
  const _descritores = {};
5
- exports.DescritorOficial = new Proxy(_descritores, {
2
+ export const DescritorOficial = new Proxy(_descritores, {
6
3
  get(target, desc, reciever) {
7
4
  if (typeof desc === "symbol")
8
5
  throw new Error("Can only handle strings");
@@ -1,5 +1,5 @@
1
1
  import { PartialJurisprudenciaDocument } from "@stjiris/jurisprudencia-document";
2
- import { ContentType, Date_Area_Section, FilesystemDocument, Retrievable_Metadata, Sharepoint_Metadata } from "./types";
2
+ import { ContentType, Date_Area_Section, FilesystemDocument, Retrievable_Metadata, Sharepoint_Metadata } from "./types.js";
3
3
  export declare function writeFilesystemDocument(filesystem_document: FilesystemDocument): void;
4
4
  export declare function loadFilesystemDocument(jsonPath: string): FilesystemDocument;
5
5
  export declare function createJurisprudenciaDocument(retrievable_Metadata: Retrievable_Metadata, contents: ContentType[], date_area_section: Date_Area_Section, sharepoint_metadata?: Sharepoint_Metadata): Promise<PartialJurisprudenciaDocument>;
@@ -1,53 +1,10 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.writeFilesystemDocument = writeFilesystemDocument;
40
- exports.loadFilesystemDocument = loadFilesystemDocument;
41
- exports.createJurisprudenciaDocument = createJurisprudenciaDocument;
42
- exports.hasSelectableText = hasSelectableText;
43
- exports.generateFilePath = generateFilePath;
44
- const jurisprudencia_document_1 = require("@stjiris/jurisprudencia-document");
45
- const fs_1 = __importDefault(require("fs"));
46
- const mammoth_1 = __importDefault(require("mammoth"));
47
- const pdfjsLib = __importStar(require("pdfjs-dist/legacy/build/pdf.mjs"));
48
- const types_1 = require("./types");
49
- const descritores_1 = require("./descritores");
50
- function writeFilesystemDocument(filesystem_document) {
1
+ import { calculateHASH, calculateUUID } from "@stjiris/jurisprudencia-document";
2
+ import fs from "fs";
3
+ import mammoth from "mammoth";
4
+ import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';
5
+ import { DETAILS_NAME, FILESYSTEM_PATH, ORIGINAL_NAME, ROOT_PATH, SHAREPOINT_COPY_PATH } from "./types.js";
6
+ import { DescritorOficial } from "./descritores.js";
7
+ export function writeFilesystemDocument(filesystem_document) {
51
8
  if (!filesystem_document.content)
52
9
  return;
53
10
  const safe = {
@@ -57,37 +14,37 @@ function writeFilesystemDocument(filesystem_document) {
57
14
  const content = filesystem_document.content;
58
15
  if (filesystem_document.file_path) {
59
16
  // make filesystem paths
60
- const filesystem_dir_path = `${types_1.ROOT_PATH}${types_1.FILESYSTEM_PATH}${filesystem_document.file_path}`;
61
- const filesystem_metadata_path = `${filesystem_dir_path}/${types_1.DETAILS_NAME}.json`;
62
- fs_1.default.mkdirSync(filesystem_dir_path, { recursive: true });
63
- fs_1.default.writeFileSync(filesystem_metadata_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
17
+ const filesystem_dir_path = `${ROOT_PATH}${FILESYSTEM_PATH}${filesystem_document.file_path}`;
18
+ const filesystem_metadata_path = `${filesystem_dir_path}/${DETAILS_NAME}.json`;
19
+ fs.mkdirSync(filesystem_dir_path, { recursive: true });
20
+ fs.writeFileSync(filesystem_metadata_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
64
21
  for (const content_i of content) {
65
- const filesystem_original_path = `${filesystem_dir_path}/${types_1.ORIGINAL_NAME}.${content_i.extension}`;
66
- fs_1.default.writeFileSync(filesystem_original_path, content_i.data, { encoding: "utf-8" });
22
+ const filesystem_original_path = `${filesystem_dir_path}/${ORIGINAL_NAME}.${content_i.extension}`;
23
+ fs.writeFileSync(filesystem_original_path, content_i.data, { encoding: "utf-8" });
67
24
  }
68
25
  // make metadata copy on filesystem copy
69
26
  if (filesystem_document.sharepoint_metadata) {
70
- const filesystem_sharepoint_dir_path = `${types_1.ROOT_PATH}${types_1.SHAREPOINT_COPY_PATH}${filesystem_document.sharepoint_metadata.sharepoint_path_rel}`;
71
- const filesystem_sharepoint_path = `${filesystem_sharepoint_dir_path}/${types_1.DETAILS_NAME}.json`;
72
- fs_1.default.mkdirSync(filesystem_sharepoint_dir_path, { recursive: true });
73
- fs_1.default.writeFileSync(filesystem_sharepoint_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
27
+ const filesystem_sharepoint_dir_path = `${ROOT_PATH}${SHAREPOINT_COPY_PATH}${filesystem_document.sharepoint_metadata.sharepoint_path_rel}`;
28
+ const filesystem_sharepoint_path = `${filesystem_sharepoint_dir_path}/${DETAILS_NAME}.json`;
29
+ fs.mkdirSync(filesystem_sharepoint_dir_path, { recursive: true });
30
+ fs.writeFileSync(filesystem_sharepoint_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
74
31
  }
75
32
  }
76
33
  else {
77
34
  if (filesystem_document.sharepoint_metadata) {
78
- const filesystem_sharepoint_dir_path = `${types_1.ROOT_PATH}${types_1.SHAREPOINT_COPY_PATH}${filesystem_document.sharepoint_metadata.sharepoint_path_rel}`;
79
- const filesystem_sharepoint_path = `${filesystem_sharepoint_dir_path}/${types_1.DETAILS_NAME}.json`;
80
- fs_1.default.mkdirSync(filesystem_sharepoint_dir_path, { recursive: true });
81
- fs_1.default.writeFileSync(filesystem_sharepoint_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
35
+ const filesystem_sharepoint_dir_path = `${ROOT_PATH}${SHAREPOINT_COPY_PATH}${filesystem_document.sharepoint_metadata.sharepoint_path_rel}`;
36
+ const filesystem_sharepoint_path = `${filesystem_sharepoint_dir_path}/${DETAILS_NAME}.json`;
37
+ fs.mkdirSync(filesystem_sharepoint_dir_path, { recursive: true });
38
+ fs.writeFileSync(filesystem_sharepoint_path, JSON.stringify(safe, null, 2), { encoding: "utf-8" });
82
39
  for (const content_i of content) {
83
- const filesystem_original_path = `${filesystem_sharepoint_dir_path}/${types_1.ORIGINAL_NAME}.${content_i.extension}`;
84
- fs_1.default.writeFileSync(filesystem_original_path, content_i.data, { encoding: "utf-8" });
40
+ const filesystem_original_path = `${filesystem_sharepoint_dir_path}/${ORIGINAL_NAME}.${content_i.extension}`;
41
+ fs.writeFileSync(filesystem_original_path, content_i.data, { encoding: "utf-8" });
85
42
  }
86
43
  }
87
44
  }
88
45
  }
89
- function loadFilesystemDocument(jsonPath) {
90
- const jsonString = fs_1.default.readFileSync(jsonPath, 'utf-8');
46
+ export function loadFilesystemDocument(jsonPath) {
47
+ const jsonString = fs.readFileSync(jsonPath, 'utf-8');
91
48
  const parsed = JSON.parse(jsonString);
92
49
  return {
93
50
  ...parsed,
@@ -99,7 +56,7 @@ function loadFilesystemDocument(jsonPath) {
99
56
  }))
100
57
  };
101
58
  }
102
- async function createJurisprudenciaDocument(retrievable_Metadata, contents, date_area_section, sharepoint_metadata) {
59
+ export async function createJurisprudenciaDocument(retrievable_Metadata, contents, date_area_section, sharepoint_metadata) {
103
60
  if (!retrievable_Metadata) {
104
61
  throw new Error("Missing metadata.");
105
62
  }
@@ -130,9 +87,9 @@ async function createJurisprudenciaDocument(retrievable_Metadata, contents, date
130
87
  obj.Texto = content.map(line => `<p><font>${line}</font><br>`).join('');
131
88
  if (retrievable_Metadata.descriptors && retrievable_Metadata.descriptors.length > 0) {
132
89
  obj.Descritores = {
133
- Index: retrievable_Metadata.descriptors.map(desc => descritores_1.DescritorOficial[desc]),
90
+ Index: retrievable_Metadata.descriptors.map(desc => DescritorOficial[desc]),
134
91
  Original: retrievable_Metadata.descriptors,
135
- Show: retrievable_Metadata.descriptors.map(desc => descritores_1.DescritorOficial[desc])
92
+ Show: retrievable_Metadata.descriptors.map(desc => DescritorOficial[desc])
136
93
  };
137
94
  }
138
95
  if (date_area_section.area && date_area_section.area.length > 0) {
@@ -150,17 +107,17 @@ async function createJurisprudenciaDocument(retrievable_Metadata, contents, date
150
107
  if (retrievable_Metadata.decision && retrievable_Metadata.decision.length > 0) {
151
108
  obj["Decisão"] = { Index: [retrievable_Metadata.decision], Original: [retrievable_Metadata.decision], Show: [retrievable_Metadata.decision] };
152
109
  }
153
- obj["HASH"] = (0, jurisprudencia_document_1.calculateHASH)({
110
+ obj["HASH"] = calculateHASH({
154
111
  ...obj,
155
112
  Original: obj.Original,
156
113
  "Número de Processo": obj["Número de Processo"] || "",
157
114
  Sumário: obj.Sumário || "",
158
115
  Texto: obj.Texto || "",
159
116
  });
160
- obj["UUID"] = (0, jurisprudencia_document_1.calculateUUID)(obj["HASH"]);
117
+ obj["UUID"] = calculateUUID(obj["HASH"]);
161
118
  return obj;
162
119
  }
163
- async function hasSelectableText(buffer) {
120
+ export async function hasSelectableText(buffer) {
164
121
  try {
165
122
  const uint8Array = new Uint8Array(buffer);
166
123
  const loadingTask = pdfjsLib.getDocument({
@@ -183,7 +140,7 @@ async function hasSelectableText(buffer) {
183
140
  return false;
184
141
  }
185
142
  }
186
- function generateFilePath(date_area_section, retrievable_metadata) {
143
+ export function generateFilePath(date_area_section, retrievable_metadata) {
187
144
  return `/${date_area_section.area}/${date_area_section.file_date.getFullYear()}/${date_area_section.file_date.getMonth() + 1}/${date_area_section.file_date.getDate()}/${retrievable_metadata.process_number.replace("/", "-")}`;
188
145
  }
189
146
  async function extractContent(contents) {
@@ -217,7 +174,7 @@ async function pdfToLines(buffer) {
217
174
  return allLines;
218
175
  }
219
176
  async function docxToLines(buffer) {
220
- const result = await mammoth_1.default.extractRawText({ buffer });
177
+ const result = await mammoth.extractRawText({ buffer });
221
178
  const text = result.value || "";
222
179
  const content = text
223
180
  .split(/\r?\n/)
@@ -1,4 +1,4 @@
1
- import { FilesystemDocument, FilesystemUpdate } from "./types";
1
+ import { FilesystemDocument, FilesystemUpdate } from "./types.js";
2
2
  export declare function addFileToUpdate(update: FilesystemUpdate, filesystem_document: FilesystemDocument): void;
3
3
  export declare function writeFilesystemUpdate(update: FilesystemUpdate): void;
4
4
  export declare function logDocumentProcessingError(update: FilesystemUpdate, err: string): void;
@@ -1,16 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.addFileToUpdate = addFileToUpdate;
7
- exports.writeFilesystemUpdate = writeFilesystemUpdate;
8
- exports.logDocumentProcessingError = logDocumentProcessingError;
9
- exports.loadLastFilesystemUpdate = loadLastFilesystemUpdate;
10
- const path_1 = __importDefault(require("path"));
11
- const fs_1 = __importDefault(require("fs"));
12
- const types_1 = require("./types");
13
- function addFileToUpdate(update, filesystem_document) {
1
+ import path from "path";
2
+ import fs from "fs";
3
+ import { UPDATE_DIR } from "./types.js";
4
+ export function addFileToUpdate(update, filesystem_document) {
14
5
  if (!filesystem_document.file_path) {
15
6
  throw new Error("File to be added to update doesn't have a system path.");
16
7
  }
@@ -23,33 +14,33 @@ function addFileToUpdate(update, filesystem_document) {
23
14
  update.created_num += 1;
24
15
  update.created.push(filesystem_document.file_path);
25
16
  }
26
- function writeFilesystemUpdate(update) {
17
+ export function writeFilesystemUpdate(update) {
27
18
  update.date_end = new Date();
28
- fs_1.default.mkdirSync(types_1.UPDATE_DIR, { recursive: true });
29
- const updates_file_path = `${types_1.UPDATE_DIR}/log_${formatUpdateDate(update.date_end)}.json`;
30
- const drive_dir_path = `${types_1.UPDATE_DIR}/All`;
31
- fs_1.default.mkdirSync(drive_dir_path, { recursive: true });
19
+ fs.mkdirSync(UPDATE_DIR, { recursive: true });
20
+ const updates_file_path = `${UPDATE_DIR}/log_${formatUpdateDate(update.date_end)}.json`;
21
+ const drive_dir_path = `${UPDATE_DIR}/All`;
22
+ fs.mkdirSync(drive_dir_path, { recursive: true });
32
23
  const drive_file_path = `${drive_dir_path}/log_${formatUpdateDate(update.date_end)}.json`;
33
- removeOldUpdate(types_1.UPDATE_DIR);
34
- fs_1.default.writeFileSync(drive_file_path, JSON.stringify(update, null, 2), { encoding: "utf-8" });
35
- fs_1.default.writeFileSync(updates_file_path, JSON.stringify(update, null, 2), { encoding: "utf-8" });
24
+ removeOldUpdate(UPDATE_DIR);
25
+ fs.writeFileSync(drive_file_path, JSON.stringify(update, null, 2), { encoding: "utf-8" });
26
+ fs.writeFileSync(updates_file_path, JSON.stringify(update, null, 2), { encoding: "utf-8" });
36
27
  }
37
- function logDocumentProcessingError(update, err) {
28
+ export function logDocumentProcessingError(update, err) {
38
29
  update.file_errors.push(err);
39
30
  }
40
- function loadLastFilesystemUpdate() {
31
+ export function loadLastFilesystemUpdate() {
41
32
  const empty_update = {
42
33
  updateSource: "STJ (Sharepoint)",
43
34
  file_errors: [],
44
35
  date_start: new Date()
45
36
  };
46
- if (!fs_1.default.existsSync(types_1.UPDATE_DIR))
37
+ if (!fs.existsSync(UPDATE_DIR))
47
38
  return empty_update;
48
- const files = fs_1.default.readdirSync(types_1.UPDATE_DIR);
39
+ const files = fs.readdirSync(UPDATE_DIR);
49
40
  for (const file of files) {
50
- const fullPath = path_1.default.join(types_1.UPDATE_DIR, file);
51
- if (fs_1.default.statSync(fullPath).isFile() && file.toLowerCase().includes("log")) {
52
- const jsonString = fs_1.default.readFileSync(fullPath, 'utf-8');
41
+ const fullPath = path.join(UPDATE_DIR, file);
42
+ if (fs.statSync(fullPath).isFile() && file.toLowerCase().includes("log")) {
43
+ const jsonString = fs.readFileSync(fullPath, 'utf-8');
53
44
  const parsed = JSON.parse(jsonString);
54
45
  return parsed;
55
46
  }
@@ -61,13 +52,13 @@ function formatUpdateDate(d = new Date()) {
61
52
  return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}_${pad(d.getHours())}-${pad(d.getMinutes())}-${pad(d.getSeconds())}`;
62
53
  }
63
54
  function removeOldUpdate(folderPath) {
64
- if (!fs_1.default.existsSync(folderPath))
55
+ if (!fs.existsSync(folderPath))
65
56
  return;
66
- const files = fs_1.default.readdirSync(folderPath);
57
+ const files = fs.readdirSync(folderPath);
67
58
  for (const file of files) {
68
- const fullPath = path_1.default.join(folderPath, file);
69
- if (fs_1.default.statSync(fullPath).isFile() && file.toLowerCase().includes("log")) {
70
- fs_1.default.unlinkSync(fullPath);
59
+ const fullPath = path.join(folderPath, file);
60
+ if (fs.statSync(fullPath).isFile() && file.toLowerCase().includes("log")) {
61
+ fs.unlinkSync(fullPath);
71
62
  console.log(`Deleted: ${fullPath} `);
72
63
  }
73
64
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./filesystemDocumentMethods";
2
- export * from "./filesystemUpdateMethods";
3
- export * from "./types";
1
+ export * from "./filesystemDocumentMethods.js";
2
+ export * from "./filesystemUpdateMethods.js";
3
+ export * from "./types.js";
package/dist/index.js CHANGED
@@ -1,19 +1,3 @@
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("./filesystemDocumentMethods"), exports);
18
- __exportStar(require("./filesystemUpdateMethods"), exports);
19
- __exportStar(require("./types"), exports);
1
+ export * from "./filesystemDocumentMethods.js";
2
+ export * from "./filesystemUpdateMethods.js";
3
+ export * from "./types.js";
package/dist/types.js CHANGED
@@ -1,21 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SUPPORTED_EXTENSIONS = exports.UPDATE_DIR = exports.LOGS_PATH = exports.ORIGINAL_NAME = exports.DETAILS_NAME = exports.SHAREPOINT_COPY_PATH = exports.FILESYSTEM_PATH = exports.ROOT_PATH = exports.UpdateSources = void 0;
7
- exports.isSupportedExtension = isSupportedExtension;
8
- exports.UpdateSources = ["STJ (Sharepoint)", "Juris"];
9
- const dotenv_1 = __importDefault(require("dotenv"));
10
- dotenv_1.default.config();
11
- exports.ROOT_PATH = process.env['LOCAL_ROOT'] || 'results';
12
- exports.FILESYSTEM_PATH = `/FileSystem`;
13
- exports.SHAREPOINT_COPY_PATH = `/Sharepoint`;
14
- exports.DETAILS_NAME = "Detalhes";
15
- exports.ORIGINAL_NAME = "Original";
16
- exports.LOGS_PATH = "/Updates";
17
- exports.UPDATE_DIR = `${exports.ROOT_PATH}${exports.LOGS_PATH}`;
18
- exports.SUPPORTED_EXTENSIONS = ["txt", "pdf", "docx"];
19
- function isSupportedExtension(ext) {
20
- return exports.SUPPORTED_EXTENSIONS.includes(ext);
1
+ export const UpdateSources = ["STJ (Sharepoint)", "Juris"];
2
+ import dotenv from 'dotenv';
3
+ dotenv.config();
4
+ export const ROOT_PATH = process.env['LOCAL_ROOT'] || 'results';
5
+ export const FILESYSTEM_PATH = `/FileSystem`;
6
+ export const SHAREPOINT_COPY_PATH = `/Sharepoint`;
7
+ export const DETAILS_NAME = "Detalhes";
8
+ export const ORIGINAL_NAME = "Original";
9
+ export const LOGS_PATH = "/Updates";
10
+ export const UPDATE_DIR = `${ROOT_PATH}${LOGS_PATH}`;
11
+ export const SUPPORTED_EXTENSIONS = ["txt", "pdf", "docx"];
12
+ export function isSupportedExtension(ext) {
13
+ return SUPPORTED_EXTENSIONS.includes(ext);
21
14
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mdgf11/filesystem-lib",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Library to extend usage of jurisprudencia-document",
5
5
  "license": "ISC",
6
6
  "author": "Miguel Fonseca",
7
- "type": "commonjs",
7
+ "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "types": "dist/index.d.ts",
10
10
  "scripts": {
@@ -1,9 +1,8 @@
1
1
  import { calculateHASH, calculateUUID, JurisprudenciaDocument, PartialJurisprudenciaDocument } from "@stjiris/jurisprudencia-document";
2
2
  import fs from "fs";
3
3
  import mammoth from "mammoth";
4
- import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';
5
- import { ContentType, Date_Area_Section, DETAILS_NAME, FILESYSTEM_PATH, FilesystemDocument, ORIGINAL_NAME, Retrievable_Metadata, ROOT_PATH, SHAREPOINT_COPY_PATH, Sharepoint_Metadata, SupportedUpdateSources } from "./types";
6
- import { DescritorOficial } from "./descritores";
4
+ 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";
5
+ import { DescritorOficial } from "./descritores.js";
7
6
 
8
7
  export function writeFilesystemDocument(filesystem_document: FilesystemDocument): void {
9
8
  if (!filesystem_document.content)
@@ -133,6 +132,7 @@ export async function createJurisprudenciaDocument(retrievable_Metadata: Retriev
133
132
  export async function hasSelectableText(buffer: Buffer): Promise<boolean> {
134
133
  try {
135
134
  const uint8Array = new Uint8Array(buffer);
135
+ const pdfjsLib = await import('pdfjs-dist/legacy/build/pdf.mjs');
136
136
  const loadingTask = pdfjsLib.getDocument({
137
137
  data: uint8Array,
138
138
  standardFontDataUrl: 'node_modules/pdfjs-dist/standard_fonts/',
@@ -178,6 +178,7 @@ async function extractContent(contents: ContentType[]): Promise<string[]> {
178
178
 
179
179
  async function pdfToLines(buffer: Buffer): Promise<string[]> {
180
180
  const uint8Array = new Uint8Array(buffer);
181
+ const pdfjsLib = await import('pdfjs-dist/legacy/build/pdf.mjs');
181
182
  const loadingTask = pdfjsLib.getDocument({ data: uint8Array, verbosity: 0 });
182
183
  const pdf = await loadingTask.promise;
183
184
 
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
- import { FilesystemDocument, FilesystemUpdate, UPDATE_DIR } from "./types";
3
+ import { FilesystemDocument, FilesystemUpdate, UPDATE_DIR } from "./types.js";
4
4
 
5
5
 
6
6
  export function addFileToUpdate(update: FilesystemUpdate, filesystem_document: FilesystemDocument): void {
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./filesystemDocumentMethods"
2
- export * from "./filesystemUpdateMethods"
3
- export * from "./types"
1
+ export * from "./filesystemDocumentMethods.js"
2
+ export * from "./filesystemUpdateMethods.js"
3
+ export * from "./types.js"
package/tsconfig.json CHANGED
@@ -25,9 +25,9 @@
25
25
  // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
26
 
27
27
  /* Modules */
28
- "module": "commonjs", /* Specify what module code is generated. */
28
+ "module": "NodeNext", /* Specify what module code is generated. */
29
29
  "rootDir": "src", /* Specify the root folder within your source files. */
30
- // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
30
+ "moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
31
31
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
32
  // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
33
  // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */