@bettercms-ai/sdk 1.33.0 → 1.34.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.d.cts +4 -392
- package/dist/index.d.ts +4 -392
- package/dist/read-ndf2I3D4.d.cts +393 -0
- package/dist/read-ndf2I3D4.d.ts +393 -0
- package/dist/read.cjs +457 -0
- package/dist/read.cjs.map +1 -0
- package/dist/read.d.cts +2 -0
- package/dist/read.d.ts +2 -0
- package/dist/read.js +423 -0
- package/dist/read.js.map +1 -0
- package/package.json +6 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as _bettercms_ai_types from '@bettercms-ai/types';
|
|
2
|
-
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, ComponentPreview,
|
|
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, Form, FormBlock, FormField, FormProps, FormSubmission, HeadingBlock, HeadingProps, ImageBlock, ImageProps, MediaAsset, Page, PageMetaJson, PaginatedResult, Perspective, Redirect, SignInInput, SignUpInput, SiteSeoDefaults, SpacerBlock, SpacerProps, TextBlock, TextProps, VideoBlock, VideoProps, Workspace, getBlockType, isBlock } from '@bettercms-ai/types';
|
|
4
|
+
import { D as DeliveryFormField } from './read-ndf2I3D4.cjs';
|
|
5
|
+
export { B as BCMSClientError, E as BCMSErrorCodes, B as BetterCMSError, a 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 SearchHit, g as SearchOptions, h as SubmitFormOptions, i as SubmitFormResult, j as asStringArray, k as createClient, l as formInitialValues, m as isMultiValueField, s as search, n as shouldShowField, o as submitForm, t as toggleOption } from './read-ndf2I3D4.cjs';
|
|
4
6
|
export { ResolvedSeo, SeoInput, SeoLocation, entrySeoInput, resolveSeo } from './seo.cjs';
|
|
5
7
|
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
|
|
6
8
|
|
|
@@ -600,253 +602,6 @@ interface ManagedMediaAsset {
|
|
|
600
602
|
createdAt: string;
|
|
601
603
|
}
|
|
602
604
|
|
|
603
|
-
/** Semantic error codes used by the SDK. */
|
|
604
|
-
declare const ErrorCodes: {
|
|
605
|
-
readonly CONTENT_NOT_FOUND: "CONTENT_NOT_FOUND";
|
|
606
|
-
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
607
|
-
readonly FORBIDDEN: "FORBIDDEN";
|
|
608
|
-
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
609
|
-
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
610
|
-
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
611
|
-
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
612
|
-
readonly ADMIN_NOT_IMPLEMENTED: "ADMIN_NOT_IMPLEMENTED";
|
|
613
|
-
};
|
|
614
|
-
/**
|
|
615
|
-
* BetterCMSError — normalized SDK error with a semantic code.
|
|
616
|
-
*/
|
|
617
|
-
declare class BetterCMSError extends Error {
|
|
618
|
-
readonly status: number;
|
|
619
|
-
readonly code: BetterCMSErrorCode;
|
|
620
|
-
/**
|
|
621
|
-
* Raw machine-readable `code` from the response body (e.g. "PROJECT_DELETED"),
|
|
622
|
-
* when the API supplies one. Distinct from `code` (which is derived from the
|
|
623
|
-
* HTTP status), this lets callers branch on a specific server condition that
|
|
624
|
-
* shares a status with others (e.g. 409 slug-conflict vs 409 project-deleted).
|
|
625
|
-
*/
|
|
626
|
-
readonly bodyCode?: string;
|
|
627
|
-
/**
|
|
628
|
-
* Per-field validation messages from a 400 `{ errors: { field: message } }` body.
|
|
629
|
-
* The backend returns validation failures in this shape (not `message`/`error`), so
|
|
630
|
-
* without this the SDK collapsed every validation 400 to a bare "Bad Request" with no
|
|
631
|
-
* hint which field or rule failed (FLO-474). Mirrors the forms client's `fieldErrors`.
|
|
632
|
-
*/
|
|
633
|
-
readonly fieldErrors?: Record<string, string>;
|
|
634
|
-
/**
|
|
635
|
-
* The parsed response body, when there was one.
|
|
636
|
-
*
|
|
637
|
-
* Several refusals carry STRUCTURED detail that neither `message` nor `fieldErrors` can hold,
|
|
638
|
-
* and which is the whole point of the refusal: a component publish 409s with the full
|
|
639
|
-
* `readiness` tuple (what evidence is missing, whether a human still has to approve it) and
|
|
640
|
-
* 422s with the `issues` naming the Layouts it would break. Collapsing those to a sentence
|
|
641
|
-
* leaves a caller able to report that something failed and not what to do about it.
|
|
642
|
-
*/
|
|
643
|
-
readonly body?: unknown;
|
|
644
|
-
constructor(message: string, status: number, code: BetterCMSErrorCode, bodyCode?: string, fieldErrors?: Record<string, string>, body?: unknown);
|
|
645
|
-
toJSON(): {
|
|
646
|
-
name: string;
|
|
647
|
-
message: string;
|
|
648
|
-
status: number;
|
|
649
|
-
code: BetterCMSErrorCode;
|
|
650
|
-
bodyCode: string | undefined;
|
|
651
|
-
fieldErrors: Record<string, string> | undefined;
|
|
652
|
-
};
|
|
653
|
-
/**
|
|
654
|
-
* Factory — creates a BetterCMSError from a failed fetch Response. Reads the body's
|
|
655
|
-
* `message` (or `error`) for the human message and `code` for a machine-readable
|
|
656
|
-
* condition surfaced as `bodyCode`. Validation failures arrive as `{ errors: {...} }`
|
|
657
|
-
* (no `message`/`error`), so fall back to the first field error for the message and
|
|
658
|
-
* expose the full map as `fieldErrors` (FLO-474).
|
|
659
|
-
*/
|
|
660
|
-
static from(res: Response): Promise<BetterCMSError>;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* Public forms — the headless integration surface for sites built on or imported
|
|
665
|
-
* into BetterCMS (the "render it yourself" model, like Sanity's delivery API).
|
|
666
|
-
*
|
|
667
|
-
* Form definitions ship in the build-time content snapshot (`bcms-content.json` →
|
|
668
|
-
* `forms` / `turnstileSiteKey`) and from `GET /api/v1/delivery/:workspace/forms`.
|
|
669
|
-
* A site renders them with its own components (see `@bettercms-ai/next`'s <BcmsForm>)
|
|
670
|
-
* and posts here. No API key — the endpoint is Turnstile-gated (Webflow model).
|
|
671
|
-
*
|
|
672
|
-
* This module is the single source of truth for the delivered form shape + the
|
|
673
|
-
* pure logic (conditional visibility, initial values) the renderers share, so the
|
|
674
|
-
* vanilla embed and the React component never drift.
|
|
675
|
-
*/
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Field types the delivery API serializes. Must stay equal to the authoring
|
|
679
|
-
* vocabulary in `packages/db/src/schema/forms.ts` — this list is what every site
|
|
680
|
-
* renderer switches on, so a type missing HERE renders as a plain text input on
|
|
681
|
-
* every published site while the builder happily offers it. `radio`/`checkboxes`
|
|
682
|
-
* were exactly that gap.
|
|
683
|
-
*/
|
|
684
|
-
type DeliveryFormFieldType = "text" | "email" | "phone" | "url" | "number" | "date" | "textarea" | "select" | "radio" | "checkboxes" | "checkbox" | "consent" | "hidden" | "step";
|
|
685
|
-
interface DeliveryFormField {
|
|
686
|
-
key: string;
|
|
687
|
-
label: string;
|
|
688
|
-
type: DeliveryFormFieldType;
|
|
689
|
-
placeholder?: string;
|
|
690
|
-
/** Hint rendered under the control. */
|
|
691
|
-
helpText?: string;
|
|
692
|
-
required?: boolean;
|
|
693
|
-
options?: string[];
|
|
694
|
-
defaultValue?: string;
|
|
695
|
-
/** Conditional visibility — render this field only when another field equals `equals`. */
|
|
696
|
-
showIf?: {
|
|
697
|
-
field: string;
|
|
698
|
-
equals: string;
|
|
699
|
-
};
|
|
700
|
-
/**
|
|
701
|
-
* Per-field rules the API enforces on submit. Renderers should mirror them onto the
|
|
702
|
-
* native control (`min`/`max`/`pattern`) so the browser reports them before the round
|
|
703
|
-
* trip — the server check is the one that counts.
|
|
704
|
-
*/
|
|
705
|
-
validation?: DeliveryFormFieldValidation;
|
|
706
|
-
/**
|
|
707
|
-
* Presentation options the renderer honours. Unlike `validation`, the API does NOT enforce
|
|
708
|
-
* these on submit — they change what the visitor is shown, not what is accepted.
|
|
709
|
-
*/
|
|
710
|
-
ui?: DeliveryFormFieldUi;
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* @see FormFieldUi in @bettercms-ai/types — same shape, delivered to the site.
|
|
714
|
-
*
|
|
715
|
-
* ── The phone composition contract every renderer implements ──
|
|
716
|
-
*
|
|
717
|
-
* A picker-enabled phone field is rendered as a country control PLUS a `tel` input, but it
|
|
718
|
-
* submits ONE value under the field's own key, in E.164. Whatever a renderer uses to hold the
|
|
719
|
-
* country (a React state, a `{key}__country` select) is scaffolding: it must never reach the
|
|
720
|
-
* POST body.
|
|
721
|
-
*
|
|
722
|
-
* Composition, from the visible input's raw text:
|
|
723
|
-
* - empty → `""`. NEVER `"+CC"`, and the reason is worse than "the server rejects it". The
|
|
724
|
-
* server's loose phone shape is `{3,32}` chars, so the outcome depends on the calling
|
|
725
|
-
* code's length: `"+1"` is REFUSED (an optional untouched field starts 400ing), while
|
|
726
|
-
* `"+91"` is ACCEPTED and stored as a real-looking submission that is only a country code.
|
|
727
|
-
* The silent case is the dangerous one. Pinned in `__tests__/lib/forms-validate.test.ts`.
|
|
728
|
-
* - starts with `"+"` → `"+" + digits(raw)`. The visitor typed an international number; the
|
|
729
|
-
* country control is ignored rather than fighting them.
|
|
730
|
-
* - otherwise → `"+" + callingCode + digits(raw).replace(/^0/, "")`, dropping ONE trunk zero.
|
|
731
|
-
* Known exception: Italian landlines keep their trunk zero, so this loses it. The value is
|
|
732
|
-
* still accepted (shape-only check) — it is a formatting loss, not a refusal.
|
|
733
|
-
*
|
|
734
|
-
* `ui` changes what the visitor SEES. It never changes what the API accepts: enforcing a format
|
|
735
|
-
* is `validation.phoneFormat`'s job and the two are independent.
|
|
736
|
-
*
|
|
737
|
-
* Renderer parity is behavioural, not implementational. FIVE lanes render this field, and they
|
|
738
|
-
* agree on the VALUE, not on the implementation:
|
|
739
|
-
*
|
|
740
|
-
* | Lane | Control | As-you-type formatting |
|
|
741
|
-
* |-------------------------------|---------------------------------|------------------------|
|
|
742
|
-
* | dashboard form preview | searchable picker + formatter | yes |
|
|
743
|
-
* | @bettercms-ai/next <BcmsForm> | native select + formatter | yes (lazy chunk) |
|
|
744
|
-
* | hosted sites (render-page) | native select + tel input | NO |
|
|
745
|
-
* | embed snippet | native select + tel input | NO |
|
|
746
|
-
* | @bettercms-ai/astro BcmsForm | native select + tel input | NO |
|
|
747
|
-
*
|
|
748
|
-
* The missing as-you-type formatting on the three vanilla lanes is a NAMED degradation, not an
|
|
749
|
-
* oversight: it is what keeps libphonenumber off a visitor's page entirely. `packages/next`
|
|
750
|
-
* pays for it only on pages that actually render a picker, via a separate chunk.
|
|
751
|
-
*
|
|
752
|
-
* When a lane builds that option list, never pass a libphonenumber helper as a bare callback:
|
|
753
|
-
* `getCountries().filter(isSupportedCountry)` hands it the array INDEX as its `metadata`
|
|
754
|
-
* argument and throws. Always wrap — `.filter((iso) => isSupportedCountry(iso))`.
|
|
755
|
-
*
|
|
756
|
-
* And when a lane ships the composition rule inside a JS TEMPLATE LITERAL (the embed snippet
|
|
757
|
-
* does), `\D` collapses to `D` and the regex silently becomes `/D/g` — stripping the letter D
|
|
758
|
-
* and leaving every other separator in place. Write `\\D` there. Raw HTML `<script>` text (the
|
|
759
|
-
* hosted renderer, the Astro inline script) takes a single backslash. Nothing throws either
|
|
760
|
-
* way; numbers just arrive malformed, so each lane pins it with an executed-script test.
|
|
761
|
-
*/
|
|
762
|
-
interface DeliveryFormFieldUi {
|
|
763
|
-
/** `phone` — render a country picker beside the number. The submitted value is E.164. */
|
|
764
|
-
countryPicker?: boolean;
|
|
765
|
-
/** `phone` — uppercase ISO 3166-1 alpha-2 the picker starts on. */
|
|
766
|
-
defaultCountry?: string;
|
|
767
|
-
/**
|
|
768
|
-
* `phone` — show the country's flag beside the dialling code.
|
|
769
|
-
*
|
|
770
|
-
* Honoured only by a renderer with a custom picker. The native `<select>` the site lanes use
|
|
771
|
-
* cannot hold an SVG, and an emoji flag renders as two grey letters on Windows, so those
|
|
772
|
-
* lanes show the country NAME instead — the same information, legibly, everywhere.
|
|
773
|
-
*/
|
|
774
|
-
showFlags?: boolean;
|
|
775
|
-
}
|
|
776
|
-
/** @see FormFieldValidation in @bettercms-ai/types — same shape, delivered to the site. */
|
|
777
|
-
interface DeliveryFormFieldValidation {
|
|
778
|
-
emailPolicy?: "any" | "business";
|
|
779
|
-
min?: number;
|
|
780
|
-
max?: number;
|
|
781
|
-
phoneFormat?: "any" | "e164";
|
|
782
|
-
pattern?: string;
|
|
783
|
-
}
|
|
784
|
-
/** The pick-many type, whose value is an array rather than a scalar. */
|
|
785
|
-
declare function isMultiValueField(type: DeliveryFormFieldType): boolean;
|
|
786
|
-
/** A form as delivered to a published/imported site. Mirrors the delivery `/forms` payload. */
|
|
787
|
-
interface DeliveryForm {
|
|
788
|
-
id: string;
|
|
789
|
-
name: string;
|
|
790
|
-
/** The project the form belongs to. */
|
|
791
|
-
projectId?: string | null;
|
|
792
|
-
/**
|
|
793
|
-
* A `draft` form refuses every submission: render it as unavailable rather than as a form that
|
|
794
|
-
* silently drops what a visitor sends. Delivered for exactly that reason, and missing from this
|
|
795
|
-
* type until the contract test held the two together.
|
|
796
|
-
*/
|
|
797
|
-
status?: "draft" | "published" | (string & {});
|
|
798
|
-
/** Set on a form the site's owner told BetterCMS to leave alone (ISO time); such a form is not wired. */
|
|
799
|
-
ignoredAt?: string | null;
|
|
800
|
-
fields: DeliveryFormField[];
|
|
801
|
-
submitLabel?: string;
|
|
802
|
-
successMessage?: string;
|
|
803
|
-
redirectUrl?: string;
|
|
804
|
-
turnstileEnabled?: boolean;
|
|
805
|
-
honeypotField?: string | null;
|
|
806
|
-
}
|
|
807
|
-
/** `string[]` is the `checkboxes` (pick-many) value; every other type is scalar. */
|
|
808
|
-
type FormValue = string | boolean | string[];
|
|
809
|
-
type FormValues = Record<string, FormValue>;
|
|
810
|
-
/** Read a `checkboxes` value defensively — stored data may predate the array shape. */
|
|
811
|
-
declare function asStringArray(value: FormValue | undefined): string[];
|
|
812
|
-
/** Add/remove `option` from a `checkboxes` value, preserving the field's option order. */
|
|
813
|
-
declare function toggleOption(value: FormValue | undefined, option: string, on: boolean): string[];
|
|
814
|
-
/**
|
|
815
|
-
* Conditional visibility. A `showIf` field is shown only when its trigger field's
|
|
816
|
-
* current value equals the target; non-conditional fields are always shown. The
|
|
817
|
-
* renderer must skip hidden fields when collecting/validating so a hidden required
|
|
818
|
-
* field never blocks submit.
|
|
819
|
-
*/
|
|
820
|
-
declare function shouldShowField(field: DeliveryFormField, values: FormValues): boolean;
|
|
821
|
-
/**
|
|
822
|
-
* Build the initial value map: checkbox/consent default to false, checkboxes to an
|
|
823
|
-
* empty array, every other field to its `defaultValue`, with `prefill` (e.g. URL
|
|
824
|
-
* query params) taking precedence.
|
|
825
|
-
*/
|
|
826
|
-
declare function formInitialValues(form: DeliveryForm, prefill?: Record<string, string>): FormValues;
|
|
827
|
-
interface SubmitFormOptions {
|
|
828
|
-
formId: string;
|
|
829
|
-
data: FormValues;
|
|
830
|
-
/** Cloudflare Turnstile token; required when the form has `turnstileEnabled`. */
|
|
831
|
-
turnstileToken?: string;
|
|
832
|
-
/** API origin. Defaults to https://api.bettercms.ai. */
|
|
833
|
-
baseUrl?: string;
|
|
834
|
-
/** Injectable fetch for tests / non-browser runtimes. */
|
|
835
|
-
fetchImpl?: typeof fetch;
|
|
836
|
-
}
|
|
837
|
-
interface SubmitFormResult {
|
|
838
|
-
id: string;
|
|
839
|
-
}
|
|
840
|
-
/** A submit failure that carries per-field validation messages from the API (HTTP 400). */
|
|
841
|
-
type FormSubmitError = BetterCMSError & {
|
|
842
|
-
fieldErrors?: Record<string, string>;
|
|
843
|
-
};
|
|
844
|
-
/**
|
|
845
|
-
* Submit a public form. Resolves with the new submission id, or throws a
|
|
846
|
-
* BetterCMSError — field-level validation errors are attached as `.fieldErrors`.
|
|
847
|
-
*/
|
|
848
|
-
declare function submitForm(opts: SubmitFormOptions): Promise<SubmitFormResult>;
|
|
849
|
-
|
|
850
605
|
/**
|
|
851
606
|
* Management API SDK methods — read-only form discovery.
|
|
852
607
|
*
|
|
@@ -1168,113 +923,6 @@ declare const BetterCMS: {
|
|
|
1168
923
|
signUp(options: SignUpInput): Promise<AuthResult>;
|
|
1169
924
|
};
|
|
1170
925
|
|
|
1171
|
-
/**
|
|
1172
|
-
* createClient — framework-agnostic typed read client for the Delivery API.
|
|
1173
|
-
*
|
|
1174
|
-
* Shared by @bettercms-ai/astro and @bettercms-ai/next so the fetch/typing/retry
|
|
1175
|
-
* logic lives in one place. Read-only; for schema authoring use the
|
|
1176
|
-
* Management client, for sessions use the Admin client.
|
|
1177
|
-
*
|
|
1178
|
-
* const client = createClient({ apiUrl, workspace, apiKey });
|
|
1179
|
-
* await client.getPage("home");
|
|
1180
|
-
* await client.listEntries({ model: "post", perPage: 50 });
|
|
1181
|
-
*/
|
|
1182
|
-
|
|
1183
|
-
interface CreateClientOptions {
|
|
1184
|
-
/** Backend base, e.g. `https://api.bettercms.ai` (no trailing slash needed). */
|
|
1185
|
-
apiUrl: string;
|
|
1186
|
-
/** Workspace slug. */
|
|
1187
|
-
workspace: string;
|
|
1188
|
-
/** Delivery API key. Use a `content:read:draft` key for drafts. */
|
|
1189
|
-
apiKey?: string;
|
|
1190
|
-
/**
|
|
1191
|
-
* The project every read is addressed to. A workspace holds many projects whose slugs
|
|
1192
|
-
* collide (each has a `blog` model and a `home` page), so a site names its own; published
|
|
1193
|
-
* reads need no key for it. BetterCMS hosting supplies `PUBLIC_BCMS_PROJECT_ID`.
|
|
1194
|
-
*/
|
|
1195
|
-
projectId?: string;
|
|
1196
|
-
/** `published` (default) or `drafts`. */
|
|
1197
|
-
perspective?: Perspective;
|
|
1198
|
-
/**
|
|
1199
|
-
* Preview-token JWT for token-based single-document draft reads via the
|
|
1200
|
-
* `/preview/:slug` endpoint. Only used when `perspective === "drafts"`.
|
|
1201
|
-
*/
|
|
1202
|
-
previewToken?: string;
|
|
1203
|
-
/**
|
|
1204
|
-
* Embed invisible visual-editing provenance in draft reads, so a preview build can
|
|
1205
|
-
* deep-link each rendered value back to its editor. Requires `perspective: "drafts"`,
|
|
1206
|
-
* and then either a `previewToken` or a `content:read:draft` key. Ignored on published
|
|
1207
|
-
* reads — the payload must never reach a production build.
|
|
1208
|
-
*
|
|
1209
|
-
* **Defaults to `true` on `perspective: "drafts"`** (since 1.15.0). Provenance is the whole
|
|
1210
|
-
* reason the drafts perspective exists in a preview build, and an option nobody knew to pass
|
|
1211
|
-
* meant every such build rendered anonymous strings: the editor could bind them only by
|
|
1212
|
-
* guessing at their text. It stays OFF on every other perspective, unconditionally, so a
|
|
1213
|
-
* published build cannot acquire a payload by accident — pass `stega: false` to opt a draft
|
|
1214
|
-
* read out (a diff or a checksum over draft content is the case that wants it).
|
|
1215
|
-
*/
|
|
1216
|
-
stega?: boolean;
|
|
1217
|
-
/** Per-attempt timeout in ms. Defaults to 10000. */
|
|
1218
|
-
timeout?: number;
|
|
1219
|
-
/**
|
|
1220
|
-
* Collapse identical GETs to one network round-trip for the life of this client.
|
|
1221
|
-
* Default false.
|
|
1222
|
-
*
|
|
1223
|
-
* Only correct where the content is a POINT-IN-TIME SNAPSHOT — i.e. a static build,
|
|
1224
|
-
* where every route renders from the same published dataset. `@bettercms-ai/astro`
|
|
1225
|
-
* turns this on automatically when Astro's `command === "build"` and never for `dev`,
|
|
1226
|
-
* SSR or the drafts perspective, where a repeat read must see the current row.
|
|
1227
|
-
*
|
|
1228
|
-
* A static build without it re-fetches the same nav/settings/collection once PER ROUTE.
|
|
1229
|
-
* That is what made a large site exhaust the delivery rate limit: hundreds of identical
|
|
1230
|
-
* requests, and `getPage()` re-scanning every page of the paginated list each time it is
|
|
1231
|
-
* called.
|
|
1232
|
-
*/
|
|
1233
|
-
cache?: boolean;
|
|
1234
|
-
}
|
|
1235
|
-
interface ListEntriesOptions {
|
|
1236
|
-
/** Filter by content-model slug. */
|
|
1237
|
-
model?: string;
|
|
1238
|
-
page?: number;
|
|
1239
|
-
perPage?: number;
|
|
1240
|
-
/** Reference hydration depth (lists cap at 1). */
|
|
1241
|
-
depth?: 0 | 1;
|
|
1242
|
-
/** Projection — field names to return. */
|
|
1243
|
-
select?: string[];
|
|
1244
|
-
}
|
|
1245
|
-
interface GetEntryOptions {
|
|
1246
|
-
depth?: 0 | 1 | 2;
|
|
1247
|
-
select?: string[];
|
|
1248
|
-
}
|
|
1249
|
-
interface ListPagesOptions {
|
|
1250
|
-
page?: number;
|
|
1251
|
-
perPage?: number;
|
|
1252
|
-
}
|
|
1253
|
-
interface BetterCMSReadClient {
|
|
1254
|
-
readonly perspective: Perspective;
|
|
1255
|
-
getEntry<T = Record<string, unknown>>(slug: string, opts?: GetEntryOptions): Promise<DeliveryEntry<T>>;
|
|
1256
|
-
listEntries<T = Record<string, unknown>>(opts?: ListEntriesOptions): Promise<DeliveryList<DeliveryEntry<T>>>;
|
|
1257
|
-
getPage(slug: string): Promise<DeliveryPage | null>;
|
|
1258
|
-
listPages(opts?: ListPagesOptions): Promise<DeliveryList<DeliveryPage>>;
|
|
1259
|
-
/**
|
|
1260
|
-
* The workspace's reusable component definitions, for resolving `component` blocks.
|
|
1261
|
-
* Under `perspective: "drafts"` this is the DRAFT definition — what makes an SSR render
|
|
1262
|
-
* of a draft page look like the page the editor is showing.
|
|
1263
|
-
*/
|
|
1264
|
-
listComponents(): Promise<DeliveryComponent[]>;
|
|
1265
|
-
/** Fetch the project-scoped Global Layout for the active perspective. */
|
|
1266
|
-
getLayout(): Promise<DeliveredLayout | null>;
|
|
1267
|
-
listForms(opts?: {
|
|
1268
|
-
projectId?: string;
|
|
1269
|
-
}): Promise<{
|
|
1270
|
-
items: DeliveryForm[];
|
|
1271
|
-
turnstileSiteKey: string | null;
|
|
1272
|
-
}>;
|
|
1273
|
-
/** Build a deterministic Next/cache tag for a resource. */
|
|
1274
|
-
tag(resource: "entry" | "page" | "forms", id?: string): string;
|
|
1275
|
-
}
|
|
1276
|
-
declare function createClient(options: CreateClientOptions): BetterCMSReadClient;
|
|
1277
|
-
|
|
1278
926
|
/** Provenance describing where a string came from, for editor deep-linking. */
|
|
1279
927
|
interface StegaPayload {
|
|
1280
928
|
/** Workspace slug. */
|
|
@@ -1476,42 +1124,6 @@ declare function rich(value: TextOrRich, fallback?: string): string;
|
|
|
1476
1124
|
*/
|
|
1477
1125
|
declare function lines(value: TextOrRich, fallback?: string): string;
|
|
1478
1126
|
|
|
1479
|
-
/**
|
|
1480
|
-
* Public site search — the headless surface for the visitor-facing search box.
|
|
1481
|
-
*
|
|
1482
|
-
* Queries `GET /api/v1/delivery/search?project=…&q=…`, the same key-less public
|
|
1483
|
-
* endpoint the embeddable widget uses. Powers <BcmsSearch> in @bettercms-ai/next
|
|
1484
|
-
* and @bettercms-ai/astro, so the component and any custom UI never drift.
|
|
1485
|
-
*
|
|
1486
|
-
* `snippet` is HTML-safe: the server escapes the field content and keeps only the
|
|
1487
|
-
* <mark> highlight wrappers, so it can be rendered with dangerouslySetInnerHTML.
|
|
1488
|
-
*/
|
|
1489
|
-
interface SearchHit {
|
|
1490
|
-
title: string;
|
|
1491
|
-
slug: string;
|
|
1492
|
-
type: "page" | "entry";
|
|
1493
|
-
/** HTML-safe snippet with <mark> highlights around matched terms. */
|
|
1494
|
-
snippet: string;
|
|
1495
|
-
/** Site-relative URL, e.g. "/about". */
|
|
1496
|
-
url: string;
|
|
1497
|
-
}
|
|
1498
|
-
interface SearchOptions {
|
|
1499
|
-
/** The project id (from the dashboard's Site Search settings). */
|
|
1500
|
-
project: string;
|
|
1501
|
-
/** The query string. Calls with fewer than 1 char resolve to []. */
|
|
1502
|
-
q: string;
|
|
1503
|
-
/** Max hits, 1–20 (default 8). */
|
|
1504
|
-
limit?: number;
|
|
1505
|
-
/** API origin. Defaults to https://api.bettercms.ai. */
|
|
1506
|
-
baseUrl?: string;
|
|
1507
|
-
/** Injectable fetch for tests / non-browser runtimes. */
|
|
1508
|
-
fetchImpl?: typeof fetch;
|
|
1509
|
-
/** AbortSignal so callers can cancel a stale in-flight search. */
|
|
1510
|
-
signal?: AbortSignal;
|
|
1511
|
-
}
|
|
1512
|
-
/** Search a published site. Resolves with hits, or [] on an empty query / network error. */
|
|
1513
|
-
declare function search(opts: SearchOptions): Promise<SearchHit[]>;
|
|
1514
|
-
|
|
1515
1127
|
/**
|
|
1516
1128
|
* The published content snapshot, read where the site RUNS — not bundled into it.
|
|
1517
1129
|
*
|
|
@@ -1875,4 +1487,4 @@ interface FramedWindow {
|
|
|
1875
1487
|
/** True inside the editor's canvas. Safe where there is no window (a server render): false. */
|
|
1876
1488
|
declare function inEditor(win?: FramedWindow | undefined): boolean;
|
|
1877
1489
|
|
|
1878
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult,
|
|
1490
|
+
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 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, 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, revokeApiKey, rich, setPageContent, signIn, signInWithGithub, signInWithGoogle, signUp, stegaClean, stripStega, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|