@clocknext/sdk 0.20.1 → 0.20.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clocknext/sdk",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "description": "Official ClockNext SDK — record usage signals and manage plans, purchases, invoices, customers, and billing from your backend.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/types.ts CHANGED
@@ -768,10 +768,10 @@ export interface WalletLedgerPage {
768
768
  /** Reserved Wallet balance, USD; `null` when the workspace hasn't enabled
769
769
  * it. */
770
770
  reservedBalanceUsd: number | null;
771
- /** The customer's own low-balance alert level, USD; `null` when none is set.
771
+ /** The customer's own low-balance threshold, USD; `null` when none is set.
772
772
  * At or below it the `wallet.balance.drop` webhook fires for this customer.
773
773
  * Set with `customers.setWalletAlert()`. */
774
- lowBalanceAlertUsd: number | null;
774
+ lowBalanceThresholdUsd: number | null;
775
775
  transactions: WalletTransaction[];
776
776
  /** Pass back as `cursor` for the next page; `null` on the last page. */
777
777
  nextCursor: string | null;
@@ -779,8 +779,8 @@ export interface WalletLedgerPage {
779
779
 
780
780
  /** Result of `customers.setWalletAlert()`. */
781
781
  export interface WalletAlert {
782
- /** The saved low-balance alert level, USD; `null` once cleared. */
783
- lowBalanceAlertUsd: number | null;
782
+ /** The saved low-balance threshold, USD; `null` once cleared. */
783
+ lowBalanceThresholdUsd: number | null;
784
784
  }
785
785
 
786
786
  export interface WalletLedgerParams {
package/src/webhooks.ts CHANGED
@@ -8,14 +8,19 @@ import { WebhookSignatureError } from "./errors.js";
8
8
  * dashboard (Settings → Webhooks). Two events exist today:
9
9
  *
10
10
  * wallet.balance.update a customer's MAIN wallet balance moved (credit or
11
- * debit). Invoice settlements and the Reserved
12
- * Wallet do not fire it.
11
+ * debit). NOT sent for changes caused by signals
12
+ * (usage debits and outcome / unit / composite
13
+ * charges): they can arrive thousands of times a
14
+ * minute. Invoice settlements and the Reserved
15
+ * Wallet do not fire it either. To read the current
16
+ * balance use `customers.balances()`.
13
17
  * wallet.balance.drop a debit took the balance from above a level to at
14
18
  * or below it. The level is the customer's own alert
15
19
  * level (`customers.setWalletAlert`) when they have
16
20
  * one, otherwise the endpoint's threshold. Fires once
17
21
  * per drop through the level, not on every debit while
18
- * the balance stays under it.
22
+ * the balance stays under it. A signal that crosses
23
+ * the level DOES fire it.
19
24
  *
20
25
  * Verify every request before trusting it — {@link constructWebhookEvent} does
21
26
  * that and returns the typed event. It needs the RAW request body: parsing the
@@ -38,6 +43,7 @@ export type WebhookEventType = "wallet.balance.update" | "wallet.balance.drop";
38
43
  * The ledger also has a `SETTLE` source (an invoice being paid off), but
39
44
  * `wallet.balance.update` is never sent for it, so it is not in this type.
40
45
  */
46
+ // `USAGE` still arrives, but only from the dashboard's hand-recorded unit usage report — signal usage no longer sends `wallet.balance.update`.
41
47
  export type WebhookWalletSource = "TOPUP" | "USAGE" | "ADJUSTMENT";
42
48
 
43
49
  /** The customer a wallet event is about. */