@mdgf11/filesystem-lib 2.0.12 → 2.0.13
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,7 +1,7 @@
|
|
|
1
|
-
import { PartialJurisprudenciaDocument } from "@stjiris/jurisprudencia-document";
|
|
1
|
+
import { JurisprudenciaDocument, PartialJurisprudenciaDocument } from "@stjiris/jurisprudencia-document";
|
|
2
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>;
|
|
6
6
|
export declare function hasSelectableText(buffer: Buffer): Promise<boolean>;
|
|
7
|
-
export declare function generateFilePath(
|
|
7
|
+
export declare function generateFilePath(jurisprudencia_document: JurisprudenciaDocument): string;
|
|
@@ -140,8 +140,19 @@ export async function hasSelectableText(buffer) {
|
|
|
140
140
|
return false;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
export function generateFilePath(
|
|
144
|
-
|
|
143
|
+
export function generateFilePath(jurisprudencia_document) {
|
|
144
|
+
if (!(jurisprudencia_document.Área && jurisprudencia_document.Data && jurisprudencia_document["Número de Processo"] && jurisprudencia_document.UUID)) {
|
|
145
|
+
throw new Error("Metadata necessária em falta.");
|
|
146
|
+
}
|
|
147
|
+
const data = parseDateFromString(jurisprudencia_document.Data);
|
|
148
|
+
return `/${jurisprudencia_document.Área.Show}/${data.getFullYear()}/${data.getMonth() + 1}/${data.getDate()}/${jurisprudencia_document["Número de Processo"].replace("/", "-")}/${jurisprudencia_document.UUID}`;
|
|
149
|
+
}
|
|
150
|
+
function parseDateFromString(dateStr) {
|
|
151
|
+
const [dayStr, monthStr, yearStr] = dateStr.split("/");
|
|
152
|
+
const day = parseInt(dayStr, 10);
|
|
153
|
+
const month = parseInt(monthStr, 10) - 1;
|
|
154
|
+
const year = yearStr ? parseInt(yearStr, 10) : new Date().getFullYear();
|
|
155
|
+
return new Date(year, month, day);
|
|
145
156
|
}
|
|
146
157
|
async function extractContent(contents) {
|
|
147
158
|
for (const content of contents) {
|
package/package.json
CHANGED
|
@@ -157,8 +157,23 @@ export async function hasSelectableText(buffer: Buffer): Promise<boolean> {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
export function generateFilePath(
|
|
161
|
-
|
|
160
|
+
export function generateFilePath(jurisprudencia_document: JurisprudenciaDocument): string {
|
|
161
|
+
|
|
162
|
+
if (!(jurisprudencia_document.Área && jurisprudencia_document.Data && jurisprudencia_document["Número de Processo"] && jurisprudencia_document.UUID)) {
|
|
163
|
+
throw new Error("Metadata necessária em falta.");
|
|
164
|
+
}
|
|
165
|
+
const data: Date = parseDateFromString(jurisprudencia_document.Data);
|
|
166
|
+
return `/${jurisprudencia_document.Área.Show}/${data.getFullYear()}/${data.getMonth() + 1}/${data.getDate()}/${jurisprudencia_document["Número de Processo"].replace("/", "-")}/${jurisprudencia_document.UUID}`
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function parseDateFromString(dateStr: string): Date {
|
|
170
|
+
const [dayStr, monthStr, yearStr] = dateStr.split("/");
|
|
171
|
+
|
|
172
|
+
const day = parseInt(dayStr, 10);
|
|
173
|
+
const month = parseInt(monthStr, 10) - 1;
|
|
174
|
+
const year = yearStr ? parseInt(yearStr, 10) : new Date().getFullYear();
|
|
175
|
+
|
|
176
|
+
return new Date(year, month, day);
|
|
162
177
|
}
|
|
163
178
|
|
|
164
179
|
async function extractContent(contents: ContentType[]): Promise<string[]> {
|