@clocknext/sdk 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -164,6 +164,8 @@ type OutcomeCompletionInput = CustomerRef & {
164
164
  runId: string;
165
165
  /** Optional member (email) this completion is attributed to. */
166
166
  member?: string;
167
+ /** Free-form metadata, stored as-is with this completion. Never priced. */
168
+ custom?: Record<string, unknown>;
167
169
  /** Idempotency key, auto-generated if omitted. Sending this completion twice
168
170
  * for the same run is already a safe no-op server-side, so this only
169
171
  * collapses a retry into one attempt rather than protecting against a
@@ -385,8 +387,9 @@ interface UsageLogOutcomeAttribution {
385
387
  interface UsageLogEntry {
386
388
  id: string;
387
389
  createdAt: string;
388
- /** Which meter this row is. */
389
- type: "credit" | "outcome" | "unit" | "wallet" | "composite";
390
+ /** Which meter this row is. `"outcome"` is one step of a run;
391
+ * `"outcome_completion"` is the finished run itself (one per run). */
392
+ type: "credit" | "outcome" | "outcome_completion" | "unit" | "wallet" | "composite";
390
393
  status: SignalStatus;
391
394
  typeName: string | null;
392
395
  member: string | null;
@@ -424,8 +427,22 @@ interface UsageLogEntry {
424
427
  composite: {
425
428
  amount: string;
426
429
  } | null;
427
- /** The `custom` object sent on the signal, as sent. `null` when none was
428
- * sent, and always `null` for unit and composite rows. */
430
+ /** Populated only when `type === "outcome_completion"`. `amount` is the
431
+ * price frozen when the run completed (your plan price, else the catalogue
432
+ * price). */
433
+ outcomeCompletion: {
434
+ runId: string | null;
435
+ amount: string;
436
+ runSignals: number;
437
+ } | null;
438
+ /** The composite that covers this row's billing, by name — the row's price
439
+ * is then included in that composite's own charge, not billed on top. Set
440
+ * on credit / outcome / unit / outcome_completion rows tagged into a
441
+ * composite on the customer's plan; `null` otherwise. */
442
+ coveredByComposite: string | null;
443
+ /** The `custom` object sent, as sent — on the signal itself, or on the
444
+ * `completeComposite()` / `completeOutcome()` call that closed a composite /
445
+ * outcome_completion row. `null` when none was sent. */
429
446
  custom: Record<string, unknown> | null;
430
447
  }
431
448
  interface UsageLogPage {
@@ -454,8 +471,6 @@ interface ApiCustomer {
454
471
  taxId: string | null;
455
472
  currencyCode: string;
456
473
  creditAllowance: number;
457
- recurringTransactionEmail: boolean;
458
- autoRecurring: boolean;
459
474
  createdAt: string;
460
475
  updatedAt: string;
461
476
  }
@@ -485,10 +500,6 @@ interface CustomerProfileInput {
485
500
  taxId?: string | null;
486
501
  /** ISO 4217 (3 letters); must be enabled for the org. */
487
502
  currencyCode?: string;
488
- /** Send the invoice, payment receipt and card-payment-failed emails for recurring invoices. Defaults to `true` on create. */
489
- recurringTransactionEmail?: boolean;
490
- /** Issue every recurring invoice as `AUTO_CLOSED` (applied as if paid, never payable). Defaults to `false` on create. */
491
- autoRecurring?: boolean;
492
503
  }
493
504
  /** `name` and `email` are required on create; every other field is optional. */
494
505
  type CreateCustomerInput = CustomerProfileInput & {
@@ -580,6 +591,79 @@ interface CustomerBalances {
580
591
  * isn't listed. */
581
592
  composites: CompositeBalance[];
582
593
  }
594
+ /** What caused a wallet ledger row (`WalletTransaction.source`). */
595
+ type WalletTransactionSource =
596
+ /** Wallet money from a new plan purchase. */
597
+ "SUBSCRIPTION"
598
+ /** Wallet money from a plan renewal, or unused money removed at renewal. */
599
+ | "RENEWAL"
600
+ /** Changed in the ClockNext dashboard. */
601
+ | "MANUAL"
602
+ /** Changed with `customers.adjustWallet()`. */
603
+ | "API"
604
+ /** Top-up paid by the customer in the customer portal. */
605
+ | "CUSTOMER_PORTAL"
606
+ /** Charged by a signal; `usageLogId` links the signal. */
607
+ | "USAGE_LOG"
608
+ /** Usage cleared by a paid pay-as-you-go invoice. */
609
+ | "INVOICE_SETTLEMENT"
610
+ /** Settlement undone by a voided invoice. */
611
+ | "INVOICE_VOID";
612
+ /** One row of a customer's wallet ledger (`customers.wallet()`). */
613
+ interface WalletTransaction {
614
+ id: string;
615
+ /** ISO 8601. */
616
+ createdAt: string;
617
+ /** `CREDIT` adds money, `DEBIT` takes it out. */
618
+ type: "CREDIT" | "DEBIT";
619
+ /** Which balance moved: the ordinary wallet or the Reserved Wallet. */
620
+ pool: "main" | "reserved";
621
+ source: WalletTransactionSource;
622
+ /** Always positive — `type` gives the direction. In `currencyCode`. */
623
+ amount: number;
624
+ /** The same amount in USD. */
625
+ amountUsd: number;
626
+ currencyCode: string;
627
+ /** 1 USD = this many units of `currencyCode`, at write time. */
628
+ currencyRateUsd: number;
629
+ /** Only text a person wrote: your own note on an `API` row, the admin's
630
+ * note on a `MANUAL` row. `null` on every row the system writes itself —
631
+ * `source` says what those are. */
632
+ notes: string | null;
633
+ /** On a usage charge for an entitlement: which kind. `null` otherwise. */
634
+ entitlementType: "CREDIT" | "OUTCOME" | "UNIT" | "COMPOSITE" | null;
635
+ /** Id of that credit / outcome / unit / composite. */
636
+ entitlementId: string | null;
637
+ /** Its name when the row was written. */
638
+ entitlementName: string | null;
639
+ /** On a `USAGE_LOG` row: the id of the matching row in
640
+ * `signals.usageLog()`. */
641
+ usageLogId: string | null;
642
+ /** On a `SUBSCRIPTION` / `RENEWAL` grant: the purchase it came from. */
643
+ purchaseId: string | null;
644
+ purchaseNumber: string | null;
645
+ }
646
+ /** One page of a customer's wallet ledger, newest first. */
647
+ interface WalletLedgerPage {
648
+ /** Ordinary wallet balance, USD. May be negative. */
649
+ balanceUsd: number;
650
+ /** Reserved Wallet balance, USD; `null` when the workspace hasn't enabled
651
+ * it. */
652
+ reservedBalanceUsd: number | null;
653
+ transactions: WalletTransaction[];
654
+ /** Pass back as `cursor` for the next page; `null` on the last page. */
655
+ nextCursor: string | null;
656
+ }
657
+ interface WalletLedgerParams {
658
+ /** Default 50, max 200. */
659
+ limit?: number;
660
+ /** A previous page's `nextCursor`. Omit for the first page. */
661
+ cursor?: string;
662
+ /** First day to include, `YYYY-MM-DD` (UTC). The whole day is included. */
663
+ from?: string;
664
+ /** Last day to include, `YYYY-MM-DD` (UTC). The whole day is included. */
665
+ to?: string;
666
+ }
583
667
  /** The customer's active plan (the `plan` field of `customers.plan()`);
584
668
  * `null` when the customer is unsubscribed. */
585
669
  interface CustomerPlanDetails {
@@ -1025,7 +1109,8 @@ interface PurchaseDetail {
1025
1109
  paidCount: number;
1026
1110
  };
1027
1111
  }
1028
- /** `AUTO_CLOSED` — a recurring invoice for a customer with `autoRecurring` on:
1112
+ /** `AUTO_CLOSED` — a recurring invoice of an organisation with "Auto close
1113
+ * invoices on recurring" on (dashboard: Settings → Organisation → Billing):
1029
1114
  * applied as if paid, but never payable. */
1030
1115
  type InvoiceStatus = "OPEN" | "PAID" | "VOID" | "AUTO_CLOSED";
1031
1116
  /** Trimmed row from `invoices.list()`. */
@@ -1398,6 +1483,8 @@ type UnitInput = CustomerRef & {
1398
1483
  quantity?: number;
1399
1484
  /** Optional composite this unit report belongs to. See {@link CompositeTag}. */
1400
1485
  composite?: CompositeTag;
1486
+ /** Free-form metadata, stored as-is with this unit report. Never priced. */
1487
+ custom?: Record<string, unknown>;
1401
1488
  /**
1402
1489
  * Idempotency key for safe retries — a repeat carrying the same key returns
1403
1490
  * the original result instead of drawing the balance down twice.
@@ -1447,6 +1534,9 @@ type CompositeCompletionInput = CustomerRef & {
1447
1534
  /** Which occurrence to close: the composite's `refId` and the correlation
1448
1535
  * value the signals were tagged with. */
1449
1536
  composite: CompositeTag;
1537
+ /** Free-form metadata, stored as-is on the occurrence this call closes.
1538
+ * Never priced. */
1539
+ custom?: Record<string, unknown>;
1450
1540
  /** Idempotency key, auto-generated if omitted. Closing twice is already a
1451
1541
  * safe no-op, so this only collapses retries into one recorded attempt
1452
1542
  * rather than protecting against a double charge. */
@@ -1747,6 +1837,22 @@ declare class Customers {
1747
1837
  delete(id: string): Promise<void>;
1748
1838
  /** Wallet / credit / outcome / unit balances. `GET …/:id/balances`. */
1749
1839
  balances(id: string): Promise<CustomerBalances>;
1840
+ /**
1841
+ * One page of the customer's wallet ledger — every movement of wallet
1842
+ * money, newest first — plus both wallet balances. Cursor-paginated: pass
1843
+ * back `nextCursor` as `cursor`. `GET /api/v1/customers/:id/wallet`.
1844
+ */
1845
+ wallet(id: string, params?: WalletLedgerParams): Promise<WalletLedgerPage>;
1846
+ /** {@link wallet}, addressing the customer by its `externalId`.
1847
+ * `GET /api/v1/customers/ext/:externalId/wallet`. */
1848
+ walletByExternalId(externalId: string, params?: WalletLedgerParams): Promise<WalletLedgerPage>;
1849
+ /**
1850
+ * Async iterator over the customer's WHOLE wallet ledger, newest first,
1851
+ * following the cursor. `params.cursor` is ignored.
1852
+ * `for await (const t of cnk.customers.iterateWallet(id)) { … }`
1853
+ */
1854
+ iterateWallet(id: string, params?: Omit<WalletLedgerParams, "cursor">): AsyncGenerator<WalletTransaction>;
1855
+ private walletPage;
1750
1856
  /** {@link balances}, addressing the customer by its `externalId`.
1751
1857
  * `GET /api/v1/customers/ext/:externalId/balances`. */
1752
1858
  balancesByExternalId(externalId: string): Promise<CustomerBalances>;
@@ -2406,4 +2512,4 @@ declare class NetworkError extends ClockNextError {
2406
2512
  });
2407
2513
  }
2408
2514
 
2409
- export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateTaxInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tax, type TaxBehavior, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateTaxInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, ValidationError, type WalletAdjustInput, type WalletInput, type WalletPool, type WalletSignal, signalToWire };
2515
+ export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateTaxInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tax, type TaxBehavior, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateTaxInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, ValidationError, type WalletAdjustInput, type WalletInput, type WalletLedgerPage, type WalletLedgerParams, type WalletPool, type WalletSignal, type WalletTransaction, type WalletTransactionSource, signalToWire };
package/dist/index.d.ts CHANGED
@@ -164,6 +164,8 @@ type OutcomeCompletionInput = CustomerRef & {
164
164
  runId: string;
165
165
  /** Optional member (email) this completion is attributed to. */
166
166
  member?: string;
167
+ /** Free-form metadata, stored as-is with this completion. Never priced. */
168
+ custom?: Record<string, unknown>;
167
169
  /** Idempotency key, auto-generated if omitted. Sending this completion twice
168
170
  * for the same run is already a safe no-op server-side, so this only
169
171
  * collapses a retry into one attempt rather than protecting against a
@@ -385,8 +387,9 @@ interface UsageLogOutcomeAttribution {
385
387
  interface UsageLogEntry {
386
388
  id: string;
387
389
  createdAt: string;
388
- /** Which meter this row is. */
389
- type: "credit" | "outcome" | "unit" | "wallet" | "composite";
390
+ /** Which meter this row is. `"outcome"` is one step of a run;
391
+ * `"outcome_completion"` is the finished run itself (one per run). */
392
+ type: "credit" | "outcome" | "outcome_completion" | "unit" | "wallet" | "composite";
390
393
  status: SignalStatus;
391
394
  typeName: string | null;
392
395
  member: string | null;
@@ -424,8 +427,22 @@ interface UsageLogEntry {
424
427
  composite: {
425
428
  amount: string;
426
429
  } | null;
427
- /** The `custom` object sent on the signal, as sent. `null` when none was
428
- * sent, and always `null` for unit and composite rows. */
430
+ /** Populated only when `type === "outcome_completion"`. `amount` is the
431
+ * price frozen when the run completed (your plan price, else the catalogue
432
+ * price). */
433
+ outcomeCompletion: {
434
+ runId: string | null;
435
+ amount: string;
436
+ runSignals: number;
437
+ } | null;
438
+ /** The composite that covers this row's billing, by name — the row's price
439
+ * is then included in that composite's own charge, not billed on top. Set
440
+ * on credit / outcome / unit / outcome_completion rows tagged into a
441
+ * composite on the customer's plan; `null` otherwise. */
442
+ coveredByComposite: string | null;
443
+ /** The `custom` object sent, as sent — on the signal itself, or on the
444
+ * `completeComposite()` / `completeOutcome()` call that closed a composite /
445
+ * outcome_completion row. `null` when none was sent. */
429
446
  custom: Record<string, unknown> | null;
430
447
  }
431
448
  interface UsageLogPage {
@@ -454,8 +471,6 @@ interface ApiCustomer {
454
471
  taxId: string | null;
455
472
  currencyCode: string;
456
473
  creditAllowance: number;
457
- recurringTransactionEmail: boolean;
458
- autoRecurring: boolean;
459
474
  createdAt: string;
460
475
  updatedAt: string;
461
476
  }
@@ -485,10 +500,6 @@ interface CustomerProfileInput {
485
500
  taxId?: string | null;
486
501
  /** ISO 4217 (3 letters); must be enabled for the org. */
487
502
  currencyCode?: string;
488
- /** Send the invoice, payment receipt and card-payment-failed emails for recurring invoices. Defaults to `true` on create. */
489
- recurringTransactionEmail?: boolean;
490
- /** Issue every recurring invoice as `AUTO_CLOSED` (applied as if paid, never payable). Defaults to `false` on create. */
491
- autoRecurring?: boolean;
492
503
  }
493
504
  /** `name` and `email` are required on create; every other field is optional. */
494
505
  type CreateCustomerInput = CustomerProfileInput & {
@@ -580,6 +591,79 @@ interface CustomerBalances {
580
591
  * isn't listed. */
581
592
  composites: CompositeBalance[];
582
593
  }
594
+ /** What caused a wallet ledger row (`WalletTransaction.source`). */
595
+ type WalletTransactionSource =
596
+ /** Wallet money from a new plan purchase. */
597
+ "SUBSCRIPTION"
598
+ /** Wallet money from a plan renewal, or unused money removed at renewal. */
599
+ | "RENEWAL"
600
+ /** Changed in the ClockNext dashboard. */
601
+ | "MANUAL"
602
+ /** Changed with `customers.adjustWallet()`. */
603
+ | "API"
604
+ /** Top-up paid by the customer in the customer portal. */
605
+ | "CUSTOMER_PORTAL"
606
+ /** Charged by a signal; `usageLogId` links the signal. */
607
+ | "USAGE_LOG"
608
+ /** Usage cleared by a paid pay-as-you-go invoice. */
609
+ | "INVOICE_SETTLEMENT"
610
+ /** Settlement undone by a voided invoice. */
611
+ | "INVOICE_VOID";
612
+ /** One row of a customer's wallet ledger (`customers.wallet()`). */
613
+ interface WalletTransaction {
614
+ id: string;
615
+ /** ISO 8601. */
616
+ createdAt: string;
617
+ /** `CREDIT` adds money, `DEBIT` takes it out. */
618
+ type: "CREDIT" | "DEBIT";
619
+ /** Which balance moved: the ordinary wallet or the Reserved Wallet. */
620
+ pool: "main" | "reserved";
621
+ source: WalletTransactionSource;
622
+ /** Always positive — `type` gives the direction. In `currencyCode`. */
623
+ amount: number;
624
+ /** The same amount in USD. */
625
+ amountUsd: number;
626
+ currencyCode: string;
627
+ /** 1 USD = this many units of `currencyCode`, at write time. */
628
+ currencyRateUsd: number;
629
+ /** Only text a person wrote: your own note on an `API` row, the admin's
630
+ * note on a `MANUAL` row. `null` on every row the system writes itself —
631
+ * `source` says what those are. */
632
+ notes: string | null;
633
+ /** On a usage charge for an entitlement: which kind. `null` otherwise. */
634
+ entitlementType: "CREDIT" | "OUTCOME" | "UNIT" | "COMPOSITE" | null;
635
+ /** Id of that credit / outcome / unit / composite. */
636
+ entitlementId: string | null;
637
+ /** Its name when the row was written. */
638
+ entitlementName: string | null;
639
+ /** On a `USAGE_LOG` row: the id of the matching row in
640
+ * `signals.usageLog()`. */
641
+ usageLogId: string | null;
642
+ /** On a `SUBSCRIPTION` / `RENEWAL` grant: the purchase it came from. */
643
+ purchaseId: string | null;
644
+ purchaseNumber: string | null;
645
+ }
646
+ /** One page of a customer's wallet ledger, newest first. */
647
+ interface WalletLedgerPage {
648
+ /** Ordinary wallet balance, USD. May be negative. */
649
+ balanceUsd: number;
650
+ /** Reserved Wallet balance, USD; `null` when the workspace hasn't enabled
651
+ * it. */
652
+ reservedBalanceUsd: number | null;
653
+ transactions: WalletTransaction[];
654
+ /** Pass back as `cursor` for the next page; `null` on the last page. */
655
+ nextCursor: string | null;
656
+ }
657
+ interface WalletLedgerParams {
658
+ /** Default 50, max 200. */
659
+ limit?: number;
660
+ /** A previous page's `nextCursor`. Omit for the first page. */
661
+ cursor?: string;
662
+ /** First day to include, `YYYY-MM-DD` (UTC). The whole day is included. */
663
+ from?: string;
664
+ /** Last day to include, `YYYY-MM-DD` (UTC). The whole day is included. */
665
+ to?: string;
666
+ }
583
667
  /** The customer's active plan (the `plan` field of `customers.plan()`);
584
668
  * `null` when the customer is unsubscribed. */
585
669
  interface CustomerPlanDetails {
@@ -1025,7 +1109,8 @@ interface PurchaseDetail {
1025
1109
  paidCount: number;
1026
1110
  };
1027
1111
  }
1028
- /** `AUTO_CLOSED` — a recurring invoice for a customer with `autoRecurring` on:
1112
+ /** `AUTO_CLOSED` — a recurring invoice of an organisation with "Auto close
1113
+ * invoices on recurring" on (dashboard: Settings → Organisation → Billing):
1029
1114
  * applied as if paid, but never payable. */
1030
1115
  type InvoiceStatus = "OPEN" | "PAID" | "VOID" | "AUTO_CLOSED";
1031
1116
  /** Trimmed row from `invoices.list()`. */
@@ -1398,6 +1483,8 @@ type UnitInput = CustomerRef & {
1398
1483
  quantity?: number;
1399
1484
  /** Optional composite this unit report belongs to. See {@link CompositeTag}. */
1400
1485
  composite?: CompositeTag;
1486
+ /** Free-form metadata, stored as-is with this unit report. Never priced. */
1487
+ custom?: Record<string, unknown>;
1401
1488
  /**
1402
1489
  * Idempotency key for safe retries — a repeat carrying the same key returns
1403
1490
  * the original result instead of drawing the balance down twice.
@@ -1447,6 +1534,9 @@ type CompositeCompletionInput = CustomerRef & {
1447
1534
  /** Which occurrence to close: the composite's `refId` and the correlation
1448
1535
  * value the signals were tagged with. */
1449
1536
  composite: CompositeTag;
1537
+ /** Free-form metadata, stored as-is on the occurrence this call closes.
1538
+ * Never priced. */
1539
+ custom?: Record<string, unknown>;
1450
1540
  /** Idempotency key, auto-generated if omitted. Closing twice is already a
1451
1541
  * safe no-op, so this only collapses retries into one recorded attempt
1452
1542
  * rather than protecting against a double charge. */
@@ -1747,6 +1837,22 @@ declare class Customers {
1747
1837
  delete(id: string): Promise<void>;
1748
1838
  /** Wallet / credit / outcome / unit balances. `GET …/:id/balances`. */
1749
1839
  balances(id: string): Promise<CustomerBalances>;
1840
+ /**
1841
+ * One page of the customer's wallet ledger — every movement of wallet
1842
+ * money, newest first — plus both wallet balances. Cursor-paginated: pass
1843
+ * back `nextCursor` as `cursor`. `GET /api/v1/customers/:id/wallet`.
1844
+ */
1845
+ wallet(id: string, params?: WalletLedgerParams): Promise<WalletLedgerPage>;
1846
+ /** {@link wallet}, addressing the customer by its `externalId`.
1847
+ * `GET /api/v1/customers/ext/:externalId/wallet`. */
1848
+ walletByExternalId(externalId: string, params?: WalletLedgerParams): Promise<WalletLedgerPage>;
1849
+ /**
1850
+ * Async iterator over the customer's WHOLE wallet ledger, newest first,
1851
+ * following the cursor. `params.cursor` is ignored.
1852
+ * `for await (const t of cnk.customers.iterateWallet(id)) { … }`
1853
+ */
1854
+ iterateWallet(id: string, params?: Omit<WalletLedgerParams, "cursor">): AsyncGenerator<WalletTransaction>;
1855
+ private walletPage;
1750
1856
  /** {@link balances}, addressing the customer by its `externalId`.
1751
1857
  * `GET /api/v1/customers/ext/:externalId/balances`. */
1752
1858
  balancesByExternalId(externalId: string): Promise<CustomerBalances>;
@@ -2406,4 +2512,4 @@ declare class NetworkError extends ClockNextError {
2406
2512
  });
2407
2513
  }
2408
2514
 
2409
- export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateTaxInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tax, type TaxBehavior, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateTaxInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, ValidationError, type WalletAdjustInput, type WalletInput, type WalletPool, type WalletSignal, signalToWire };
2515
+ export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateTaxInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tax, type TaxBehavior, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateTaxInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, ValidationError, type WalletAdjustInput, type WalletInput, type WalletLedgerPage, type WalletLedgerParams, type WalletPool, type WalletSignal, type WalletTransaction, type WalletTransactionSource, signalToWire };
package/dist/index.js CHANGED
@@ -331,7 +331,7 @@ function sleep(ms) {
331
331
  }
332
332
 
333
333
  // src/http.ts
334
- var SDK_VERSION = "0.18.0" ;
334
+ var SDK_VERSION = "0.19.0" ;
335
335
  var Transport = class {
336
336
  constructor(cfg) {
337
337
  this.cfg = cfg;
@@ -680,6 +680,47 @@ var Customers = class {
680
680
  path: `/api/v1/customers/${encodeURIComponent(id)}/balances`
681
681
  });
682
682
  }
683
+ /**
684
+ * One page of the customer's wallet ledger — every movement of wallet
685
+ * money, newest first — plus both wallet balances. Cursor-paginated: pass
686
+ * back `nextCursor` as `cursor`. `GET /api/v1/customers/:id/wallet`.
687
+ */
688
+ wallet(id, params = {}) {
689
+ return this.walletPage(`/api/v1/customers/${encodeURIComponent(id)}/wallet`, params);
690
+ }
691
+ /** {@link wallet}, addressing the customer by its `externalId`.
692
+ * `GET /api/v1/customers/ext/:externalId/wallet`. */
693
+ walletByExternalId(externalId, params = {}) {
694
+ return this.walletPage(
695
+ `/api/v1/customers/ext/${encodeURIComponent(externalId)}/wallet`,
696
+ params
697
+ );
698
+ }
699
+ /**
700
+ * Async iterator over the customer's WHOLE wallet ledger, newest first,
701
+ * following the cursor. `params.cursor` is ignored.
702
+ * `for await (const t of cnk.customers.iterateWallet(id)) { … }`
703
+ */
704
+ async *iterateWallet(id, params = {}) {
705
+ let cursor;
706
+ do {
707
+ const page = await this.wallet(id, { ...params, cursor });
708
+ for (const t of page.transactions) yield t;
709
+ cursor = page.nextCursor ?? void 0;
710
+ } while (cursor);
711
+ }
712
+ walletPage(path, params) {
713
+ return this.transport.request({
714
+ method: "GET",
715
+ path,
716
+ query: {
717
+ limit: params.limit,
718
+ cursor: params.cursor,
719
+ from: params.from,
720
+ to: params.to
721
+ }
722
+ });
723
+ }
683
724
  /** {@link balances}, addressing the customer by its `externalId`.
684
725
  * `GET /api/v1/customers/ext/:externalId/balances`. */
685
726
  balancesByExternalId(externalId) {
@@ -1304,6 +1345,7 @@ var Signals = class {
1304
1345
  ...customerRefToWire(input),
1305
1346
  runId: input.runId,
1306
1347
  ...input.member ? { member: input.member } : {},
1348
+ ...input.custom ? { custom: input.custom } : {},
1307
1349
  idempotencyKey
1308
1350
  },
1309
1351
  retry: true
@@ -1341,6 +1383,7 @@ var Signals = class {
1341
1383
  ...input.quantity != null ? { quantity: input.quantity } : {},
1342
1384
  ...input.member ? { member: input.member } : {},
1343
1385
  ...input.composite ? { composite: { [input.composite.ref]: input.composite.value } } : {},
1386
+ ...input.custom ? { custom: input.custom } : {},
1344
1387
  // Assigned HERE, before the send, so the SAME key rides every
1345
1388
  // transport-level retry below. Without it a single 500 followed by a
1346
1389
  // success is TWO un-keyed reports, and the server dedups on the key —
@@ -1395,6 +1438,7 @@ var Signals = class {
1395
1438
  body: {
1396
1439
  ...customerRefToWire(input),
1397
1440
  composite: { [input.composite.ref]: input.composite.value },
1441
+ ...input.custom ? { custom: input.custom } : {},
1398
1442
  // Auto-assigned like the others. A retry here could not double-BILL
1399
1443
  // even without it — closing a closed occurrence is a server-side
1400
1444
  // no-op — but that safety comes from occurrence-level dedup, not from