@bettercms-ai/sdk 1.25.0 → 1.26.0
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.cjs +47 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -94,8 +94,12 @@ __export(index_exports, {
|
|
|
94
94
|
portableText: () => portableText,
|
|
95
95
|
publishManagedLayout: () => publishManagedLayout,
|
|
96
96
|
publishPage: () => publishPage,
|
|
97
|
+
publishedContentFile: () => publishedContentFile,
|
|
98
|
+
publishedEntry: () => publishedEntry,
|
|
99
|
+
readPublishedContent: () => readPublishedContent,
|
|
97
100
|
regenerateApiKey: () => regenerateApiKey,
|
|
98
101
|
removeMember: () => removeMember,
|
|
102
|
+
resetPublishedContentCache: () => resetPublishedContentCache,
|
|
99
103
|
resolveSeo: () => resolveSeo,
|
|
100
104
|
revokeApiKey: () => revokeApiKey,
|
|
101
105
|
rich: () => rich,
|
|
@@ -1685,6 +1689,45 @@ async function search(opts) {
|
|
|
1685
1689
|
}
|
|
1686
1690
|
}
|
|
1687
1691
|
|
|
1692
|
+
// src/published-content.ts
|
|
1693
|
+
var cache = null;
|
|
1694
|
+
var checkedAt = 0;
|
|
1695
|
+
function publishedContentFile() {
|
|
1696
|
+
const proc = globalThis.process;
|
|
1697
|
+
if (typeof proc?.getBuiltinModule !== "function") return null;
|
|
1698
|
+
return proc.env?.BCMS_CONTENT_FILE || `${proc.cwd?.() ?? "."}/bcms-content.json`;
|
|
1699
|
+
}
|
|
1700
|
+
function readPublishedContent() {
|
|
1701
|
+
const file = publishedContentFile();
|
|
1702
|
+
if (!file) return null;
|
|
1703
|
+
const now = Date.now();
|
|
1704
|
+
if (cache && cache.file === file && now - checkedAt < 1e3) return cache.content;
|
|
1705
|
+
checkedAt = now;
|
|
1706
|
+
const proc = globalThis.process;
|
|
1707
|
+
const fs = proc.getBuiltinModule("node:fs");
|
|
1708
|
+
try {
|
|
1709
|
+
const stamp = fs.statSync(file).mtimeMs;
|
|
1710
|
+
if (cache && cache.file === file && cache.stamp === stamp) return cache.content;
|
|
1711
|
+
cache = { file, stamp, content: JSON.parse(fs.readFileSync(file, "utf8")) };
|
|
1712
|
+
} catch {
|
|
1713
|
+
if (!cache || cache.file !== file) cache = { file, stamp: -1, content: null };
|
|
1714
|
+
}
|
|
1715
|
+
return cache.content;
|
|
1716
|
+
}
|
|
1717
|
+
function publishedEntry(slug) {
|
|
1718
|
+
const collections = readPublishedContent()?.collections ?? {};
|
|
1719
|
+
for (const rows of Object.values(collections)) {
|
|
1720
|
+
if (!Array.isArray(rows)) continue;
|
|
1721
|
+
const hit = rows.find((row) => row?.slug === slug);
|
|
1722
|
+
if (hit) return hit;
|
|
1723
|
+
}
|
|
1724
|
+
return null;
|
|
1725
|
+
}
|
|
1726
|
+
function resetPublishedContentCache() {
|
|
1727
|
+
cache = null;
|
|
1728
|
+
checkedAt = 0;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1688
1731
|
// src/index.ts
|
|
1689
1732
|
var import_image_url = __toESM(require("@bettercms-ai/image-url"), 1);
|
|
1690
1733
|
|
|
@@ -2042,8 +2085,12 @@ var import_types = require("@bettercms-ai/types");
|
|
|
2042
2085
|
portableText,
|
|
2043
2086
|
publishManagedLayout,
|
|
2044
2087
|
publishPage,
|
|
2088
|
+
publishedContentFile,
|
|
2089
|
+
publishedEntry,
|
|
2090
|
+
readPublishedContent,
|
|
2045
2091
|
regenerateApiKey,
|
|
2046
2092
|
removeMember,
|
|
2093
|
+
resetPublishedContentCache,
|
|
2047
2094
|
resolveSeo,
|
|
2048
2095
|
revokeApiKey,
|
|
2049
2096
|
rich,
|