@bettercms-ai/sdk 1.19.0 → 1.20.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 +82 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -3
- package/dist/index.d.ts +103 -3
- package/dist/index.js +81 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -58,6 +58,7 @@ __export(index_exports, {
|
|
|
58
58
|
deleteSubmission: () => deleteSubmission,
|
|
59
59
|
deleteWorkspace: () => deleteWorkspace,
|
|
60
60
|
encodeStega: () => encodeStega,
|
|
61
|
+
entrySeoInput: () => entrySeoInput,
|
|
61
62
|
formInitialValues: () => formInitialValues,
|
|
62
63
|
getApiKeyUsage: () => getApiKeyUsage,
|
|
63
64
|
getBlockType: () => import_types.getBlockType,
|
|
@@ -677,6 +678,13 @@ async function deleteModel(client, id) {
|
|
|
677
678
|
}
|
|
678
679
|
|
|
679
680
|
// src/methods/management/media.ts
|
|
681
|
+
async function updateAsset(client, id, input) {
|
|
682
|
+
const { data } = await client.fetchJSON(
|
|
683
|
+
client.url(`/management/media/${encodeURIComponent(id)}`),
|
|
684
|
+
{ method: "PATCH", body: JSON.stringify(input) }
|
|
685
|
+
);
|
|
686
|
+
return data;
|
|
687
|
+
}
|
|
680
688
|
var MIME_BY_EXT = {
|
|
681
689
|
png: "image/png",
|
|
682
690
|
jpg: "image/jpeg",
|
|
@@ -804,6 +812,10 @@ async function uploadAsset(client, input) {
|
|
|
804
812
|
body: bytes
|
|
805
813
|
}
|
|
806
814
|
);
|
|
815
|
+
if (input.transcript && input.transcript.trim()) {
|
|
816
|
+
await updateAsset(client, data.id, { transcript: input.transcript });
|
|
817
|
+
return { ...data, transcript: input.transcript };
|
|
818
|
+
}
|
|
807
819
|
return data;
|
|
808
820
|
}
|
|
809
821
|
|
|
@@ -1065,6 +1077,10 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
|
|
|
1065
1077
|
uploadAsset(input) {
|
|
1066
1078
|
return uploadAsset(this, input);
|
|
1067
1079
|
}
|
|
1080
|
+
/** Set an asset's alt text, caption or transcript (video/audio only). `null` clears. */
|
|
1081
|
+
updateAsset(id, input) {
|
|
1082
|
+
return updateAsset(this, id, input);
|
|
1083
|
+
}
|
|
1068
1084
|
// ── Forms (read-only): discover dashboard-built forms to embed into site code ──
|
|
1069
1085
|
/** List forms in the key's project (or workspace-level). */
|
|
1070
1086
|
listForms() {
|
|
@@ -1533,6 +1549,68 @@ function jsonLdNodes(schema) {
|
|
|
1533
1549
|
}
|
|
1534
1550
|
return out;
|
|
1535
1551
|
}
|
|
1552
|
+
var SCHEMA_TYPE_CHOICES = [
|
|
1553
|
+
"WebPage",
|
|
1554
|
+
"AboutPage",
|
|
1555
|
+
"ContactPage",
|
|
1556
|
+
"CollectionPage",
|
|
1557
|
+
"Blog",
|
|
1558
|
+
"BlogPosting",
|
|
1559
|
+
"Article",
|
|
1560
|
+
"Product",
|
|
1561
|
+
"FAQPage",
|
|
1562
|
+
"Event",
|
|
1563
|
+
"Organization",
|
|
1564
|
+
"LocalBusiness"
|
|
1565
|
+
];
|
|
1566
|
+
function compact(node) {
|
|
1567
|
+
return Object.fromEntries(Object.entries(node).filter(([, value]) => value != null && value !== ""));
|
|
1568
|
+
}
|
|
1569
|
+
function schemaNode(type, { name, description, image, url }) {
|
|
1570
|
+
switch (type) {
|
|
1571
|
+
case "BlogPosting":
|
|
1572
|
+
case "Article":
|
|
1573
|
+
return compact({ "@type": type, headline: name, description, image, url, mainEntityOfPage: url });
|
|
1574
|
+
case "Product":
|
|
1575
|
+
case "Event":
|
|
1576
|
+
return compact({ "@type": type, name, description, image, url });
|
|
1577
|
+
case "FAQPage":
|
|
1578
|
+
case "WebSite":
|
|
1579
|
+
return compact({ "@type": type, name, description, url });
|
|
1580
|
+
case "Organization":
|
|
1581
|
+
return compact({ "@type": type, name, description, url, logo: image });
|
|
1582
|
+
default:
|
|
1583
|
+
return compact({ "@type": type, name, description, url, image });
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
function pageJsonLd(page, meta, canonical, siteSchema) {
|
|
1587
|
+
const custom = jsonLdNodes(meta.schema);
|
|
1588
|
+
if (custom.length > 0) return custom;
|
|
1589
|
+
const props = {
|
|
1590
|
+
name: (page.metaTitle || page.title || "").trim(),
|
|
1591
|
+
description: (page.metaDescription || "").trim(),
|
|
1592
|
+
image: (meta.og?.image || "").trim(),
|
|
1593
|
+
url: canonical.trim()
|
|
1594
|
+
};
|
|
1595
|
+
const schemaType = meta.schemaType;
|
|
1596
|
+
if (typeof schemaType === "string" && SCHEMA_TYPE_CHOICES.includes(schemaType)) {
|
|
1597
|
+
return [schemaNode(schemaType, props)];
|
|
1598
|
+
}
|
|
1599
|
+
if (page.slug === "home") {
|
|
1600
|
+
return jsonLdNodes(siteSchema).length > 0 ? [] : [schemaNode("WebSite", props)];
|
|
1601
|
+
}
|
|
1602
|
+
return [schemaNode("WebPage", props)];
|
|
1603
|
+
}
|
|
1604
|
+
function entrySeoInput(entry) {
|
|
1605
|
+
const { metaTitle, metaDescription, noindex, ...metaJson } = entry.seo ?? {};
|
|
1606
|
+
return {
|
|
1607
|
+
title: metaTitle || entry.slug,
|
|
1608
|
+
metaTitle: metaTitle ?? null,
|
|
1609
|
+
metaDescription: metaDescription ?? null,
|
|
1610
|
+
metaJson,
|
|
1611
|
+
noindex: noindex === true
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
1536
1614
|
function resolveSeo(page, defaults = {}, location = {}) {
|
|
1537
1615
|
const meta = page.metaJson ?? {};
|
|
1538
1616
|
const title = page.metaTitle || page.title || "";
|
|
@@ -1560,7 +1638,9 @@ function resolveSeo(page, defaults = {}, location = {}) {
|
|
|
1560
1638
|
image: twImage,
|
|
1561
1639
|
site: defaults.twitterHandle || ""
|
|
1562
1640
|
},
|
|
1563
|
-
jsonLd: [...jsonLdNodes(defaults.siteSchema), ...
|
|
1641
|
+
jsonLd: [...jsonLdNodes(defaults.siteSchema), ...pageJsonLd(page, meta, canonical, defaults.siteSchema)],
|
|
1642
|
+
noindex: page.noindex === true,
|
|
1643
|
+
robots: { index: page.noindex !== true, follow: true }
|
|
1564
1644
|
};
|
|
1565
1645
|
}
|
|
1566
1646
|
|
|
@@ -1904,6 +1984,7 @@ var import_types = require("@bettercms-ai/types");
|
|
|
1904
1984
|
deleteSubmission,
|
|
1905
1985
|
deleteWorkspace,
|
|
1906
1986
|
encodeStega,
|
|
1987
|
+
entrySeoInput,
|
|
1907
1988
|
formInitialValues,
|
|
1908
1989
|
getApiKeyUsage,
|
|
1909
1990
|
getBlockType,
|