@bettercms-ai/sdk 1.18.0 → 1.19.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 CHANGED
@@ -426,7 +426,17 @@ declare class BetterCMSError extends Error {
426
426
  * hint which field or rule failed (FLO-474). Mirrors the forms client's `fieldErrors`.
427
427
  */
428
428
  readonly fieldErrors?: Record<string, string>;
429
- constructor(message: string, status: number, code: BetterCMSErrorCode, bodyCode?: string, fieldErrors?: Record<string, string>);
429
+ /**
430
+ * The parsed response body, when there was one.
431
+ *
432
+ * Several refusals carry STRUCTURED detail that neither `message` nor `fieldErrors` can hold,
433
+ * and which is the whole point of the refusal: a component publish 409s with the full
434
+ * `readiness` tuple (what evidence is missing, whether a human still has to approve it) and
435
+ * 422s with the `issues` naming the Layouts it would break. Collapsing those to a sentence
436
+ * leaves a caller able to report that something failed and not what to do about it.
437
+ */
438
+ readonly body?: unknown;
439
+ constructor(message: string, status: number, code: BetterCMSErrorCode, bodyCode?: string, fieldErrors?: Record<string, string>, body?: unknown);
430
440
  toJSON(): {
431
441
  name: string;
432
442
  message: string;
@@ -628,10 +638,40 @@ interface ManagedComponentInput {
628
638
  name?: string;
629
639
  slug?: string;
630
640
  category?: string;
641
+ sectionType?: string | null;
642
+ /**
643
+ * The organisational Group, by NAME. The API resolves it against the project's Groups and
644
+ * creates it when missing — a caller filing a whole site's components into folders has a name
645
+ * ("Sections"), never an id.
646
+ */
647
+ group?: string;
648
+ groupId?: string | null;
631
649
  description?: string;
632
650
  blockJson?: unknown[];
633
651
  props?: unknown[];
634
652
  }
653
+ /**
654
+ * The catalogue shape: what each component IS, without its block trees.
655
+ *
656
+ * The default list carries every component's draft AND live `blockJson`, which on a
657
+ * componentized site is the largest response this API produces — and a caller asking which
658
+ * components exist wants none of it. This shape also carries `sectionType`, `status` and the
659
+ * Group, the three facts that decide whether a component is insertable, whether it is on the
660
+ * live site, and where an editor finds it.
661
+ */
662
+ interface ManagedComponentSummary {
663
+ id: string;
664
+ projectId: string | null;
665
+ name: string;
666
+ slug: string;
667
+ category: string;
668
+ sectionType: string | null;
669
+ status: string | null;
670
+ groupId: string | null;
671
+ groupName: string | null;
672
+ updatedAt: string | null;
673
+ builtin?: boolean;
674
+ }
635
675
  /**
636
676
  * A set of sections that repeat across the project's pages, proposed as one component.
637
677
  * Derived per request from the pages' DRAFT blocks — never stored.
@@ -809,6 +849,9 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
809
849
  /** Update a form by id (passing `fields` replaces the array). */
810
850
  updateForm(id: string, input: ManagedFormInput): Promise<ManagedForm>;
811
851
  listComponents(): Promise<ManagedComponent[]>;
852
+ listComponents(options: {
853
+ select: "summary";
854
+ }): Promise<ManagedComponentSummary[]>;
812
855
  getComponent(id: string): Promise<ManagedComponent>;
813
856
  createComponent(input: ManagedComponentInput): Promise<ManagedComponent>;
814
857
  updateComponent(id: string, input: ManagedComponentInput): Promise<ManagedComponent>;
@@ -1437,4 +1480,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
1437
1480
  declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
1438
1481
  declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
1439
1482
 
1440
- 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 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 ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, PORTABLE_TEXT_FORMAT, 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 UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, 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, updateWorkspace, uploadMedia };
1483
+ 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 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 ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, PORTABLE_TEXT_FORMAT, 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 UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, 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, updateWorkspace, uploadMedia };
package/dist/index.d.ts CHANGED
@@ -426,7 +426,17 @@ declare class BetterCMSError extends Error {
426
426
  * hint which field or rule failed (FLO-474). Mirrors the forms client's `fieldErrors`.
427
427
  */
428
428
  readonly fieldErrors?: Record<string, string>;
429
- constructor(message: string, status: number, code: BetterCMSErrorCode, bodyCode?: string, fieldErrors?: Record<string, string>);
429
+ /**
430
+ * The parsed response body, when there was one.
431
+ *
432
+ * Several refusals carry STRUCTURED detail that neither `message` nor `fieldErrors` can hold,
433
+ * and which is the whole point of the refusal: a component publish 409s with the full
434
+ * `readiness` tuple (what evidence is missing, whether a human still has to approve it) and
435
+ * 422s with the `issues` naming the Layouts it would break. Collapsing those to a sentence
436
+ * leaves a caller able to report that something failed and not what to do about it.
437
+ */
438
+ readonly body?: unknown;
439
+ constructor(message: string, status: number, code: BetterCMSErrorCode, bodyCode?: string, fieldErrors?: Record<string, string>, body?: unknown);
430
440
  toJSON(): {
431
441
  name: string;
432
442
  message: string;
@@ -628,10 +638,40 @@ interface ManagedComponentInput {
628
638
  name?: string;
629
639
  slug?: string;
630
640
  category?: string;
641
+ sectionType?: string | null;
642
+ /**
643
+ * The organisational Group, by NAME. The API resolves it against the project's Groups and
644
+ * creates it when missing — a caller filing a whole site's components into folders has a name
645
+ * ("Sections"), never an id.
646
+ */
647
+ group?: string;
648
+ groupId?: string | null;
631
649
  description?: string;
632
650
  blockJson?: unknown[];
633
651
  props?: unknown[];
634
652
  }
653
+ /**
654
+ * The catalogue shape: what each component IS, without its block trees.
655
+ *
656
+ * The default list carries every component's draft AND live `blockJson`, which on a
657
+ * componentized site is the largest response this API produces — and a caller asking which
658
+ * components exist wants none of it. This shape also carries `sectionType`, `status` and the
659
+ * Group, the three facts that decide whether a component is insertable, whether it is on the
660
+ * live site, and where an editor finds it.
661
+ */
662
+ interface ManagedComponentSummary {
663
+ id: string;
664
+ projectId: string | null;
665
+ name: string;
666
+ slug: string;
667
+ category: string;
668
+ sectionType: string | null;
669
+ status: string | null;
670
+ groupId: string | null;
671
+ groupName: string | null;
672
+ updatedAt: string | null;
673
+ builtin?: boolean;
674
+ }
635
675
  /**
636
676
  * A set of sections that repeat across the project's pages, proposed as one component.
637
677
  * Derived per request from the pages' DRAFT blocks — never stored.
@@ -809,6 +849,9 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
809
849
  /** Update a form by id (passing `fields` replaces the array). */
810
850
  updateForm(id: string, input: ManagedFormInput): Promise<ManagedForm>;
811
851
  listComponents(): Promise<ManagedComponent[]>;
852
+ listComponents(options: {
853
+ select: "summary";
854
+ }): Promise<ManagedComponentSummary[]>;
812
855
  getComponent(id: string): Promise<ManagedComponent>;
813
856
  createComponent(input: ManagedComponentInput): Promise<ManagedComponent>;
814
857
  updateComponent(id: string, input: ManagedComponentInput): Promise<ManagedComponent>;
@@ -1437,4 +1480,4 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
1437
1480
  declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
1438
1481
  declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
1439
1482
 
1440
- 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 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 ManagedContentEntry, type ManagedContentModel, type ManagedForm, type ManagedFormInput, type ManagedLayoutClient, type ManagedLayoutDocument, type ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, PORTABLE_TEXT_FORMAT, 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 UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, 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, updateWorkspace, uploadMedia };
1483
+ 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 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 ManagedPage, type ManagementClient, type MediaListOptions, type MediaMetadata, type Member, type MemberRole, PORTABLE_TEXT_FORMAT, 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 UpdateEntryInput, type UpdateFormInput, type UpdateModelInput, type UpdatePageInput, type UpdateWorkspaceInput, type UploadAssetInput, type UploadedAsset, type WriteContentInput, addModelFields, addPageFields, asStringArray, commandManagedLayout, createApiKey, createClient, createEntry, createForm, createManagedPage, createModel, createPage, createWorkspace, decodeStega, deleteForm, deleteMedia, deletePage, deleteSubmission, deleteWorkspace, encodeStega, 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, updateWorkspace, uploadMedia };
package/dist/index.js CHANGED
@@ -35,13 +35,24 @@ var BetterCMSError = class _BetterCMSError extends Error {
35
35
  * hint which field or rule failed (FLO-474). Mirrors the forms client's `fieldErrors`.
36
36
  */
37
37
  fieldErrors;
38
- constructor(message, status, code, bodyCode, fieldErrors) {
38
+ /**
39
+ * The parsed response body, when there was one.
40
+ *
41
+ * Several refusals carry STRUCTURED detail that neither `message` nor `fieldErrors` can hold,
42
+ * and which is the whole point of the refusal: a component publish 409s with the full
43
+ * `readiness` tuple (what evidence is missing, whether a human still has to approve it) and
44
+ * 422s with the `issues` naming the Layouts it would break. Collapsing those to a sentence
45
+ * leaves a caller able to report that something failed and not what to do about it.
46
+ */
47
+ body;
48
+ constructor(message, status, code, bodyCode, fieldErrors, body) {
39
49
  super(message);
40
50
  this.name = "BetterCMSError";
41
51
  this.status = status;
42
52
  this.code = code;
43
53
  this.bodyCode = bodyCode;
44
54
  this.fieldErrors = fieldErrors;
55
+ this.body = body;
45
56
  if (Error.captureStackTrace) {
46
57
  Error.captureStackTrace(this, _BetterCMSError);
47
58
  }
@@ -68,6 +79,7 @@ var BetterCMSError = class _BetterCMSError extends Error {
68
79
  let bodyCode;
69
80
  let fieldErrors;
70
81
  let code = statusToCode(res.status);
82
+ let raw;
71
83
  try {
72
84
  const body = await res.json();
73
85
  if (body?.errors && typeof body.errors === "object") {
@@ -83,9 +95,10 @@ var BetterCMSError = class _BetterCMSError extends Error {
83
95
  if (field) message = `${field}: ${detail}`;
84
96
  }
85
97
  if (body?.code) bodyCode = body.code;
98
+ raw = body;
86
99
  } catch {
87
100
  }
88
- return new _BetterCMSError(message, res.status, code, bodyCode, fieldErrors);
101
+ return new _BetterCMSError(message, res.status, code, bodyCode, fieldErrors, raw);
89
102
  }
90
103
  };
91
104
 
@@ -706,9 +719,10 @@ async function updateForm(client, id, input) {
706
719
  }
707
720
 
708
721
  // src/methods/management/components.ts
709
- async function listComponents(client) {
722
+ async function listComponents(client, options) {
723
+ const query = options?.select ? `?select=${options.select}` : "";
710
724
  const res = await client.fetchJSON(
711
- client.url("/management/components"),
725
+ client.url(`/management/components${query}`),
712
726
  { method: "GET" }
713
727
  );
714
728
  return res.data;
@@ -949,9 +963,8 @@ var BetterCMSManagementClient = class extends BetterCMSDeliveryClient {
949
963
  updateForm(id, input) {
950
964
  return updateForm(this, id, input);
951
965
  }
952
- // ── Components: discover + author reusable symbols ──
953
- listComponents() {
954
- return listComponents(this);
966
+ listComponents(options) {
967
+ return options?.select ? listComponents(this, { select: options.select }) : listComponents(this);
955
968
  }
956
969
  getComponent(id) {
957
970
  return getComponent(this, id);