@quatrain/okf-ingest-catalog 1.0.1-beta.0 → 1.0.1-beta.1
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/engine.js +6 -5
- package/package.json +2 -2
- package/src/engine.ts +6 -5
package/dist/engine.js
CHANGED
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ingestCatalogMonograph = ingestCatalogMonograph;
|
|
37
|
+
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
37
38
|
const fs = __importStar(require("node:fs/promises"));
|
|
38
39
|
const path = __importStar(require("node:path"));
|
|
39
40
|
const okf_ingest_1 = require("@quatrain/okf-ingest");
|
|
@@ -62,9 +63,9 @@ async function ingestCatalogMonograph(input, options) {
|
|
|
62
63
|
};
|
|
63
64
|
// 1. Prepare target filesystem structure
|
|
64
65
|
const bookRelativeFolder = path.join('content', input.category, bookSlug);
|
|
65
|
-
const absoluteBookFolder = path.
|
|
66
|
+
const absoluteBookFolder = path.resolve(options.gitLocalPath, bookRelativeFolder);
|
|
66
67
|
const entriesRelativeFolder = path.join(bookRelativeFolder, 'entries');
|
|
67
|
-
const absoluteEntriesFolder = path.
|
|
68
|
+
const absoluteEntriesFolder = path.resolve(options.gitLocalPath, entriesRelativeFolder);
|
|
68
69
|
await fs.mkdir(absoluteBookFolder, { recursive: true });
|
|
69
70
|
await fs.mkdir(absoluteEntriesFolder, { recursive: true });
|
|
70
71
|
const allCreatedFiles = [];
|
|
@@ -123,7 +124,7 @@ Chapter ${ch.index}: "${ch.title}".`,
|
|
|
123
124
|
originalLanguage: input.originalLanguage || 'fr',
|
|
124
125
|
});
|
|
125
126
|
const chapterRelPath = path.join(bookRelativeFolder, `${ch.slug}.md`);
|
|
126
|
-
const absoluteChapterPath = path.
|
|
127
|
+
const absoluteChapterPath = path.resolve(options.gitLocalPath, chapterRelPath);
|
|
127
128
|
const content = (0, okf_ingest_1.serializeOkfDocument)(chapterMetadata, chapterResult.body);
|
|
128
129
|
await fs.writeFile(absoluteChapterPath, content, 'utf-8');
|
|
129
130
|
allCreatedFiles.push(chapterRelPath);
|
|
@@ -170,7 +171,7 @@ Chapter ${ch.index}: "${ch.title}".`,
|
|
|
170
171
|
const cleanSlugName = (0, detector_1.slugify)(entryNamingSeed);
|
|
171
172
|
const finalEntrySlug = `${String(entryChunk.sequence).padStart(3, '0')}-${cleanSlugName}`;
|
|
172
173
|
const entryRelPath = path.join(entriesRelativeFolder, `${finalEntrySlug}.md`);
|
|
173
|
-
const absoluteEntryPath = path.
|
|
174
|
+
const absoluteEntryPath = path.resolve(options.gitLocalPath, entryRelPath);
|
|
174
175
|
const entrySerialized = (0, okf_ingest_1.serializeOkfDocument)(entryResult.metadata, entryResult.body);
|
|
175
176
|
await fs.writeFile(absoluteEntryPath, entrySerialized, 'utf-8');
|
|
176
177
|
allCreatedFiles.push(entryRelPath);
|
|
@@ -269,7 +270,7 @@ Chapter ${ch.index}: "${ch.title}".`,
|
|
|
269
270
|
masterBody += `\n`;
|
|
270
271
|
}
|
|
271
272
|
const masterIndexPath = path.join(bookRelativeFolder, 'index.md');
|
|
272
|
-
const absoluteMasterIndexPath = path.
|
|
273
|
+
const absoluteMasterIndexPath = path.resolve(options.gitLocalPath, masterIndexPath);
|
|
273
274
|
const masterContent = (0, okf_ingest_1.serializeOkfDocument)(masterMetadata, masterBody);
|
|
274
275
|
await fs.writeFile(absoluteMasterIndexPath, masterContent, 'utf-8');
|
|
275
276
|
allCreatedFiles.push(masterIndexPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/okf-ingest-catalog",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.1",
|
|
4
4
|
"description": "Agnostic ingestion and decomposition engine for encyclopedic catalogs, plant floras, dictionaries, pharmacopeias, and ordered entry collections into OKF v0.2 atomic entities",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@quatrain/ai": "^1.1.5",
|
|
29
29
|
"@quatrain/core": "^1.2.20",
|
|
30
30
|
"@quatrain/log": "^1.2.6",
|
|
31
|
-
"@quatrain/okf-ingest": "^1.0.1-beta.
|
|
31
|
+
"@quatrain/okf-ingest": "^1.0.1-beta.1",
|
|
32
32
|
"@quatrain/types": "^1.2.18",
|
|
33
33
|
"pdf-parse": "^1.1.1",
|
|
34
34
|
"yaml": "^2.4.0"
|
package/src/engine.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
1
2
|
import * as fs from 'node:fs/promises';
|
|
2
3
|
import * as path from 'node:path';
|
|
3
4
|
import {
|
|
@@ -76,9 +77,9 @@ export async function ingestCatalogMonograph(
|
|
|
76
77
|
|
|
77
78
|
// 1. Prepare target filesystem structure
|
|
78
79
|
const bookRelativeFolder = path.join('content', input.category, bookSlug);
|
|
79
|
-
const absoluteBookFolder = path.
|
|
80
|
+
const absoluteBookFolder = path.resolve(options.gitLocalPath, bookRelativeFolder);
|
|
80
81
|
const entriesRelativeFolder = path.join(bookRelativeFolder, 'entries');
|
|
81
|
-
const absoluteEntriesFolder = path.
|
|
82
|
+
const absoluteEntriesFolder = path.resolve(options.gitLocalPath, entriesRelativeFolder);
|
|
82
83
|
|
|
83
84
|
await fs.mkdir(absoluteBookFolder, { recursive: true });
|
|
84
85
|
await fs.mkdir(absoluteEntriesFolder, { recursive: true });
|
|
@@ -148,7 +149,7 @@ Chapter ${ch.index}: "${ch.title}".`,
|
|
|
148
149
|
});
|
|
149
150
|
|
|
150
151
|
const chapterRelPath = path.join(bookRelativeFolder, `${ch.slug}.md`);
|
|
151
|
-
const absoluteChapterPath = path.
|
|
152
|
+
const absoluteChapterPath = path.resolve(options.gitLocalPath, chapterRelPath);
|
|
152
153
|
const content = serializeOkfDocument(chapterMetadata, chapterResult.body);
|
|
153
154
|
await fs.writeFile(absoluteChapterPath, content, 'utf-8');
|
|
154
155
|
|
|
@@ -203,7 +204,7 @@ Chapter ${ch.index}: "${ch.title}".`,
|
|
|
203
204
|
const finalEntrySlug = `${String(entryChunk.sequence).padStart(3, '0')}-${cleanSlugName}`;
|
|
204
205
|
|
|
205
206
|
const entryRelPath = path.join(entriesRelativeFolder, `${finalEntrySlug}.md`);
|
|
206
|
-
const absoluteEntryPath = path.
|
|
207
|
+
const absoluteEntryPath = path.resolve(options.gitLocalPath, entryRelPath);
|
|
207
208
|
const entrySerialized = serializeOkfDocument(entryResult.metadata, entryResult.body);
|
|
208
209
|
await fs.writeFile(absoluteEntryPath, entrySerialized, 'utf-8');
|
|
209
210
|
|
|
@@ -309,7 +310,7 @@ Chapter ${ch.index}: "${ch.title}".`,
|
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
const masterIndexPath = path.join(bookRelativeFolder, 'index.md');
|
|
312
|
-
const absoluteMasterIndexPath = path.
|
|
313
|
+
const absoluteMasterIndexPath = path.resolve(options.gitLocalPath, masterIndexPath);
|
|
313
314
|
const masterContent = serializeOkfDocument(masterMetadata, masterBody);
|
|
314
315
|
await fs.writeFile(absoluteMasterIndexPath, masterContent, 'utf-8');
|
|
315
316
|
allCreatedFiles.push(masterIndexPath);
|