@peam-ai/next 0.1.4 → 0.1.5
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/index.d.mts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +150 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -140
- package/dist/index.mjs.map +1 -1
- package/dist/peam.adapter.js +3 -6
- package/dist/peam.adapter.js.map +1 -1
- package/dist/route.js +37 -9
- package/dist/route.js.map +1 -1
- package/dist/route.mjs +36 -9
- package/dist/route.mjs.map +1 -1
- package/package.json +2 -2
package/dist/route.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHandler } from 'peam/server';
|
|
2
|
+
import * as fsSync from 'fs';
|
|
2
3
|
import * as fs from 'fs/promises';
|
|
3
4
|
import * as path from 'path';
|
|
4
5
|
|
|
@@ -2445,7 +2446,8 @@ var log3 = loggers.search;
|
|
|
2445
2446
|
var FileBasedSearchIndexExporter = class {
|
|
2446
2447
|
constructor(options) {
|
|
2447
2448
|
this.cachedData = null;
|
|
2448
|
-
|
|
2449
|
+
var _a;
|
|
2450
|
+
this.baseDir = (_a = options.baseDir) != null ? _a : process.cwd();
|
|
2449
2451
|
this.indexPath = options.indexPath;
|
|
2450
2452
|
}
|
|
2451
2453
|
getFullPath() {
|
|
@@ -2483,10 +2485,18 @@ var FileBasedSearchIndexExporter = class {
|
|
|
2483
2485
|
return data;
|
|
2484
2486
|
});
|
|
2485
2487
|
}
|
|
2486
|
-
export(
|
|
2487
|
-
return __async(this,
|
|
2488
|
+
export(_0) {
|
|
2489
|
+
return __async(this, arguments, function* (data, options = { override: true }) {
|
|
2488
2490
|
const fullPath = this.getFullPath();
|
|
2489
2491
|
try {
|
|
2492
|
+
if (!(options == null ? void 0 : options.override)) {
|
|
2493
|
+
try {
|
|
2494
|
+
yield fs.access(fullPath);
|
|
2495
|
+
log3.debug("Search index file already exists and override is false, skipping export:", fullPath);
|
|
2496
|
+
return;
|
|
2497
|
+
} catch (e) {
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2490
2500
|
const dir = path.dirname(fullPath);
|
|
2491
2501
|
yield fs.mkdir(dir, { recursive: true });
|
|
2492
2502
|
yield fs.writeFile(fullPath, JSON.stringify(data, null, 2), "utf-8");
|
|
@@ -2497,6 +2507,26 @@ var FileBasedSearchIndexExporter = class {
|
|
|
2497
2507
|
}
|
|
2498
2508
|
});
|
|
2499
2509
|
}
|
|
2510
|
+
exportSync(data, options = { override: true }) {
|
|
2511
|
+
const fullPath = this.getFullPath();
|
|
2512
|
+
try {
|
|
2513
|
+
if (!(options == null ? void 0 : options.override)) {
|
|
2514
|
+
try {
|
|
2515
|
+
fsSync.accessSync(fullPath);
|
|
2516
|
+
log3.debug("Search index file already exists and override is false, skipping export:", fullPath);
|
|
2517
|
+
return;
|
|
2518
|
+
} catch (e) {
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
const dir = path.dirname(fullPath);
|
|
2522
|
+
fsSync.mkdirSync(dir, { recursive: true });
|
|
2523
|
+
fsSync.writeFileSync(fullPath, JSON.stringify(data, null, 2), "utf-8");
|
|
2524
|
+
log3.debug("Search index saved to file:", fullPath, "with", data.keys.length, "keys");
|
|
2525
|
+
} catch (error) {
|
|
2526
|
+
log3.error("Failed to save search index to file:", fullPath, error);
|
|
2527
|
+
throw error;
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2500
2530
|
};
|
|
2501
2531
|
function createExporterFromConfig(exporterConfig) {
|
|
2502
2532
|
if (exporterConfig.type === "fileBased") {
|
|
@@ -2506,22 +2536,19 @@ function createExporterFromConfig(exporterConfig) {
|
|
|
2506
2536
|
}
|
|
2507
2537
|
|
|
2508
2538
|
// src/config.ts
|
|
2509
|
-
({
|
|
2510
|
-
searchExporter: {
|
|
2511
|
-
config: { baseDir: process.cwd()}
|
|
2512
|
-
}});
|
|
2513
2539
|
var getConfig = () => {
|
|
2514
2540
|
if (!process.env.PEAM_SEARCH_EXPORTER_TYPE || !process.env.PEAM_SEARCH_EXPORTER_CONFIG) {
|
|
2515
2541
|
throw new Error(
|
|
2516
2542
|
"Peam configuration not found. Make sure withPeam() is properly configured in your next.config file."
|
|
2517
2543
|
);
|
|
2518
2544
|
}
|
|
2519
|
-
const
|
|
2545
|
+
const searchExporterConfig = {
|
|
2520
2546
|
type: process.env.PEAM_SEARCH_EXPORTER_TYPE,
|
|
2521
2547
|
config: JSON.parse(process.env.PEAM_SEARCH_EXPORTER_CONFIG)
|
|
2522
2548
|
};
|
|
2523
2549
|
const resolvedConfig = {
|
|
2524
|
-
|
|
2550
|
+
searchExporter: searchExporterConfig,
|
|
2551
|
+
searchIndexExporter: createExporterFromConfig(searchExporterConfig),
|
|
2525
2552
|
respectRobotsTxt: process.env.PEAM_RESPECT_ROBOTS_TXT === "true",
|
|
2526
2553
|
robotsTxtPath: process.env.PEAM_ROBOTS_TXT_PATH || void 0,
|
|
2527
2554
|
exclude: process.env.PEAM_EXCLUDE ? JSON.parse(process.env.PEAM_EXCLUDE) : []
|