@bettercms-ai/sdk 1.26.0 → 1.26.2
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 +9 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1134,7 +1134,11 @@ interface CreateClientOptions {
|
|
|
1134
1134
|
workspace: string;
|
|
1135
1135
|
/** Delivery API key. Use a `content:read:draft` key for drafts. */
|
|
1136
1136
|
apiKey?: string;
|
|
1137
|
-
/**
|
|
1137
|
+
/**
|
|
1138
|
+
* The project every read is addressed to. A workspace holds many projects whose slugs
|
|
1139
|
+
* collide (each has a `blog` model and a `home` page), so a site names its own; published
|
|
1140
|
+
* reads need no key for it. BetterCMS hosting supplies `PUBLIC_BCMS_PROJECT_ID`.
|
|
1141
|
+
*/
|
|
1138
1142
|
projectId?: string;
|
|
1139
1143
|
/** `published` (default) or `drafts`. */
|
|
1140
1144
|
perspective?: Perspective;
|
|
@@ -1483,7 +1487,7 @@ declare function search(opts: SearchOptions): Promise<SearchHit[]>;
|
|
|
1483
1487
|
* `import.meta.glob`) and the bundle holds a frozen copy no publish can reach: the platform then
|
|
1484
1488
|
* has to rebuild the whole site for every edit.
|
|
1485
1489
|
*
|
|
1486
|
-
* - On a hosted server: `BCMS_CONTENT_FILE`, re-read when it changes (
|
|
1490
|
+
* - On a hosted server: `BCMS_CONTENT_FILE`, re-read when it changes (its time is asked on every call).
|
|
1487
1491
|
* - At build time and in local dev: `<cwd>/bcms-content.json`, the snapshot the build was given.
|
|
1488
1492
|
* - Anywhere without a filesystem (a browser, an edge runtime): `null`.
|
|
1489
1493
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1134,7 +1134,11 @@ interface CreateClientOptions {
|
|
|
1134
1134
|
workspace: string;
|
|
1135
1135
|
/** Delivery API key. Use a `content:read:draft` key for drafts. */
|
|
1136
1136
|
apiKey?: string;
|
|
1137
|
-
/**
|
|
1137
|
+
/**
|
|
1138
|
+
* The project every read is addressed to. A workspace holds many projects whose slugs
|
|
1139
|
+
* collide (each has a `blog` model and a `home` page), so a site names its own; published
|
|
1140
|
+
* reads need no key for it. BetterCMS hosting supplies `PUBLIC_BCMS_PROJECT_ID`.
|
|
1141
|
+
*/
|
|
1138
1142
|
projectId?: string;
|
|
1139
1143
|
/** `published` (default) or `drafts`. */
|
|
1140
1144
|
perspective?: Perspective;
|
|
@@ -1483,7 +1487,7 @@ declare function search(opts: SearchOptions): Promise<SearchHit[]>;
|
|
|
1483
1487
|
* `import.meta.glob`) and the bundle holds a frozen copy no publish can reach: the platform then
|
|
1484
1488
|
* has to rebuild the whole site for every edit.
|
|
1485
1489
|
*
|
|
1486
|
-
* - On a hosted server: `BCMS_CONTENT_FILE`, re-read when it changes (
|
|
1490
|
+
* - On a hosted server: `BCMS_CONTENT_FILE`, re-read when it changes (its time is asked on every call).
|
|
1487
1491
|
* - At build time and in local dev: `<cwd>/bcms-content.json`, the snapshot the build was given.
|
|
1488
1492
|
* - Anywhere without a filesystem (a browser, an edge runtime): `null`.
|
|
1489
1493
|
*
|
package/dist/index.js
CHANGED
|
@@ -1270,7 +1270,8 @@ function createClient(options) {
|
|
|
1270
1270
|
depth: opts?.depth,
|
|
1271
1271
|
select: opts?.select?.join(","),
|
|
1272
1272
|
perspective: draft ? "draft" : void 0,
|
|
1273
|
-
stega: draft && stega ? "1" : void 0
|
|
1273
|
+
stega: draft && stega ? "1" : void 0,
|
|
1274
|
+
projectId: defaultProjectId
|
|
1274
1275
|
})}`;
|
|
1275
1276
|
return unwrap(await fetchJSON(url));
|
|
1276
1277
|
},
|
|
@@ -1282,7 +1283,8 @@ function createClient(options) {
|
|
|
1282
1283
|
depth: opts?.depth,
|
|
1283
1284
|
select: opts?.select?.join(","),
|
|
1284
1285
|
perspective: draft ? "draft" : void 0,
|
|
1285
|
-
stega: draft && stega ? "1" : void 0
|
|
1286
|
+
stega: draft && stega ? "1" : void 0,
|
|
1287
|
+
projectId: defaultProjectId
|
|
1286
1288
|
})}`;
|
|
1287
1289
|
return unwrap(await fetchJSON(url));
|
|
1288
1290
|
},
|
|
@@ -1316,19 +1318,21 @@ function createClient(options) {
|
|
|
1316
1318
|
async listPages(opts) {
|
|
1317
1319
|
const url = `${base}/pages${qs({
|
|
1318
1320
|
page: opts?.page,
|
|
1319
|
-
perPage: opts?.perPage
|
|
1321
|
+
perPage: opts?.perPage,
|
|
1322
|
+
projectId: defaultProjectId
|
|
1320
1323
|
})}`;
|
|
1321
1324
|
return unwrap(await fetchJSON(url));
|
|
1322
1325
|
},
|
|
1323
1326
|
async listComponents() {
|
|
1324
1327
|
const url = `${base}/components${qs({
|
|
1325
1328
|
perspective: draft ? "draft" : void 0,
|
|
1326
|
-
token: draft ? previewToken : void 0
|
|
1329
|
+
token: draft ? previewToken : void 0,
|
|
1330
|
+
projectId: defaultProjectId
|
|
1327
1331
|
})}`;
|
|
1328
1332
|
return unwrap(await fetchJSON(url));
|
|
1329
1333
|
},
|
|
1330
1334
|
async getLayout() {
|
|
1331
|
-
const url = `${base}/layout${draft ? "
|
|
1335
|
+
const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, projectId: defaultProjectId })}`;
|
|
1332
1336
|
try {
|
|
1333
1337
|
return unwrap(await fetchJSON(url));
|
|
1334
1338
|
} catch (error) {
|
|
@@ -1564,7 +1568,6 @@ async function search(opts) {
|
|
|
1564
1568
|
|
|
1565
1569
|
// src/published-content.ts
|
|
1566
1570
|
var cache = null;
|
|
1567
|
-
var checkedAt = 0;
|
|
1568
1571
|
function publishedContentFile() {
|
|
1569
1572
|
const proc = globalThis.process;
|
|
1570
1573
|
if (typeof proc?.getBuiltinModule !== "function") return null;
|
|
@@ -1573,9 +1576,6 @@ function publishedContentFile() {
|
|
|
1573
1576
|
function readPublishedContent() {
|
|
1574
1577
|
const file = publishedContentFile();
|
|
1575
1578
|
if (!file) return null;
|
|
1576
|
-
const now = Date.now();
|
|
1577
|
-
if (cache && cache.file === file && now - checkedAt < 1e3) return cache.content;
|
|
1578
|
-
checkedAt = now;
|
|
1579
1579
|
const proc = globalThis.process;
|
|
1580
1580
|
const fs = proc.getBuiltinModule("node:fs");
|
|
1581
1581
|
try {
|
|
@@ -1598,7 +1598,6 @@ function publishedEntry(slug) {
|
|
|
1598
1598
|
}
|
|
1599
1599
|
function resetPublishedContentCache() {
|
|
1600
1600
|
cache = null;
|
|
1601
|
-
checkedAt = 0;
|
|
1602
1601
|
}
|
|
1603
1602
|
|
|
1604
1603
|
// src/index.ts
|