@bettercms-ai/sdk 1.21.0 → 1.22.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 +22 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +104 -81
- package/dist/index.d.ts +104 -81
- package/dist/index.js +22 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
/**
|
|
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
|
-
|
|
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.
|
|
@@ -745,8 +685,6 @@ interface ManagedFormInput {
|
|
|
745
685
|
honeypotField?: string | null;
|
|
746
686
|
/** Addresses notified of each submission. */
|
|
747
687
|
notifyEmails?: string[];
|
|
748
|
-
/** URL that receives each submission as a POST. */
|
|
749
|
-
webhookUrl?: string | null;
|
|
750
688
|
}
|
|
751
689
|
|
|
752
690
|
/**
|
|
@@ -966,7 +904,7 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
|
|
|
966
904
|
listPages(): Promise<ManagedPage[]>;
|
|
967
905
|
/** Get one page by id INCLUDING its field schema + pageType. */
|
|
968
906
|
getPage(id: string): Promise<ManagedPage>;
|
|
969
|
-
createPage(input: CreateManagedPageInput): Promise<ManagedPage>;
|
|
907
|
+
createPage(input: CreateManagedPageInput): Promise<ManagedPage & PageCreateReport>;
|
|
970
908
|
/** Append fields to an existing page (additive — the API rejects existing keys). */
|
|
971
909
|
addPageFields(id: string, input: AddPageFieldsInput): Promise<ManagedPage>;
|
|
972
910
|
/** Set a page's field VALUES — singleton pages get/update their one entry. */
|
|
@@ -1539,7 +1477,6 @@ interface CreateFormInput {
|
|
|
1539
1477
|
submitLabel?: string;
|
|
1540
1478
|
successMessage?: string;
|
|
1541
1479
|
redirectUrl?: string;
|
|
1542
|
-
webhookUrl?: string;
|
|
1543
1480
|
}
|
|
1544
1481
|
/**
|
|
1545
1482
|
* A field in an admin create/update payload.
|
|
@@ -1670,4 +1607,90 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
|
|
|
1670
1607
|
declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
|
|
1671
1608
|
declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
|
|
1672
1609
|
|
|
1673
|
-
|
|
1610
|
+
/**
|
|
1611
|
+
* SDK webhook methods — create, list, delete, test webhooks.
|
|
1612
|
+
*/
|
|
1613
|
+
/**
|
|
1614
|
+
* Webhook event types supported by BetterCMS.
|
|
1615
|
+
*/
|
|
1616
|
+
type WebhookEvent = "content.publish" | "content.unpublish" | "content.stage_changed" | "deployment.triggered";
|
|
1617
|
+
interface WebhookAdvancedConfig {
|
|
1618
|
+
version: 1;
|
|
1619
|
+
envelopeVersion: "legacy" | "v2";
|
|
1620
|
+
subscriptions: Array<{
|
|
1621
|
+
event: WebhookEvent;
|
|
1622
|
+
payload: {
|
|
1623
|
+
mode: "complete";
|
|
1624
|
+
} | {
|
|
1625
|
+
mode: "selected";
|
|
1626
|
+
fields: Array<{
|
|
1627
|
+
path: string;
|
|
1628
|
+
alias?: string;
|
|
1629
|
+
}>;
|
|
1630
|
+
};
|
|
1631
|
+
filters: Array<{
|
|
1632
|
+
path: string;
|
|
1633
|
+
operator: "equals" | "not_equals" | "contains" | "exists";
|
|
1634
|
+
value?: string | number | boolean | null;
|
|
1635
|
+
}>;
|
|
1636
|
+
}>;
|
|
1637
|
+
headers: Array<{
|
|
1638
|
+
name: string;
|
|
1639
|
+
secretId: string;
|
|
1640
|
+
}>;
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Webhook record returned from the API (without secret).
|
|
1644
|
+
*/
|
|
1645
|
+
interface Webhook {
|
|
1646
|
+
id: string;
|
|
1647
|
+
projectId: string;
|
|
1648
|
+
workspaceId: string;
|
|
1649
|
+
name: string;
|
|
1650
|
+
url: string;
|
|
1651
|
+
events: WebhookEvent[];
|
|
1652
|
+
advancedConfig: WebhookAdvancedConfig | null;
|
|
1653
|
+
isActive: boolean;
|
|
1654
|
+
createdAt: string;
|
|
1655
|
+
updatedAt: string;
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Webhook with secret — returned only on create.
|
|
1659
|
+
*/
|
|
1660
|
+
interface WebhookWithSecret extends Webhook {
|
|
1661
|
+
secret: string;
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Input for creating a webhook.
|
|
1665
|
+
*/
|
|
1666
|
+
interface CreateWebhookInput {
|
|
1667
|
+
name: string;
|
|
1668
|
+
url: string;
|
|
1669
|
+
events?: WebhookEvent[];
|
|
1670
|
+
isActive?: boolean;
|
|
1671
|
+
advancedConfig?: WebhookAdvancedConfig;
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Input for updating a webhook.
|
|
1675
|
+
*/
|
|
1676
|
+
interface UpdateWebhookInput {
|
|
1677
|
+
name?: string;
|
|
1678
|
+
url?: string;
|
|
1679
|
+
events?: WebhookEvent[];
|
|
1680
|
+
isActive?: boolean;
|
|
1681
|
+
advancedConfig?: WebhookAdvancedConfig | null;
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Paginated list response.
|
|
1685
|
+
*/
|
|
1686
|
+
interface WebhookListResponse {
|
|
1687
|
+
data: Webhook[];
|
|
1688
|
+
pagination: {
|
|
1689
|
+
page: number;
|
|
1690
|
+
limit: number;
|
|
1691
|
+
total: number;
|
|
1692
|
+
totalPages: number;
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
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
|
-
/**
|
|
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
|
-
|
|
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.
|
|
@@ -745,8 +685,6 @@ interface ManagedFormInput {
|
|
|
745
685
|
honeypotField?: string | null;
|
|
746
686
|
/** Addresses notified of each submission. */
|
|
747
687
|
notifyEmails?: string[];
|
|
748
|
-
/** URL that receives each submission as a POST. */
|
|
749
|
-
webhookUrl?: string | null;
|
|
750
688
|
}
|
|
751
689
|
|
|
752
690
|
/**
|
|
@@ -966,7 +904,7 @@ declare class BetterCMSManagementClient extends BetterCMSDeliveryClient {
|
|
|
966
904
|
listPages(): Promise<ManagedPage[]>;
|
|
967
905
|
/** Get one page by id INCLUDING its field schema + pageType. */
|
|
968
906
|
getPage(id: string): Promise<ManagedPage>;
|
|
969
|
-
createPage(input: CreateManagedPageInput): Promise<ManagedPage>;
|
|
907
|
+
createPage(input: CreateManagedPageInput): Promise<ManagedPage & PageCreateReport>;
|
|
970
908
|
/** Append fields to an existing page (additive — the API rejects existing keys). */
|
|
971
909
|
addPageFields(id: string, input: AddPageFieldsInput): Promise<ManagedPage>;
|
|
972
910
|
/** Set a page's field VALUES — singleton pages get/update their one entry. */
|
|
@@ -1539,7 +1477,6 @@ interface CreateFormInput {
|
|
|
1539
1477
|
submitLabel?: string;
|
|
1540
1478
|
successMessage?: string;
|
|
1541
1479
|
redirectUrl?: string;
|
|
1542
|
-
webhookUrl?: string;
|
|
1543
1480
|
}
|
|
1544
1481
|
/**
|
|
1545
1482
|
* A field in an admin create/update payload.
|
|
@@ -1670,4 +1607,90 @@ declare function inviteMember(client: BetterCMSAdminClient, workspaceId: string,
|
|
|
1670
1607
|
declare function updateMemberRole(client: BetterCMSAdminClient, workspaceId: string, memberId: string, role: MemberRole): Promise<Member>;
|
|
1671
1608
|
declare function removeMember(client: BetterCMSAdminClient, workspaceId: string, memberId: string): Promise<void>;
|
|
1672
1609
|
|
|
1673
|
-
|
|
1610
|
+
/**
|
|
1611
|
+
* SDK webhook methods — create, list, delete, test webhooks.
|
|
1612
|
+
*/
|
|
1613
|
+
/**
|
|
1614
|
+
* Webhook event types supported by BetterCMS.
|
|
1615
|
+
*/
|
|
1616
|
+
type WebhookEvent = "content.publish" | "content.unpublish" | "content.stage_changed" | "deployment.triggered";
|
|
1617
|
+
interface WebhookAdvancedConfig {
|
|
1618
|
+
version: 1;
|
|
1619
|
+
envelopeVersion: "legacy" | "v2";
|
|
1620
|
+
subscriptions: Array<{
|
|
1621
|
+
event: WebhookEvent;
|
|
1622
|
+
payload: {
|
|
1623
|
+
mode: "complete";
|
|
1624
|
+
} | {
|
|
1625
|
+
mode: "selected";
|
|
1626
|
+
fields: Array<{
|
|
1627
|
+
path: string;
|
|
1628
|
+
alias?: string;
|
|
1629
|
+
}>;
|
|
1630
|
+
};
|
|
1631
|
+
filters: Array<{
|
|
1632
|
+
path: string;
|
|
1633
|
+
operator: "equals" | "not_equals" | "contains" | "exists";
|
|
1634
|
+
value?: string | number | boolean | null;
|
|
1635
|
+
}>;
|
|
1636
|
+
}>;
|
|
1637
|
+
headers: Array<{
|
|
1638
|
+
name: string;
|
|
1639
|
+
secretId: string;
|
|
1640
|
+
}>;
|
|
1641
|
+
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Webhook record returned from the API (without secret).
|
|
1644
|
+
*/
|
|
1645
|
+
interface Webhook {
|
|
1646
|
+
id: string;
|
|
1647
|
+
projectId: string;
|
|
1648
|
+
workspaceId: string;
|
|
1649
|
+
name: string;
|
|
1650
|
+
url: string;
|
|
1651
|
+
events: WebhookEvent[];
|
|
1652
|
+
advancedConfig: WebhookAdvancedConfig | null;
|
|
1653
|
+
isActive: boolean;
|
|
1654
|
+
createdAt: string;
|
|
1655
|
+
updatedAt: string;
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Webhook with secret — returned only on create.
|
|
1659
|
+
*/
|
|
1660
|
+
interface WebhookWithSecret extends Webhook {
|
|
1661
|
+
secret: string;
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Input for creating a webhook.
|
|
1665
|
+
*/
|
|
1666
|
+
interface CreateWebhookInput {
|
|
1667
|
+
name: string;
|
|
1668
|
+
url: string;
|
|
1669
|
+
events?: WebhookEvent[];
|
|
1670
|
+
isActive?: boolean;
|
|
1671
|
+
advancedConfig?: WebhookAdvancedConfig;
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Input for updating a webhook.
|
|
1675
|
+
*/
|
|
1676
|
+
interface UpdateWebhookInput {
|
|
1677
|
+
name?: string;
|
|
1678
|
+
url?: string;
|
|
1679
|
+
events?: WebhookEvent[];
|
|
1680
|
+
isActive?: boolean;
|
|
1681
|
+
advancedConfig?: WebhookAdvancedConfig | null;
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Paginated list response.
|
|
1685
|
+
*/
|
|
1686
|
+
interface WebhookListResponse {
|
|
1687
|
+
data: Webhook[];
|
|
1688
|
+
pagination: {
|
|
1689
|
+
page: number;
|
|
1690
|
+
limit: number;
|
|
1691
|
+
total: number;
|
|
1692
|
+
totalPages: number;
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
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(
|
|
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
|
-
|
|
304
|
-
client.url(
|
|
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
|
-
|
|
317
|
-
client.url(
|
|
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
|
-
|
|
326
|
-
client.url(
|
|
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(
|
|
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(
|
|
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
|
-
/**
|
|
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
|
|
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(
|