@waffo/pancake-ts 0.5.1 → 0.6.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/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +63 -23
- package/dist/index.cjs +93 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +153 -24
- package/dist/index.d.ts +153 -24
- package/dist/index.js +93 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -236,18 +236,61 @@ interface SessionToken {
|
|
|
236
236
|
expiresAt: string;
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
|
-
* Webhook
|
|
239
|
+
* Webhook channel — HTTP for the standard RSA-signed envelope, the rest for
|
|
240
|
+
* IM platform native payloads (Feishu / Discord / Telegram / Slack).
|
|
241
|
+
*/
|
|
242
|
+
type WebhookChannel = "http" | "feishu" | "discord" | "telegram" | "slack";
|
|
243
|
+
/**
|
|
244
|
+
* Configured webhook endpoint (one row of `store.store_webhooks`).
|
|
245
|
+
*
|
|
240
246
|
* @see waffo-pancake-store-service/app/lib/types.ts
|
|
241
247
|
*/
|
|
242
|
-
interface
|
|
243
|
-
/**
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
interface StoreWebhook {
|
|
249
|
+
/** Webhook UUID (not Short ID) */
|
|
250
|
+
id: string;
|
|
251
|
+
/** Owning store Short ID (`STO_…`) */
|
|
252
|
+
storeId: string;
|
|
253
|
+
channel: WebhookChannel;
|
|
254
|
+
/** Target webhook URL */
|
|
255
|
+
url: string;
|
|
256
|
+
/** Subscribed event types (e.g. `order.completed`) */
|
|
257
|
+
events: string[];
|
|
258
|
+
/** Whether this webhook fires in test or prod environment */
|
|
259
|
+
testMode: boolean;
|
|
260
|
+
/** Channel-specific credential (e.g. Telegram chat_id) */
|
|
261
|
+
secret: string | null;
|
|
262
|
+
createdAt: string;
|
|
263
|
+
updatedAt: string;
|
|
264
|
+
}
|
|
265
|
+
/** Parameters for creating a webhook. */
|
|
266
|
+
interface AddWebhookParams {
|
|
267
|
+
/** Store Short ID (`STO_…`) */
|
|
268
|
+
storeId: string;
|
|
269
|
+
channel: WebhookChannel;
|
|
270
|
+
/** Target webhook URL */
|
|
271
|
+
url: string;
|
|
272
|
+
/** Subscribed event types */
|
|
273
|
+
events: string[];
|
|
274
|
+
/** Whether this webhook fires in test (true) or prod (false) */
|
|
275
|
+
testMode: boolean;
|
|
276
|
+
/** Channel-specific credential (e.g. Telegram chat_id) */
|
|
277
|
+
secret?: string | null;
|
|
278
|
+
}
|
|
279
|
+
/** Parameters for updating a webhook. `channel` and `testMode` are immutable. */
|
|
280
|
+
interface UpdateWebhookParams {
|
|
281
|
+
/** Webhook UUID */
|
|
282
|
+
id: string;
|
|
283
|
+
/** Replace target URL (must remain on the same channel host) */
|
|
284
|
+
url?: string;
|
|
285
|
+
/** Replace subscribed event types */
|
|
286
|
+
events?: string[];
|
|
287
|
+
/** Replace channel-specific credential */
|
|
288
|
+
secret?: string | null;
|
|
289
|
+
}
|
|
290
|
+
/** Parameters for hard-deleting a webhook. */
|
|
291
|
+
interface RemoveWebhookParams {
|
|
292
|
+
/** Webhook UUID */
|
|
293
|
+
id: string;
|
|
251
294
|
}
|
|
252
295
|
/**
|
|
253
296
|
* Notification settings (all default to true).
|
|
@@ -297,7 +340,6 @@ interface Store {
|
|
|
297
340
|
website: string | null;
|
|
298
341
|
slug: string | null;
|
|
299
342
|
prodEnabled: boolean;
|
|
300
|
-
webhookSettings: WebhookSettings | null;
|
|
301
343
|
notificationSettings: NotificationSettings | null;
|
|
302
344
|
checkoutSettings: CheckoutSettings | null;
|
|
303
345
|
deletedAt: string | null;
|
|
@@ -315,6 +357,10 @@ interface CreateStoreParams {
|
|
|
315
357
|
* Settings objects support partial updates — omitted sub-fields keep their
|
|
316
358
|
* existing values, `null` clears a field, and a concrete value sets it.
|
|
317
359
|
* Pass the entire settings object as `null` to clear all fields in the group.
|
|
360
|
+
*
|
|
361
|
+
* **BREAKING (2026-05)**: the legacy `webhookSettings` field is removed.
|
|
362
|
+
* Manage webhooks via `client.webhooks.add / update / remove`; query the
|
|
363
|
+
* webhook list through GraphQL `Store.storeWebhooks`.
|
|
318
364
|
*/
|
|
319
365
|
interface UpdateStoreParams {
|
|
320
366
|
/** Store ID */
|
|
@@ -329,8 +375,6 @@ interface UpdateStoreParams {
|
|
|
329
375
|
supportEmail?: string | null;
|
|
330
376
|
/** Store website URL (set to `null` to remove) */
|
|
331
377
|
website?: string | null;
|
|
332
|
-
/** Webhook configuration (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
333
|
-
webhookSettings?: Partial<WebhookSettings> | null;
|
|
334
378
|
/** Notification preferences (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
335
379
|
notificationSettings?: Partial<NotificationSettings> | null;
|
|
336
380
|
/** Checkout page theme configuration (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
@@ -1507,9 +1551,13 @@ declare class StoresResource {
|
|
|
1507
1551
|
/**
|
|
1508
1552
|
* Update an existing store's settings.
|
|
1509
1553
|
*
|
|
1510
|
-
* Settings objects (`
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1554
|
+
* Settings objects (`notificationSettings`, `checkoutSettings`) support
|
|
1555
|
+
* partial updates: omitted sub-fields keep existing values, `null` clears a
|
|
1556
|
+
* field. Pass the entire settings object as `null` to clear all fields.
|
|
1557
|
+
*
|
|
1558
|
+
* **BREAKING (2026-05)**: the legacy `webhookSettings` parameter is removed.
|
|
1559
|
+
* Use `client.webhooks.add / update / remove` to manage webhook endpoints,
|
|
1560
|
+
* and query the configured webhook list via GraphQL `Store.storeWebhooks`.
|
|
1513
1561
|
*
|
|
1514
1562
|
* @param params - Fields to update (only provided fields are changed)
|
|
1515
1563
|
* @returns Updated store entity
|
|
@@ -1522,10 +1570,10 @@ declare class StoresResource {
|
|
|
1522
1570
|
* });
|
|
1523
1571
|
*
|
|
1524
1572
|
* @example
|
|
1525
|
-
* //
|
|
1573
|
+
* // Toggle a notification preference
|
|
1526
1574
|
* const { store } = await client.stores.update({
|
|
1527
1575
|
* id: "STO_xxx",
|
|
1528
|
-
*
|
|
1576
|
+
* notificationSettings: { emailOrderConfirmation: false },
|
|
1529
1577
|
* });
|
|
1530
1578
|
*/
|
|
1531
1579
|
update(params: UpdateStoreParams): Promise<{
|
|
@@ -1682,15 +1730,96 @@ declare class SubscriptionProductsResource {
|
|
|
1682
1730
|
}
|
|
1683
1731
|
|
|
1684
1732
|
/**
|
|
1685
|
-
* Webhook
|
|
1733
|
+
* Webhook resource — manages webhook configurations (HTTP / Feishu / Discord
|
|
1734
|
+
* / Telegram / Slack) and verifies inbound webhook signatures.
|
|
1735
|
+
*
|
|
1736
|
+
* **Mutations only**: `add`, `update`, `remove` all hit POST endpoints.
|
|
1737
|
+
* To list a store's webhooks, use GraphQL `Store.storeWebhooks` via
|
|
1738
|
+
* `client.graphql.query`.
|
|
1686
1739
|
*
|
|
1687
|
-
*
|
|
1688
|
-
*
|
|
1740
|
+
* Verification (`verify`) is a local cryptographic operation that does not
|
|
1741
|
+
* require API calls.
|
|
1689
1742
|
*/
|
|
1690
1743
|
declare class WebhooksResource {
|
|
1744
|
+
private readonly http;
|
|
1691
1745
|
private readonly publicKeys;
|
|
1692
|
-
/**
|
|
1693
|
-
|
|
1746
|
+
/**
|
|
1747
|
+
* @param http - HTTP client (used for add/update/remove)
|
|
1748
|
+
* @param publicKeys - Optional config-level public key(s) from WaffoPancakeConfig
|
|
1749
|
+
*/
|
|
1750
|
+
constructor(http: HttpClient, publicKeys: WebhookPublicKeys | undefined);
|
|
1751
|
+
/**
|
|
1752
|
+
* Add a webhook endpoint to a store.
|
|
1753
|
+
*
|
|
1754
|
+
* @param params - Webhook configuration
|
|
1755
|
+
* @returns Created webhook entity
|
|
1756
|
+
*
|
|
1757
|
+
* @example
|
|
1758
|
+
* // HTTP webhook (RSA-signed envelope, default)
|
|
1759
|
+
* const { webhook } = await client.webhooks.add({
|
|
1760
|
+
* storeId: "STO_xxx",
|
|
1761
|
+
* channel: "http",
|
|
1762
|
+
* url: "https://example.com/webhook",
|
|
1763
|
+
* events: ["order.completed", "refund.succeeded"],
|
|
1764
|
+
* testMode: false,
|
|
1765
|
+
* });
|
|
1766
|
+
*
|
|
1767
|
+
* @example
|
|
1768
|
+
* // Discord webhook (uses Discord embed format)
|
|
1769
|
+
* await client.webhooks.add({
|
|
1770
|
+
* storeId: "STO_xxx",
|
|
1771
|
+
* channel: "discord",
|
|
1772
|
+
* url: "https://discord.com/api/webhooks/...",
|
|
1773
|
+
* events: ["order.completed"],
|
|
1774
|
+
* testMode: false,
|
|
1775
|
+
* });
|
|
1776
|
+
*
|
|
1777
|
+
* @example
|
|
1778
|
+
* // Telegram bot — chat_id goes in `secret`; URL is the bot's sendMessage endpoint
|
|
1779
|
+
* await client.webhooks.add({
|
|
1780
|
+
* storeId: "STO_xxx",
|
|
1781
|
+
* channel: "telegram",
|
|
1782
|
+
* url: "https://api.telegram.org/bot123:ABC/sendMessage",
|
|
1783
|
+
* events: ["order.completed"],
|
|
1784
|
+
* testMode: false,
|
|
1785
|
+
* secret: "8737101383",
|
|
1786
|
+
* });
|
|
1787
|
+
*/
|
|
1788
|
+
add(params: AddWebhookParams): Promise<{
|
|
1789
|
+
webhook: StoreWebhook;
|
|
1790
|
+
}>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Update an existing webhook (only `url`, `events`, and `secret` are mutable).
|
|
1793
|
+
*
|
|
1794
|
+
* `channel` and `testMode` cannot be changed — remove the webhook and
|
|
1795
|
+
* re-add it instead. URL changes must remain on the same channel host
|
|
1796
|
+
* whitelist.
|
|
1797
|
+
*
|
|
1798
|
+
* @param params - Fields to update
|
|
1799
|
+
* @returns Updated webhook entity
|
|
1800
|
+
*
|
|
1801
|
+
* @example
|
|
1802
|
+
* await client.webhooks.update({
|
|
1803
|
+
* id: "11111111-2222-3333-4444-555555555555",
|
|
1804
|
+
* events: ["order.completed", "refund.succeeded", "subscription.canceled"],
|
|
1805
|
+
* });
|
|
1806
|
+
*/
|
|
1807
|
+
update(params: UpdateWebhookParams): Promise<{
|
|
1808
|
+
webhook: StoreWebhook;
|
|
1809
|
+
}>;
|
|
1810
|
+
/**
|
|
1811
|
+
* Hard-delete a webhook. Historical `webhook_deliveries` rows are retained
|
|
1812
|
+
* (with `storeWebhookId` set to null) for audit purposes.
|
|
1813
|
+
*
|
|
1814
|
+
* @param params - Webhook to remove
|
|
1815
|
+
* @returns The removed webhook entity (snapshot before deletion)
|
|
1816
|
+
*
|
|
1817
|
+
* @example
|
|
1818
|
+
* await client.webhooks.remove({ id: "11111111-..." });
|
|
1819
|
+
*/
|
|
1820
|
+
remove(params: RemoveWebhookParams): Promise<{
|
|
1821
|
+
webhook: StoreWebhook;
|
|
1822
|
+
}>;
|
|
1694
1823
|
/**
|
|
1695
1824
|
* Verify and parse an incoming webhook event.
|
|
1696
1825
|
*
|
|
@@ -1882,4 +2011,4 @@ declare class WaffoPancakeError extends Error {
|
|
|
1882
2011
|
*/
|
|
1883
2012
|
declare function verifyWebhook<T = Record<string, unknown>>(payload: string, signatureHeader: string | undefined | null, options?: VerifyWebhookOptions): WebhookEvent<T>;
|
|
1884
2013
|
|
|
1885
|
-
export { type AddMerchantParams, type AddMerchantResult, type AnonymousCheckoutParams, type ApiError, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, type BillingDetail, BillingPeriod, type CancelOnetimeOrderParams, type CancelOnetimeOrderResult, type CancelSubscriptionParams, type CancelSubscriptionResult, type CheckoutSessionResult, type CheckoutSettings, type CheckoutThemeSettings, type CreateCheckoutSessionParams, type CreateOnetimeProductParams, type CreateRefundTicketParams, type CreateStoreParams, type CreateSubscriptionProductGroupParams, type CreateSubscriptionProductParams, type DeleteStoreParams, type DeleteSubscriptionProductGroupParams, EntityStatus, Environment, ErrorLayer, type GraphQLParams, type GraphQLResponse, type GroupRules, type IssueSessionTokenParams, type MediaItem, MediaType, type NotificationSettings, OnetimeOrderStatus, type OnetimeProductDetail, PaymentStatus, type PriceInfo, type Prices, ProductVersionStatus, type PublishOnetimeProductParams, type PublishSubscriptionProductGroupParams, type PublishSubscriptionProductParams, type ReactivateSubscriptionParams, type ReactivateSubscriptionResult, RefundStatus, type RefundTicket, RefundTicketStatus, type RefundTicketVersionData, type RemoveMerchantParams, type RemoveMerchantResult, type RequestedAmount, type ResubmitRefundTicketParams, type SessionToken, type Store, StoreRole, SubscriptionOrderStatus, type SubscriptionProductDetail, type SubscriptionProductGroup, TaxCategory, type UpdateOnetimeProductParams, type UpdateOnetimeStatusParams, type UpdateRoleParams, type UpdateRoleResult, type UpdateStoreParams, type UpdateSubscriptionProductGroupParams, type UpdateSubscriptionProductParams, type UpdateSubscriptionStatusParams, type VerifyWebhookOptions, WaffoPancake, type WaffoPancakeConfig, WaffoPancakeError, type WebhookEvent, type WebhookEventData, WebhookEventType, type WebhookPublicKeys,
|
|
2014
|
+
export { type AddMerchantParams, type AddMerchantResult, type AddWebhookParams, type AnonymousCheckoutParams, type ApiError, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, type BillingDetail, BillingPeriod, type CancelOnetimeOrderParams, type CancelOnetimeOrderResult, type CancelSubscriptionParams, type CancelSubscriptionResult, type CheckoutSessionResult, type CheckoutSettings, type CheckoutThemeSettings, type CreateCheckoutSessionParams, type CreateOnetimeProductParams, type CreateRefundTicketParams, type CreateStoreParams, type CreateSubscriptionProductGroupParams, type CreateSubscriptionProductParams, type DeleteStoreParams, type DeleteSubscriptionProductGroupParams, EntityStatus, Environment, ErrorLayer, type GraphQLParams, type GraphQLResponse, type GroupRules, type IssueSessionTokenParams, type MediaItem, MediaType, type NotificationSettings, OnetimeOrderStatus, type OnetimeProductDetail, PaymentStatus, type PriceInfo, type Prices, ProductVersionStatus, type PublishOnetimeProductParams, type PublishSubscriptionProductGroupParams, type PublishSubscriptionProductParams, type ReactivateSubscriptionParams, type ReactivateSubscriptionResult, RefundStatus, type RefundTicket, RefundTicketStatus, type RefundTicketVersionData, type RemoveMerchantParams, type RemoveMerchantResult, type RemoveWebhookParams, type RequestedAmount, type ResubmitRefundTicketParams, type SessionToken, type Store, StoreRole, type StoreWebhook, SubscriptionOrderStatus, type SubscriptionProductDetail, type SubscriptionProductGroup, TaxCategory, type UpdateOnetimeProductParams, type UpdateOnetimeStatusParams, type UpdateRoleParams, type UpdateRoleResult, type UpdateStoreParams, type UpdateSubscriptionProductGroupParams, type UpdateSubscriptionProductParams, type UpdateSubscriptionStatusParams, type UpdateWebhookParams, type VerifyWebhookOptions, WaffoPancake, type WaffoPancakeConfig, WaffoPancakeError, type WebhookChannel, type WebhookEvent, type WebhookEventData, WebhookEventType, type WebhookPublicKeys, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -236,18 +236,61 @@ interface SessionToken {
|
|
|
236
236
|
expiresAt: string;
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
|
-
* Webhook
|
|
239
|
+
* Webhook channel — HTTP for the standard RSA-signed envelope, the rest for
|
|
240
|
+
* IM platform native payloads (Feishu / Discord / Telegram / Slack).
|
|
241
|
+
*/
|
|
242
|
+
type WebhookChannel = "http" | "feishu" | "discord" | "telegram" | "slack";
|
|
243
|
+
/**
|
|
244
|
+
* Configured webhook endpoint (one row of `store.store_webhooks`).
|
|
245
|
+
*
|
|
240
246
|
* @see waffo-pancake-store-service/app/lib/types.ts
|
|
241
247
|
*/
|
|
242
|
-
interface
|
|
243
|
-
/**
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
interface StoreWebhook {
|
|
249
|
+
/** Webhook UUID (not Short ID) */
|
|
250
|
+
id: string;
|
|
251
|
+
/** Owning store Short ID (`STO_…`) */
|
|
252
|
+
storeId: string;
|
|
253
|
+
channel: WebhookChannel;
|
|
254
|
+
/** Target webhook URL */
|
|
255
|
+
url: string;
|
|
256
|
+
/** Subscribed event types (e.g. `order.completed`) */
|
|
257
|
+
events: string[];
|
|
258
|
+
/** Whether this webhook fires in test or prod environment */
|
|
259
|
+
testMode: boolean;
|
|
260
|
+
/** Channel-specific credential (e.g. Telegram chat_id) */
|
|
261
|
+
secret: string | null;
|
|
262
|
+
createdAt: string;
|
|
263
|
+
updatedAt: string;
|
|
264
|
+
}
|
|
265
|
+
/** Parameters for creating a webhook. */
|
|
266
|
+
interface AddWebhookParams {
|
|
267
|
+
/** Store Short ID (`STO_…`) */
|
|
268
|
+
storeId: string;
|
|
269
|
+
channel: WebhookChannel;
|
|
270
|
+
/** Target webhook URL */
|
|
271
|
+
url: string;
|
|
272
|
+
/** Subscribed event types */
|
|
273
|
+
events: string[];
|
|
274
|
+
/** Whether this webhook fires in test (true) or prod (false) */
|
|
275
|
+
testMode: boolean;
|
|
276
|
+
/** Channel-specific credential (e.g. Telegram chat_id) */
|
|
277
|
+
secret?: string | null;
|
|
278
|
+
}
|
|
279
|
+
/** Parameters for updating a webhook. `channel` and `testMode` are immutable. */
|
|
280
|
+
interface UpdateWebhookParams {
|
|
281
|
+
/** Webhook UUID */
|
|
282
|
+
id: string;
|
|
283
|
+
/** Replace target URL (must remain on the same channel host) */
|
|
284
|
+
url?: string;
|
|
285
|
+
/** Replace subscribed event types */
|
|
286
|
+
events?: string[];
|
|
287
|
+
/** Replace channel-specific credential */
|
|
288
|
+
secret?: string | null;
|
|
289
|
+
}
|
|
290
|
+
/** Parameters for hard-deleting a webhook. */
|
|
291
|
+
interface RemoveWebhookParams {
|
|
292
|
+
/** Webhook UUID */
|
|
293
|
+
id: string;
|
|
251
294
|
}
|
|
252
295
|
/**
|
|
253
296
|
* Notification settings (all default to true).
|
|
@@ -297,7 +340,6 @@ interface Store {
|
|
|
297
340
|
website: string | null;
|
|
298
341
|
slug: string | null;
|
|
299
342
|
prodEnabled: boolean;
|
|
300
|
-
webhookSettings: WebhookSettings | null;
|
|
301
343
|
notificationSettings: NotificationSettings | null;
|
|
302
344
|
checkoutSettings: CheckoutSettings | null;
|
|
303
345
|
deletedAt: string | null;
|
|
@@ -315,6 +357,10 @@ interface CreateStoreParams {
|
|
|
315
357
|
* Settings objects support partial updates — omitted sub-fields keep their
|
|
316
358
|
* existing values, `null` clears a field, and a concrete value sets it.
|
|
317
359
|
* Pass the entire settings object as `null` to clear all fields in the group.
|
|
360
|
+
*
|
|
361
|
+
* **BREAKING (2026-05)**: the legacy `webhookSettings` field is removed.
|
|
362
|
+
* Manage webhooks via `client.webhooks.add / update / remove`; query the
|
|
363
|
+
* webhook list through GraphQL `Store.storeWebhooks`.
|
|
318
364
|
*/
|
|
319
365
|
interface UpdateStoreParams {
|
|
320
366
|
/** Store ID */
|
|
@@ -329,8 +375,6 @@ interface UpdateStoreParams {
|
|
|
329
375
|
supportEmail?: string | null;
|
|
330
376
|
/** Store website URL (set to `null` to remove) */
|
|
331
377
|
website?: string | null;
|
|
332
|
-
/** Webhook configuration (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
333
|
-
webhookSettings?: Partial<WebhookSettings> | null;
|
|
334
378
|
/** Notification preferences (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
335
379
|
notificationSettings?: Partial<NotificationSettings> | null;
|
|
336
380
|
/** Checkout page theme configuration (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
@@ -1507,9 +1551,13 @@ declare class StoresResource {
|
|
|
1507
1551
|
/**
|
|
1508
1552
|
* Update an existing store's settings.
|
|
1509
1553
|
*
|
|
1510
|
-
* Settings objects (`
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1554
|
+
* Settings objects (`notificationSettings`, `checkoutSettings`) support
|
|
1555
|
+
* partial updates: omitted sub-fields keep existing values, `null` clears a
|
|
1556
|
+
* field. Pass the entire settings object as `null` to clear all fields.
|
|
1557
|
+
*
|
|
1558
|
+
* **BREAKING (2026-05)**: the legacy `webhookSettings` parameter is removed.
|
|
1559
|
+
* Use `client.webhooks.add / update / remove` to manage webhook endpoints,
|
|
1560
|
+
* and query the configured webhook list via GraphQL `Store.storeWebhooks`.
|
|
1513
1561
|
*
|
|
1514
1562
|
* @param params - Fields to update (only provided fields are changed)
|
|
1515
1563
|
* @returns Updated store entity
|
|
@@ -1522,10 +1570,10 @@ declare class StoresResource {
|
|
|
1522
1570
|
* });
|
|
1523
1571
|
*
|
|
1524
1572
|
* @example
|
|
1525
|
-
* //
|
|
1573
|
+
* // Toggle a notification preference
|
|
1526
1574
|
* const { store } = await client.stores.update({
|
|
1527
1575
|
* id: "STO_xxx",
|
|
1528
|
-
*
|
|
1576
|
+
* notificationSettings: { emailOrderConfirmation: false },
|
|
1529
1577
|
* });
|
|
1530
1578
|
*/
|
|
1531
1579
|
update(params: UpdateStoreParams): Promise<{
|
|
@@ -1682,15 +1730,96 @@ declare class SubscriptionProductsResource {
|
|
|
1682
1730
|
}
|
|
1683
1731
|
|
|
1684
1732
|
/**
|
|
1685
|
-
* Webhook
|
|
1733
|
+
* Webhook resource — manages webhook configurations (HTTP / Feishu / Discord
|
|
1734
|
+
* / Telegram / Slack) and verifies inbound webhook signatures.
|
|
1735
|
+
*
|
|
1736
|
+
* **Mutations only**: `add`, `update`, `remove` all hit POST endpoints.
|
|
1737
|
+
* To list a store's webhooks, use GraphQL `Store.storeWebhooks` via
|
|
1738
|
+
* `client.graphql.query`.
|
|
1686
1739
|
*
|
|
1687
|
-
*
|
|
1688
|
-
*
|
|
1740
|
+
* Verification (`verify`) is a local cryptographic operation that does not
|
|
1741
|
+
* require API calls.
|
|
1689
1742
|
*/
|
|
1690
1743
|
declare class WebhooksResource {
|
|
1744
|
+
private readonly http;
|
|
1691
1745
|
private readonly publicKeys;
|
|
1692
|
-
/**
|
|
1693
|
-
|
|
1746
|
+
/**
|
|
1747
|
+
* @param http - HTTP client (used for add/update/remove)
|
|
1748
|
+
* @param publicKeys - Optional config-level public key(s) from WaffoPancakeConfig
|
|
1749
|
+
*/
|
|
1750
|
+
constructor(http: HttpClient, publicKeys: WebhookPublicKeys | undefined);
|
|
1751
|
+
/**
|
|
1752
|
+
* Add a webhook endpoint to a store.
|
|
1753
|
+
*
|
|
1754
|
+
* @param params - Webhook configuration
|
|
1755
|
+
* @returns Created webhook entity
|
|
1756
|
+
*
|
|
1757
|
+
* @example
|
|
1758
|
+
* // HTTP webhook (RSA-signed envelope, default)
|
|
1759
|
+
* const { webhook } = await client.webhooks.add({
|
|
1760
|
+
* storeId: "STO_xxx",
|
|
1761
|
+
* channel: "http",
|
|
1762
|
+
* url: "https://example.com/webhook",
|
|
1763
|
+
* events: ["order.completed", "refund.succeeded"],
|
|
1764
|
+
* testMode: false,
|
|
1765
|
+
* });
|
|
1766
|
+
*
|
|
1767
|
+
* @example
|
|
1768
|
+
* // Discord webhook (uses Discord embed format)
|
|
1769
|
+
* await client.webhooks.add({
|
|
1770
|
+
* storeId: "STO_xxx",
|
|
1771
|
+
* channel: "discord",
|
|
1772
|
+
* url: "https://discord.com/api/webhooks/...",
|
|
1773
|
+
* events: ["order.completed"],
|
|
1774
|
+
* testMode: false,
|
|
1775
|
+
* });
|
|
1776
|
+
*
|
|
1777
|
+
* @example
|
|
1778
|
+
* // Telegram bot — chat_id goes in `secret`; URL is the bot's sendMessage endpoint
|
|
1779
|
+
* await client.webhooks.add({
|
|
1780
|
+
* storeId: "STO_xxx",
|
|
1781
|
+
* channel: "telegram",
|
|
1782
|
+
* url: "https://api.telegram.org/bot123:ABC/sendMessage",
|
|
1783
|
+
* events: ["order.completed"],
|
|
1784
|
+
* testMode: false,
|
|
1785
|
+
* secret: "8737101383",
|
|
1786
|
+
* });
|
|
1787
|
+
*/
|
|
1788
|
+
add(params: AddWebhookParams): Promise<{
|
|
1789
|
+
webhook: StoreWebhook;
|
|
1790
|
+
}>;
|
|
1791
|
+
/**
|
|
1792
|
+
* Update an existing webhook (only `url`, `events`, and `secret` are mutable).
|
|
1793
|
+
*
|
|
1794
|
+
* `channel` and `testMode` cannot be changed — remove the webhook and
|
|
1795
|
+
* re-add it instead. URL changes must remain on the same channel host
|
|
1796
|
+
* whitelist.
|
|
1797
|
+
*
|
|
1798
|
+
* @param params - Fields to update
|
|
1799
|
+
* @returns Updated webhook entity
|
|
1800
|
+
*
|
|
1801
|
+
* @example
|
|
1802
|
+
* await client.webhooks.update({
|
|
1803
|
+
* id: "11111111-2222-3333-4444-555555555555",
|
|
1804
|
+
* events: ["order.completed", "refund.succeeded", "subscription.canceled"],
|
|
1805
|
+
* });
|
|
1806
|
+
*/
|
|
1807
|
+
update(params: UpdateWebhookParams): Promise<{
|
|
1808
|
+
webhook: StoreWebhook;
|
|
1809
|
+
}>;
|
|
1810
|
+
/**
|
|
1811
|
+
* Hard-delete a webhook. Historical `webhook_deliveries` rows are retained
|
|
1812
|
+
* (with `storeWebhookId` set to null) for audit purposes.
|
|
1813
|
+
*
|
|
1814
|
+
* @param params - Webhook to remove
|
|
1815
|
+
* @returns The removed webhook entity (snapshot before deletion)
|
|
1816
|
+
*
|
|
1817
|
+
* @example
|
|
1818
|
+
* await client.webhooks.remove({ id: "11111111-..." });
|
|
1819
|
+
*/
|
|
1820
|
+
remove(params: RemoveWebhookParams): Promise<{
|
|
1821
|
+
webhook: StoreWebhook;
|
|
1822
|
+
}>;
|
|
1694
1823
|
/**
|
|
1695
1824
|
* Verify and parse an incoming webhook event.
|
|
1696
1825
|
*
|
|
@@ -1882,4 +2011,4 @@ declare class WaffoPancakeError extends Error {
|
|
|
1882
2011
|
*/
|
|
1883
2012
|
declare function verifyWebhook<T = Record<string, unknown>>(payload: string, signatureHeader: string | undefined | null, options?: VerifyWebhookOptions): WebhookEvent<T>;
|
|
1884
2013
|
|
|
1885
|
-
export { type AddMerchantParams, type AddMerchantResult, type AnonymousCheckoutParams, type ApiError, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, type BillingDetail, BillingPeriod, type CancelOnetimeOrderParams, type CancelOnetimeOrderResult, type CancelSubscriptionParams, type CancelSubscriptionResult, type CheckoutSessionResult, type CheckoutSettings, type CheckoutThemeSettings, type CreateCheckoutSessionParams, type CreateOnetimeProductParams, type CreateRefundTicketParams, type CreateStoreParams, type CreateSubscriptionProductGroupParams, type CreateSubscriptionProductParams, type DeleteStoreParams, type DeleteSubscriptionProductGroupParams, EntityStatus, Environment, ErrorLayer, type GraphQLParams, type GraphQLResponse, type GroupRules, type IssueSessionTokenParams, type MediaItem, MediaType, type NotificationSettings, OnetimeOrderStatus, type OnetimeProductDetail, PaymentStatus, type PriceInfo, type Prices, ProductVersionStatus, type PublishOnetimeProductParams, type PublishSubscriptionProductGroupParams, type PublishSubscriptionProductParams, type ReactivateSubscriptionParams, type ReactivateSubscriptionResult, RefundStatus, type RefundTicket, RefundTicketStatus, type RefundTicketVersionData, type RemoveMerchantParams, type RemoveMerchantResult, type RequestedAmount, type ResubmitRefundTicketParams, type SessionToken, type Store, StoreRole, SubscriptionOrderStatus, type SubscriptionProductDetail, type SubscriptionProductGroup, TaxCategory, type UpdateOnetimeProductParams, type UpdateOnetimeStatusParams, type UpdateRoleParams, type UpdateRoleResult, type UpdateStoreParams, type UpdateSubscriptionProductGroupParams, type UpdateSubscriptionProductParams, type UpdateSubscriptionStatusParams, type VerifyWebhookOptions, WaffoPancake, type WaffoPancakeConfig, WaffoPancakeError, type WebhookEvent, type WebhookEventData, WebhookEventType, type WebhookPublicKeys,
|
|
2014
|
+
export { type AddMerchantParams, type AddMerchantResult, type AddWebhookParams, type AnonymousCheckoutParams, type ApiError, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, type BillingDetail, BillingPeriod, type CancelOnetimeOrderParams, type CancelOnetimeOrderResult, type CancelSubscriptionParams, type CancelSubscriptionResult, type CheckoutSessionResult, type CheckoutSettings, type CheckoutThemeSettings, type CreateCheckoutSessionParams, type CreateOnetimeProductParams, type CreateRefundTicketParams, type CreateStoreParams, type CreateSubscriptionProductGroupParams, type CreateSubscriptionProductParams, type DeleteStoreParams, type DeleteSubscriptionProductGroupParams, EntityStatus, Environment, ErrorLayer, type GraphQLParams, type GraphQLResponse, type GroupRules, type IssueSessionTokenParams, type MediaItem, MediaType, type NotificationSettings, OnetimeOrderStatus, type OnetimeProductDetail, PaymentStatus, type PriceInfo, type Prices, ProductVersionStatus, type PublishOnetimeProductParams, type PublishSubscriptionProductGroupParams, type PublishSubscriptionProductParams, type ReactivateSubscriptionParams, type ReactivateSubscriptionResult, RefundStatus, type RefundTicket, RefundTicketStatus, type RefundTicketVersionData, type RemoveMerchantParams, type RemoveMerchantResult, type RemoveWebhookParams, type RequestedAmount, type ResubmitRefundTicketParams, type SessionToken, type Store, StoreRole, type StoreWebhook, SubscriptionOrderStatus, type SubscriptionProductDetail, type SubscriptionProductGroup, TaxCategory, type UpdateOnetimeProductParams, type UpdateOnetimeStatusParams, type UpdateRoleParams, type UpdateRoleResult, type UpdateStoreParams, type UpdateSubscriptionProductGroupParams, type UpdateSubscriptionProductParams, type UpdateSubscriptionStatusParams, type UpdateWebhookParams, type VerifyWebhookOptions, WaffoPancake, type WaffoPancakeConfig, WaffoPancakeError, type WebhookChannel, type WebhookEvent, type WebhookEventData, WebhookEventType, type WebhookPublicKeys, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -791,9 +791,13 @@ var StoresResource = class {
|
|
|
791
791
|
/**
|
|
792
792
|
* Update an existing store's settings.
|
|
793
793
|
*
|
|
794
|
-
* Settings objects (`
|
|
795
|
-
*
|
|
796
|
-
*
|
|
794
|
+
* Settings objects (`notificationSettings`, `checkoutSettings`) support
|
|
795
|
+
* partial updates: omitted sub-fields keep existing values, `null` clears a
|
|
796
|
+
* field. Pass the entire settings object as `null` to clear all fields.
|
|
797
|
+
*
|
|
798
|
+
* **BREAKING (2026-05)**: the legacy `webhookSettings` parameter is removed.
|
|
799
|
+
* Use `client.webhooks.add / update / remove` to manage webhook endpoints,
|
|
800
|
+
* and query the configured webhook list via GraphQL `Store.storeWebhooks`.
|
|
797
801
|
*
|
|
798
802
|
* @param params - Fields to update (only provided fields are changed)
|
|
799
803
|
* @returns Updated store entity
|
|
@@ -806,10 +810,10 @@ var StoresResource = class {
|
|
|
806
810
|
* });
|
|
807
811
|
*
|
|
808
812
|
* @example
|
|
809
|
-
* //
|
|
813
|
+
* // Toggle a notification preference
|
|
810
814
|
* const { store } = await client.stores.update({
|
|
811
815
|
* id: "STO_xxx",
|
|
812
|
-
*
|
|
816
|
+
* notificationSettings: { emailOrderConfirmation: false },
|
|
813
817
|
* });
|
|
814
818
|
*/
|
|
815
819
|
async update(params) {
|
|
@@ -1090,10 +1094,91 @@ function verifyWebhook(payload, signatureHeader, options) {
|
|
|
1090
1094
|
|
|
1091
1095
|
// src/resources/webhooks.ts
|
|
1092
1096
|
var WebhooksResource = class {
|
|
1093
|
-
/**
|
|
1094
|
-
|
|
1097
|
+
/**
|
|
1098
|
+
* @param http - HTTP client (used for add/update/remove)
|
|
1099
|
+
* @param publicKeys - Optional config-level public key(s) from WaffoPancakeConfig
|
|
1100
|
+
*/
|
|
1101
|
+
constructor(http, publicKeys) {
|
|
1102
|
+
this.http = http;
|
|
1095
1103
|
this.publicKeys = publicKeys;
|
|
1096
1104
|
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Add a webhook endpoint to a store.
|
|
1107
|
+
*
|
|
1108
|
+
* @param params - Webhook configuration
|
|
1109
|
+
* @returns Created webhook entity
|
|
1110
|
+
*
|
|
1111
|
+
* @example
|
|
1112
|
+
* // HTTP webhook (RSA-signed envelope, default)
|
|
1113
|
+
* const { webhook } = await client.webhooks.add({
|
|
1114
|
+
* storeId: "STO_xxx",
|
|
1115
|
+
* channel: "http",
|
|
1116
|
+
* url: "https://example.com/webhook",
|
|
1117
|
+
* events: ["order.completed", "refund.succeeded"],
|
|
1118
|
+
* testMode: false,
|
|
1119
|
+
* });
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* // Discord webhook (uses Discord embed format)
|
|
1123
|
+
* await client.webhooks.add({
|
|
1124
|
+
* storeId: "STO_xxx",
|
|
1125
|
+
* channel: "discord",
|
|
1126
|
+
* url: "https://discord.com/api/webhooks/...",
|
|
1127
|
+
* events: ["order.completed"],
|
|
1128
|
+
* testMode: false,
|
|
1129
|
+
* });
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* // Telegram bot — chat_id goes in `secret`; URL is the bot's sendMessage endpoint
|
|
1133
|
+
* await client.webhooks.add({
|
|
1134
|
+
* storeId: "STO_xxx",
|
|
1135
|
+
* channel: "telegram",
|
|
1136
|
+
* url: "https://api.telegram.org/bot123:ABC/sendMessage",
|
|
1137
|
+
* events: ["order.completed"],
|
|
1138
|
+
* testMode: false,
|
|
1139
|
+
* secret: "8737101383",
|
|
1140
|
+
* });
|
|
1141
|
+
*/
|
|
1142
|
+
async add(params) {
|
|
1143
|
+
validateShortId("storeId", params.storeId, "STO");
|
|
1144
|
+
validateRequired("channel", params.channel);
|
|
1145
|
+
validateRequired("url", params.url);
|
|
1146
|
+
return this.http.post("/v1/actions/store/add-webhook", params);
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Update an existing webhook (only `url`, `events`, and `secret` are mutable).
|
|
1150
|
+
*
|
|
1151
|
+
* `channel` and `testMode` cannot be changed — remove the webhook and
|
|
1152
|
+
* re-add it instead. URL changes must remain on the same channel host
|
|
1153
|
+
* whitelist.
|
|
1154
|
+
*
|
|
1155
|
+
* @param params - Fields to update
|
|
1156
|
+
* @returns Updated webhook entity
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* await client.webhooks.update({
|
|
1160
|
+
* id: "11111111-2222-3333-4444-555555555555",
|
|
1161
|
+
* events: ["order.completed", "refund.succeeded", "subscription.canceled"],
|
|
1162
|
+
* });
|
|
1163
|
+
*/
|
|
1164
|
+
async update(params) {
|
|
1165
|
+
validateRequired("id", params.id);
|
|
1166
|
+
return this.http.post("/v1/actions/store/update-webhook", params);
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Hard-delete a webhook. Historical `webhook_deliveries` rows are retained
|
|
1170
|
+
* (with `storeWebhookId` set to null) for audit purposes.
|
|
1171
|
+
*
|
|
1172
|
+
* @param params - Webhook to remove
|
|
1173
|
+
* @returns The removed webhook entity (snapshot before deletion)
|
|
1174
|
+
*
|
|
1175
|
+
* @example
|
|
1176
|
+
* await client.webhooks.remove({ id: "11111111-..." });
|
|
1177
|
+
*/
|
|
1178
|
+
async remove(params) {
|
|
1179
|
+
validateRequired("id", params.id);
|
|
1180
|
+
return this.http.post("/v1/actions/store/remove-webhook", params);
|
|
1181
|
+
}
|
|
1097
1182
|
/**
|
|
1098
1183
|
* Verify and parse an incoming webhook event.
|
|
1099
1184
|
*
|
|
@@ -1157,7 +1242,7 @@ var WaffoPancake = class {
|
|
|
1157
1242
|
this.orders = new OrdersResource(this.http);
|
|
1158
1243
|
this.checkout = new CheckoutResource(this.http);
|
|
1159
1244
|
this.graphql = new GraphQLResource(this.http);
|
|
1160
|
-
this.webhooks = new WebhooksResource(config.webhookPublicKey);
|
|
1245
|
+
this.webhooks = new WebhooksResource(this.http, config.webhookPublicKey);
|
|
1161
1246
|
}
|
|
1162
1247
|
/**
|
|
1163
1248
|
* Create a buyer session for self-service operations.
|