@bettercms-ai/sdk 1.24.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 +51 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +51 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -74,6 +74,8 @@ __export(index_exports, {
|
|
|
74
74
|
getWorkspace: () => getWorkspace,
|
|
75
75
|
imageUrl: () => import_image_url.imageUrl,
|
|
76
76
|
imageUrlBuilder: () => import_image_url.default,
|
|
77
|
+
imageValueObjectPosition: () => import_image_url.imageValueObjectPosition,
|
|
78
|
+
imageValueUrl: () => import_image_url.imageValueUrl,
|
|
77
79
|
inviteMember: () => inviteMember,
|
|
78
80
|
isBlock: () => import_types.isBlock,
|
|
79
81
|
isMultiValueField: () => isMultiValueField,
|
|
@@ -92,8 +94,12 @@ __export(index_exports, {
|
|
|
92
94
|
portableText: () => portableText,
|
|
93
95
|
publishManagedLayout: () => publishManagedLayout,
|
|
94
96
|
publishPage: () => publishPage,
|
|
97
|
+
publishedContentFile: () => publishedContentFile,
|
|
98
|
+
publishedEntry: () => publishedEntry,
|
|
99
|
+
readPublishedContent: () => readPublishedContent,
|
|
95
100
|
regenerateApiKey: () => regenerateApiKey,
|
|
96
101
|
removeMember: () => removeMember,
|
|
102
|
+
resetPublishedContentCache: () => resetPublishedContentCache,
|
|
97
103
|
resolveSeo: () => resolveSeo,
|
|
98
104
|
revokeApiKey: () => revokeApiKey,
|
|
99
105
|
rich: () => rich,
|
|
@@ -1683,6 +1689,45 @@ async function search(opts) {
|
|
|
1683
1689
|
}
|
|
1684
1690
|
}
|
|
1685
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
|
+
|
|
1686
1731
|
// src/index.ts
|
|
1687
1732
|
var import_image_url = __toESM(require("@bettercms-ai/image-url"), 1);
|
|
1688
1733
|
|
|
@@ -2020,6 +2065,8 @@ var import_types = require("@bettercms-ai/types");
|
|
|
2020
2065
|
getWorkspace,
|
|
2021
2066
|
imageUrl,
|
|
2022
2067
|
imageUrlBuilder,
|
|
2068
|
+
imageValueObjectPosition,
|
|
2069
|
+
imageValueUrl,
|
|
2023
2070
|
inviteMember,
|
|
2024
2071
|
isBlock,
|
|
2025
2072
|
isMultiValueField,
|
|
@@ -2038,8 +2085,12 @@ var import_types = require("@bettercms-ai/types");
|
|
|
2038
2085
|
portableText,
|
|
2039
2086
|
publishManagedLayout,
|
|
2040
2087
|
publishPage,
|
|
2088
|
+
publishedContentFile,
|
|
2089
|
+
publishedEntry,
|
|
2090
|
+
readPublishedContent,
|
|
2041
2091
|
regenerateApiKey,
|
|
2042
2092
|
removeMember,
|
|
2093
|
+
resetPublishedContentCache,
|
|
2043
2094
|
resolveSeo,
|
|
2044
2095
|
revokeApiKey,
|
|
2045
2096
|
rich,
|