@bettercms-ai/sdk 1.39.0 → 1.41.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/bindings.cjs +146 -0
- package/dist/bindings.cjs.map +1 -0
- package/dist/bindings.d.cts +174 -0
- package/dist/bindings.d.ts +174 -0
- package/dist/bindings.js +109 -0
- package/dist/bindings.js.map +1 -0
- package/dist/in-editor-D1vXPgJh.d.cts +63 -0
- package/dist/in-editor-D1vXPgJh.d.ts +63 -0
- package/dist/index.d.cts +4 -216
- package/dist/index.d.ts +4 -216
- package/dist/live.cjs +158 -0
- package/dist/live.cjs.map +1 -0
- package/dist/live.d.cts +95 -0
- package/dist/live.d.ts +95 -0
- package/dist/live.js +120 -0
- package/dist/live.js.map +1 -0
- package/dist/read-AYzXKCU-.d.cts +191 -0
- package/dist/read-Bb60mWmW.d.ts +191 -0
- package/dist/read.cjs +49 -0
- package/dist/read.cjs.map +1 -1
- package/dist/read.d.cts +1 -38
- package/dist/read.d.ts +1 -38
- package/dist/read.js +44 -0
- package/dist/read.js.map +1 -1
- package/dist/sections.cjs +89 -10
- package/dist/sections.cjs.map +1 -1
- package/dist/sections.d.cts +65 -4
- package/dist/sections.d.ts +65 -4
- package/dist/sections.js +83 -10
- package/dist/sections.js.map +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bindings.ts"],"sourcesContent":["/**\n * The attributes a site's OWN markup spreads so the BetterCMS editor binds it: a page field, a\n * collection entry, a section root and its content column. Plain objects of string attributes\n * (the style is a CSS string), so they spread as they are in every template language:\n *\n * Astro / Svelte <h1 {...fieldAttrs(\"hero-title\", page.fieldStyles)}>…</h1>\n * Vue <h1 v-bind=\"fieldAttrs('hero-title', page.fieldStyles)\">…</h1>\n *\n * @bettercms-ai/astro, /sveltekit and /nuxt re-export these; @bettercms-ai/next keeps twins whose\n * `style` is a React style object.\n */\nimport imageUrlBuilder, {\n focalInCrop,\n normalizeImageCrop,\n normalizeImageFocal,\n objectPosition,\n type ImageFit,\n type ImageFormat,\n type ImageSource,\n} from \"@bettercms-ai/image-url\";\nimport { blockStyleToColumnCss, blockStyleToCss, fieldStyleCssText, hideOnAttr, type BlockStyle, type FieldStyle, type FieldStyles } from \"@bettercms-ai/types\";\n\n/**\n * C3 — `fieldAttrs(path, fieldStyles)`: the attributes a site's OWN element spreads to bind a PAGE\n * FIELD and apply that field's stored style, so the BetterCMS editor offers its width and spacing\n * handles and its Align / Size / Weight controls.\n *\n * ---\n * const page = await loadPage(Astro, \"home\");\n * ---\n * <h1 class=\"title\" {...fieldAttrs(\"hero-title\", page?.fieldStyles)}>{entry.data[\"hero-title\"]}</h1>\n *\n * `data-bcms-style` is the site's promise that \"this element's inline style is\n * `fieldStyleToCss(fieldStyles[path])`\". The editor offers a field's handles only on an element that\n * carries it: a handle on one that does not would paint the canvas and never ship. The marker is\n * present even when the field has no style (then there is no `style` attribute at all, byte for\n * byte the element it was): an unstyled field is the one an author is about to give its first edit.\n */\nexport interface FieldAttrs {\n \"data-bcms-field\": string;\n /** The marker's revision: \"2\" promises `size` (zoom) too. Section roots keep \"\". */\n \"data-bcms-style\": \"2\";\n /** `fieldStyleToCss(fieldStyles[path])` as a CSS string; absent when the field has no style. */\n style?: string;\n}\n\n/** The stored style for `path`, by OWN key only — a path like `constructor` never reads the prototype. */\nexport function fieldStyleOf(path: string, fieldStyles: FieldStyles | Record<string, unknown> | null | undefined): FieldStyle | undefined {\n if (!fieldStyles || typeof fieldStyles !== \"object\" || !Object.prototype.hasOwnProperty.call(fieldStyles, path)) return undefined;\n const style = (fieldStyles as Record<string, unknown>)[path];\n return style && typeof style === \"object\" ? (style as FieldStyle) : undefined;\n}\n\nexport function fieldAttrs(path: string, fieldStyles?: FieldStyles | Record<string, unknown> | null): FieldAttrs {\n const style = fieldStyleCssText(fieldStyleOf(path, fieldStyles));\n return { \"data-bcms-field\": path, \"data-bcms-style\": \"2\", ...(style ? { style } : {}) };\n}\n\n/**\n * P7 — `entryAttrs(entry)` and `entryField(entry, path)`: the attributes a site's OWN card spreads to\n * declare a collection ENTRY, so the editor binds it without guessing from the rendered text.\n *\n * <article {...entryAttrs(post)}><h3 {...entryField(post, \"title\")}>{post.fields.title}</h3></article>\n *\n * The field address is ABSOLUTE (`entry:<id>:<path>`). With a `transform` the value is shown\n * changed (a date formatted, text truncated), so it is declared as `data-bcms-entry-from`: the\n * editor knows where it is but cannot re-render it.\n */\nexport type EntryRef = { id?: string } | string;\nexport type EntryTransform = \"format\" | \"truncate\" | \"rendition\" | \"route\";\n/** One key is present: `data-bcms-entry-field`, or `data-bcms-entry-from` when transformed; none without an id. */\nexport interface EntryFieldAttrs {\n \"data-bcms-entry-field\"?: string;\n \"data-bcms-entry-from\"?: string;\n}\n\nfunction entryIdOf(entry: EntryRef): string | null {\n const id = typeof entry === \"string\" ? entry : entry?.id;\n return typeof id === \"string\" && id.trim() !== \"\" ? id : null;\n}\n\n/** An entry with no id (a snapshot written before ids were kept) renders unbound, never fails the build. */\nexport function entryAttrs(entry: EntryRef): { \"data-bcms-entry\"?: string } {\n const id = entryIdOf(entry);\n return id ? { \"data-bcms-entry\": id } : {};\n}\n\nexport function entryField(entry: EntryRef, path: string, opts?: { transform?: EntryTransform }): EntryFieldAttrs {\n const id = entryIdOf(entry);\n if (typeof path !== \"string\" || path.trim() === \"\") throw new Error(`entryField: no field path given for entry ${id ?? \"(no id)\"}`);\n if (!id) return {};\n const address = `entry:${id}:${path}`;\n return opts?.transform ? { \"data-bcms-entry-from\": `${address}|${opts.transform}` } : { \"data-bcms-entry-field\": address };\n}\n\n/**\n * C3/C4 — `sectionRootAttrs(block)`: the attributes a site's OWN section root spreads so the\n * BetterCMS editor offers that section's spacing and style handles.\n *\n * <section class=\"hero\" {...sectionRootAttrs(block)}>…</section>\n *\n * The editor shows those handles on a site-rendered page only when EVERY root the site stamps\n * with `data-bcms-block` also carries `data-bcms-style`, which is the site's promise that \"this\n * root's inline style is `blockStyleToCss(block.style)`\" — the same declarations `<BcmsBlocks>`\n * puts on its own wrapper. A root that stamps the block without applying its style would get a\n * capsule that paints the canvas and never ships, so the marker must travel with the style.\n *\n * The marker is present even when the style is EMPTY (then there is no `style` attribute at all):\n * an unstyled section is exactly the one an author is about to give its first spacing edit.\n */\nexport interface SectionRootBlock {\n id?: string | null;\n style?: BlockStyle | Record<string, unknown> | null;\n}\n\nexport interface SectionRootAttrs {\n \"data-bcms-block\"?: string;\n \"data-bcms-style\": \"\";\n /** `\"mobile tablet\"` when `style.hideOn` hides it there; the site ships `RESPONSIVE_CSS` for it. */\n \"data-bcms-hide\"?: string;\n /** `blockStyleToCss(block.style)` as a CSS string; absent when the block has no style. */\n style?: string;\n}\n\n/** `paddingTop` → `padding-top`, joined the way `<BcmsBlocks>` writes its wrapper's attribute. */\nfunction cssText(css: Record<string, string | number>): string {\n return Object.entries(css)\n .map(([k, v]) => `${k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}:${v}`)\n .join(\";\");\n}\n\nexport function sectionRootAttrs(block: SectionRootBlock | null | undefined): SectionRootAttrs {\n const css = blockStyleToCss((block?.style ?? undefined) as BlockStyle | undefined);\n const id = typeof block?.id === \"string\" && block.id !== \"\" ? block.id : undefined;\n const hide = hideOnAttr(block?.style);\n return {\n ...(id !== undefined ? { \"data-bcms-block\": id } : {}),\n \"data-bcms-style\": \"\",\n ...(hide ? { \"data-bcms-hide\": hide } : {}),\n ...(css ? { style: cssText(css) } : {}),\n };\n}\n\nexport interface SectionColumnAttrs {\n \"data-bcms-column\": \"\";\n /** `blockStyleToColumnCss(block.style)` as a CSS string; absent when the section has no column. */\n style?: string;\n}\n\n/**\n * C3 — `sectionColumnAttrs(block)`: the attributes a site's own INNER container spreads so the\n * section's content WIDTH (`style.contentWidth`, placed by `contentAlign`) ships.\n *\n * <section {...sectionRootAttrs(block)}>\n * <div class=\"container\" {...sectionColumnAttrs(block)}>…</div>\n * </section>\n *\n * The width is the column BetterCMS draws as `.bcms-block-inner` inside the section's styled box —\n * never on the root itself, whose background must stay full-bleed. `data-bcms-column` is the\n * site's promise that this box's inline style is the column; the editor offers the width handle\n * on a site-rendered page only where every styled root holds one. Max-width plus left/right\n * margins, so the container keeps its own vertical margins and, with no column, its own width.\n */\nexport function sectionColumnAttrs(block: SectionRootBlock | null | undefined): SectionColumnAttrs {\n const css = blockStyleToColumnCss((block?.style ?? undefined) as BlockStyle | undefined);\n return { \"data-bcms-column\": \"\", ...(css ? { style: cssText(css) } : {}) };\n}\n\n/** The image facts a value or asset may carry beside its URL. */\ntype ImageFacts = { altText?: string | null; alt?: string | null; width?: number | null; height?: number | null; focalX?: number | null; focalY?: number | null };\n\nexport interface ImageOptions {\n /** The field this image renders, in the editor grammar (`cover`, `hero.image`). */\n path?: string;\n alt?: string;\n width?: number;\n height?: number;\n format?: ImageFormat;\n quality?: number;\n fit?: ImageFit;\n sizes?: string;\n loading?: \"lazy\" | \"eager\";\n /** Focal point override, 0–1. Normally omitted: the value and the asset carry their own. */\n focalX?: number | null;\n focalY?: number | null;\n /** Media host for a `src` that is only an asset id. Defaults to the platform's. */\n baseUrl?: string;\n}\n\n/** The widths a `sizes` image offers: phone to desktop, and never an upscale of the picture. */\nconst LADDER = [480, 768, 1080, 1440, 1920];\nconst num = (v: unknown): number | undefined => (typeof v === \"number\" && Number.isFinite(v) ? v : undefined);\n\n/**\n * What every `<BcmsImage>` renders, computed once for all of them: the transform URL, a srcset\n * (a WIDTH ladder with `sizes` and no `width`, else 1x/2x), the alt (the value's `altText` unless\n * `alt` says otherwise) and the style declarations, camel-cased. The value's crop and focal point\n * are applied by image-url itself; a source-relative focal is re-expressed inside the crop.\n */\nexport function imageCore(src: ImageSource | (Exclude<ImageSource, string> & ImageFacts), opts: ImageOptions = {}) {\n const { width, height, format = \"webp\", quality, fit, sizes, focalX, focalY, baseUrl } = opts;\n const asset = (typeof src === \"object\" && src !== null ? src : {}) as Record<string, unknown>;\n const explicit = focalX != null || focalY != null;\n const stored =\n normalizeImageFocal(asset.focal) ??\n (num(asset.focalX) != null || num(asset.focalY) != null ? { x: num(asset.focalX) ?? 0.5, y: num(asset.focalY) ?? 0.5 } : null);\n const inWindow = stored ? focalInCrop(stored, normalizeImageCrop(asset.crop)) : null;\n const fx = explicit ? focalX : inWindow?.x;\n const fy = explicit ? focalY : inWindow?.y;\n const hasFocal = fx != null || fy != null;\n const builder = imageUrlBuilder({ baseUrl });\n const make = () => {\n let b = builder(src as ImageSource);\n if (width) b = b.width(width);\n if (height) b = b.height(height);\n if (format) b = b.format(format);\n if (quality) b = b.quality(quality);\n if (fit) b = b.fit(fit);\n if (hasFocal) b = b.focal(fx ?? 0.5, fy ?? 0.5);\n return b;\n };\n const url = make().url();\n const own = num(asset.width);\n const ladder = own ? [...new Set([...LADDER.filter((w) => w < own), Math.min(own, LADDER[LADDER.length - 1]!)])] : LADDER;\n const srcset = sizes && !width ? ladder.map((w) => `${make().width(w).url()} ${w}w`).join(\", \") : `${url} 1x, ${make().dpr(2).url()} 2x`;\n // A pixel width is the author's size for THIS image, so it also goes on as a style (a site rule\n // like `img { width: 100% }` beats a bare attribute), capped at the column it sits in. The focal\n // point rides as object-position, inert unless the site's CSS sets object-fit.\n const css: Record<string, string> = {\n ...(width ? { width: `${width}px`, maxWidth: \"100%\", height: \"auto\" } : {}),\n ...(hasFocal ? { objectPosition: objectPosition({ x: fx, y: fy }) } : {}),\n };\n const alt = opts.alt ?? (typeof asset.altText === \"string\" ? asset.altText : typeof asset.alt === \"string\" ? asset.alt : \"\");\n return { src: url, srcset, alt, css };\n}\n\nexport interface ImageAttrs {\n src: string;\n srcset: string;\n alt: string;\n loading: \"lazy\" | \"eager\";\n sizes?: string;\n width?: number;\n height?: number;\n style?: string;\n \"data-bcms-field\"?: string;\n \"data-bcms-kind\"?: \"image\";\n}\n\n/**\n * The `<img>` attributes for an image value, the same markup as every `<BcmsImage>`. Given `path`,\n * the image declares its field, so the editor binds it and a publish writes the new picture in:\n *\n * <img {...imageAttrs(page.hero.image, { path: \"hero.image\", sizes: \"100vw\" })} class=\"hero\" />\n */\nexport function imageAttrs(src: Parameters<typeof imageCore>[0], opts: ImageOptions = {}): ImageAttrs {\n const { src: url, srcset, alt, css } = imageCore(src, opts);\n const style = cssText(css);\n return {\n src: url,\n srcset,\n alt,\n loading: opts.loading ?? \"lazy\",\n ...(opts.sizes ? { sizes: opts.sizes } : {}),\n ...(opts.width ? { width: opts.width } : {}),\n ...(opts.height ? { height: opts.height } : {}),\n ...(style ? { style } : {}),\n ...(opts.path ? { \"data-bcms-field\": opts.path, \"data-bcms-kind\": \"image\" as const } : {}),\n };\n}\n"],"mappings":";AAWA,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,uBAAuB,iBAAiB,mBAAmB,kBAAsE;AA2BnI,SAAS,aAAa,MAAc,aAA+F;AACxI,MAAI,CAAC,eAAe,OAAO,gBAAgB,YAAY,CAAC,OAAO,UAAU,eAAe,KAAK,aAAa,IAAI,EAAG,QAAO;AACxH,QAAM,QAAS,YAAwC,IAAI;AAC3D,SAAO,SAAS,OAAO,UAAU,WAAY,QAAuB;AACtE;AAEO,SAAS,WAAW,MAAc,aAAwE;AAC/G,QAAM,QAAQ,kBAAkB,aAAa,MAAM,WAAW,CAAC;AAC/D,SAAO,EAAE,mBAAmB,MAAM,mBAAmB,KAAK,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAG;AACxF;AAoBA,SAAS,UAAU,OAAgC;AACjD,QAAM,KAAK,OAAO,UAAU,WAAW,QAAQ,OAAO;AACtD,SAAO,OAAO,OAAO,YAAY,GAAG,KAAK,MAAM,KAAK,KAAK;AAC3D;AAGO,SAAS,WAAW,OAAiD;AAC1E,QAAM,KAAK,UAAU,KAAK;AAC1B,SAAO,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;AAC3C;AAEO,SAAS,WAAW,OAAiB,MAAc,MAAwD;AAChH,QA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1F;AACF;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `bcms:content-applied` — what the visual editor tells a page after it has applied an edit to
|
|
3
|
+
* the page's DOM.
|
|
4
|
+
*
|
|
5
|
+
* An edit changes how tall a heading is. Everything on the page that measured the layout once
|
|
6
|
+
* (ScrollTrigger's start and end positions, Lenis's scroll limit, a carousel's slide widths, a
|
|
7
|
+
* text splitter's lines) is now wrong, and only the page's own code can measure again. So the
|
|
8
|
+
* editor posts one message to the frame's window after each applied edit, and the site listens:
|
|
9
|
+
*
|
|
10
|
+
* onContentApplied(() => ScrollTrigger.refresh());
|
|
11
|
+
*
|
|
12
|
+
* A published page receives no such message: nothing there posts it, and the listener is inert.
|
|
13
|
+
*/
|
|
14
|
+
/** The `type` of the message. */
|
|
15
|
+
declare const CONTENT_APPLIED = "bcms:content-applied";
|
|
16
|
+
interface ContentAppliedMessage {
|
|
17
|
+
type: typeof CONTENT_APPLIED;
|
|
18
|
+
/** The field addresses whose rendering changed; empty when the editor does not say. */
|
|
19
|
+
fields: string[];
|
|
20
|
+
}
|
|
21
|
+
/** The message the editor posts: `frame.contentWindow.postMessage(contentApplied(fields), origin)`. */
|
|
22
|
+
declare const contentApplied: (fields?: readonly string[]) => ContentAppliedMessage;
|
|
23
|
+
/** The least of `window` this needs. */
|
|
24
|
+
interface MessageTarget {
|
|
25
|
+
addEventListener(type: "message", listener: (event: {
|
|
26
|
+
data: unknown;
|
|
27
|
+
}) => void): void;
|
|
28
|
+
removeEventListener(type: "message", listener: (event: {
|
|
29
|
+
data: unknown;
|
|
30
|
+
}) => void): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Run `handler` after every edit the editor applies to this page. Returns the function that
|
|
34
|
+
* stops listening. Safe to call where there is no window (a server render): it does nothing.
|
|
35
|
+
*/
|
|
36
|
+
declare function onContentApplied(handler: (message: ContentAppliedMessage) => void, target?: MessageTarget | undefined): () => void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* `inEditor()`: is this page running inside the BetterCMS Visual Editor's canvas?
|
|
40
|
+
*
|
|
41
|
+
* The editor frames the site and names the frame, so the answer is the page's own `window.name`:
|
|
42
|
+
* there from the first script, kept through every navigation inside the frame, and never set on
|
|
43
|
+
* a published page a visitor opens. A site asks before it starts what the canvas cannot share:
|
|
44
|
+
*
|
|
45
|
+
* const smooth = inEditor() ? null : new LocomotiveScroll({ el, smooth: true });
|
|
46
|
+
*
|
|
47
|
+
* The canvas owns the scroll, the pointer and the place on the page; the site's motion (scroll
|
|
48
|
+
* triggers, timelines, WebGL scenes) runs there as it does live. What has to stand down is only
|
|
49
|
+
* what takes those three away: scroll that is not the window's own, an intro that holds the
|
|
50
|
+
* page, a cursor drawn over it.
|
|
51
|
+
*/
|
|
52
|
+
/** The canvas frame's name. The dashboard sets this exact word (`EDITOR_FRAME_NAME`). */
|
|
53
|
+
declare const EDITOR_FRAME_NAME = "bcms-editor";
|
|
54
|
+
/** The least of `window` this needs. */
|
|
55
|
+
interface FramedWindow {
|
|
56
|
+
name: string;
|
|
57
|
+
self: unknown;
|
|
58
|
+
top: unknown;
|
|
59
|
+
}
|
|
60
|
+
/** True inside the editor's canvas. Safe where there is no window (a server render): false. */
|
|
61
|
+
declare function inEditor(win?: FramedWindow | undefined): boolean;
|
|
62
|
+
|
|
63
|
+
export { CONTENT_APPLIED as C, EDITOR_FRAME_NAME as E, type ContentAppliedMessage as a, contentApplied as c, inEditor as i, onContentApplied as o };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `bcms:content-applied` — what the visual editor tells a page after it has applied an edit to
|
|
3
|
+
* the page's DOM.
|
|
4
|
+
*
|
|
5
|
+
* An edit changes how tall a heading is. Everything on the page that measured the layout once
|
|
6
|
+
* (ScrollTrigger's start and end positions, Lenis's scroll limit, a carousel's slide widths, a
|
|
7
|
+
* text splitter's lines) is now wrong, and only the page's own code can measure again. So the
|
|
8
|
+
* editor posts one message to the frame's window after each applied edit, and the site listens:
|
|
9
|
+
*
|
|
10
|
+
* onContentApplied(() => ScrollTrigger.refresh());
|
|
11
|
+
*
|
|
12
|
+
* A published page receives no such message: nothing there posts it, and the listener is inert.
|
|
13
|
+
*/
|
|
14
|
+
/** The `type` of the message. */
|
|
15
|
+
declare const CONTENT_APPLIED = "bcms:content-applied";
|
|
16
|
+
interface ContentAppliedMessage {
|
|
17
|
+
type: typeof CONTENT_APPLIED;
|
|
18
|
+
/** The field addresses whose rendering changed; empty when the editor does not say. */
|
|
19
|
+
fields: string[];
|
|
20
|
+
}
|
|
21
|
+
/** The message the editor posts: `frame.contentWindow.postMessage(contentApplied(fields), origin)`. */
|
|
22
|
+
declare const contentApplied: (fields?: readonly string[]) => ContentAppliedMessage;
|
|
23
|
+
/** The least of `window` this needs. */
|
|
24
|
+
interface MessageTarget {
|
|
25
|
+
addEventListener(type: "message", listener: (event: {
|
|
26
|
+
data: unknown;
|
|
27
|
+
}) => void): void;
|
|
28
|
+
removeEventListener(type: "message", listener: (event: {
|
|
29
|
+
data: unknown;
|
|
30
|
+
}) => void): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Run `handler` after every edit the editor applies to this page. Returns the function that
|
|
34
|
+
* stops listening. Safe to call where there is no window (a server render): it does nothing.
|
|
35
|
+
*/
|
|
36
|
+
declare function onContentApplied(handler: (message: ContentAppliedMessage) => void, target?: MessageTarget | undefined): () => void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* `inEditor()`: is this page running inside the BetterCMS Visual Editor's canvas?
|
|
40
|
+
*
|
|
41
|
+
* The editor frames the site and names the frame, so the answer is the page's own `window.name`:
|
|
42
|
+
* there from the first script, kept through every navigation inside the frame, and never set on
|
|
43
|
+
* a published page a visitor opens. A site asks before it starts what the canvas cannot share:
|
|
44
|
+
*
|
|
45
|
+
* const smooth = inEditor() ? null : new LocomotiveScroll({ el, smooth: true });
|
|
46
|
+
*
|
|
47
|
+
* The canvas owns the scroll, the pointer and the place on the page; the site's motion (scroll
|
|
48
|
+
* triggers, timelines, WebGL scenes) runs there as it does live. What has to stand down is only
|
|
49
|
+
* what takes those three away: scroll that is not the window's own, an intro that holds the
|
|
50
|
+
* page, a cursor drawn over it.
|
|
51
|
+
*/
|
|
52
|
+
/** The canvas frame's name. The dashboard sets this exact word (`EDITOR_FRAME_NAME`). */
|
|
53
|
+
declare const EDITOR_FRAME_NAME = "bcms-editor";
|
|
54
|
+
/** The least of `window` this needs. */
|
|
55
|
+
interface FramedWindow {
|
|
56
|
+
name: string;
|
|
57
|
+
self: unknown;
|
|
58
|
+
top: unknown;
|
|
59
|
+
}
|
|
60
|
+
/** True inside the editor's canvas. Safe where there is no window (a server render): false. */
|
|
61
|
+
declare function inEditor(win?: FramedWindow | undefined): boolean;
|
|
62
|
+
|
|
63
|
+
export { CONTENT_APPLIED as C, EDITOR_FRAME_NAME as E, type ContentAppliedMessage as a, contentApplied as c, inEditor as i, onContentApplied as o };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as _bettercms_ai_types from '@bettercms-ai/types';
|
|
2
|
-
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput,
|
|
2
|
+
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Page, MediaAsset, FormField, Form, FormSubmission, Workspace, ApiKey, ApiKeyPermission, ApiKeyTokenType } from '@bettercms-ai/types';
|
|
3
3
|
export { ApiError, ApiKey, ApiKeyPermission, ApiKeyTokenType, AssertEqual, AuthSession, AuthUser, BetterCMSErrorCode, BlockType, ButtonBlock, ButtonProps, ColumnsBlock, ColumnsProps, Content, ContentBlock, ContentEntry, ContentModel, ContentModelField, ContentPageResult, ContentResponse, DeepReadonly, DeliveryComponent, DeliveryEntry, DeliveryList, DeliveryPage, EmbedCard, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, ResolvedAuthor, ResolvedPost, RichTextEmbeds, RichTextResolved, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
4
|
import { D as DeliveryFormField } from './read-client-CnkVzNP0.cjs';
|
|
5
5
|
export { a as BCMSClientError, E as BCMSErrorCodes, a as BetterCMSError, B as BetterCMSReadClient, C as CreateClientOptions, b as DeliveryForm, c as DeliveryFormFieldType, E as ErrorCodes, F as FormSubmitError, d as FormValue, e as FormValues, G as GetEntryOptions, L as ListEntriesOptions, f as ListPagesOptions, S as SubmitFormOptions, g as SubmitFormResult, h as asStringArray, i as createClient, j as formInitialValues, k as isMultiValueField, s as shouldShowField, l as submitForm, t as toggleOption } from './read-client-CnkVzNP0.cjs';
|
|
6
|
+
export { C as CONTENT_APPLIED, a as ContentAppliedMessage, E as EDITOR_FRAME_NAME, c as contentApplied, i as inEditor, o as onContentApplied } from './in-editor-D1vXPgJh.cjs';
|
|
7
|
+
export { P as PORTABLE_TEXT_FORMAT, R as ResolvedHolder, a as RichTextValue, S as SearchHit, b as SearchOptions, T as TextOrRich, e as embeds, i as isRichText, l as lines, p as plain, c as portableText, r as resolved, d as rich, s as search } from './read-AYzXKCU-.cjs';
|
|
6
8
|
export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.cjs';
|
|
7
|
-
export { SearchHit, SearchOptions, search } from './read.cjs';
|
|
8
9
|
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -982,194 +983,6 @@ declare function resolveStega(node: StegaNode): {
|
|
|
982
983
|
element: StegaNode;
|
|
983
984
|
} | null;
|
|
984
985
|
|
|
985
|
-
/**
|
|
986
|
-
* `bcms:content-applied` — what the visual editor tells a page after it has applied an edit to
|
|
987
|
-
* the page's DOM.
|
|
988
|
-
*
|
|
989
|
-
* An edit changes how tall a heading is. Everything on the page that measured the layout once
|
|
990
|
-
* (ScrollTrigger's start and end positions, Lenis's scroll limit, a carousel's slide widths, a
|
|
991
|
-
* text splitter's lines) is now wrong, and only the page's own code can measure again. So the
|
|
992
|
-
* editor posts one message to the frame's window after each applied edit, and the site listens:
|
|
993
|
-
*
|
|
994
|
-
* onContentApplied(() => ScrollTrigger.refresh());
|
|
995
|
-
*
|
|
996
|
-
* A published page receives no such message: nothing there posts it, and the listener is inert.
|
|
997
|
-
*/
|
|
998
|
-
/** The `type` of the message. */
|
|
999
|
-
declare const CONTENT_APPLIED = "bcms:content-applied";
|
|
1000
|
-
interface ContentAppliedMessage {
|
|
1001
|
-
type: typeof CONTENT_APPLIED;
|
|
1002
|
-
/** The field addresses whose rendering changed; empty when the editor does not say. */
|
|
1003
|
-
fields: string[];
|
|
1004
|
-
}
|
|
1005
|
-
/** The message the editor posts: `frame.contentWindow.postMessage(contentApplied(fields), origin)`. */
|
|
1006
|
-
declare const contentApplied: (fields?: readonly string[]) => ContentAppliedMessage;
|
|
1007
|
-
/** The least of `window` this needs. */
|
|
1008
|
-
interface MessageTarget {
|
|
1009
|
-
addEventListener(type: "message", listener: (event: {
|
|
1010
|
-
data: unknown;
|
|
1011
|
-
}) => void): void;
|
|
1012
|
-
removeEventListener(type: "message", listener: (event: {
|
|
1013
|
-
data: unknown;
|
|
1014
|
-
}) => void): void;
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
* Run `handler` after every edit the editor applies to this page. Returns the function that
|
|
1018
|
-
* stops listening. Safe to call where there is no window (a server render): it does nothing.
|
|
1019
|
-
*/
|
|
1020
|
-
declare function onContentApplied(handler: (message: ContentAppliedMessage) => void, target?: MessageTarget | undefined): () => void;
|
|
1021
|
-
|
|
1022
|
-
/**
|
|
1023
|
-
* Reading a rich-text field, for any site.
|
|
1024
|
-
*
|
|
1025
|
-
* A `text` field delivers a bare string. A `richtext` field delivers the canonical envelope
|
|
1026
|
-
* `{ format, value, html }`. Those are different shapes, and switching a field's type in the
|
|
1027
|
-
* CMS switches which one your site receives — the Visual Editor offers exactly that switch,
|
|
1028
|
-
* so it happens on live projects. A template that interpolates the value directly then
|
|
1029
|
-
* renders `[object Object]` (or, in React, throws `Objects are not valid as a React child`).
|
|
1030
|
-
*
|
|
1031
|
-
* No payload can be both structured and safe to interpolate, which is why every headless CMS
|
|
1032
|
-
* requires a renderer for rich text. These are ours:
|
|
1033
|
-
*
|
|
1034
|
-
* plain(v) → text, for <title>, meta descriptions, JSON-LD, alt text, aria-label
|
|
1035
|
-
* rich(v) → HTML, for `set:html` / `dangerouslySetInnerHTML`
|
|
1036
|
-
*
|
|
1037
|
-
* Both accept a bare string, so a field can be switched in the CMS without touching the site.
|
|
1038
|
-
*
|
|
1039
|
-
* <h1 set:html={rich(page.heroTitle)} /> // Astro
|
|
1040
|
-
* <h1 dangerouslySetInnerHTML={{ __html: rich(f.heroTitle) }}/> // React
|
|
1041
|
-
* seo({ title: plain(page.heroTitle) })
|
|
1042
|
-
*/
|
|
1043
|
-
|
|
1044
|
-
/**
|
|
1045
|
-
* A block in a Body field's `doc`. Bounded vocabulary — the server only emits what it can
|
|
1046
|
-
* parse back, so an unknown `type` means your SDK is older than the content, not that the
|
|
1047
|
-
* content is malformed. Handle the default case rather than exhausting on it.
|
|
1048
|
-
*/
|
|
1049
|
-
type DocBlock = {
|
|
1050
|
-
/**
|
|
1051
|
-
* Stable within THIS document only — never a global key. Two different entries both have a
|
|
1052
|
-
* block called "0.0". A cross-document anchor is (entryId, fieldKey, id).
|
|
1053
|
-
*
|
|
1054
|
-
* Ids on content authored before block ids existed are derived from position, so they SHIFT
|
|
1055
|
-
* when that document is edited. Do not persist an id as a bookmark unless you know it came
|
|
1056
|
-
* from the editor rather than from the positional fallback.
|
|
1057
|
-
*/
|
|
1058
|
-
readonly id: string;
|
|
1059
|
-
readonly type: string;
|
|
1060
|
-
readonly [key: string]: unknown;
|
|
1061
|
-
};
|
|
1062
|
-
/** The `doc` rendition of a Body field — a versioned block array. */
|
|
1063
|
-
type DocValue = {
|
|
1064
|
-
readonly version: 1;
|
|
1065
|
-
readonly blocks: readonly DocBlock[];
|
|
1066
|
-
};
|
|
1067
|
-
/** The canonical rich-text envelope returned by the Delivery API. */
|
|
1068
|
-
interface RichTextValue {
|
|
1069
|
-
readonly format?: string;
|
|
1070
|
-
readonly value?: unknown;
|
|
1071
|
-
/** Server-rendered, sanitized HTML. Computed on write. */
|
|
1072
|
-
readonly html?: string;
|
|
1073
|
-
/**
|
|
1074
|
-
* Structured blocks — present on `document` (Body) fields only, and NOT guaranteed even
|
|
1075
|
-
* there: it is derived at write time, so an entry saved before this existed carries none
|
|
1076
|
-
* until its next save. There is no backfill. Always branch on its absence; `html` is the
|
|
1077
|
-
* field that is always there.
|
|
1078
|
-
*/
|
|
1079
|
-
readonly doc?: DocValue;
|
|
1080
|
-
/**
|
|
1081
|
-
* The embeds the server resolved when it built `html`: X cards keyed by canonical url (X's
|
|
1082
|
-
* script, when a site opts in, is the page's, never the value's). `html` already holds each card, so `rich()` never needs this; it is
|
|
1083
|
-
* for renderers of the STRUCTURE (`<PortableText embeds={…}>`). Absent on a value with no embed
|
|
1084
|
-
* and on any envelope written before it existed: read it through `embeds()`.
|
|
1085
|
-
*/
|
|
1086
|
-
readonly embeds?: RichTextEmbeds;
|
|
1087
|
-
/**
|
|
1088
|
-
* What the value's related posts and author bios point at, resolved by the server for THIS
|
|
1089
|
-
* response from the published entries (never stored). `html` already draws them; this is for
|
|
1090
|
-
* renderers of the structure (`<PortableText resolved={…}>`). Absent on a value with neither block.
|
|
1091
|
-
* Read it through `resolved()`.
|
|
1092
|
-
*/
|
|
1093
|
-
readonly resolved?: RichTextResolved;
|
|
1094
|
-
}
|
|
1095
|
-
/** The marker on a Portable Text envelope. `format` is a plain string, never a union — see below. */
|
|
1096
|
-
declare const PORTABLE_TEXT_FORMAT = "portable-text-1";
|
|
1097
|
-
/**
|
|
1098
|
-
* Structured blocks, when the field stores Portable Text.
|
|
1099
|
-
*
|
|
1100
|
-
* ── The compatibility guarantee, stated once ────────────────────────────────────────────
|
|
1101
|
-
* Portable Text did NOT change this envelope. `format`, `value` and `html` are the same three
|
|
1102
|
-
* keys they always were, so `isRichText`, `plain()` and `rich()` keep working untouched — and
|
|
1103
|
-
* they have to, because sites compiled months ago read `.html` directly and cannot be
|
|
1104
|
-
* rebuilt. `bettercms-starter-modern/lib/cms.ts` even carries its OWN copy of `rich()`, baked
|
|
1105
|
-
* into deployments nobody can reach. Storing a bare array instead would have made
|
|
1106
|
-
* `isRichText` return false (it rejects arrays), every shipped `rich()` call return "", and
|
|
1107
|
-
* every one of those pages go blank at 200 OK.
|
|
1108
|
-
*
|
|
1109
|
-
* `portableText()` is therefore ADDITIVE: `html` remains the always-present field, and this is
|
|
1110
|
-
* the opt-in for consumers that want to render structure with `@portabletext/react` instead.
|
|
1111
|
-
*/
|
|
1112
|
-
declare function portableText(value: TextOrRich): readonly unknown[] | null;
|
|
1113
|
-
/**
|
|
1114
|
-
* The value's resolved embeds, for a renderer of its structure (`<PortableText embeds>`), or null:
|
|
1115
|
-
* a bare string, a value with no embed, or an envelope written before embeds existed. Additive,
|
|
1116
|
-
* like `portableText()`: `rich()` reads `html`, which already holds the cards.
|
|
1117
|
-
*/
|
|
1118
|
-
declare function embeds(value: TextOrRich): RichTextEmbeds | null;
|
|
1119
|
-
/** A delivered entry as far as `resolved()` reads it: its entry-level map. */
|
|
1120
|
-
interface ResolvedHolder {
|
|
1121
|
-
readonly resolved?: RichTextResolved | null;
|
|
1122
|
-
readonly data?: unknown;
|
|
1123
|
-
}
|
|
1124
|
-
/**
|
|
1125
|
-
* What a rich-text value's related posts and author bios resolved to, for a renderer of its
|
|
1126
|
-
* structure (`<PortableText resolved>`), or null when there is nothing.
|
|
1127
|
-
*
|
|
1128
|
-
* resolved(entry.data.body, entry) // a field value, with the entry it came in
|
|
1129
|
-
* resolved(entry) // the entry's merged map
|
|
1130
|
-
*
|
|
1131
|
-
* An envelope value carries its own (`value.resolved`), which wins. A Body stored as a bare block
|
|
1132
|
-
* array has nowhere to carry one, so delivery puts the entry's merged map beside `data`
|
|
1133
|
-
* (`entry.resolved`): pass the entry and that is what you get. Additive, like `embeds()`: `rich()`
|
|
1134
|
-
* reads `html`, which already draws them.
|
|
1135
|
-
*/
|
|
1136
|
-
declare function resolved(value: TextOrRich | readonly unknown[] | ResolvedHolder, entry?: ResolvedHolder | null): RichTextResolved | null;
|
|
1137
|
-
/**
|
|
1138
|
-
* A field that may arrive as either shape. Type author-editable text fields with this and the
|
|
1139
|
-
* compiler routes you through `plain()`/`rich()`, so a type switch in the CMS can never reach
|
|
1140
|
-
* production as `[object Object]`.
|
|
1141
|
-
*/
|
|
1142
|
-
type TextOrRich = string | RichTextValue | null | undefined;
|
|
1143
|
-
/** True when the value is a rich-text envelope rather than a bare string. */
|
|
1144
|
-
declare function isRichText(value: unknown): value is RichTextValue;
|
|
1145
|
-
/**
|
|
1146
|
-
* Plain text for an attribute context — `<title>`, meta description, JSON-LD, `alt`.
|
|
1147
|
-
* Strips tags and decodes the entities that survive stripping, so the result is text the
|
|
1148
|
-
* consumer can escape once without double-escaping.
|
|
1149
|
-
*/
|
|
1150
|
-
declare function plain(value: TextOrRich): string;
|
|
1151
|
-
/**
|
|
1152
|
-
* Renderable HTML. Rich text keeps its inline marks (the server sanitizes `html` on write);
|
|
1153
|
-
* a bare string is escaped, so a plain field can never inject markup.
|
|
1154
|
-
*
|
|
1155
|
-
* A lone wrapping block is unwrapped: a field switched from `text` stores its value as
|
|
1156
|
-
* `<p>…</p>`, but it renders inside the element that already is the block — and
|
|
1157
|
-
* `<h1><p>…</p></h1>` is invalid, the parser closes the heading at the `<p>` and the text
|
|
1158
|
-
* falls out of it. Values with real block structure (several paragraphs, a list) are left
|
|
1159
|
-
* alone, so a body field still renders as a document.
|
|
1160
|
-
*/
|
|
1161
|
-
declare function rich(value: TextOrRich, fallback?: string): string;
|
|
1162
|
-
/**
|
|
1163
|
-
* Renderable HTML for a ONE-LINE place: a heading, a button, a caption. `rich()`, except that several
|
|
1164
|
-
* paragraphs are that place's LINES, joined with `<br>` (a heading-styled first block counts as one).
|
|
1165
|
-
*
|
|
1166
|
-
* An author who presses Enter in a heading's editor stores a second paragraph. `rich()` leaves it a
|
|
1167
|
-
* paragraph, and `<h1><p>…</p><p>…</p></h1>` is what the build then draws, while a publish between
|
|
1168
|
-
* builds writes the same value into the built heading as lines. This draws what the publish draws.
|
|
1169
|
-
* A value holding anything else (a list, an image, a table) is returned as `rich()` returns it.
|
|
1170
|
-
*/
|
|
1171
|
-
declare function lines(value: TextOrRich, fallback?: string): string;
|
|
1172
|
-
|
|
1173
986
|
/**
|
|
1174
987
|
* The published content snapshot, read where the site RUNS — not bundled into it.
|
|
1175
988
|
*
|
|
@@ -1508,29 +1321,4 @@ interface WebhookListResponse {
|
|
|
1508
1321
|
};
|
|
1509
1322
|
}
|
|
1510
1323
|
|
|
1511
|
-
|
|
1512
|
-
* `inEditor()`: is this page running inside the BetterCMS Visual Editor's canvas?
|
|
1513
|
-
*
|
|
1514
|
-
* The editor frames the site and names the frame, so the answer is the page's own `window.name`:
|
|
1515
|
-
* there from the first script, kept through every navigation inside the frame, and never set on
|
|
1516
|
-
* a published page a visitor opens. A site asks before it starts what the canvas cannot share:
|
|
1517
|
-
*
|
|
1518
|
-
* const smooth = inEditor() ? null : new LocomotiveScroll({ el, smooth: true });
|
|
1519
|
-
*
|
|
1520
|
-
* The canvas owns the scroll, the pointer and the place on the page; the site's motion (scroll
|
|
1521
|
-
* triggers, timelines, WebGL scenes) runs there as it does live. What has to stand down is only
|
|
1522
|
-
* what takes those three away: scroll that is not the window's own, an intro that holds the
|
|
1523
|
-
* page, a cursor drawn over it.
|
|
1524
|
-
*/
|
|
1525
|
-
/** The canvas frame's name. The dashboard sets this exact word (`EDITOR_FRAME_NAME`). */
|
|
1526
|
-
declare const EDITOR_FRAME_NAME = "bcms-editor";
|
|
1527
|
-
/** The least of `window` this needs. */
|
|
1528
|
-
interface FramedWindow {
|
|
1529
|
-
name: string;
|
|
1530
|
-
self: unknown;
|
|
1531
|
-
top: unknown;
|
|
1532
|
-
}
|
|
1533
|
-
/** True inside the editor's canvas. Safe where there is no window (a server render): false. */
|
|
1534
|
-
declare function inEditor(win?: FramedWindow | undefined): boolean;
|
|
1535
|
-
|
|
1536
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, CONTENT_APPLIED, type CommandManagedLayoutInput, type ContentAppliedMessage, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, EDITOR_FRAME_NAME, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, PORTABLE_TEXT_FORMAT, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, type ResolvedHolder, type RichTextValue, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type TextOrRich, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, contentApplied, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, embeds, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inEditor, inviteMember, isRichText, lines, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, onContentApplied, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveStega, resolved, revokeApiKey, rich, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1324
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, DeliveryFormField, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ManagedComponent, type ManagedComponentInput, type ManagedComponentSummary, type ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedMediaAsset, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, type ModelFieldset, type PageCreateReport, type PageListOptions, type PendingInvite, type PublishManagedLayoutInput, type PublishedContent, STEGA_OPEN, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaNode, type StegaPayload, type SubmissionListOptions, type UpdateApiKeyInput, type UpdateAssetInput, type UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWebhookInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type Webhook, type WebhookAdvancedConfig, type WebhookEvent, type WebhookListResponse, type WebhookWithSecret, type WriteContentInput, addModelFields, addPageFields, commandManagedLayout, createApiKey, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveStega, revokeApiKey, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|