@bettercms-ai/sdk 1.21.0 → 1.22.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
@@ -84,73 +84,6 @@ declare class BetterCMSDeliveryClient {
84
84
  fetchJSON<T>(url: string): Promise<T>;
85
85
  }
86
86
 
87
- /**
88
- * SDK webhook methods — create, list, delete, test webhooks.
89
- */
90
- /**
91
- * Webhook event types supported by BetterCMS.
92
- */
93
- type WebhookEvent = "content.publish" | "content.unpublish" | "content.created" | "content.updated" | "content.deleted" | "page.published" | "page.unpublished" | "page.created" | "page.updated" | "page.deleted" | "form.submitted" | "api_key.created" | "api_key.deleted";
94
- /**
95
- * Webhook record returned from the API (without secret).
96
- */
97
- interface Webhook {
98
- id: string;
99
- projectId: string;
100
- workspaceId: string;
101
- name: string;
102
- url: string;
103
- events: WebhookEvent[];
104
- isActive: boolean;
105
- createdAt: string;
106
- updatedAt: string;
107
- }
108
- /**
109
- * Webhook with secret — returned only on create.
110
- */
111
- interface WebhookWithSecret extends Webhook {
112
- secret: string;
113
- }
114
- /**
115
- * Input for creating a webhook.
116
- */
117
- interface CreateWebhookInput {
118
- name: string;
119
- url: string;
120
- events?: WebhookEvent[];
121
- }
122
- /**
123
- * Input for updating a webhook.
124
- */
125
- interface UpdateWebhookInput {
126
- name?: string;
127
- url?: string;
128
- events?: WebhookEvent[];
129
- isActive?: boolean;
130
- }
131
- /**
132
- * Paginated list response.
133
- */
134
- interface WebhookListResponse {
135
- data: Webhook[];
136
- pagination: {
137
- page: number;
138
- limit: number;
139
- total: number;
140
- totalPages: number;
141
- };
142
- }
143
-
144
- /**
145
- * BetterCMSAdminClient — typed SDK client for admin CRUD operations.
146
- *
147
- * Extends BetterCMSDeliveryClient but overrides:
148
- * - `headers()` — uses Bearer token auth instead of API key
149
- * - `fetchJSON()` — adds Retry-After-aware retry on 429/503 (see ./retry.ts)
150
- *
151
- * @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
152
- */
153
-
154
87
  interface BetterCMSAdminOptions {
155
88
  /** Base URL of the Admin API. Defaults to https://api.bettercms.ai/v1 */
156
89
  baseUrl?: string;
@@ -175,19 +108,15 @@ declare class BetterCMSAdminClient extends BetterCMSDeliveryClient {
175
108
  fetchJSON<T>(url: string, init?: RequestInit): Promise<T>;
176
109
  /** Build the admin API URL. */
177
110
  url(path: string): string;
178
- /** Webhook management methods. */
179
- webhooks(): {
111
+ /** Project-scoped webhook management methods. */
112
+ webhooks(projectId: string): {
180
113
  list: (options?: {
181
114
  page?: number;
182
115
  limit?: number;
183
116
  }) => Promise<WebhookListResponse>;
184
117
  create: (input: CreateWebhookInput) => Promise<WebhookWithSecret>;
185
- get: (webhookId: string) => Promise<{
186
- data: Webhook;
187
- }>;
188
- update: (webhookId: string, input: UpdateWebhookInput) => Promise<{
189
- data: Webhook;
190
- }>;
118
+ get: (webhookId: string) => Promise<Webhook>;
119
+ update: (webhookId: string, input: UpdateWebhookInput) => Promise<Webhook>;
191
120
  delete: (webhookId: string) => Promise<{
192
121
  data: {
193
122
  id: string;
@@ -269,10 +198,21 @@ interface CreateManagedPageInput {
269
198
  slug: string;
270
199
  pageType?: "singleton" | "dynamic";
271
200
  fields?: ContentModelField[];
201
+ /**
202
+ * A singleton's field VALUES, keyed by field key — seeds its entry in the same call. When the
203
+ * server cannot store them the page is still created and the result carries `warnings`
204
+ * (`ENTRY_SEED_FAILED`) and `seedErrors`: check them, because none of `data` was saved.
205
+ */
206
+ data?: Record<string, unknown>;
272
207
  metaTitle?: string;
273
208
  metaDescription?: string;
274
209
  status?: "draft" | "published";
275
210
  }
211
+ /** What a page create reports beyond the page: the seed of `data` that did not happen. */
212
+ type PageCreateReport = {
213
+ warnings?: string[];
214
+ seedErrors?: Record<string, string>;
215
+ };
276
216
  /** Append fields to an existing page's schema (additive — see addPageFields). */
277
217
  interface AddPageFieldsInput {
278
218
  addFields: ContentModelField[];
@@ -371,7 +311,7 @@ declare function getModel(client: ManagementClient, id: string): Promise<Managed
371
311
  declare function listManagedPages(client: ManagementClient): Promise<ManagedPage[]>;
372
312
  /** Create a page (the page-first schema: title/slug/pageType/fields). Project-scoped from the key.
373
313
  * Supports both `singleton` and `dynamic` pageType. */
374
- declare function createManagedPage(client: ManagementClient, input: CreateManagedPageInput): Promise<ManagedPage>;
314
+ declare function createManagedPage(client: ManagementClient, input: CreateManagedPageInput): Promise<ManagedPage & PageCreateReport>;
375
315
  /**
376
316
  * Append fields to an existing page's schema (additive read-append). The API
377
317
  * rejects keys that already exist, so this never overwrites or retypes a field.
@@ -966,7 +906,7 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
966
906
  listPages(): Promise<ManagedPage[]>;
967
907
  /** Get one page by id INCLUDING its field schema + pageType. */
968
908
  getPage(id: string): Promise<ManagedPage>;
969
- createPage(input: CreateManagedPageInput): Promise<ManagedPage>;
909
+ createPage(input: CreateManagedPageInput): Promise<ManagedPage & PageCreateReport>;
970
910
  /** Append fields to an existing page (additive — the API rejects existing keys). */
971
911
  addPageFields(id: string, input: AddPageFieldsInput): Promise<ManagedPage>;
972
912
  /** Set a page's field VALUES — singleton pages get/update their one entry. */
@@ -1670,4 +1610,90 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
1670
1610
  declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
1671
1611
  declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
1672
1612
 
1673
- 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 ManagedMediaAsset, 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 UpdateAssetInput, 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, 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, updateWorkspace, uploadMedia };
1613
+ /**
1614
+ * SDK webhook methods — create, list, delete, test webhooks.
1615
+ */
1616
+ /**
1617
+ * Webhook event types supported by BetterCMS.
1618
+ */
1619
+ type WebhookEvent = "content.publish" | "content.unpublish" | "content.stage_changed" | "deployment.triggered";
1620
+ interface WebhookAdvancedConfig {
1621
+ version: 1;
1622
+ envelopeVersion: "legacy" | "v2";
1623
+ subscriptions: Array<{
1624
+ event: WebhookEvent;
1625
+ payload: {
1626
+ mode: "complete";
1627
+ } | {
1628
+ mode: "selected";
1629
+ fields: Array<{
1630
+ path: string;
1631
+ alias?: string;
1632
+ }>;
1633
+ };
1634
+ filters: Array<{
1635
+ path: string;
1636
+ operator: "equals" | "not_equals" | "contains" | "exists";
1637
+ value?: string | number | boolean | null;
1638
+ }>;
1639
+ }>;
1640
+ headers: Array<{
1641
+ name: string;
1642
+ secretId: string;
1643
+ }>;
1644
+ }
1645
+ /**
1646
+ * Webhook record returned from the API (without secret).
1647
+ */
1648
+ interface Webhook {
1649
+ id: string;
1650
+ projectId: string;
1651
+ workspaceId: string;
1652
+ name: string;
1653
+ url: string;
1654
+ events: WebhookEvent[];
1655
+ advancedConfig: WebhookAdvancedConfig | null;
1656
+ isActive: boolean;
1657
+ createdAt: string;
1658
+ updatedAt: string;
1659
+ }
1660
+ /**
1661
+ * Webhook with secret — returned only on create.
1662
+ */
1663
+ interface WebhookWithSecret extends Webhook {
1664
+ secret: string;
1665
+ }
1666
+ /**
1667
+ * Input for creating a webhook.
1668
+ */
1669
+ interface CreateWebhookInput {
1670
+ name: string;
1671
+ url: string;
1672
+ events?: WebhookEvent[];
1673
+ isActive?: boolean;
1674
+ advancedConfig?: WebhookAdvancedConfig;
1675
+ }
1676
+ /**
1677
+ * Input for updating a webhook.
1678
+ */
1679
+ interface UpdateWebhookInput {
1680
+ name?: string;
1681
+ url?: string;
1682
+ events?: WebhookEvent[];
1683
+ isActive?: boolean;
1684
+ advancedConfig?: WebhookAdvancedConfig | null;
1685
+ }
1686
+ /**
1687
+ * Paginated list response.
1688
+ */
1689
+ interface WebhookListResponse {
1690
+ data: Webhook[];
1691
+ pagination: {
1692
+ page: number;
1693
+ limit: number;
1694
+ total: number;
1695
+ totalPages: number;
1696
+ };
1697
+ }
1698
+
1699
+ 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, 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, updateWorkspace, uploadMedia };
package/dist/index.d.ts CHANGED
@@ -84,73 +84,6 @@ declare class BetterCMSDeliveryClient {
84
84
  fetchJSON<T>(url: string): Promise<T>;
85
85
  }
86
86
 
87
- /**
88
- * SDK webhook methods — create, list, delete, test webhooks.
89
- */
90
- /**
91
- * Webhook event types supported by BetterCMS.
92
- */
93
- type WebhookEvent = "content.publish" | "content.unpublish" | "content.created" | "content.updated" | "content.deleted" | "page.published" | "page.unpublished" | "page.created" | "page.updated" | "page.deleted" | "form.submitted" | "api_key.created" | "api_key.deleted";
94
- /**
95
- * Webhook record returned from the API (without secret).
96
- */
97
- interface Webhook {
98
- id: string;
99
- projectId: string;
100
- workspaceId: string;
101
- name: string;
102
- url: string;
103
- events: WebhookEvent[];
104
- isActive: boolean;
105
- createdAt: string;
106
- updatedAt: string;
107
- }
108
- /**
109
- * Webhook with secret — returned only on create.
110
- */
111
- interface WebhookWithSecret extends Webhook {
112
- secret: string;
113
- }
114
- /**
115
- * Input for creating a webhook.
116
- */
117
- interface CreateWebhookInput {
118
- name: string;
119
- url: string;
120
- events?: WebhookEvent[];
121
- }
122
- /**
123
- * Input for updating a webhook.
124
- */
125
- interface UpdateWebhookInput {
126
- name?: string;
127
- url?: string;
128
- events?: WebhookEvent[];
129
- isActive?: boolean;
130
- }
131
- /**
132
- * Paginated list response.
133
- */
134
- interface WebhookListResponse {
135
- data: Webhook[];
136
- pagination: {
137
- page: number;
138
- limit: number;
139
- total: number;
140
- totalPages: number;
141
- };
142
- }
143
-
144
- /**
145
- * BetterCMSAdminClient — typed SDK client for admin CRUD operations.
146
- *
147
- * Extends BetterCMSDeliveryClient but overrides:
148
- * - `headers()` — uses Bearer token auth instead of API key
149
- * - `fetchJSON()` — adds Retry-After-aware retry on 429/503 (see ./retry.ts)
150
- *
151
- * @see openspec/changes/flo-6-backend-sdk-admin/specs/sdk-admin-client/spec.md
152
- */
153
-
154
87
  interface BetterCMSAdminOptions {
155
88
  /** Base URL of the Admin API. Defaults to https://api.bettercms.ai/v1 */
156
89
  baseUrl?: string;
@@ -175,19 +108,15 @@ declare class BetterCMSAdminClient extends BetterCMSDeliveryClient {
175
108
  fetchJSON<T>(url: string, init?: RequestInit): Promise<T>;
176
109
  /** Build the admin API URL. */
177
110
  url(path: string): string;
178
- /** Webhook management methods. */
179
- webhooks(): {
111
+ /** Project-scoped webhook management methods. */
112
+ webhooks(projectId: string): {
180
113
  list: (options?: {
181
114
  page?: number;
182
115
  limit?: number;
183
116
  }) => Promise<WebhookListResponse>;
184
117
  create: (input: CreateWebhookInput) => Promise<WebhookWithSecret>;
185
- get: (webhookId: string) => Promise<{
186
- data: Webhook;
187
- }>;
188
- update: (webhookId: string, input: UpdateWebhookInput) => Promise<{
189
- data: Webhook;
190
- }>;
118
+ get: (webhookId: string) => Promise<Webhook>;
119
+ update: (webhookId: string, input: UpdateWebhookInput) => Promise<Webhook>;
191
120
  delete: (webhookId: string) => Promise<{
192
121
  data: {
193
122
  id: string;
@@ -269,10 +198,21 @@ interface CreateManagedPageInput {
269
198
  slug: string;
270
199
  pageType?: "singleton" | "dynamic";
271
200
  fields?: ContentModelField[];
201
+ /**
202
+ * A singleton's field VALUES, keyed by field key — seeds its entry in the same call. When the
203
+ * server cannot store them the page is still created and the result carries `warnings`
204
+ * (`ENTRY_SEED_FAILED`) and `seedErrors`: check them, because none of `data` was saved.
205
+ */
206
+ data?: Record<string, unknown>;
272
207
  metaTitle?: string;
273
208
  metaDescription?: string;
274
209
  status?: "draft" | "published";
275
210
  }
211
+ /** What a page create reports beyond the page: the seed of `data` that did not happen. */
212
+ type PageCreateReport = {
213
+ warnings?: string[];
214
+ seedErrors?: Record<string, string>;
215
+ };
276
216
  /** Append fields to an existing page's schema (additive — see addPageFields). */
277
217
  interface AddPageFieldsInput {
278
218
  addFields: ContentModelField[];
@@ -371,7 +311,7 @@ declare function getModel(client: ManagementClient, id: string): Promise<Managed
371
311
  declare function listManagedPages(client: ManagementClient): Promise<ManagedPage[]>;
372
312
  /** Create a page (the page-first schema: title/slug/pageType/fields). Project-scoped from the key.
373
313
  * Supports both `singleton` and `dynamic` pageType. */
374
- declare function createManagedPage(client: ManagementClient, input: CreateManagedPageInput): Promise<ManagedPage>;
314
+ declare function createManagedPage(client: ManagementClient, input: CreateManagedPageInput): Promise<ManagedPage & PageCreateReport>;
375
315
  /**
376
316
  * Append fields to an existing page's schema (additive read-append). The API
377
317
  * rejects keys that already exist, so this never overwrites or retypes a field.
@@ -966,7 +906,7 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
966
906
  listPages(): Promise<ManagedPage[]>;
967
907
  /** Get one page by id INCLUDING its field schema + pageType. */
968
908
  getPage(id: string): Promise<ManagedPage>;
969
- createPage(input: CreateManagedPageInput): Promise<ManagedPage>;
909
+ createPage(input: CreateManagedPageInput): Promise<ManagedPage & PageCreateReport>;
970
910
  /** Append fields to an existing page (additive — the API rejects existing keys). */
971
911
  addPageFields(id: string, input: AddPageFieldsInput): Promise<ManagedPage>;
972
912
  /** Set a page's field VALUES — singleton pages get/update their one entry. */
@@ -1670,4 +1610,90 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
1670
1610
  declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
1671
1611
  declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
1672
1612
 
1673
- 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 ManagedMediaAsset, 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 UpdateAssetInput, 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, 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, updateWorkspace, uploadMedia };
1613
+ /**
1614
+ * SDK webhook methods — create, list, delete, test webhooks.
1615
+ */
1616
+ /**
1617
+ * Webhook event types supported by BetterCMS.
1618
+ */
1619
+ type WebhookEvent = "content.publish" | "content.unpublish" | "content.stage_changed" | "deployment.triggered";
1620
+ interface WebhookAdvancedConfig {
1621
+ version: 1;
1622
+ envelopeVersion: "legacy" | "v2";
1623
+ subscriptions: Array<{
1624
+ event: WebhookEvent;
1625
+ payload: {
1626
+ mode: "complete";
1627
+ } | {
1628
+ mode: "selected";
1629
+ fields: Array<{
1630
+ path: string;
1631
+ alias?: string;
1632
+ }>;
1633
+ };
1634
+ filters: Array<{
1635
+ path: string;
1636
+ operator: "equals" | "not_equals" | "contains" | "exists";
1637
+ value?: string | number | boolean | null;
1638
+ }>;
1639
+ }>;
1640
+ headers: Array<{
1641
+ name: string;
1642
+ secretId: string;
1643
+ }>;
1644
+ }
1645
+ /**
1646
+ * Webhook record returned from the API (without secret).
1647
+ */
1648
+ interface Webhook {
1649
+ id: string;
1650
+ projectId: string;
1651
+ workspaceId: string;
1652
+ name: string;
1653
+ url: string;
1654
+ events: WebhookEvent[];
1655
+ advancedConfig: WebhookAdvancedConfig | null;
1656
+ isActive: boolean;
1657
+ createdAt: string;
1658
+ updatedAt: string;
1659
+ }
1660
+ /**
1661
+ * Webhook with secret — returned only on create.
1662
+ */
1663
+ interface WebhookWithSecret extends Webhook {
1664
+ secret: string;
1665
+ }
1666
+ /**
1667
+ * Input for creating a webhook.
1668
+ */
1669
+ interface CreateWebhookInput {
1670
+ name: string;
1671
+ url: string;
1672
+ events?: WebhookEvent[];
1673
+ isActive?: boolean;
1674
+ advancedConfig?: WebhookAdvancedConfig;
1675
+ }
1676
+ /**
1677
+ * Input for updating a webhook.
1678
+ */
1679
+ interface UpdateWebhookInput {
1680
+ name?: string;
1681
+ url?: string;
1682
+ events?: WebhookEvent[];
1683
+ isActive?: boolean;
1684
+ advancedConfig?: WebhookAdvancedConfig | null;
1685
+ }
1686
+ /**
1687
+ * Paginated list response.
1688
+ */
1689
+ interface WebhookListResponse {
1690
+ data: Webhook[];
1691
+ pagination: {
1692
+ page: number;
1693
+ limit: number;
1694
+ total: number;
1695
+ totalPages: number;
1696
+ };
1697
+ }
1698
+
1699
+ 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, 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, updateWorkspace, uploadMedia };
package/dist/index.js CHANGED
@@ -282,7 +282,8 @@ var BetterCMSDeliveryClient = class {
282
282
  };
283
283
 
284
284
  // src/methods/webhooks.ts
285
- function addWebhookMethods(client) {
285
+ function addWebhookMethods(client, projectId) {
286
+ const root = `/projects/${encodeURIComponent(projectId)}/webhooks`;
286
287
  return {
287
288
  /**
288
289
  * List webhooks for a project.
@@ -292,7 +293,7 @@ function addWebhookMethods(client) {
292
293
  if (options?.page) params2.set("page", String(options.page));
293
294
  if (options?.limit) params2.set("limit", String(options.limit));
294
295
  return client.fetchJSON(
295
- client.url(`/webhooks?${params2}`),
296
+ client.url(`${root}?${params2}`),
296
297
  { method: "GET" }
297
298
  );
298
299
  },
@@ -300,43 +301,46 @@ function addWebhookMethods(client) {
300
301
  * Create a new webhook. Returns the webhook with secret (shown once).
301
302
  */
302
303
  create: async (input) => {
303
- return client.fetchJSON(
304
- client.url("/webhooks"),
304
+ const response = await client.fetchJSON(
305
+ client.url(root),
305
306
  {
306
307
  method: "POST",
307
308
  headers: { "Content-Type": "application/json" },
308
309
  body: JSON.stringify(input)
309
310
  }
310
311
  );
312
+ return response.data;
311
313
  },
312
314
  /**
313
315
  * Get a single webhook.
314
316
  */
315
317
  get: async (webhookId) => {
316
- return client.fetchJSON(
317
- client.url(`/webhooks/${webhookId}`),
318
+ const response = await client.fetchJSON(
319
+ client.url(`${root}/${encodeURIComponent(webhookId)}`),
318
320
  { method: "GET" }
319
321
  );
322
+ return response.data;
320
323
  },
321
324
  /**
322
325
  * Update a webhook.
323
326
  */
324
327
  update: async (webhookId, input) => {
325
- return client.fetchJSON(
326
- client.url(`/webhooks/${webhookId}`),
328
+ const response = await client.fetchJSON(
329
+ client.url(`${root}/${encodeURIComponent(webhookId)}`),
327
330
  {
328
331
  method: "PATCH",
329
332
  headers: { "Content-Type": "application/json" },
330
333
  body: JSON.stringify(input)
331
334
  }
332
335
  );
336
+ return response.data;
333
337
  },
334
338
  /**
335
339
  * Delete a webhook.
336
340
  */
337
341
  delete: async (webhookId) => {
338
342
  return client.fetchJSON(
339
- client.url(`/webhooks/${webhookId}`),
343
+ client.url(`${root}/${encodeURIComponent(webhookId)}`),
340
344
  { method: "DELETE" }
341
345
  );
342
346
  },
@@ -345,7 +349,7 @@ function addWebhookMethods(client) {
345
349
  */
346
350
  test: async (webhookId, event) => {
347
351
  return client.fetchJSON(
348
- client.url(`/webhooks/${webhookId}/test`),
352
+ client.url(`${root}/${encodeURIComponent(webhookId)}/test`),
349
353
  {
350
354
  method: "POST",
351
355
  headers: { "Content-Type": "application/json" },
@@ -423,9 +427,9 @@ var BetterCMSAdminClient = class extends BetterCMSDeliveryClient {
423
427
  url(path) {
424
428
  return `${this.baseUrl}${path}`;
425
429
  }
426
- /** Webhook management methods. */
427
- webhooks() {
428
- return addWebhookMethods(this);
430
+ /** Project-scoped webhook management methods. */
431
+ webhooks(projectId) {
432
+ return addWebhookMethods(this, projectId);
429
433
  }
430
434
  };
431
435
 
@@ -456,7 +460,11 @@ async function createManagedPage(client, input) {
456
460
  client.url("/management/pages"),
457
461
  { method: "POST", body: JSON.stringify(input) }
458
462
  );
459
- return res.data;
463
+ return {
464
+ ...res.data,
465
+ ...res.warnings?.length ? { warnings: res.warnings } : {},
466
+ ...res.seedErrors ? { seedErrors: res.seedErrors } : {}
467
+ };
460
468
  }
461
469
  async function addPageFields(client, id, input) {
462
470
  const res = await client.fetchJSON(