@bettercms-ai/sdk 1.25.0 → 1.26.1
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 +56 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -2
- package/dist/index.d.ts +56 -2
- package/dist/index.js +52 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1134,7 +1134,11 @@ interface CreateClientOptions {
|
|
|
1134
1134
|
workspace: string;
|
|
1135
1135
|
/** Delivery API key. Use a `content:read:draft` key for drafts. */
|
|
1136
1136
|
apiKey?: string;
|
|
1137
|
-
/**
|
|
1137
|
+
/**
|
|
1138
|
+
* The project every read is addressed to. A workspace holds many projects whose slugs
|
|
1139
|
+
* collide (each has a `blog` model and a `home` page), so a site names its own; published
|
|
1140
|
+
* reads need no key for it. BetterCMS hosting supplies `PUBLIC_BCMS_PROJECT_ID`.
|
|
1141
|
+
*/
|
|
1138
1142
|
projectId?: string;
|
|
1139
1143
|
/** `published` (default) or `drafts`. */
|
|
1140
1144
|
perspective?: Perspective;
|
|
@@ -1473,6 +1477,56 @@ interface SearchOptions {
|
|
|
1473
1477
|
/** Search a published site. Resolves with hits, or [] on an empty query / network error. */
|
|
1474
1478
|
declare function search(opts: SearchOptions): Promise<SearchHit[]>;
|
|
1475
1479
|
|
|
1480
|
+
/**
|
|
1481
|
+
* The published content snapshot, read where the site RUNS — not bundled into it.
|
|
1482
|
+
*
|
|
1483
|
+
* Every BetterCMS build gets the published content as `bcms-content.json` in the project root,
|
|
1484
|
+
* and a server app hosted on BetterCMS runs with `BCMS_CONTENT_FILE` pointing at a copy the
|
|
1485
|
+
* platform rewrites on every publish. Read through this, a server-rendered page shows a publish
|
|
1486
|
+
* within seconds and the publish never rebuilds the site. Import the JSON instead (a JSON import,
|
|
1487
|
+
* `import.meta.glob`) and the bundle holds a frozen copy no publish can reach: the platform then
|
|
1488
|
+
* has to rebuild the whole site for every edit.
|
|
1489
|
+
*
|
|
1490
|
+
* - On a hosted server: `BCMS_CONTENT_FILE`, re-read when it changes (checked at most once a second).
|
|
1491
|
+
* - At build time and in local dev: `<cwd>/bcms-content.json`, the snapshot the build was given.
|
|
1492
|
+
* - Anywhere without a filesystem (a browser, an edge runtime): `null`.
|
|
1493
|
+
*
|
|
1494
|
+
* A file that cannot be read keeps the last good copy; never throws into a render.
|
|
1495
|
+
* No `node:fs` import at module scope, so the SDK stays safe to bundle for the browser.
|
|
1496
|
+
*/
|
|
1497
|
+
/** The snapshot's shape (`bcms-content/v1`, written by the platform's content fetch). */
|
|
1498
|
+
interface PublishedContent {
|
|
1499
|
+
generatedAt?: string;
|
|
1500
|
+
apiUrl?: string | null;
|
|
1501
|
+
workspace?: string;
|
|
1502
|
+
projectId?: string | null;
|
|
1503
|
+
/** Published entries by model slug; each row carries its own `slug` and its field values. */
|
|
1504
|
+
collections?: Record<string, Array<Record<string, unknown> & {
|
|
1505
|
+
slug?: string;
|
|
1506
|
+
}>>;
|
|
1507
|
+
pages?: unknown[];
|
|
1508
|
+
components?: unknown[];
|
|
1509
|
+
forms?: unknown[];
|
|
1510
|
+
layout?: unknown;
|
|
1511
|
+
[key: string]: unknown;
|
|
1512
|
+
}
|
|
1513
|
+
/** Where the published content is read from here, or null where there is no filesystem. */
|
|
1514
|
+
declare function publishedContentFile(): string | null;
|
|
1515
|
+
/**
|
|
1516
|
+
* The published content snapshot, or null when there is none here (no file, no filesystem).
|
|
1517
|
+
* Call it per render — it is cached and cheap — never once at module scope, which would freeze it.
|
|
1518
|
+
*/
|
|
1519
|
+
declare function readPublishedContent<T extends PublishedContent = PublishedContent>(): T | null;
|
|
1520
|
+
/**
|
|
1521
|
+
* One published entry by its slug, searched across every collection (first match wins, in the
|
|
1522
|
+
* snapshot's model order). Not keyed by model slug: a page's backing model is named by the CMS.
|
|
1523
|
+
*/
|
|
1524
|
+
declare function publishedEntry<T extends Record<string, unknown> = Record<string, unknown>>(slug: string): (T & {
|
|
1525
|
+
slug: string;
|
|
1526
|
+
}) | null;
|
|
1527
|
+
/** Test seam: forget the cached snapshot. */
|
|
1528
|
+
declare function resetPublishedContentCache(): void;
|
|
1529
|
+
|
|
1476
1530
|
/**
|
|
1477
1531
|
* Admin pages methods.
|
|
1478
1532
|
* @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
|
|
@@ -1748,4 +1802,4 @@ interface WebhookListResponse {
|
|
|
1748
1802
|
};
|
|
1749
1803
|
}
|
|
1750
1804
|
|
|
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 };
|
|
1805
|
+
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
|
@@ -1134,7 +1134,11 @@ interface CreateClientOptions {
|
|
|
1134
1134
|
workspace: string;
|
|
1135
1135
|
/** Delivery API key. Use a `content:read:draft` key for drafts. */
|
|
1136
1136
|
apiKey?: string;
|
|
1137
|
-
/**
|
|
1137
|
+
/**
|
|
1138
|
+
* The project every read is addressed to. A workspace holds many projects whose slugs
|
|
1139
|
+
* collide (each has a `blog` model and a `home` page), so a site names its own; published
|
|
1140
|
+
* reads need no key for it. BetterCMS hosting supplies `PUBLIC_BCMS_PROJECT_ID`.
|
|
1141
|
+
*/
|
|
1138
1142
|
projectId?: string;
|
|
1139
1143
|
/** `published` (default) or `drafts`. */
|
|
1140
1144
|
perspective?: Perspective;
|
|
@@ -1473,6 +1477,56 @@ interface SearchOptions {
|
|
|
1473
1477
|
/** Search a published site. Resolves with hits, or [] on an empty query / network error. */
|
|
1474
1478
|
declare function search(opts: SearchOptions): Promise<SearchHit[]>;
|
|
1475
1479
|
|
|
1480
|
+
/**
|
|
1481
|
+
* The published content snapshot, read where the site RUNS — not bundled into it.
|
|
1482
|
+
*
|
|
1483
|
+
* Every BetterCMS build gets the published content as `bcms-content.json` in the project root,
|
|
1484
|
+
* and a server app hosted on BetterCMS runs with `BCMS_CONTENT_FILE` pointing at a copy the
|
|
1485
|
+
* platform rewrites on every publish. Read through this, a server-rendered page shows a publish
|
|
1486
|
+
* within seconds and the publish never rebuilds the site. Import the JSON instead (a JSON import,
|
|
1487
|
+
* `import.meta.glob`) and the bundle holds a frozen copy no publish can reach: the platform then
|
|
1488
|
+
* has to rebuild the whole site for every edit.
|
|
1489
|
+
*
|
|
1490
|
+
* - On a hosted server: `BCMS_CONTENT_FILE`, re-read when it changes (checked at most once a second).
|
|
1491
|
+
* - At build time and in local dev: `<cwd>/bcms-content.json`, the snapshot the build was given.
|
|
1492
|
+
* - Anywhere without a filesystem (a browser, an edge runtime): `null`.
|
|
1493
|
+
*
|
|
1494
|
+
* A file that cannot be read keeps the last good copy; never throws into a render.
|
|
1495
|
+
* No `node:fs` import at module scope, so the SDK stays safe to bundle for the browser.
|
|
1496
|
+
*/
|
|
1497
|
+
/** The snapshot's shape (`bcms-content/v1`, written by the platform's content fetch). */
|
|
1498
|
+
interface PublishedContent {
|
|
1499
|
+
generatedAt?: string;
|
|
1500
|
+
apiUrl?: string | null;
|
|
1501
|
+
workspace?: string;
|
|
1502
|
+
projectId?: string | null;
|
|
1503
|
+
/** Published entries by model slug; each row carries its own `slug` and its field values. */
|
|
1504
|
+
collections?: Record<string, Array<Record<string, unknown> & {
|
|
1505
|
+
slug?: string;
|
|
1506
|
+
}>>;
|
|
1507
|
+
pages?: unknown[];
|
|
1508
|
+
components?: unknown[];
|
|
1509
|
+
forms?: unknown[];
|
|
1510
|
+
layout?: unknown;
|
|
1511
|
+
[key: string]: unknown;
|
|
1512
|
+
}
|
|
1513
|
+
/** Where the published content is read from here, or null where there is no filesystem. */
|
|
1514
|
+
declare function publishedContentFile(): string | null;
|
|
1515
|
+
/**
|
|
1516
|
+
* The published content snapshot, or null when there is none here (no file, no filesystem).
|
|
1517
|
+
* Call it per render — it is cached and cheap — never once at module scope, which would freeze it.
|
|
1518
|
+
*/
|
|
1519
|
+
declare function readPublishedContent<T extends PublishedContent = PublishedContent>(): T | null;
|
|
1520
|
+
/**
|
|
1521
|
+
* One published entry by its slug, searched across every collection (first match wins, in the
|
|
1522
|
+
* snapshot's model order). Not keyed by model slug: a page's backing model is named by the CMS.
|
|
1523
|
+
*/
|
|
1524
|
+
declare function publishedEntry<T extends Record<string, unknown> = Record<string, unknown>>(slug: string): (T & {
|
|
1525
|
+
slug: string;
|
|
1526
|
+
}) | null;
|
|
1527
|
+
/** Test seam: forget the cached snapshot. */
|
|
1528
|
+
declare function resetPublishedContentCache(): void;
|
|
1529
|
+
|
|
1476
1530
|
/**
|
|
1477
1531
|
* Admin pages methods.
|
|
1478
1532
|
* @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
|
|
@@ -1748,4 +1802,4 @@ interface WebhookListResponse {
|
|
|
1748
1802
|
};
|
|
1749
1803
|
}
|
|
1750
1804
|
|
|
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 };
|
|
1805
|
+
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
|
@@ -1270,7 +1270,8 @@ function createClient(options) {
|
|
|
1270
1270
|
depth: opts?.depth,
|
|
1271
1271
|
select: opts?.select?.join(","),
|
|
1272
1272
|
perspective: draft ? "draft" : void 0,
|
|
1273
|
-
stega: draft && stega ? "1" : void 0
|
|
1273
|
+
stega: draft && stega ? "1" : void 0,
|
|
1274
|
+
projectId: defaultProjectId
|
|
1274
1275
|
})}`;
|
|
1275
1276
|
return unwrap(await fetchJSON(url));
|
|
1276
1277
|
},
|
|
@@ -1282,7 +1283,8 @@ function createClient(options) {
|
|
|
1282
1283
|
depth: opts?.depth,
|
|
1283
1284
|
select: opts?.select?.join(","),
|
|
1284
1285
|
perspective: draft ? "draft" : void 0,
|
|
1285
|
-
stega: draft && stega ? "1" : void 0
|
|
1286
|
+
stega: draft && stega ? "1" : void 0,
|
|
1287
|
+
projectId: defaultProjectId
|
|
1286
1288
|
})}`;
|
|
1287
1289
|
return unwrap(await fetchJSON(url));
|
|
1288
1290
|
},
|
|
@@ -1316,19 +1318,21 @@ function createClient(options) {
|
|
|
1316
1318
|
async listPages(opts) {
|
|
1317
1319
|
const url = `${base}/pages${qs({
|
|
1318
1320
|
page: opts?.page,
|
|
1319
|
-
perPage: opts?.perPage
|
|
1321
|
+
perPage: opts?.perPage,
|
|
1322
|
+
projectId: defaultProjectId
|
|
1320
1323
|
})}`;
|
|
1321
1324
|
return unwrap(await fetchJSON(url));
|
|
1322
1325
|
},
|
|
1323
1326
|
async listComponents() {
|
|
1324
1327
|
const url = `${base}/components${qs({
|
|
1325
1328
|
perspective: draft ? "draft" : void 0,
|
|
1326
|
-
token: draft ? previewToken : void 0
|
|
1329
|
+
token: draft ? previewToken : void 0,
|
|
1330
|
+
projectId: defaultProjectId
|
|
1327
1331
|
})}`;
|
|
1328
1332
|
return unwrap(await fetchJSON(url));
|
|
1329
1333
|
},
|
|
1330
1334
|
async getLayout() {
|
|
1331
|
-
const url = `${base}/layout${draft ? "
|
|
1335
|
+
const url = `${base}/layout${qs({ perspective: draft ? "draft" : void 0, projectId: defaultProjectId })}`;
|
|
1332
1336
|
try {
|
|
1333
1337
|
return unwrap(await fetchJSON(url));
|
|
1334
1338
|
} catch (error) {
|
|
@@ -1562,6 +1566,45 @@ async function search(opts) {
|
|
|
1562
1566
|
}
|
|
1563
1567
|
}
|
|
1564
1568
|
|
|
1569
|
+
// src/published-content.ts
|
|
1570
|
+
var cache = null;
|
|
1571
|
+
var checkedAt = 0;
|
|
1572
|
+
function publishedContentFile() {
|
|
1573
|
+
const proc = globalThis.process;
|
|
1574
|
+
if (typeof proc?.getBuiltinModule !== "function") return null;
|
|
1575
|
+
return proc.env?.BCMS_CONTENT_FILE || `${proc.cwd?.() ?? "."}/bcms-content.json`;
|
|
1576
|
+
}
|
|
1577
|
+
function readPublishedContent() {
|
|
1578
|
+
const file = publishedContentFile();
|
|
1579
|
+
if (!file) return null;
|
|
1580
|
+
const now = Date.now();
|
|
1581
|
+
if (cache && cache.file === file && now - checkedAt < 1e3) return cache.content;
|
|
1582
|
+
checkedAt = now;
|
|
1583
|
+
const proc = globalThis.process;
|
|
1584
|
+
const fs = proc.getBuiltinModule("node:fs");
|
|
1585
|
+
try {
|
|
1586
|
+
const stamp = fs.statSync(file).mtimeMs;
|
|
1587
|
+
if (cache && cache.file === file && cache.stamp === stamp) return cache.content;
|
|
1588
|
+
cache = { file, stamp, content: JSON.parse(fs.readFileSync(file, "utf8")) };
|
|
1589
|
+
} catch {
|
|
1590
|
+
if (!cache || cache.file !== file) cache = { file, stamp: -1, content: null };
|
|
1591
|
+
}
|
|
1592
|
+
return cache.content;
|
|
1593
|
+
}
|
|
1594
|
+
function publishedEntry(slug) {
|
|
1595
|
+
const collections = readPublishedContent()?.collections ?? {};
|
|
1596
|
+
for (const rows of Object.values(collections)) {
|
|
1597
|
+
if (!Array.isArray(rows)) continue;
|
|
1598
|
+
const hit = rows.find((row) => row?.slug === slug);
|
|
1599
|
+
if (hit) return hit;
|
|
1600
|
+
}
|
|
1601
|
+
return null;
|
|
1602
|
+
}
|
|
1603
|
+
function resetPublishedContentCache() {
|
|
1604
|
+
cache = null;
|
|
1605
|
+
checkedAt = 0;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1565
1608
|
// src/index.ts
|
|
1566
1609
|
import {
|
|
1567
1610
|
default as default2,
|
|
@@ -1923,8 +1966,12 @@ export {
|
|
|
1923
1966
|
portableText,
|
|
1924
1967
|
publishManagedLayout,
|
|
1925
1968
|
publishPage,
|
|
1969
|
+
publishedContentFile,
|
|
1970
|
+
publishedEntry,
|
|
1971
|
+
readPublishedContent,
|
|
1926
1972
|
regenerateApiKey,
|
|
1927
1973
|
removeMember,
|
|
1974
|
+
resetPublishedContentCache,
|
|
1928
1975
|
resolveSeo,
|
|
1929
1976
|
revokeApiKey,
|
|
1930
1977
|
rich,
|