octocms 0.4.12 → 0.4.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.
- package/dist/admin/actions/entries.js +46 -45
- package/dist/admin/actions/entries.js.map +1 -1
- package/dist/admin/actions/files.d.ts +5 -0
- package/dist/admin/actions/files.d.ts.map +1 -1
- package/dist/admin/actions/files.js +48 -9
- package/dist/admin/actions/files.js.map +1 -1
- package/dist/admin/actions/search.js +2 -2
- package/dist/admin/actions/search.js.map +1 -1
- package/dist/agent/embedder.js +1 -1
- package/dist/agent/embedder.js.map +1 -1
- package/dist/agent/index.cjs +118 -41
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/tools/index.js +1 -1
- package/dist/agent/tools/index.js.map +1 -1
- package/dist/chunk-NAHOP7TG.js +7 -0
- package/dist/{chunk-L27J3XWV.js.map → chunk-NAHOP7TG.js.map} +1 -1
- package/dist/{chunk-TG624CCO.js → chunk-ZYUK2J5L.js} +4 -43
- package/dist/chunk-ZYUK2J5L.js.map +1 -0
- package/dist/cli/index.js +6 -6
- package/dist/cli/lib/codegen.d.ts +2 -8
- package/dist/cli/lib/codegen.d.ts.map +1 -1
- package/dist/cli/lib/codegen.js +11 -18
- package/dist/cli/lib/codegen.js.map +1 -1
- package/dist/cli/lib/project.js +2 -41
- package/dist/cli/lib/project.js.map +1 -1
- package/dist/components/FormReferenceField.d.ts.map +1 -1
- package/dist/components/FormReferenceField.js +1 -1
- package/dist/components/FormReferenceField.js.map +1 -1
- package/dist/{embeddingsGen-7MXSZQ43.js → embeddingsGen-FXWCPGB7.js} +39 -8
- package/dist/embeddingsGen-FXWCPGB7.js.map +1 -0
- package/dist/index.cjs +88 -68
- package/dist/index.cjs.map +1 -1
- package/dist/{init-N6K464EZ.js → init-KWH66PKY.js} +2 -2
- package/dist/lib/localReader.d.ts +13 -0
- package/dist/lib/localReader.d.ts.map +1 -1
- package/dist/lib/localReader.js +20 -0
- package/dist/lib/localReader.js.map +1 -1
- package/dist/lib/publicSearchIndex.d.ts.map +1 -1
- package/dist/lib/publicSearchIndex.js +2 -2
- package/dist/lib/publicSearchIndex.js.map +1 -1
- package/dist/query.cjs +88 -68
- package/dist/query.cjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/{typesGen-EYRZAA56.js → typesGen-MFAL3B4V.js} +32 -6
- package/dist/typesGen-MFAL3B4V.js.map +1 -0
- package/dist/{validate-6AFW6U2X.js → validate-AAW4IGWD.js} +2 -2
- package/package.json +1 -1
- package/dist/admin/consts.d.ts +0 -3
- package/dist/admin/consts.d.ts.map +0 -1
- package/dist/admin/consts.js +0 -24
- package/dist/admin/consts.js.map +0 -1
- package/dist/chunk-L27J3XWV.js +0 -7
- package/dist/chunk-TG624CCO.js.map +0 -1
- package/dist/embeddingsGen-7MXSZQ43.js.map +0 -1
- package/dist/typesGen-EYRZAA56.js.map +0 -1
- /package/dist/{init-N6K464EZ.js.map → init-KWH66PKY.js.map} +0 -0
- /package/dist/{validate-6AFW6U2X.js.map → validate-AAW4IGWD.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
version
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NAHOP7TG.js";
|
|
4
4
|
import {
|
|
5
5
|
adminErrorTemplate,
|
|
6
6
|
agentChatRouteTemplate,
|
|
@@ -264,4 +264,4 @@ async function initCommand(projectRoot, options = {}) {
|
|
|
264
264
|
export {
|
|
265
265
|
initCommand
|
|
266
266
|
};
|
|
267
|
-
//# sourceMappingURL=init-
|
|
267
|
+
//# sourceMappingURL=init-KWH66PKY.js.map
|
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
export declare function readLocalContentFile(filePath: string): Promise<unknown | null>;
|
|
3
3
|
/** Read a raw text file (e.g. companion .md) from local disk. Returns '' on ENOENT. */
|
|
4
4
|
export declare function readLocalRawFile(filePath: string): Promise<string>;
|
|
5
|
+
/**
|
|
6
|
+
* List all files under `dirPath` whose name ends with `ext`, recursively.
|
|
7
|
+
* Returns paths like `dirPath/sub/file.ext` with forward slashes, sorted.
|
|
8
|
+
* Returns [] if the directory does not exist.
|
|
9
|
+
*/
|
|
10
|
+
export declare function listLocalFilesRecursive(dirPath: string, ext: string): Promise<string[]>;
|
|
11
|
+
/**
|
|
12
|
+
* List files in `dirPath` whose name ends with any of the given extensions.
|
|
13
|
+
* Pass `recursive: true` to descend into subdirectories.
|
|
14
|
+
* Extensions may include or omit the leading dot.
|
|
15
|
+
* Returns [] if the directory does not exist.
|
|
16
|
+
*/
|
|
17
|
+
export declare function listLocalFilesWithExtensions(dirPath: string, extensions: string[], recursive?: boolean): Promise<string[]>;
|
|
5
18
|
/** List .json files in a collection directory on local disk. Returns [] if directory does not exist. */
|
|
6
19
|
export declare function listLocalCollectionFiles(dirPath: string): Promise<string[]>;
|
|
7
20
|
//# sourceMappingURL=localReader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localReader.d.ts","sourceRoot":"","sources":["../../lib/localReader.ts"],"names":[],"mappings":"AAGA,uFAAuF;AACvF,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CASpF;AAED,uFAAuF;AACvF,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQxE;AAED,wGAAwG;AACxG,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CASjF"}
|
|
1
|
+
{"version":3,"file":"localReader.d.ts","sourceRoot":"","sources":["../../lib/localReader.ts"],"names":[],"mappings":"AAGA,uFAAuF;AACvF,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CASpF;AAED,uFAAuF;AACvF,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQxE;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAE7F;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,UAAQ,GAChB,OAAO,CAAC,MAAM,EAAE,CAAC,CAsBnB;AAED,wGAAwG;AACxG,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CASjF"}
|
package/dist/lib/localReader.js
CHANGED
|
@@ -20,6 +20,24 @@ async function readLocalRawFile(filePath) {
|
|
|
20
20
|
throw error;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
async function listLocalFilesRecursive(dirPath, ext) {
|
|
24
|
+
return listLocalFilesWithExtensions(dirPath, [ext], true);
|
|
25
|
+
}
|
|
26
|
+
async function listLocalFilesWithExtensions(dirPath, extensions, recursive = false) {
|
|
27
|
+
const fullDir = path.join(process.cwd(), dirPath);
|
|
28
|
+
const normalizedExts = extensions.map((e) => e.startsWith(".") ? e : `.${e}`);
|
|
29
|
+
try {
|
|
30
|
+
if (recursive) {
|
|
31
|
+
const names = await fsPromises.readdir(fullDir, { recursive: true });
|
|
32
|
+
return names.filter((n) => normalizedExts.some((e) => n.endsWith(e))).map((n) => `${dirPath}/${n}`.replace(/\\/g, "/")).sort();
|
|
33
|
+
}
|
|
34
|
+
const entries = await fsPromises.readdir(fullDir, { withFileTypes: true });
|
|
35
|
+
return entries.filter((e) => e.isFile() && normalizedExts.some((ext) => e.name.endsWith(ext))).map((e) => `${dirPath}/${e.name}`).sort();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if ((error == null ? void 0 : error.code) === "ENOENT") return [];
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
23
41
|
async function listLocalCollectionFiles(dirPath) {
|
|
24
42
|
const fullDir = path.join(process.cwd(), dirPath);
|
|
25
43
|
try {
|
|
@@ -32,6 +50,8 @@ async function listLocalCollectionFiles(dirPath) {
|
|
|
32
50
|
}
|
|
33
51
|
export {
|
|
34
52
|
listLocalCollectionFiles,
|
|
53
|
+
listLocalFilesRecursive,
|
|
54
|
+
listLocalFilesWithExtensions,
|
|
35
55
|
readLocalContentFile,
|
|
36
56
|
readLocalRawFile
|
|
37
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../lib/localReader.ts"],"sourcesContent":["import fsPromises from 'fs/promises';\nimport path from 'path';\n\n/** Read a JSON content file from local disk. Returns null on ENOENT or parse error. */\nexport async function readLocalContentFile(filePath: string): Promise<unknown | null> {\n const fullPath = path.join(process.cwd(), filePath);\n try {\n const data = await fsPromises.readFile(fullPath, { encoding: 'utf8' });\n return JSON.parse(data);\n } catch (error: any) {\n if (error?.code === 'ENOENT' || error instanceof SyntaxError) return null;\n throw error;\n }\n}\n\n/** Read a raw text file (e.g. companion .md) from local disk. Returns '' on ENOENT. */\nexport async function readLocalRawFile(filePath: string): Promise<string> {\n const fullPath = path.join(process.cwd(), filePath);\n try {\n return await fsPromises.readFile(fullPath, { encoding: 'utf8' });\n } catch (error: any) {\n if (error?.code === 'ENOENT') return '';\n throw error;\n }\n}\n\n/** List .json files in a collection directory on local disk. Returns [] if directory does not exist. */\nexport async function listLocalCollectionFiles(dirPath: string): Promise<string[]> {\n const fullDir = path.join(process.cwd(), dirPath);\n try {\n const entries = await fsPromises.readdir(fullDir, { withFileTypes: true });\n return entries.filter((e) => e.isFile() && e.name.endsWith('.json')).map((e) => `${dirPath}/${e.name}`);\n } catch (error: any) {\n if (error?.code === 'ENOENT') return [];\n throw error;\n }\n}\n"],"mappings":";AAAA,OAAO,gBAAgB;AACvB,OAAO,UAAU;AAGjB,eAAsB,qBAAqB,UAA2C;AACpF,QAAM,WAAW,KAAK,KAAK,QAAQ,IAAI,GAAG,QAAQ;AAClD,MAAI;AACF,UAAM,OAAO,MAAM,WAAW,SAAS,UAAU,EAAE,UAAU,OAAO,CAAC;AACrE,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,SAAS,OAAY;AACnB,SAAI,+BAAO,UAAS,YAAY,iBAAiB,YAAa,QAAO;AACrE,UAAM;AAAA,EACR;AACF;AAGA,eAAsB,iBAAiB,UAAmC;AACxE,QAAM,WAAW,KAAK,KAAK,QAAQ,IAAI,GAAG,QAAQ;AAClD,MAAI;AACF,WAAO,MAAM,WAAW,SAAS,UAAU,EAAE,UAAU,OAAO,CAAC;AAAA,EACjE,SAAS,OAAY;AACnB,SAAI,+BAAO,UAAS,SAAU,QAAO;AACrC,UAAM;AAAA,EACR;AACF;AAGA,eAAsB,yBAAyB,SAAoC;AACjF,QAAM,UAAU,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO;AAChD,MAAI;AACF,UAAM,UAAU,MAAM,WAAW,QAAQ,SAAS,EAAE,eAAe,KAAK,CAAC;AACzE,WAAO,QAAQ,OAAO,CAAC,MAAM,EAAE,OAAO,KAAK,EAAE,KAAK,SAAS,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,OAAO,IAAI,EAAE,IAAI,EAAE;AAAA,EACxG,SAAS,OAAY;AACnB,SAAI,+BAAO,UAAS,SAAU,QAAO,CAAC;AACtC,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../lib/localReader.ts"],"sourcesContent":["import fsPromises from 'fs/promises';\nimport path from 'path';\n\n/** Read a JSON content file from local disk. Returns null on ENOENT or parse error. */\nexport async function readLocalContentFile(filePath: string): Promise<unknown | null> {\n const fullPath = path.join(process.cwd(), filePath);\n try {\n const data = await fsPromises.readFile(fullPath, { encoding: 'utf8' });\n return JSON.parse(data);\n } catch (error: any) {\n if (error?.code === 'ENOENT' || error instanceof SyntaxError) return null;\n throw error;\n }\n}\n\n/** Read a raw text file (e.g. companion .md) from local disk. Returns '' on ENOENT. */\nexport async function readLocalRawFile(filePath: string): Promise<string> {\n const fullPath = path.join(process.cwd(), filePath);\n try {\n return await fsPromises.readFile(fullPath, { encoding: 'utf8' });\n } catch (error: any) {\n if (error?.code === 'ENOENT') return '';\n throw error;\n }\n}\n\n/**\n * List all files under `dirPath` whose name ends with `ext`, recursively.\n * Returns paths like `dirPath/sub/file.ext` with forward slashes, sorted.\n * Returns [] if the directory does not exist.\n */\nexport async function listLocalFilesRecursive(dirPath: string, ext: string): Promise<string[]> {\n return listLocalFilesWithExtensions(dirPath, [ext], true);\n}\n\n/**\n * List files in `dirPath` whose name ends with any of the given extensions.\n * Pass `recursive: true` to descend into subdirectories.\n * Extensions may include or omit the leading dot.\n * Returns [] if the directory does not exist.\n */\nexport async function listLocalFilesWithExtensions(\n dirPath: string,\n extensions: string[],\n recursive = false,\n): Promise<string[]> {\n const fullDir = path.join(process.cwd(), dirPath);\n const normalizedExts = extensions.map((e) => (e.startsWith('.') ? e : `.${e}`));\n\n try {\n if (recursive) {\n const names = (await fsPromises.readdir(fullDir, { recursive: true })) as unknown as string[];\n return names\n .filter((n) => normalizedExts.some((e) => n.endsWith(e)))\n .map((n) => `${dirPath}/${n}`.replace(/\\\\/g, '/'))\n .sort();\n }\n\n const entries = await fsPromises.readdir(fullDir, { withFileTypes: true });\n return (entries as import('fs').Dirent[])\n .filter((e) => e.isFile() && normalizedExts.some((ext) => e.name.endsWith(ext)))\n .map((e) => `${dirPath}/${e.name}`)\n .sort();\n } catch (error: any) {\n if (error?.code === 'ENOENT') return [];\n throw error;\n }\n}\n\n/** List .json files in a collection directory on local disk. Returns [] if directory does not exist. */\nexport async function listLocalCollectionFiles(dirPath: string): Promise<string[]> {\n const fullDir = path.join(process.cwd(), dirPath);\n try {\n const entries = await fsPromises.readdir(fullDir, { withFileTypes: true });\n return entries.filter((e) => e.isFile() && e.name.endsWith('.json')).map((e)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IACV;AAEA,UAAM,UAAU,MAAM,WAAW,QAAQ,SAAS,EAAE,eAAe,KAAK,CAAC;AACzE,WAAQ,QACL,OAAO,CAAC,MAAM,EAAE,OAAO,KAAK,eAAe,KAAK,CAAC,QAAQ,EAAE,KAAK,SAAS,GAAG,CAAC,CAAC,EAC9E,IAAI,CAAC,MAAM,GAAG,OAAO,IAAI,EAAE,IAAI,EAAE,EACjC,KAAK;AAAA,EACV,SAAS,OAAY;AACnB,SAAI,+BAAO,UAAS,SAAU,QAAO,CAAC;AACtC,UAAM;AAAA,EACR;AACF;AAGA,eAAsB,yBAAyB,SAAoC;AACjF,QAAM,UAAU,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO;AAChD,MAAI;AACF,UAAM,UAAU,MAAM,WAAW,QAAQ,SAAS,EAAE,eAAe,KAAK,CAAC;AACzE,WAAO,QAAQ,OAAO,CAAC,MAAM,EAAE,OAAO,KAAK,EAAE,KAAK,SAAS,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,OAAO,IAAI,EAAE,IAAI,EAAE;AAAA,EACxG,SAAS,OAAY;AACnB,SAAI,+BAAO,UAAS,SAAU,QAAO,CAAC;AACtC,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicSearchIndex.d.ts","sourceRoot":"","sources":["../../lib/publicSearchIndex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publicSearchIndex.d.ts","sourceRoot":"","sources":["../../lib/publicSearchIndex.ts"],"names":[],"mappings":"AA+GA;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA+BxE"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "../chunk-B5LE2OEC.js";
|
|
2
2
|
import fsPromises from "fs/promises";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { glob } from "glob";
|
|
5
4
|
import {
|
|
6
5
|
isProductionMode,
|
|
7
6
|
listGitHubFilesRecursive,
|
|
@@ -9,12 +8,13 @@ import {
|
|
|
9
8
|
resolveContentBranch
|
|
10
9
|
} from "../github-public";
|
|
11
10
|
import { getConfig } from "./configStore";
|
|
11
|
+
import { listLocalFilesRecursive } from "./localReader";
|
|
12
12
|
import { companionMarkdownPathsForEntry, companionRichTextPathsForEntry } from "./companionMarkdown";
|
|
13
13
|
import { buildSearchIndex } from "./searchIndex";
|
|
14
14
|
const PREBUILT_REL_PATH = "cms/__generated__/search-index.json";
|
|
15
15
|
async function gatherEntriesFromLocalFs(publicCollectionKeys) {
|
|
16
16
|
const config = getConfig();
|
|
17
|
-
const files = await
|
|
17
|
+
const files = await listLocalFilesRecursive(config.contentFolder, ".json");
|
|
18
18
|
const entries = [];
|
|
19
19
|
for (const file of files) {
|
|
20
20
|
const normalized = file.replace(/\\/g, "/");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../lib/publicSearchIndex.ts"],"sourcesContent":["import fsPromises from 'fs/promises';\nimport path from 'path';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../lib/publicSearchIndex.ts"],"sourcesContent":["import fsPromises from 'fs/promises';\nimport path from 'path';\n\nimport {\n isProductionMode,\n listGitHubFilesRecursive,\n readGitHubFilePublic,\n resolveContentBranch,\n} from '../github-public';\nimport { getConfig } from './configStore';\nimport { listLocalFilesRecursive } from './localReader';\nimport { companionMarkdownPathsForEntry, companionRichTextPathsForEntry } from './companionMarkdown';\nimport { buildSearchIndex, type EntryForSearch } from './searchIndex';\n\nconst PREBUILT_REL_PATH = 'cms/__generated__/search-index.json';\n\nasync function gatherEntriesFromLocalFs(publicCollectionKeys: string[]): Promise<EntryForSearch[]> {\n const config = getConfig();\n const files = await listLocalFilesRecursive(config.contentFolder, '.json');\n const entries: EntryForSearch[] = [];\n\n for (const file of files) {\n const normalized = file.replace(/\\\\/g, '/');\n try {\n const type = normalized.split('/').at(-2);\n if (!type || !publicCollectionKeys.includes(type)) continue;\n\n const filePath = path.join(/* turbopackIgnore: true */ process.cwd(), normalized);\n const data = await fsPromises.readFile(filePath, { encoding: 'utf8' });\n const content = JSON.parse(data) as Record<string, unknown>;\n\n const companions: Record<string, string> = {};\n const mdPaths = companionMarkdownPathsForEntry(normalized, type, config.collections);\n for (const [fieldName, mdPath] of Object.entries(mdPaths)) {\n try {\n const mdFilePath = path.join(/* turbopackIgnore: true */ process.cwd(), mdPath);\n companions[fieldName] = await fsPromises.readFile(mdFilePath, { encoding: 'utf8' });\n } catch {\n companions[fieldName] = '';\n }\n }\n const rtPaths = companionRichTextPathsForEntry(normalized, type, config.collections);\n for (const [fieldName, rtPath] of Object.entries(rtPaths)) {\n try {\n const rtFilePath = path.join(/* turbopackIgnore: true */ process.cwd(), rtPath);\n companions[fieldName] = await fsPromises.readFile(rtFilePath, { encoding: 'utf8' });\n } catch {\n companions[fieldName] = '';\n }\n }\n\n entries.push({\n path: normalized.replace(`${config.contentFolder}/`, ''),\n content,\n companionContent: companions,\n });\n } catch {\n /* skip */\n }\n }\n\n return entries;\n}\n\nasync function gatherEntriesFromGitHubRef(ref: string, publicCollectionKeys: string[]): Promise<EntryForSearch[]> {\n const config = getConfig();\n const paths = await listGitHubFilesRecursive(config.contentFolder, '.json', ref);\n const entries: EntryForSearch[] = [];\n\n for (const p of paths) {\n const normalized = p.replace(/\\\\/g, '/');\n const parts = normalized.split('/');\n const type = parts.at(-2);\n if (!type || !publicCollectionKeys.includes(type)) continue;\n\n try {\n const raw = await readGitHubFilePublic(normalized, ref);\n if (!raw) continue;\n const content = JSON.parse(raw) as Record<string, unknown>;\n\n const companions: Record<string, string> = {};\n const mdPaths = companionMarkdownPathsForEntry(normalized, type, config.collections);\n for (const [fieldName, mdPath] of Object.entries(mdPaths)) {\n try {\n companions[fieldName] = (await readGitHubFilePublic(mdPath, ref)) ?? '';\n } catch {\n companions[fieldName] = '';\n }\n }\n const rtPaths = companionRichTextPathsForEntry(normalized, type, config.collections);\n for (const [fieldName, rtPath] of Object.entries(rtPaths)) {\n try {\n companions[fieldName] = (await readGitHubFilePublic(rtPath, ref)) ?? '';\n } catch {\n companions[fieldName] = '';\n }\n }\n\n entries.push({\n path: normalized.replace(`${config.contentFolder}/`, ''),\n content,\n companionContent: companions,\n });\n } catch {\n /* skip */\n }\n }\n\n return entries;\n}\n\n/**\n * Serialized MiniSearch JSON for public `/api/search`, or `null` if search is disabled or nothing could be built.\n */\nexport async function loadPublicSearchIndexJson(): Promise<string | null> {\n const config = getConfig();\n const publicCollections = config.search?.publicCollections;\n if (!publicCollections || Object.keys(publicCollections).length === 0) {\n return null;\n }\n\n const keys = Object.keys(publicCollections);\n\n try {\n if (!isProductionMode()) {\n const prebuiltPath = path.join(/* turbopackIgnore: true */ process.cwd(), PREBUILT_REL_PATH);\n try {\n const existing = await fsPromises.readFile(prebuiltPath, 'utf8');\n if (existing.trim()) return existing;\n } catch {\n /* fall through to build from workspace */\n }\n const entries = await gatherEntriesFromLocalFs(keys);\n return buildSearchIndex(entries, config, keys);\n }\n\n const ref = await resolveContentBranch();\n const prebuilt = await readGitHubFilePublic(PREBUILT_REL_PATH, ref);\n if (prebuilt?.trim()) return prebuilt;\n\n const entries = await gatherEntriesFromGitHubRef(ref, keys);\n return buildSearchIndex(entries, config, keys);\n } catch {\n return null;\n }\n}\n"],"mappings":";AAAA,OAAO,gBAAgB;AACvB,OAAO,UAAU;AAEjB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,+BAA+B;AACxC,SAAS,gCAAgC,sCAAsC;AAC/E,SAAS,wBAA6C;AAEtD,MAAM,oBAAoB;AAE1B,eAAe,yBAAyB,sBAA2D;AACjG,QAAM,SAAS,UAAU;AACzB,QAAM,QAAQ,MAAM,wBAAwB,OAAO,eAAe,OAAO;AACzE,QAAM,UAA4B,CAAC;AAEnC,aAAW,QAAQ,OAAO;AACxB,UAAM,aAAa,KAAK,QAAQ,O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