@bettercms-ai/sdk 1.26.2 → 1.26.3
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 +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -633,6 +633,16 @@ declare function isMultiValueField(type: DeliveryFormFieldType): boolean;
|
|
|
633
633
|
interface DeliveryForm {
|
|
634
634
|
id: string;
|
|
635
635
|
name: string;
|
|
636
|
+
/** The project the form belongs to. */
|
|
637
|
+
projectId?: string | null;
|
|
638
|
+
/**
|
|
639
|
+
* A `draft` form refuses every submission: render it as unavailable rather than as a form that
|
|
640
|
+
* silently drops what a visitor sends. Delivered for exactly that reason, and missing from this
|
|
641
|
+
* type until the contract test held the two together.
|
|
642
|
+
*/
|
|
643
|
+
status?: "draft" | "published" | (string & {});
|
|
644
|
+
/** Set on a form the site's owner told BetterCMS to leave alone (ISO time); such a form is not wired. */
|
|
645
|
+
ignoredAt?: string | null;
|
|
636
646
|
fields: DeliveryFormField[];
|
|
637
647
|
submitLabel?: string;
|
|
638
648
|
successMessage?: string;
|
|
@@ -1500,9 +1510,14 @@ interface PublishedContent {
|
|
|
1500
1510
|
apiUrl?: string | null;
|
|
1501
1511
|
workspace?: string;
|
|
1502
1512
|
projectId?: string | null;
|
|
1503
|
-
/**
|
|
1513
|
+
/**
|
|
1514
|
+
* Published entries by model slug, each row AS THE DELIVERY API SERVES IT: `id`, `slug`, `status`,
|
|
1515
|
+
* `publishedAt`, `updatedAt`, `locale`, `translationOf`, `_meta`, and the field values under
|
|
1516
|
+
* `data`. Read a value through {@link publishedEntry}, which answers either spelling.
|
|
1517
|
+
*/
|
|
1504
1518
|
collections?: Record<string, Array<Record<string, unknown> & {
|
|
1505
1519
|
slug?: string;
|
|
1520
|
+
data?: Record<string, unknown>;
|
|
1506
1521
|
}>>;
|
|
1507
1522
|
pages?: unknown[];
|
|
1508
1523
|
components?: unknown[];
|
|
@@ -1520,6 +1535,14 @@ declare function readPublishedContent<T extends PublishedContent = PublishedCont
|
|
|
1520
1535
|
/**
|
|
1521
1536
|
* One published entry by its slug, searched across every collection (first match wins, in the
|
|
1522
1537
|
* snapshot's model order). Not keyed by model slug: a page's backing model is named by the CMS.
|
|
1538
|
+
*
|
|
1539
|
+
* 🔴 THE VALUES ARE ON THE ENTRY: `publishedEntry("home")?.title`. The snapshot holds each row as
|
|
1540
|
+
* the delivery API serves it, values under `data`, and this used to hand that row back as it was
|
|
1541
|
+
* while its own doc (and the skill that names it) said "the row carries its field values" — so
|
|
1542
|
+
* `entry.title` was `undefined` and every field of a server-rendered page fell back to the copy in
|
|
1543
|
+
* the code, on every publish. Both spellings are answered: the values at the top level and the
|
|
1544
|
+
* row's own keys (`id`, `slug`, `status`, `data`, `_meta`, …) beside them, the row's winning where
|
|
1545
|
+
* a field is named like one — that field is read through `.data`, as before.
|
|
1523
1546
|
*/
|
|
1524
1547
|
declare function publishedEntry<T extends Record<string, unknown> = Record<string, unknown>>(slug: string): (T & {
|
|
1525
1548
|
slug: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -633,6 +633,16 @@ declare function isMultiValueField(type: DeliveryFormFieldType): boolean;
|
|
|
633
633
|
interface DeliveryForm {
|
|
634
634
|
id: string;
|
|
635
635
|
name: string;
|
|
636
|
+
/** The project the form belongs to. */
|
|
637
|
+
projectId?: string | null;
|
|
638
|
+
/**
|
|
639
|
+
* A `draft` form refuses every submission: render it as unavailable rather than as a form that
|
|
640
|
+
* silently drops what a visitor sends. Delivered for exactly that reason, and missing from this
|
|
641
|
+
* type until the contract test held the two together.
|
|
642
|
+
*/
|
|
643
|
+
status?: "draft" | "published" | (string & {});
|
|
644
|
+
/** Set on a form the site's owner told BetterCMS to leave alone (ISO time); such a form is not wired. */
|
|
645
|
+
ignoredAt?: string | null;
|
|
636
646
|
fields: DeliveryFormField[];
|
|
637
647
|
submitLabel?: string;
|
|
638
648
|
successMessage?: string;
|
|
@@ -1500,9 +1510,14 @@ interface PublishedContent {
|
|
|
1500
1510
|
apiUrl?: string | null;
|
|
1501
1511
|
workspace?: string;
|
|
1502
1512
|
projectId?: string | null;
|
|
1503
|
-
/**
|
|
1513
|
+
/**
|
|
1514
|
+
* Published entries by model slug, each row AS THE DELIVERY API SERVES IT: `id`, `slug`, `status`,
|
|
1515
|
+
* `publishedAt`, `updatedAt`, `locale`, `translationOf`, `_meta`, and the field values under
|
|
1516
|
+
* `data`. Read a value through {@link publishedEntry}, which answers either spelling.
|
|
1517
|
+
*/
|
|
1504
1518
|
collections?: Record<string, Array<Record<string, unknown> & {
|
|
1505
1519
|
slug?: string;
|
|
1520
|
+
data?: Record<string, unknown>;
|
|
1506
1521
|
}>>;
|
|
1507
1522
|
pages?: unknown[];
|
|
1508
1523
|
components?: unknown[];
|
|
@@ -1520,6 +1535,14 @@ declare function readPublishedContent<T extends PublishedContent = PublishedCont
|
|
|
1520
1535
|
/**
|
|
1521
1536
|
* One published entry by its slug, searched across every collection (first match wins, in the
|
|
1522
1537
|
* snapshot's model order). Not keyed by model slug: a page's backing model is named by the CMS.
|
|
1538
|
+
*
|
|
1539
|
+
* 🔴 THE VALUES ARE ON THE ENTRY: `publishedEntry("home")?.title`. The snapshot holds each row as
|
|
1540
|
+
* the delivery API serves it, values under `data`, and this used to hand that row back as it was
|
|
1541
|
+
* while its own doc (and the skill that names it) said "the row carries its field values" — so
|
|
1542
|
+
* `entry.title` was `undefined` and every field of a server-rendered page fell back to the copy in
|
|
1543
|
+
* the code, on every publish. Both spellings are answered: the values at the top level and the
|
|
1544
|
+
* row's own keys (`id`, `slug`, `status`, `data`, `_meta`, …) beside them, the row's winning where
|
|
1545
|
+
* a field is named like one — that field is read through `.data`, as before.
|
|
1523
1546
|
*/
|
|
1524
1547
|
declare function publishedEntry<T extends Record<string, unknown> = Record<string, unknown>>(slug: string): (T & {
|
|
1525
1548
|
slug: string;
|
package/dist/index.js
CHANGED
|
@@ -1587,12 +1587,18 @@ function readPublishedContent() {
|
|
|
1587
1587
|
}
|
|
1588
1588
|
return cache.content;
|
|
1589
1589
|
}
|
|
1590
|
+
var flat = /* @__PURE__ */ new WeakMap();
|
|
1590
1591
|
function publishedEntry(slug) {
|
|
1591
1592
|
const collections = readPublishedContent()?.collections ?? {};
|
|
1592
1593
|
for (const rows of Object.values(collections)) {
|
|
1593
1594
|
if (!Array.isArray(rows)) continue;
|
|
1594
1595
|
const hit = rows.find((row) => row?.slug === slug);
|
|
1595
|
-
if (hit)
|
|
1596
|
+
if (!hit) continue;
|
|
1597
|
+
const data = hit.data;
|
|
1598
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return hit;
|
|
1599
|
+
let entry = flat.get(hit);
|
|
1600
|
+
if (!entry) flat.set(hit, entry = { ...data, ...hit });
|
|
1601
|
+
return entry;
|
|
1596
1602
|
}
|
|
1597
1603
|
return null;
|
|
1598
1604
|
}
|