@crvouga/mockingbird-service-paddle 2.0.0 → 2.1.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.
@@ -3,7 +3,7 @@ import {
3
3
  createRuntime,
4
4
  parseDuration,
5
5
  resolveAdminPrefix
6
- } from "./chunk-XGQMUZI5.js";
6
+ } from "./chunk-RX7CMM47.js";
7
7
 
8
8
  // ../../adapters/node/dist/cli.js
9
9
  import { readFile as readFile2 } from "node:fs/promises";
@@ -857,4 +857,4 @@ export {
857
857
  createServer2 as createServer,
858
858
  serveTarget
859
859
  };
860
- //# sourceMappingURL=chunk-EBTO3BI2.js.map
860
+ //# sourceMappingURL=chunk-VDA33BHD.js.map
package/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-EBTO3BI2.js";
7
- import "./chunk-XGQMUZI5.js";
6
+ } from "./chunk-VDA33BHD.js";
7
+ import "./chunk-RX7CMM47.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -1001,6 +1001,41 @@ type EventRecord = {
1001
1001
  notification_id: null;
1002
1002
  data: Record<string, unknown>;
1003
1003
  };
1004
+ type NotificationTrafficSource = "platform" | "simulation" | "all";
1005
+ /** A vendor notification destination. `endpoint_secret_key` is stored always and disclosed on create only. */
1006
+ type NotificationSettingRecord = {
1007
+ id: string;
1008
+ description: string;
1009
+ type: "url" | "email";
1010
+ destination: string;
1011
+ active: boolean;
1012
+ api_version: number;
1013
+ traffic_source: NotificationTrafficSource;
1014
+ include_sensitive_fields: boolean;
1015
+ /** Event type names. The wire view returns `{ name }` objects. */
1016
+ subscribed_events: string[];
1017
+ endpoint_secret_key: string;
1018
+ created_at: string;
1019
+ updated_at: string;
1020
+ };
1021
+ type PortalSubscriptionLinks = {
1022
+ id: string;
1023
+ cancel_subscription: string;
1024
+ update_subscription_payment_method: string;
1025
+ update_subscription: string;
1026
+ };
1027
+ /** A customer portal session. The links are temporary https URLs; no portal page is served. */
1028
+ type PortalSessionRecord = {
1029
+ id: string;
1030
+ customer_id: string;
1031
+ created_at: string;
1032
+ urls: {
1033
+ general: {
1034
+ overview: string;
1035
+ };
1036
+ subscriptions: PortalSubscriptionLinks[];
1037
+ };
1038
+ };
1004
1039
 
1005
1040
  /** Paddle id prefixes, per entity. */
1006
1041
  declare const ID_PREFIX: {
@@ -1013,6 +1048,8 @@ declare const ID_PREFIX: {
1013
1048
  readonly subscription: "sub";
1014
1049
  readonly event: "evt";
1015
1050
  readonly notification: "ntf";
1051
+ readonly notification_setting: "ntfset";
1052
+ readonly portal_session: "cpls";
1016
1053
  readonly line_item: "txnitm";
1017
1054
  readonly payment_attempt: "payatt";
1018
1055
  readonly payment_method: "paymtd";
@@ -1030,6 +1067,8 @@ declare class PaddleState {
1030
1067
  /** Queued one-time charges per subscription id. */
1031
1068
  readonly pendingCharges: Collection<PendingCharge[]>;
1032
1069
  readonly events: Collection<EventRecord>;
1070
+ readonly notificationSettings: Collection<NotificationSettingRecord>;
1071
+ readonly portalSessions: Collection<PortalSessionRecord>;
1033
1072
  private readonly ids;
1034
1073
  constructor(sqlite: SqliteClient, namespace: string);
1035
1074
  /**
@@ -1220,10 +1259,10 @@ type OpenAPIDocument = {
1220
1259
  };
1221
1260
 
1222
1261
  declare const document: OpenAPIDocument;
1223
- type OperationId = "ListCustomers" | "CreateCustomer" | "GetCustomer" | "UpdateCustomer" | "GetCustomerCreditBalances" | "CreateCustomerAuthToken" | "ListAddresses" | "CreateAddress" | "GetAddress" | "UpdateAddress" | "ListBusinesses" | "CreateBusiness" | "GetBusiness" | "UpdateBusiness" | "ListProducts" | "CreateProduct" | "GetProduct" | "UpdateProduct" | "ListPrices" | "CreatePrice" | "GetPrice" | "UpdatePrice" | "ListTransactions" | "CreateTransaction" | "PreviewTransaction" | "GetTransaction" | "UpdateTransaction" | "GetTransactionInvoice" | "ReviseTransaction" | "ListSubscriptions" | "GetSubscription" | "UpdateSubscription" | "PreviewSubscriptionUpdate" | "ActivateSubscription" | "PauseSubscription" | "ResumeSubscription" | "CancelSubscription" | "CreateSubscriptionCharge" | "PreviewSubscriptionCharge" | "GetSubscriptionPaymentMethodChangeTransaction" | "ListEvents" | "ListNotificationSettings" | "CreateNotificationSetting" | "ListDiscounts" | "CreateDiscount" | "ListAdjustments" | "CreateAdjustment" | "CreateCustomerPortalSession";
1224
- type SupportedOperationId = "ListCustomers" | "CreateCustomer" | "GetCustomer" | "UpdateCustomer" | "GetCustomerCreditBalances" | "CreateCustomerAuthToken" | "ListAddresses" | "CreateAddress" | "GetAddress" | "UpdateAddress" | "ListBusinesses" | "CreateBusiness" | "GetBusiness" | "UpdateBusiness" | "ListProducts" | "CreateProduct" | "GetProduct" | "UpdateProduct" | "ListPrices" | "CreatePrice" | "GetPrice" | "UpdatePrice" | "ListTransactions" | "CreateTransaction" | "PreviewTransaction" | "GetTransaction" | "UpdateTransaction" | "GetTransactionInvoice" | "ListSubscriptions" | "GetSubscription" | "UpdateSubscription" | "ActivateSubscription" | "PauseSubscription" | "ResumeSubscription" | "CancelSubscription" | "CreateSubscriptionCharge" | "ListEvents";
1225
- declare const operationIds: readonly ["ListCustomers", "CreateCustomer", "GetCustomer", "UpdateCustomer", "GetCustomerCreditBalances", "CreateCustomerAuthToken", "ListAddresses", "CreateAddress", "GetAddress", "UpdateAddress", "ListBusinesses", "CreateBusiness", "GetBusiness", "UpdateBusiness", "ListProducts", "CreateProduct", "GetProduct", "UpdateProduct", "ListPrices", "CreatePrice", "GetPrice", "UpdatePrice", "ListTransactions", "CreateTransaction", "PreviewTransaction", "GetTransaction", "UpdateTransaction", "GetTransactionInvoice", "ReviseTransaction", "ListSubscriptions", "GetSubscription", "UpdateSubscription", "PreviewSubscriptionUpdate", "ActivateSubscription", "PauseSubscription", "ResumeSubscription", "CancelSubscription", "CreateSubscriptionCharge", "PreviewSubscriptionCharge", "GetSubscriptionPaymentMethodChangeTransaction", "ListEvents", "ListNotificationSettings", "CreateNotificationSetting", "ListDiscounts", "CreateDiscount", "ListAdjustments", "CreateAdjustment", "CreateCustomerPortalSession"];
1226
- declare const supportedOperationIds: readonly ["ListCustomers", "CreateCustomer", "GetCustomer", "UpdateCustomer", "GetCustomerCreditBalances", "CreateCustomerAuthToken", "ListAddresses", "CreateAddress", "GetAddress", "UpdateAddress", "ListBusinesses", "CreateBusiness", "GetBusiness", "UpdateBusiness", "ListProducts", "CreateProduct", "GetProduct", "UpdateProduct", "ListPrices", "CreatePrice", "GetPrice", "UpdatePrice", "ListTransactions", "CreateTransaction", "PreviewTransaction", "GetTransaction", "UpdateTransaction", "GetTransactionInvoice", "ListSubscriptions", "GetSubscription", "UpdateSubscription", "ActivateSubscription", "PauseSubscription", "ResumeSubscription", "CancelSubscription", "CreateSubscriptionCharge", "ListEvents"];
1262
+ type OperationId = "ListCustomers" | "CreateCustomer" | "GetCustomer" | "UpdateCustomer" | "GetCustomerCreditBalances" | "CreateCustomerAuthToken" | "ListAddresses" | "CreateAddress" | "GetAddress" | "UpdateAddress" | "ListBusinesses" | "CreateBusiness" | "GetBusiness" | "UpdateBusiness" | "ListProducts" | "CreateProduct" | "GetProduct" | "UpdateProduct" | "ListPrices" | "CreatePrice" | "GetPrice" | "UpdatePrice" | "ListTransactions" | "CreateTransaction" | "PreviewTransaction" | "GetTransaction" | "UpdateTransaction" | "GetTransactionInvoice" | "ReviseTransaction" | "ListSubscriptions" | "GetSubscription" | "UpdateSubscription" | "PreviewSubscriptionUpdate" | "ActivateSubscription" | "PauseSubscription" | "ResumeSubscription" | "CancelSubscription" | "CreateSubscriptionCharge" | "PreviewSubscriptionCharge" | "GetSubscriptionPaymentMethodChangeTransaction" | "ListEvents" | "ListNotificationSettings" | "CreateNotificationSetting" | "GetNotificationSetting" | "UpdateNotificationSetting" | "ListDiscounts" | "CreateDiscount" | "ListAdjustments" | "CreateAdjustment" | "CreateCustomerPortalSession";
1263
+ type SupportedOperationId = "ListCustomers" | "CreateCustomer" | "GetCustomer" | "UpdateCustomer" | "GetCustomerCreditBalances" | "CreateCustomerAuthToken" | "ListAddresses" | "CreateAddress" | "GetAddress" | "UpdateAddress" | "ListBusinesses" | "CreateBusiness" | "GetBusiness" | "UpdateBusiness" | "ListProducts" | "CreateProduct" | "GetProduct" | "UpdateProduct" | "ListPrices" | "CreatePrice" | "GetPrice" | "UpdatePrice" | "ListTransactions" | "CreateTransaction" | "PreviewTransaction" | "GetTransaction" | "UpdateTransaction" | "GetTransactionInvoice" | "ListSubscriptions" | "GetSubscription" | "UpdateSubscription" | "ActivateSubscription" | "PauseSubscription" | "ResumeSubscription" | "CancelSubscription" | "CreateSubscriptionCharge" | "ListEvents" | "ListNotificationSettings" | "CreateNotificationSetting" | "GetNotificationSetting" | "UpdateNotificationSetting" | "CreateCustomerPortalSession";
1264
+ declare const operationIds: readonly ["ListCustomers", "CreateCustomer", "GetCustomer", "UpdateCustomer", "GetCustomerCreditBalances", "CreateCustomerAuthToken", "ListAddresses", "CreateAddress", "GetAddress", "UpdateAddress", "ListBusinesses", "CreateBusiness", "GetBusiness", "UpdateBusiness", "ListProducts", "CreateProduct", "GetProduct", "UpdateProduct", "ListPrices", "CreatePrice", "GetPrice", "UpdatePrice", "ListTransactions", "CreateTransaction", "PreviewTransaction", "GetTransaction", "UpdateTransaction", "GetTransactionInvoice", "ReviseTransaction", "ListSubscriptions", "GetSubscription", "UpdateSubscription", "PreviewSubscriptionUpdate", "ActivateSubscription", "PauseSubscription", "ResumeSubscription", "CancelSubscription", "CreateSubscriptionCharge", "PreviewSubscriptionCharge", "GetSubscriptionPaymentMethodChangeTransaction", "ListEvents", "ListNotificationSettings", "CreateNotificationSetting", "GetNotificationSetting", "UpdateNotificationSetting", "ListDiscounts", "CreateDiscount", "ListAdjustments", "CreateAdjustment", "CreateCustomerPortalSession"];
1265
+ declare const supportedOperationIds: readonly ["ListCustomers", "CreateCustomer", "GetCustomer", "UpdateCustomer", "GetCustomerCreditBalances", "CreateCustomerAuthToken", "ListAddresses", "CreateAddress", "GetAddress", "UpdateAddress", "ListBusinesses", "CreateBusiness", "GetBusiness", "UpdateBusiness", "ListProducts", "CreateProduct", "GetProduct", "UpdateProduct", "ListPrices", "CreatePrice", "GetPrice", "UpdatePrice", "ListTransactions", "CreateTransaction", "PreviewTransaction", "GetTransaction", "UpdateTransaction", "GetTransactionInvoice", "ListSubscriptions", "GetSubscription", "UpdateSubscription", "ActivateSubscription", "PauseSubscription", "ResumeSubscription", "CancelSubscription", "CreateSubscriptionCharge", "ListEvents", "ListNotificationSettings", "CreateNotificationSetting", "GetNotificationSetting", "UpdateNotificationSetting", "CreateCustomerPortalSession"];
1227
1266
 
1228
1267
  /**
1229
1268
  * Every named Paddle misbehaviour a consumer branches on, switched on with
@@ -1308,6 +1347,16 @@ type PaddleAPIOptions = APIOptions & {
1308
1347
  paymentLink?: string;
1309
1348
  /** Called with every event the account produces (the body a webhook would carry). */
1310
1349
  onEvent?: (event: EventRecord) => void;
1350
+ /**
1351
+ * Active URL notification destinations, replaced whenever they change. The runtime registers
1352
+ * them on the webhook hub without dropping admin-configured endpoints.
1353
+ */
1354
+ onDestinations?: (endpoints: {
1355
+ id: string;
1356
+ url: string;
1357
+ secret: string;
1358
+ events: string[];
1359
+ }[]) => void;
1311
1360
  /**
1312
1361
  * Seed the fixture account (`seedFixtures`) on construction when the namespace is empty, and
1313
1362
  * again after every `reset()`. Fixture events are recorded (`GET /events`) but not passed to
@@ -1331,6 +1380,7 @@ declare class PaddleAPI implements FetchAPI$1 {
1331
1380
  private readonly publicNamespace;
1332
1381
  private readonly paymentLink;
1333
1382
  private readonly onEvent;
1383
+ private readonly onDestinations;
1334
1384
  private readonly fixtures;
1335
1385
  private readonly requestIds;
1336
1386
  private requestCounter;
@@ -1497,6 +1547,27 @@ declare class PaddleAPI implements FetchAPI$1 {
1497
1547
  private cancelSubscription;
1498
1548
  private chargeSubscription;
1499
1549
  private listEvents;
1550
+ /**
1551
+ * Active `url` destinations as webhook endpoints. Derived from the notification-settings
1552
+ * collection so a timeline restore brings the same rows back; the runtime merges them
1553
+ * into the webhook hub beside admin endpoints.
1554
+ */
1555
+ notificationDestinations(): {
1556
+ id: string;
1557
+ url: string;
1558
+ secret: string;
1559
+ events: string[];
1560
+ }[];
1561
+ private syncDestinations;
1562
+ private eventNames;
1563
+ private notificationView;
1564
+ private mustNotificationSetting;
1565
+ private listNotificationSettings;
1566
+ private createNotificationSetting;
1567
+ private getNotificationSetting;
1568
+ private updateNotificationSetting;
1569
+ private portalLink;
1570
+ private createPortalSession;
1500
1571
  /**
1501
1572
  * A small account to start from: a customer with an address and a business, a "Pro" product
1502
1573
  * with monthly, yearly and one-time prices, a "Starter" price with a 14-day trial, an active
@@ -1527,4 +1598,4 @@ declare class PaddleAPI implements FetchAPI$1 {
1527
1598
  }
1528
1599
 
1529
1600
  export { AUTH_TOKEN_TTL_MS, ID_PREFIX, PADDLE_NAMESPACE, PADDLE_PRESETS, PaddleAPI, PaddleError, PaddleState, createRuntime, document, operationIds, paddleSigner, supportedOperationIds };
1530
- export type { AddressRecord, BillingDetails, BusinessRecord, CardInput, CheckoutInput, CollectionMode, CustomData, CustomerRecord, EventRecord, FetchAPI$1 as FetchAPI, LineItem, OperationId, PaddleAPIOptions, PaddleRuntime, PaddleRuntimeOptions, PaymentAttempt, Period, PreviewDetails, PriceRecord, ProductRecord, ScheduledChange, SqliteClient, SubscriptionItem, SubscriptionRecord, SubscriptionStatus, SupportedOperationId, TimePeriod, TransactionItem, TransactionOrigin, TransactionRecord, TransactionStatus, TrialPeriod };
1601
+ export type { AddressRecord, BillingDetails, BusinessRecord, CardInput, CheckoutInput, CollectionMode, CustomData, CustomerRecord, EventRecord, FetchAPI$1 as FetchAPI, LineItem, NotificationSettingRecord, NotificationTrafficSource, OperationId, PaddleAPIOptions, PaddleRuntime, PaddleRuntimeOptions, PaymentAttempt, Period, PortalSessionRecord, PreviewDetails, PriceRecord, ProductRecord, ScheduledChange, SqliteClient, SubscriptionItem, SubscriptionRecord, SubscriptionStatus, SupportedOperationId, TimePeriod, TransactionItem, TransactionOrigin, TransactionRecord, TransactionStatus, TrialPeriod };
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  operationIds,
12
12
  paddleSigner,
13
13
  supportedOperationIds
14
- } from "./chunk-XGQMUZI5.js";
14
+ } from "./chunk-RX7CMM47.js";
15
15
  export {
16
16
  AUTH_TOKEN_TTL_MS,
17
17
  ID_PREFIX,
package/dist/server.d.ts CHANGED
@@ -1566,6 +1566,41 @@ type EventRecord = {
1566
1566
  notification_id: null;
1567
1567
  data: Record<string, unknown>;
1568
1568
  };
1569
+ type NotificationTrafficSource = "platform" | "simulation" | "all";
1570
+ /** A vendor notification destination. `endpoint_secret_key` is stored always and disclosed on create only. */
1571
+ type NotificationSettingRecord = {
1572
+ id: string;
1573
+ description: string;
1574
+ type: "url" | "email";
1575
+ destination: string;
1576
+ active: boolean;
1577
+ api_version: number;
1578
+ traffic_source: NotificationTrafficSource;
1579
+ include_sensitive_fields: boolean;
1580
+ /** Event type names. The wire view returns `{ name }` objects. */
1581
+ subscribed_events: string[];
1582
+ endpoint_secret_key: string;
1583
+ created_at: string;
1584
+ updated_at: string;
1585
+ };
1586
+ type PortalSubscriptionLinks = {
1587
+ id: string;
1588
+ cancel_subscription: string;
1589
+ update_subscription_payment_method: string;
1590
+ update_subscription: string;
1591
+ };
1592
+ /** A customer portal session. The links are temporary https URLs; no portal page is served. */
1593
+ type PortalSessionRecord = {
1594
+ id: string;
1595
+ customer_id: string;
1596
+ created_at: string;
1597
+ urls: {
1598
+ general: {
1599
+ overview: string;
1600
+ };
1601
+ subscriptions: PortalSubscriptionLinks[];
1602
+ };
1603
+ };
1569
1604
 
1570
1605
  /** Paddle id prefixes, per entity. */
1571
1606
  declare const ID_PREFIX: {
@@ -1578,6 +1613,8 @@ declare const ID_PREFIX: {
1578
1613
  readonly subscription: "sub";
1579
1614
  readonly event: "evt";
1580
1615
  readonly notification: "ntf";
1616
+ readonly notification_setting: "ntfset";
1617
+ readonly portal_session: "cpls";
1581
1618
  readonly line_item: "txnitm";
1582
1619
  readonly payment_attempt: "payatt";
1583
1620
  readonly payment_method: "paymtd";
@@ -1595,6 +1632,8 @@ declare class PaddleState {
1595
1632
  /** Queued one-time charges per subscription id. */
1596
1633
  readonly pendingCharges: Collection<PendingCharge[]>;
1597
1634
  readonly events: Collection<EventRecord>;
1635
+ readonly notificationSettings: Collection<NotificationSettingRecord>;
1636
+ readonly portalSessions: Collection<PortalSessionRecord>;
1598
1637
  private readonly ids;
1599
1638
  constructor(sqlite: SqliteClient, namespace: string);
1600
1639
  /**
@@ -1643,6 +1682,16 @@ type PaddleAPIOptions = APIOptions & {
1643
1682
  paymentLink?: string;
1644
1683
  /** Called with every event the account produces (the body a webhook would carry). */
1645
1684
  onEvent?: (event: EventRecord) => void;
1685
+ /**
1686
+ * Active URL notification destinations, replaced whenever they change. The runtime registers
1687
+ * them on the webhook hub without dropping admin-configured endpoints.
1688
+ */
1689
+ onDestinations?: (endpoints: {
1690
+ id: string;
1691
+ url: string;
1692
+ secret: string;
1693
+ events: string[];
1694
+ }[]) => void;
1646
1695
  /**
1647
1696
  * Seed the fixture account (`seedFixtures`) on construction when the namespace is empty, and
1648
1697
  * again after every `reset()`. Fixture events are recorded (`GET /events`) but not passed to
@@ -1666,6 +1715,7 @@ declare class PaddleAPI implements FetchAPI {
1666
1715
  private readonly publicNamespace;
1667
1716
  private readonly paymentLink;
1668
1717
  private readonly onEvent;
1718
+ private readonly onDestinations;
1669
1719
  private readonly fixtures;
1670
1720
  private readonly requestIds;
1671
1721
  private requestCounter;
@@ -1832,6 +1882,27 @@ declare class PaddleAPI implements FetchAPI {
1832
1882
  private cancelSubscription;
1833
1883
  private chargeSubscription;
1834
1884
  private listEvents;
1885
+ /**
1886
+ * Active `url` destinations as webhook endpoints. Derived from the notification-settings
1887
+ * collection so a timeline restore brings the same rows back; the runtime merges them
1888
+ * into the webhook hub beside admin endpoints.
1889
+ */
1890
+ notificationDestinations(): {
1891
+ id: string;
1892
+ url: string;
1893
+ secret: string;
1894
+ events: string[];
1895
+ }[];
1896
+ private syncDestinations;
1897
+ private eventNames;
1898
+ private notificationView;
1899
+ private mustNotificationSetting;
1900
+ private listNotificationSettings;
1901
+ private createNotificationSetting;
1902
+ private getNotificationSetting;
1903
+ private updateNotificationSetting;
1904
+ private portalLink;
1905
+ private createPortalSession;
1835
1906
  /**
1836
1907
  * A small account to start from: a customer with an address and a business, a "Pro" product
1837
1908
  * with monthly, yearly and one-time prices, a "Starter" price with a 14-day trial, an active
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-EBTO3BI2.js";
6
- import "./chunk-XGQMUZI5.js";
5
+ } from "./chunk-VDA33BHD.js";
6
+ import "./chunk-RX7CMM47.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,