@bettercms-ai/sdk 1.24.0 → 1.26.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 +51 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +51 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _bettercms_ai_types from '@bettercms-ai/types';
|
|
2
2
|
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, BetterCMSErrorCode, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, DeliveryComponent, PageMetaJson, DeliveryEntrySeo, SiteSeoDefaults, 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
|
-
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder } from '@bettercms-ai/image-url';
|
|
4
|
+
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Options for {@link BetterCMSDeliveryClient.listContent}.
|
|
@@ -1473,6 +1473,56 @@ interface SearchOptions {
|
|
|
1473
1473
|
/** Search a published site. Resolves with hits, or [] on an empty query / network error. */
|
|
1474
1474
|
declare function search(opts: SearchOptions): Promise<SearchHit[]>;
|
|
1475
1475
|
|
|
1476
|
+
/**
|
|
1477
|
+
* The published content snapshot, read where the site RUNS — not bundled into it.
|
|
1478
|
+
*
|
|
1479
|
+
* Every BetterCMS build gets the published content as `bcms-content.json` in the project root,
|
|
1480
|
+
* and a server app hosted on BetterCMS runs with `BCMS_CONTENT_FILE` pointing at a copy the
|
|
1481
|
+
* platform rewrites on every publish. Read through this, a server-rendered page shows a publish
|
|
1482
|
+
* within seconds and the publish never rebuilds the site. Import the JSON instead (a JSON import,
|
|
1483
|
+
* `import.meta.glob`) and the bundle holds a frozen copy no publish can reach: the platform then
|
|
1484
|
+
* has to rebuild the whole site for every edit.
|
|
1485
|
+
*
|
|
1486
|
+
* - On a hosted server: `BCMS_CONTENT_FILE`, re-read when it changes (checked at most once a second).
|
|
1487
|
+
* - At build time and in local dev: `<cwd>/bcms-content.json`, the snapshot the build was given.
|
|
1488
|
+
* - Anywhere without a filesystem (a browser, an edge runtime): `null`.
|
|
1489
|
+
*
|
|
1490
|
+
* A file that cannot be read keeps the last good copy; never throws into a render.
|
|
1491
|
+
* No `node:fs` import at module scope, so the SDK stays safe to bundle for the browser.
|
|
1492
|
+
*/
|
|
1493
|
+
/** The snapshot's shape (`bcms-content/v1`, written by the platform's content fetch). */
|
|
1494
|
+
interface PublishedContent {
|
|
1495
|
+
generatedAt?: string;
|
|
1496
|
+
apiUrl?: string | null;
|
|
1497
|
+
workspace?: string;
|
|
1498
|
+
projectId?: string | null;
|
|
1499
|
+
/** Published entries by model slug; each row carries its own `slug` and its field values. */
|
|
1500
|
+
collections?: Record<string, Array<Record<string, unknown> & {
|
|
1501
|
+
slug?: string;
|
|
1502
|
+
}>>;
|
|
1503
|
+
pages?: unknown[];
|
|
1504
|
+
components?: unknown[];
|
|
1505
|
+
forms?: unknown[];
|
|
1506
|
+
layout?: unknown;
|
|
1507
|
+
[key: string]: unknown;
|
|
1508
|
+
}
|
|
1509
|
+
/** Where the published content is read from here, or null where there is no filesystem. */
|
|
1510
|
+
declare function publishedContentFile(): string | null;
|
|
1511
|
+
/**
|
|
1512
|
+
* The published content snapshot, or null when there is none here (no file, no filesystem).
|
|
1513
|
+
* Call it per render — it is cached and cheap — never once at module scope, which would freeze it.
|
|
1514
|
+
*/
|
|
1515
|
+
declare function readPublishedContent<T extends PublishedContent = PublishedContent>(): T | null;
|
|
1516
|
+
/**
|
|
1517
|
+
* One published entry by its slug, searched across every collection (first match wins, in the
|
|
1518
|
+
* snapshot's model order). Not keyed by model slug: a page's backing model is named by the CMS.
|
|
1519
|
+
*/
|
|
1520
|
+
declare function publishedEntry<T extends Record<string, unknown> = Record<string, unknown>>(slug: string): (T & {
|
|
1521
|
+
slug: string;
|
|
1522
|
+
}) | null;
|
|
1523
|
+
/** Test seam: forget the cached snapshot. */
|
|
1524
|
+
declare function resetPublishedContentCache(): void;
|
|
1525
|
+
|
|
1476
1526
|
/**
|
|
1477
1527
|
* Admin pages methods.
|
|
1478
1528
|
* @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
|
|
@@ -1748,4 +1798,4 @@ interface WebhookListResponse {
|
|
|
1748
1798
|
};
|
|
1749
1799
|
}
|
|
1750
1800
|
|
|
1751
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, 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 ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, 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, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, portableText, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1801
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, 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 ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, 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, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _bettercms_ai_types from '@bettercms-ai/types';
|
|
2
2
|
import { ContentPageResult, Content, DeliveredLayout, ContentModelField, Fieldset, BetterCMSErrorCode, LayoutStructureDocument, LayoutDataDocument, PageLayoutOverrideDocument, ManagementLayoutCommand, AuthUser, AuthSession, SignInInput, SignUpInput, Perspective, DeliveryEntry, DeliveryList, DeliveryPage, DeliveryComponent, PageMetaJson, DeliveryEntrySeo, SiteSeoDefaults, 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
|
-
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder } from '@bettercms-ai/image-url';
|
|
4
|
+
export { ImageFit, ImageFormat, ImageSource, ImageUrlBuilder, ImageUrlOptions, imageUrl, default as imageUrlBuilder, imageValueObjectPosition, imageValueUrl } from '@bettercms-ai/image-url';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Options for {@link BetterCMSDeliveryClient.listContent}.
|
|
@@ -1473,6 +1473,56 @@ interface SearchOptions {
|
|
|
1473
1473
|
/** Search a published site. Resolves with hits, or [] on an empty query / network error. */
|
|
1474
1474
|
declare function search(opts: SearchOptions): Promise<SearchHit[]>;
|
|
1475
1475
|
|
|
1476
|
+
/**
|
|
1477
|
+
* The published content snapshot, read where the site RUNS — not bundled into it.
|
|
1478
|
+
*
|
|
1479
|
+
* Every BetterCMS build gets the published content as `bcms-content.json` in the project root,
|
|
1480
|
+
* and a server app hosted on BetterCMS runs with `BCMS_CONTENT_FILE` pointing at a copy the
|
|
1481
|
+
* platform rewrites on every publish. Read through this, a server-rendered page shows a publish
|
|
1482
|
+
* within seconds and the publish never rebuilds the site. Import the JSON instead (a JSON import,
|
|
1483
|
+
* `import.meta.glob`) and the bundle holds a frozen copy no publish can reach: the platform then
|
|
1484
|
+
* has to rebuild the whole site for every edit.
|
|
1485
|
+
*
|
|
1486
|
+
* - On a hosted server: `BCMS_CONTENT_FILE`, re-read when it changes (checked at most once a second).
|
|
1487
|
+
* - At build time and in local dev: `<cwd>/bcms-content.json`, the snapshot the build was given.
|
|
1488
|
+
* - Anywhere without a filesystem (a browser, an edge runtime): `null`.
|
|
1489
|
+
*
|
|
1490
|
+
* A file that cannot be read keeps the last good copy; never throws into a render.
|
|
1491
|
+
* No `node:fs` import at module scope, so the SDK stays safe to bundle for the browser.
|
|
1492
|
+
*/
|
|
1493
|
+
/** The snapshot's shape (`bcms-content/v1`, written by the platform's content fetch). */
|
|
1494
|
+
interface PublishedContent {
|
|
1495
|
+
generatedAt?: string;
|
|
1496
|
+
apiUrl?: string | null;
|
|
1497
|
+
workspace?: string;
|
|
1498
|
+
projectId?: string | null;
|
|
1499
|
+
/** Published entries by model slug; each row carries its own `slug` and its field values. */
|
|
1500
|
+
collections?: Record<string, Array<Record<string, unknown> & {
|
|
1501
|
+
slug?: string;
|
|
1502
|
+
}>>;
|
|
1503
|
+
pages?: unknown[];
|
|
1504
|
+
components?: unknown[];
|
|
1505
|
+
forms?: unknown[];
|
|
1506
|
+
layout?: unknown;
|
|
1507
|
+
[key: string]: unknown;
|
|
1508
|
+
}
|
|
1509
|
+
/** Where the published content is read from here, or null where there is no filesystem. */
|
|
1510
|
+
declare function publishedContentFile(): string | null;
|
|
1511
|
+
/**
|
|
1512
|
+
* The published content snapshot, or null when there is none here (no file, no filesystem).
|
|
1513
|
+
* Call it per render — it is cached and cheap — never once at module scope, which would freeze it.
|
|
1514
|
+
*/
|
|
1515
|
+
declare function readPublishedContent<T extends PublishedContent = PublishedContent>(): T | null;
|
|
1516
|
+
/**
|
|
1517
|
+
* One published entry by its slug, searched across every collection (first match wins, in the
|
|
1518
|
+
* snapshot's model order). Not keyed by model slug: a page's backing model is named by the CMS.
|
|
1519
|
+
*/
|
|
1520
|
+
declare function publishedEntry<T extends Record<string, unknown> = Record<string, unknown>>(slug: string): (T & {
|
|
1521
|
+
slug: string;
|
|
1522
|
+
}) | null;
|
|
1523
|
+
/** Test seam: forget the cached snapshot. */
|
|
1524
|
+
declare function resetPublishedContentCache(): void;
|
|
1525
|
+
|
|
1476
1526
|
/**
|
|
1477
1527
|
* Admin pages methods.
|
|
1478
1528
|
* @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
|
|
@@ -1748,4 +1798,4 @@ interface WebhookListResponse {
|
|
|
1748
1798
|
};
|
|
1749
1799
|
}
|
|
1750
1800
|
|
|
1751
|
-
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, 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 ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, 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, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, portableText, publishManagedLayout, publishPage, regenerateApiKey, removeMember, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
|
1801
|
+
export { type AddPageFieldsInput, type ApiKeyUsage, type ApiKeyWithRaw, type AuthResult, BetterCMSError as BCMSClientError, ErrorCodes as BCMSErrorCodes, BetterCMS, BetterCMSAdminClient, type BetterCMSAdminOptions, BetterCMSDeliveryClient, BetterCMSError, BetterCMSManagementClient, type BetterCMSManagementOptions, type BetterCMSReadClient, type BetterCMSSiteOptions, type CommandManagedLayoutInput, type CreateApiKeyInput, type CreateClientOptions, type CreateEntryInput, type CreateFormInput, type CreateManagedPageInput, type CreateModelInput, type CreatePageInput, type CreateWebhookInput, type CreateWorkspaceInput, type DeliveryForm, type DeliveryFormField, type DeliveryFormFieldType, ErrorCodes, type ExtractionCandidate, type FormFieldInput, type FormListOptions, type FormSubmitError, type FormValue, type FormValues, type GetEntryOptions, type GetManagedLayoutOptions, type ListContentAllOptions, type ListContentOptions, type ListEntriesFilter, type ListEntriesOptions, type ListPagesOptions, 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 ResolvedSeo, type RichTextValue, type SearchHit, type SearchOptions, type SeoInput, type SeoLocation, type SeoMeta, type SeoMetaInput, type SetPageContentInput, type StegaPayload, type SubmissionListOptions, type SubmitFormOptions, type SubmitFormResult, 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, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, entrySeoInput, formInitialValues, getApiKeyUsage, getEntry, getForm, getManagedLayout, getManagedPage, getMedia, getMember, getModel, getPage, getSubmission, getWorkspace, inviteMember, isMultiValueField, isRichText, listApiKeys, listEntries, listForms, listManagedPages, listMedia, listMembers, listModels, listPages, listSubmissions, listWorkspaces, plain, portableText, publishManagedLayout, publishPage, publishedContentFile, publishedEntry, readPublishedContent, regenerateApiKey, removeMember, resetPublishedContentCache, resolveSeo, revokeApiKey, rich, search, setPageContent, shouldShowField, signIn, signInWithGithub, signInWithGoogle, signUp, stripStega, submitForm, toggleOption, updateApiKey, updateEntry, updateForm, updateMemberRole, updateModel, updatePage, updatePageModel, updateWorkspace, uploadMedia };
|
package/dist/index.js
CHANGED
|
@@ -1562,8 +1562,52 @@ async function search(opts) {
|
|
|
1562
1562
|
}
|
|
1563
1563
|
}
|
|
1564
1564
|
|
|
1565
|
+
// src/published-content.ts
|
|
1566
|
+
var cache = null;
|
|
1567
|
+
var checkedAt = 0;
|
|
1568
|
+
function publishedContentFile() {
|
|
1569
|
+
const proc = globalThis.process;
|
|
1570
|
+
if (typeof proc?.getBuiltinModule !== "function") return null;
|
|
1571
|
+
return proc.env?.BCMS_CONTENT_FILE || `${proc.cwd?.() ?? "."}/bcms-content.json`;
|
|
1572
|
+
}
|
|
1573
|
+
function readPublishedContent() {
|
|
1574
|
+
const file = publishedContentFile();
|
|
1575
|
+
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
|
+
const proc = globalThis.process;
|
|
1580
|
+
const fs = proc.getBuiltinModule("node:fs");
|
|
1581
|
+
try {
|
|
1582
|
+
const stamp = fs.statSync(file).mtimeMs;
|
|
1583
|
+
if (cache && cache.file === file && cache.stamp === stamp) return cache.content;
|
|
1584
|
+
cache = { file, stamp, content: JSON.parse(fs.readFileSync(file, "utf8")) };
|
|
1585
|
+
} catch {
|
|
1586
|
+
if (!cache || cache.file !== file) cache = { file, stamp: -1, content: null };
|
|
1587
|
+
}
|
|
1588
|
+
return cache.content;
|
|
1589
|
+
}
|
|
1590
|
+
function publishedEntry(slug) {
|
|
1591
|
+
const collections = readPublishedContent()?.collections ?? {};
|
|
1592
|
+
for (const rows of Object.values(collections)) {
|
|
1593
|
+
if (!Array.isArray(rows)) continue;
|
|
1594
|
+
const hit = rows.find((row) => row?.slug === slug);
|
|
1595
|
+
if (hit) return hit;
|
|
1596
|
+
}
|
|
1597
|
+
return null;
|
|
1598
|
+
}
|
|
1599
|
+
function resetPublishedContentCache() {
|
|
1600
|
+
cache = null;
|
|
1601
|
+
checkedAt = 0;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1565
1604
|
// src/index.ts
|
|
1566
|
-
import {
|
|
1605
|
+
import {
|
|
1606
|
+
default as default2,
|
|
1607
|
+
imageUrl,
|
|
1608
|
+
imageValueUrl,
|
|
1609
|
+
imageValueObjectPosition
|
|
1610
|
+
} from "@bettercms-ai/image-url";
|
|
1567
1611
|
|
|
1568
1612
|
// src/methods/admin/pages.ts
|
|
1569
1613
|
function params(opts) {
|
|
@@ -1898,6 +1942,8 @@ export {
|
|
|
1898
1942
|
getWorkspace,
|
|
1899
1943
|
imageUrl,
|
|
1900
1944
|
default2 as imageUrlBuilder,
|
|
1945
|
+
imageValueObjectPosition,
|
|
1946
|
+
imageValueUrl,
|
|
1901
1947
|
inviteMember,
|
|
1902
1948
|
isBlock,
|
|
1903
1949
|
isMultiValueField,
|
|
@@ -1916,8 +1962,12 @@ export {
|
|
|
1916
1962
|
portableText,
|
|
1917
1963
|
publishManagedLayout,
|
|
1918
1964
|
publishPage,
|
|
1965
|
+
publishedContentFile,
|
|
1966
|
+
publishedEntry,
|
|
1967
|
+
readPublishedContent,
|
|
1919
1968
|
regenerateApiKey,
|
|
1920
1969
|
removeMember,
|
|
1970
|
+
resetPublishedContentCache,
|
|
1921
1971
|
resolveSeo,
|
|
1922
1972
|
revokeApiKey,
|
|
1923
1973
|
rich,
|