@stackbe/sdk 0.7.4 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1256,7 +1256,8 @@ declare class OrganizationsClient {
1256
1256
  role: 'admin' | 'member';
1257
1257
  }): Promise<OrganizationMember>;
1258
1258
  /**
1259
- * Send an invite to join an organization.
1259
+ * Send an invite email to join an organization.
1260
+ * The recipient will receive a magic link.
1260
1261
  *
1261
1262
  * @example
1262
1263
  * ```typescript
@@ -1267,6 +1268,21 @@ declare class OrganizationsClient {
1267
1268
  * ```
1268
1269
  */
1269
1270
  invite(orgId: string, options: InviteMemberOptions): Promise<OrganizationInvite>;
1271
+ /**
1272
+ * List all members and pending invites for an organization.
1273
+ *
1274
+ * @example
1275
+ * ```typescript
1276
+ * const { members, invites } = await stackbe.organizations.listMembers('org_123');
1277
+ *
1278
+ * members.forEach(m => console.log(`${m.customer.email} - ${m.role}`));
1279
+ * invites.forEach(i => console.log(`Pending: ${i.email}`));
1280
+ * ```
1281
+ */
1282
+ listMembers(orgId: string): Promise<{
1283
+ members: OrganizationMember[];
1284
+ invites: OrganizationInvite[];
1285
+ }>;
1270
1286
  /**
1271
1287
  * List pending invites for an organization.
1272
1288
  *
@@ -1653,6 +1669,252 @@ declare class FeatureRequestsClient {
1653
1669
  getCustomerActivity(customerId: string): Promise<CustomerFeatureActivity>;
1654
1670
  }
1655
1671
 
1672
+ interface AffiliateInfo {
1673
+ enrolled: boolean;
1674
+ id?: string;
1675
+ code?: string;
1676
+ status?: 'active' | 'suspended' | 'pending';
1677
+ totalEarned?: number;
1678
+ pendingBalance?: number;
1679
+ paidOut?: number;
1680
+ totalReferrals?: number;
1681
+ totalConversions?: number;
1682
+ createdAt?: string;
1683
+ }
1684
+ interface AffiliateEnrollment {
1685
+ id: string;
1686
+ code: string;
1687
+ status: string;
1688
+ createdAt: string;
1689
+ }
1690
+ interface AffiliateStats {
1691
+ enrolled: boolean;
1692
+ totalEarned: number;
1693
+ pendingBalance: number;
1694
+ paidOut: number;
1695
+ totalReferrals: number;
1696
+ totalConversions: number;
1697
+ }
1698
+ interface AffiliateCommission {
1699
+ id: string;
1700
+ amount: number;
1701
+ currency: string;
1702
+ status: 'pending' | 'approved' | 'paid' | 'rejected';
1703
+ createdAt: string;
1704
+ referredCustomerEmail?: string;
1705
+ }
1706
+ interface AffiliateCommissionsResponse {
1707
+ commissions: AffiliateCommission[];
1708
+ total: number;
1709
+ }
1710
+ interface TrackReferralResponse {
1711
+ token: string;
1712
+ expiresInDays: number;
1713
+ }
1714
+ interface EnrollOptions {
1715
+ /** Preferred referral code (auto-generated if not provided) */
1716
+ code?: string;
1717
+ /** PayPal email for payouts */
1718
+ payoutEmail?: string;
1719
+ }
1720
+ declare class AffiliatesClient {
1721
+ private http;
1722
+ constructor(http: HttpClient);
1723
+ /**
1724
+ * Get the current customer's affiliate info.
1725
+ * Requires customer session token.
1726
+ *
1727
+ * @example
1728
+ * ```typescript
1729
+ * const affiliate = await stackbe.affiliates.get();
1730
+ *
1731
+ * if (affiliate.enrolled) {
1732
+ * console.log(`Your referral code: ${affiliate.code}`);
1733
+ * console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
1734
+ * } else {
1735
+ * console.log('Not enrolled in affiliate program');
1736
+ * }
1737
+ * ```
1738
+ */
1739
+ get(): Promise<AffiliateInfo>;
1740
+ /**
1741
+ * Enroll the current customer as an affiliate.
1742
+ * Requires customer session token.
1743
+ *
1744
+ * @example
1745
+ * ```typescript
1746
+ * // Enroll with auto-generated code
1747
+ * const affiliate = await stackbe.affiliates.enroll();
1748
+ * console.log(`Your referral code: ${affiliate.code}`);
1749
+ *
1750
+ * // Enroll with custom code
1751
+ * const affiliate = await stackbe.affiliates.enroll({
1752
+ * code: 'MYCODE',
1753
+ * payoutEmail: 'payouts@example.com',
1754
+ * });
1755
+ * ```
1756
+ */
1757
+ enroll(options?: EnrollOptions): Promise<AffiliateEnrollment>;
1758
+ /**
1759
+ * Get affiliate statistics.
1760
+ * Requires customer session token.
1761
+ *
1762
+ * @example
1763
+ * ```typescript
1764
+ * const stats = await stackbe.affiliates.getStats();
1765
+ *
1766
+ * if (stats.enrolled) {
1767
+ * console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
1768
+ * console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
1769
+ * console.log(`Referrals: ${stats.totalReferrals}`);
1770
+ * console.log(`Conversions: ${stats.totalConversions}`);
1771
+ * }
1772
+ * ```
1773
+ */
1774
+ getStats(): Promise<AffiliateStats>;
1775
+ /**
1776
+ * Get affiliate commission history.
1777
+ * Requires customer session token.
1778
+ *
1779
+ * @example
1780
+ * ```typescript
1781
+ * const { commissions, total } = await stackbe.affiliates.getCommissions();
1782
+ *
1783
+ * commissions.forEach((c) => {
1784
+ * console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
1785
+ * });
1786
+ * ```
1787
+ */
1788
+ getCommissions(): Promise<AffiliateCommissionsResponse>;
1789
+ /**
1790
+ * Track a referral click (store token for attribution).
1791
+ * Call this when a user lands on your site with a referral code.
1792
+ * Requires API key.
1793
+ *
1794
+ * @example
1795
+ * ```typescript
1796
+ * // In your landing page handler
1797
+ * const refCode = req.query.ref;
1798
+ * if (refCode) {
1799
+ * const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
1800
+ * // Store token in cookie for attribution on signup
1801
+ * res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
1802
+ * }
1803
+ * ```
1804
+ */
1805
+ trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
1806
+ }
1807
+
1808
+ interface EarlyAccessSignup {
1809
+ id: string;
1810
+ status: 'new' | 'invited' | 'converted' | 'archived';
1811
+ email: string;
1812
+ name?: string;
1813
+ createdAt: string;
1814
+ }
1815
+ interface CreateEarlyAccessSignupOptions {
1816
+ email: string;
1817
+ name?: string;
1818
+ note?: string;
1819
+ metadata?: Record<string, any>;
1820
+ }
1821
+ interface EarlyAccessSignupListResponse {
1822
+ items: Array<{
1823
+ id: string;
1824
+ email: string;
1825
+ name?: string;
1826
+ status: string;
1827
+ metadata?: Record<string, any>;
1828
+ createdAt: string;
1829
+ }>;
1830
+ page: number;
1831
+ limit: number;
1832
+ total: number;
1833
+ hasMore: boolean;
1834
+ }
1835
+ interface ListEarlyAccessOptions {
1836
+ status?: 'new' | 'invited' | 'converted' | 'archived';
1837
+ search?: string;
1838
+ limit?: number;
1839
+ offset?: number;
1840
+ }
1841
+ declare class EarlyAccessClient {
1842
+ private http;
1843
+ private appId;
1844
+ constructor(http: HttpClient, appId: string);
1845
+ /**
1846
+ * Submit an early access / waitlist signup.
1847
+ * This is a public endpoint - no auth required.
1848
+ *
1849
+ * @example
1850
+ * ```typescript
1851
+ * // Basic signup
1852
+ * const signup = await stackbe.earlyAccess.signup({
1853
+ * email: 'user@example.com',
1854
+ * });
1855
+ *
1856
+ * // With additional info
1857
+ * const signup = await stackbe.earlyAccess.signup({
1858
+ * email: 'user@example.com',
1859
+ * name: 'John Doe',
1860
+ * note: 'Interested in enterprise features',
1861
+ * metadata: { source: 'landing_page', campaign: 'launch' },
1862
+ * });
1863
+ *
1864
+ * console.log(`Signup ID: ${signup.id}`);
1865
+ * ```
1866
+ */
1867
+ signup(options: CreateEarlyAccessSignupOptions): Promise<EarlyAccessSignup>;
1868
+ /**
1869
+ * List early access signups.
1870
+ * Requires API key (admin).
1871
+ *
1872
+ * @example
1873
+ * ```typescript
1874
+ * // Get all signups
1875
+ * const { items, total } = await stackbe.earlyAccess.list();
1876
+ *
1877
+ * // Filter by status
1878
+ * const newSignups = await stackbe.earlyAccess.list({ status: 'new' });
1879
+ *
1880
+ * // Search by email
1881
+ * const results = await stackbe.earlyAccess.list({ search: 'example.com' });
1882
+ *
1883
+ * // Paginate
1884
+ * const page2 = await stackbe.earlyAccess.list({ offset: 50, limit: 50 });
1885
+ * ```
1886
+ */
1887
+ list(options?: ListEarlyAccessOptions): Promise<EarlyAccessSignupListResponse>;
1888
+ /**
1889
+ * Get a specific early access signup.
1890
+ * Requires API key (admin).
1891
+ *
1892
+ * @example
1893
+ * ```typescript
1894
+ * const signup = await stackbe.earlyAccess.get('signup_123');
1895
+ * console.log(`${signup.email} - ${signup.status}`);
1896
+ * ```
1897
+ */
1898
+ get(signupId: string): Promise<EarlyAccessSignup>;
1899
+ /**
1900
+ * Update the status of an early access signup.
1901
+ * Requires API key (admin).
1902
+ *
1903
+ * @example
1904
+ * ```typescript
1905
+ * // Mark as invited
1906
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'invited');
1907
+ *
1908
+ * // Mark as converted (user signed up)
1909
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'converted');
1910
+ *
1911
+ * // Archive
1912
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'archived');
1913
+ * ```
1914
+ */
1915
+ updateStatus(signupId: string, status: 'new' | 'invited' | 'converted' | 'archived'): Promise<EarlyAccessSignup>;
1916
+ }
1917
+
1656
1918
  declare class StackBE {
1657
1919
  private http;
1658
1920
  private appId;
@@ -1676,6 +1938,10 @@ declare class StackBE {
1676
1938
  readonly products: ProductsClient;
1677
1939
  /** Feature requests and voting */
1678
1940
  readonly featureRequests: FeatureRequestsClient;
1941
+ /** Affiliate program (customer-facing) */
1942
+ readonly affiliates: AffiliatesClient;
1943
+ /** Early access / waitlist signups */
1944
+ readonly earlyAccess: EarlyAccessClient;
1679
1945
  /**
1680
1946
  * Create a new StackBE client.
1681
1947
  *
@@ -1776,4 +2042,4 @@ declare class StackBE {
1776
2042
  }): (req: any, res: any, next: any) => Promise<any>;
1777
2043
  }
1778
2044
 
1779
- export { type AddMemberOptions, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestListResponse, FeatureRequestsClient, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
2045
+ export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestListResponse, FeatureRequestsClient, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
package/dist/index.d.ts CHANGED
@@ -1256,7 +1256,8 @@ declare class OrganizationsClient {
1256
1256
  role: 'admin' | 'member';
1257
1257
  }): Promise<OrganizationMember>;
1258
1258
  /**
1259
- * Send an invite to join an organization.
1259
+ * Send an invite email to join an organization.
1260
+ * The recipient will receive a magic link.
1260
1261
  *
1261
1262
  * @example
1262
1263
  * ```typescript
@@ -1267,6 +1268,21 @@ declare class OrganizationsClient {
1267
1268
  * ```
1268
1269
  */
1269
1270
  invite(orgId: string, options: InviteMemberOptions): Promise<OrganizationInvite>;
1271
+ /**
1272
+ * List all members and pending invites for an organization.
1273
+ *
1274
+ * @example
1275
+ * ```typescript
1276
+ * const { members, invites } = await stackbe.organizations.listMembers('org_123');
1277
+ *
1278
+ * members.forEach(m => console.log(`${m.customer.email} - ${m.role}`));
1279
+ * invites.forEach(i => console.log(`Pending: ${i.email}`));
1280
+ * ```
1281
+ */
1282
+ listMembers(orgId: string): Promise<{
1283
+ members: OrganizationMember[];
1284
+ invites: OrganizationInvite[];
1285
+ }>;
1270
1286
  /**
1271
1287
  * List pending invites for an organization.
1272
1288
  *
@@ -1653,6 +1669,252 @@ declare class FeatureRequestsClient {
1653
1669
  getCustomerActivity(customerId: string): Promise<CustomerFeatureActivity>;
1654
1670
  }
1655
1671
 
1672
+ interface AffiliateInfo {
1673
+ enrolled: boolean;
1674
+ id?: string;
1675
+ code?: string;
1676
+ status?: 'active' | 'suspended' | 'pending';
1677
+ totalEarned?: number;
1678
+ pendingBalance?: number;
1679
+ paidOut?: number;
1680
+ totalReferrals?: number;
1681
+ totalConversions?: number;
1682
+ createdAt?: string;
1683
+ }
1684
+ interface AffiliateEnrollment {
1685
+ id: string;
1686
+ code: string;
1687
+ status: string;
1688
+ createdAt: string;
1689
+ }
1690
+ interface AffiliateStats {
1691
+ enrolled: boolean;
1692
+ totalEarned: number;
1693
+ pendingBalance: number;
1694
+ paidOut: number;
1695
+ totalReferrals: number;
1696
+ totalConversions: number;
1697
+ }
1698
+ interface AffiliateCommission {
1699
+ id: string;
1700
+ amount: number;
1701
+ currency: string;
1702
+ status: 'pending' | 'approved' | 'paid' | 'rejected';
1703
+ createdAt: string;
1704
+ referredCustomerEmail?: string;
1705
+ }
1706
+ interface AffiliateCommissionsResponse {
1707
+ commissions: AffiliateCommission[];
1708
+ total: number;
1709
+ }
1710
+ interface TrackReferralResponse {
1711
+ token: string;
1712
+ expiresInDays: number;
1713
+ }
1714
+ interface EnrollOptions {
1715
+ /** Preferred referral code (auto-generated if not provided) */
1716
+ code?: string;
1717
+ /** PayPal email for payouts */
1718
+ payoutEmail?: string;
1719
+ }
1720
+ declare class AffiliatesClient {
1721
+ private http;
1722
+ constructor(http: HttpClient);
1723
+ /**
1724
+ * Get the current customer's affiliate info.
1725
+ * Requires customer session token.
1726
+ *
1727
+ * @example
1728
+ * ```typescript
1729
+ * const affiliate = await stackbe.affiliates.get();
1730
+ *
1731
+ * if (affiliate.enrolled) {
1732
+ * console.log(`Your referral code: ${affiliate.code}`);
1733
+ * console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
1734
+ * } else {
1735
+ * console.log('Not enrolled in affiliate program');
1736
+ * }
1737
+ * ```
1738
+ */
1739
+ get(): Promise<AffiliateInfo>;
1740
+ /**
1741
+ * Enroll the current customer as an affiliate.
1742
+ * Requires customer session token.
1743
+ *
1744
+ * @example
1745
+ * ```typescript
1746
+ * // Enroll with auto-generated code
1747
+ * const affiliate = await stackbe.affiliates.enroll();
1748
+ * console.log(`Your referral code: ${affiliate.code}`);
1749
+ *
1750
+ * // Enroll with custom code
1751
+ * const affiliate = await stackbe.affiliates.enroll({
1752
+ * code: 'MYCODE',
1753
+ * payoutEmail: 'payouts@example.com',
1754
+ * });
1755
+ * ```
1756
+ */
1757
+ enroll(options?: EnrollOptions): Promise<AffiliateEnrollment>;
1758
+ /**
1759
+ * Get affiliate statistics.
1760
+ * Requires customer session token.
1761
+ *
1762
+ * @example
1763
+ * ```typescript
1764
+ * const stats = await stackbe.affiliates.getStats();
1765
+ *
1766
+ * if (stats.enrolled) {
1767
+ * console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
1768
+ * console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
1769
+ * console.log(`Referrals: ${stats.totalReferrals}`);
1770
+ * console.log(`Conversions: ${stats.totalConversions}`);
1771
+ * }
1772
+ * ```
1773
+ */
1774
+ getStats(): Promise<AffiliateStats>;
1775
+ /**
1776
+ * Get affiliate commission history.
1777
+ * Requires customer session token.
1778
+ *
1779
+ * @example
1780
+ * ```typescript
1781
+ * const { commissions, total } = await stackbe.affiliates.getCommissions();
1782
+ *
1783
+ * commissions.forEach((c) => {
1784
+ * console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
1785
+ * });
1786
+ * ```
1787
+ */
1788
+ getCommissions(): Promise<AffiliateCommissionsResponse>;
1789
+ /**
1790
+ * Track a referral click (store token for attribution).
1791
+ * Call this when a user lands on your site with a referral code.
1792
+ * Requires API key.
1793
+ *
1794
+ * @example
1795
+ * ```typescript
1796
+ * // In your landing page handler
1797
+ * const refCode = req.query.ref;
1798
+ * if (refCode) {
1799
+ * const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
1800
+ * // Store token in cookie for attribution on signup
1801
+ * res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
1802
+ * }
1803
+ * ```
1804
+ */
1805
+ trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
1806
+ }
1807
+
1808
+ interface EarlyAccessSignup {
1809
+ id: string;
1810
+ status: 'new' | 'invited' | 'converted' | 'archived';
1811
+ email: string;
1812
+ name?: string;
1813
+ createdAt: string;
1814
+ }
1815
+ interface CreateEarlyAccessSignupOptions {
1816
+ email: string;
1817
+ name?: string;
1818
+ note?: string;
1819
+ metadata?: Record<string, any>;
1820
+ }
1821
+ interface EarlyAccessSignupListResponse {
1822
+ items: Array<{
1823
+ id: string;
1824
+ email: string;
1825
+ name?: string;
1826
+ status: string;
1827
+ metadata?: Record<string, any>;
1828
+ createdAt: string;
1829
+ }>;
1830
+ page: number;
1831
+ limit: number;
1832
+ total: number;
1833
+ hasMore: boolean;
1834
+ }
1835
+ interface ListEarlyAccessOptions {
1836
+ status?: 'new' | 'invited' | 'converted' | 'archived';
1837
+ search?: string;
1838
+ limit?: number;
1839
+ offset?: number;
1840
+ }
1841
+ declare class EarlyAccessClient {
1842
+ private http;
1843
+ private appId;
1844
+ constructor(http: HttpClient, appId: string);
1845
+ /**
1846
+ * Submit an early access / waitlist signup.
1847
+ * This is a public endpoint - no auth required.
1848
+ *
1849
+ * @example
1850
+ * ```typescript
1851
+ * // Basic signup
1852
+ * const signup = await stackbe.earlyAccess.signup({
1853
+ * email: 'user@example.com',
1854
+ * });
1855
+ *
1856
+ * // With additional info
1857
+ * const signup = await stackbe.earlyAccess.signup({
1858
+ * email: 'user@example.com',
1859
+ * name: 'John Doe',
1860
+ * note: 'Interested in enterprise features',
1861
+ * metadata: { source: 'landing_page', campaign: 'launch' },
1862
+ * });
1863
+ *
1864
+ * console.log(`Signup ID: ${signup.id}`);
1865
+ * ```
1866
+ */
1867
+ signup(options: CreateEarlyAccessSignupOptions): Promise<EarlyAccessSignup>;
1868
+ /**
1869
+ * List early access signups.
1870
+ * Requires API key (admin).
1871
+ *
1872
+ * @example
1873
+ * ```typescript
1874
+ * // Get all signups
1875
+ * const { items, total } = await stackbe.earlyAccess.list();
1876
+ *
1877
+ * // Filter by status
1878
+ * const newSignups = await stackbe.earlyAccess.list({ status: 'new' });
1879
+ *
1880
+ * // Search by email
1881
+ * const results = await stackbe.earlyAccess.list({ search: 'example.com' });
1882
+ *
1883
+ * // Paginate
1884
+ * const page2 = await stackbe.earlyAccess.list({ offset: 50, limit: 50 });
1885
+ * ```
1886
+ */
1887
+ list(options?: ListEarlyAccessOptions): Promise<EarlyAccessSignupListResponse>;
1888
+ /**
1889
+ * Get a specific early access signup.
1890
+ * Requires API key (admin).
1891
+ *
1892
+ * @example
1893
+ * ```typescript
1894
+ * const signup = await stackbe.earlyAccess.get('signup_123');
1895
+ * console.log(`${signup.email} - ${signup.status}`);
1896
+ * ```
1897
+ */
1898
+ get(signupId: string): Promise<EarlyAccessSignup>;
1899
+ /**
1900
+ * Update the status of an early access signup.
1901
+ * Requires API key (admin).
1902
+ *
1903
+ * @example
1904
+ * ```typescript
1905
+ * // Mark as invited
1906
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'invited');
1907
+ *
1908
+ * // Mark as converted (user signed up)
1909
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'converted');
1910
+ *
1911
+ * // Archive
1912
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'archived');
1913
+ * ```
1914
+ */
1915
+ updateStatus(signupId: string, status: 'new' | 'invited' | 'converted' | 'archived'): Promise<EarlyAccessSignup>;
1916
+ }
1917
+
1656
1918
  declare class StackBE {
1657
1919
  private http;
1658
1920
  private appId;
@@ -1676,6 +1938,10 @@ declare class StackBE {
1676
1938
  readonly products: ProductsClient;
1677
1939
  /** Feature requests and voting */
1678
1940
  readonly featureRequests: FeatureRequestsClient;
1941
+ /** Affiliate program (customer-facing) */
1942
+ readonly affiliates: AffiliatesClient;
1943
+ /** Early access / waitlist signups */
1944
+ readonly earlyAccess: EarlyAccessClient;
1679
1945
  /**
1680
1946
  * Create a new StackBE client.
1681
1947
  *
@@ -1776,4 +2042,4 @@ declare class StackBE {
1776
2042
  }): (req: any, res: any, next: any) => Promise<any>;
1777
2043
  }
1778
2044
 
1779
- export { type AddMemberOptions, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestListResponse, FeatureRequestsClient, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
2045
+ export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestListResponse, FeatureRequestsClient, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
package/dist/index.js CHANGED
@@ -20,9 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AffiliatesClient: () => AffiliatesClient,
23
24
  AuthClient: () => AuthClient,
24
25
  CheckoutClient: () => CheckoutClient,
25
26
  CustomersClient: () => CustomersClient,
27
+ EarlyAccessClient: () => EarlyAccessClient,
26
28
  EntitlementsClient: () => EntitlementsClient,
27
29
  FeatureRequestsClient: () => FeatureRequestsClient,
28
30
  OrganizationsClient: () => OrganizationsClient,
@@ -1331,7 +1333,8 @@ var OrganizationsClient = class {
1331
1333
  );
1332
1334
  }
1333
1335
  /**
1334
- * Send an invite to join an organization.
1336
+ * Send an invite email to join an organization.
1337
+ * The recipient will receive a magic link.
1335
1338
  *
1336
1339
  * @example
1337
1340
  * ```typescript
@@ -1343,10 +1346,26 @@ var OrganizationsClient = class {
1343
1346
  */
1344
1347
  async invite(orgId, options) {
1345
1348
  return this.http.post(
1346
- `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites`,
1349
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members/invite`,
1347
1350
  options
1348
1351
  );
1349
1352
  }
1353
+ /**
1354
+ * List all members and pending invites for an organization.
1355
+ *
1356
+ * @example
1357
+ * ```typescript
1358
+ * const { members, invites } = await stackbe.organizations.listMembers('org_123');
1359
+ *
1360
+ * members.forEach(m => console.log(`${m.customer.email} - ${m.role}`));
1361
+ * invites.forEach(i => console.log(`Pending: ${i.email}`));
1362
+ * ```
1363
+ */
1364
+ async listMembers(orgId) {
1365
+ return this.http.get(
1366
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members`
1367
+ );
1368
+ }
1350
1369
  /**
1351
1370
  * List pending invites for an organization.
1352
1371
  *
@@ -1356,9 +1375,8 @@ var OrganizationsClient = class {
1356
1375
  * ```
1357
1376
  */
1358
1377
  async listInvites(orgId) {
1359
- return this.http.get(
1360
- `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites`
1361
- );
1378
+ const { invites } = await this.listMembers(orgId);
1379
+ return invites;
1362
1380
  }
1363
1381
  /**
1364
1382
  * Cancel a pending invite.
@@ -1370,7 +1388,7 @@ var OrganizationsClient = class {
1370
1388
  */
1371
1389
  async cancelInvite(orgId, inviteId) {
1372
1390
  return this.http.delete(
1373
- `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites/${inviteId}`
1391
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members/${inviteId}`
1374
1392
  );
1375
1393
  }
1376
1394
  };
@@ -1694,6 +1712,213 @@ var FeatureRequestsClient = class {
1694
1712
  }
1695
1713
  };
1696
1714
 
1715
+ // src/affiliates.ts
1716
+ var AffiliatesClient = class {
1717
+ constructor(http) {
1718
+ this.http = http;
1719
+ }
1720
+ /**
1721
+ * Get the current customer's affiliate info.
1722
+ * Requires customer session token.
1723
+ *
1724
+ * @example
1725
+ * ```typescript
1726
+ * const affiliate = await stackbe.affiliates.get();
1727
+ *
1728
+ * if (affiliate.enrolled) {
1729
+ * console.log(`Your referral code: ${affiliate.code}`);
1730
+ * console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
1731
+ * } else {
1732
+ * console.log('Not enrolled in affiliate program');
1733
+ * }
1734
+ * ```
1735
+ */
1736
+ async get() {
1737
+ return this.http.get("/v1/affiliate");
1738
+ }
1739
+ /**
1740
+ * Enroll the current customer as an affiliate.
1741
+ * Requires customer session token.
1742
+ *
1743
+ * @example
1744
+ * ```typescript
1745
+ * // Enroll with auto-generated code
1746
+ * const affiliate = await stackbe.affiliates.enroll();
1747
+ * console.log(`Your referral code: ${affiliate.code}`);
1748
+ *
1749
+ * // Enroll with custom code
1750
+ * const affiliate = await stackbe.affiliates.enroll({
1751
+ * code: 'MYCODE',
1752
+ * payoutEmail: 'payouts@example.com',
1753
+ * });
1754
+ * ```
1755
+ */
1756
+ async enroll(options = {}) {
1757
+ return this.http.post("/v1/affiliate/enroll", options);
1758
+ }
1759
+ /**
1760
+ * Get affiliate statistics.
1761
+ * Requires customer session token.
1762
+ *
1763
+ * @example
1764
+ * ```typescript
1765
+ * const stats = await stackbe.affiliates.getStats();
1766
+ *
1767
+ * if (stats.enrolled) {
1768
+ * console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
1769
+ * console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
1770
+ * console.log(`Referrals: ${stats.totalReferrals}`);
1771
+ * console.log(`Conversions: ${stats.totalConversions}`);
1772
+ * }
1773
+ * ```
1774
+ */
1775
+ async getStats() {
1776
+ return this.http.get("/v1/affiliate/stats");
1777
+ }
1778
+ /**
1779
+ * Get affiliate commission history.
1780
+ * Requires customer session token.
1781
+ *
1782
+ * @example
1783
+ * ```typescript
1784
+ * const { commissions, total } = await stackbe.affiliates.getCommissions();
1785
+ *
1786
+ * commissions.forEach((c) => {
1787
+ * console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
1788
+ * });
1789
+ * ```
1790
+ */
1791
+ async getCommissions() {
1792
+ return this.http.get("/v1/affiliate/commissions");
1793
+ }
1794
+ /**
1795
+ * Track a referral click (store token for attribution).
1796
+ * Call this when a user lands on your site with a referral code.
1797
+ * Requires API key.
1798
+ *
1799
+ * @example
1800
+ * ```typescript
1801
+ * // In your landing page handler
1802
+ * const refCode = req.query.ref;
1803
+ * if (refCode) {
1804
+ * const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
1805
+ * // Store token in cookie for attribution on signup
1806
+ * res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
1807
+ * }
1808
+ * ```
1809
+ */
1810
+ async trackReferral(code, referralUrl) {
1811
+ return this.http.post("/v1/affiliate/track", {
1812
+ code,
1813
+ referralUrl
1814
+ });
1815
+ }
1816
+ };
1817
+
1818
+ // src/early-access.ts
1819
+ var EarlyAccessClient = class {
1820
+ constructor(http, appId) {
1821
+ this.http = http;
1822
+ this.appId = appId;
1823
+ }
1824
+ /**
1825
+ * Submit an early access / waitlist signup.
1826
+ * This is a public endpoint - no auth required.
1827
+ *
1828
+ * @example
1829
+ * ```typescript
1830
+ * // Basic signup
1831
+ * const signup = await stackbe.earlyAccess.signup({
1832
+ * email: 'user@example.com',
1833
+ * });
1834
+ *
1835
+ * // With additional info
1836
+ * const signup = await stackbe.earlyAccess.signup({
1837
+ * email: 'user@example.com',
1838
+ * name: 'John Doe',
1839
+ * note: 'Interested in enterprise features',
1840
+ * metadata: { source: 'landing_page', campaign: 'launch' },
1841
+ * });
1842
+ *
1843
+ * console.log(`Signup ID: ${signup.id}`);
1844
+ * ```
1845
+ */
1846
+ async signup(options) {
1847
+ return this.http.post(
1848
+ `/v1/apps/${this.appId}/early-access/signups`,
1849
+ options
1850
+ );
1851
+ }
1852
+ // ==================== Admin Methods ====================
1853
+ /**
1854
+ * List early access signups.
1855
+ * Requires API key (admin).
1856
+ *
1857
+ * @example
1858
+ * ```typescript
1859
+ * // Get all signups
1860
+ * const { items, total } = await stackbe.earlyAccess.list();
1861
+ *
1862
+ * // Filter by status
1863
+ * const newSignups = await stackbe.earlyAccess.list({ status: 'new' });
1864
+ *
1865
+ * // Search by email
1866
+ * const results = await stackbe.earlyAccess.list({ search: 'example.com' });
1867
+ *
1868
+ * // Paginate
1869
+ * const page2 = await stackbe.earlyAccess.list({ offset: 50, limit: 50 });
1870
+ * ```
1871
+ */
1872
+ async list(options = {}) {
1873
+ const params = {};
1874
+ if (options.status) params.status = options.status;
1875
+ if (options.search) params.search = options.search;
1876
+ if (options.limit) params.limit = options.limit;
1877
+ if (options.offset) params.offset = options.offset;
1878
+ return this.http.get(
1879
+ `/v1/apps/${this.appId}/early-access/signups`,
1880
+ params
1881
+ );
1882
+ }
1883
+ /**
1884
+ * Get a specific early access signup.
1885
+ * Requires API key (admin).
1886
+ *
1887
+ * @example
1888
+ * ```typescript
1889
+ * const signup = await stackbe.earlyAccess.get('signup_123');
1890
+ * console.log(`${signup.email} - ${signup.status}`);
1891
+ * ```
1892
+ */
1893
+ async get(signupId) {
1894
+ return this.http.get(
1895
+ `/v1/apps/${this.appId}/early-access/signups/${signupId}`
1896
+ );
1897
+ }
1898
+ /**
1899
+ * Update the status of an early access signup.
1900
+ * Requires API key (admin).
1901
+ *
1902
+ * @example
1903
+ * ```typescript
1904
+ * // Mark as invited
1905
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'invited');
1906
+ *
1907
+ * // Mark as converted (user signed up)
1908
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'converted');
1909
+ *
1910
+ * // Archive
1911
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'archived');
1912
+ * ```
1913
+ */
1914
+ async updateStatus(signupId, status) {
1915
+ return this.http.patch(
1916
+ `/v1/apps/${this.appId}/early-access/signups/${signupId}`,
1917
+ { status }
1918
+ );
1919
+ }
1920
+ };
1921
+
1697
1922
  // src/client.ts
1698
1923
  var DEFAULT_BASE_URL = "https://api.stackbe.io";
1699
1924
  var DEFAULT_TIMEOUT = 3e4;
@@ -1757,6 +1982,8 @@ var StackBE = class {
1757
1982
  this.plans = new PlansClient(this.http);
1758
1983
  this.products = new ProductsClient(this.http, config.appId);
1759
1984
  this.featureRequests = new FeatureRequestsClient(this.http, config.appId);
1985
+ this.affiliates = new AffiliatesClient(this.http);
1986
+ this.earlyAccess = new EarlyAccessClient(this.http, config.appId);
1760
1987
  }
1761
1988
  /**
1762
1989
  * Create a middleware for Express that tracks usage automatically.
@@ -1890,9 +2117,11 @@ var StackBE = class {
1890
2117
  };
1891
2118
  // Annotate the CommonJS export names for ESM import in node:
1892
2119
  0 && (module.exports = {
2120
+ AffiliatesClient,
1893
2121
  AuthClient,
1894
2122
  CheckoutClient,
1895
2123
  CustomersClient,
2124
+ EarlyAccessClient,
1896
2125
  EntitlementsClient,
1897
2126
  FeatureRequestsClient,
1898
2127
  OrganizationsClient,
package/dist/index.mjs CHANGED
@@ -1294,7 +1294,8 @@ var OrganizationsClient = class {
1294
1294
  );
1295
1295
  }
1296
1296
  /**
1297
- * Send an invite to join an organization.
1297
+ * Send an invite email to join an organization.
1298
+ * The recipient will receive a magic link.
1298
1299
  *
1299
1300
  * @example
1300
1301
  * ```typescript
@@ -1306,10 +1307,26 @@ var OrganizationsClient = class {
1306
1307
  */
1307
1308
  async invite(orgId, options) {
1308
1309
  return this.http.post(
1309
- `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites`,
1310
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members/invite`,
1310
1311
  options
1311
1312
  );
1312
1313
  }
1314
+ /**
1315
+ * List all members and pending invites for an organization.
1316
+ *
1317
+ * @example
1318
+ * ```typescript
1319
+ * const { members, invites } = await stackbe.organizations.listMembers('org_123');
1320
+ *
1321
+ * members.forEach(m => console.log(`${m.customer.email} - ${m.role}`));
1322
+ * invites.forEach(i => console.log(`Pending: ${i.email}`));
1323
+ * ```
1324
+ */
1325
+ async listMembers(orgId) {
1326
+ return this.http.get(
1327
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members`
1328
+ );
1329
+ }
1313
1330
  /**
1314
1331
  * List pending invites for an organization.
1315
1332
  *
@@ -1319,9 +1336,8 @@ var OrganizationsClient = class {
1319
1336
  * ```
1320
1337
  */
1321
1338
  async listInvites(orgId) {
1322
- return this.http.get(
1323
- `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites`
1324
- );
1339
+ const { invites } = await this.listMembers(orgId);
1340
+ return invites;
1325
1341
  }
1326
1342
  /**
1327
1343
  * Cancel a pending invite.
@@ -1333,7 +1349,7 @@ var OrganizationsClient = class {
1333
1349
  */
1334
1350
  async cancelInvite(orgId, inviteId) {
1335
1351
  return this.http.delete(
1336
- `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites/${inviteId}`
1352
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members/${inviteId}`
1337
1353
  );
1338
1354
  }
1339
1355
  };
@@ -1657,6 +1673,213 @@ var FeatureRequestsClient = class {
1657
1673
  }
1658
1674
  };
1659
1675
 
1676
+ // src/affiliates.ts
1677
+ var AffiliatesClient = class {
1678
+ constructor(http) {
1679
+ this.http = http;
1680
+ }
1681
+ /**
1682
+ * Get the current customer's affiliate info.
1683
+ * Requires customer session token.
1684
+ *
1685
+ * @example
1686
+ * ```typescript
1687
+ * const affiliate = await stackbe.affiliates.get();
1688
+ *
1689
+ * if (affiliate.enrolled) {
1690
+ * console.log(`Your referral code: ${affiliate.code}`);
1691
+ * console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
1692
+ * } else {
1693
+ * console.log('Not enrolled in affiliate program');
1694
+ * }
1695
+ * ```
1696
+ */
1697
+ async get() {
1698
+ return this.http.get("/v1/affiliate");
1699
+ }
1700
+ /**
1701
+ * Enroll the current customer as an affiliate.
1702
+ * Requires customer session token.
1703
+ *
1704
+ * @example
1705
+ * ```typescript
1706
+ * // Enroll with auto-generated code
1707
+ * const affiliate = await stackbe.affiliates.enroll();
1708
+ * console.log(`Your referral code: ${affiliate.code}`);
1709
+ *
1710
+ * // Enroll with custom code
1711
+ * const affiliate = await stackbe.affiliates.enroll({
1712
+ * code: 'MYCODE',
1713
+ * payoutEmail: 'payouts@example.com',
1714
+ * });
1715
+ * ```
1716
+ */
1717
+ async enroll(options = {}) {
1718
+ return this.http.post("/v1/affiliate/enroll", options);
1719
+ }
1720
+ /**
1721
+ * Get affiliate statistics.
1722
+ * Requires customer session token.
1723
+ *
1724
+ * @example
1725
+ * ```typescript
1726
+ * const stats = await stackbe.affiliates.getStats();
1727
+ *
1728
+ * if (stats.enrolled) {
1729
+ * console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
1730
+ * console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
1731
+ * console.log(`Referrals: ${stats.totalReferrals}`);
1732
+ * console.log(`Conversions: ${stats.totalConversions}`);
1733
+ * }
1734
+ * ```
1735
+ */
1736
+ async getStats() {
1737
+ return this.http.get("/v1/affiliate/stats");
1738
+ }
1739
+ /**
1740
+ * Get affiliate commission history.
1741
+ * Requires customer session token.
1742
+ *
1743
+ * @example
1744
+ * ```typescript
1745
+ * const { commissions, total } = await stackbe.affiliates.getCommissions();
1746
+ *
1747
+ * commissions.forEach((c) => {
1748
+ * console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
1749
+ * });
1750
+ * ```
1751
+ */
1752
+ async getCommissions() {
1753
+ return this.http.get("/v1/affiliate/commissions");
1754
+ }
1755
+ /**
1756
+ * Track a referral click (store token for attribution).
1757
+ * Call this when a user lands on your site with a referral code.
1758
+ * Requires API key.
1759
+ *
1760
+ * @example
1761
+ * ```typescript
1762
+ * // In your landing page handler
1763
+ * const refCode = req.query.ref;
1764
+ * if (refCode) {
1765
+ * const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
1766
+ * // Store token in cookie for attribution on signup
1767
+ * res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
1768
+ * }
1769
+ * ```
1770
+ */
1771
+ async trackReferral(code, referralUrl) {
1772
+ return this.http.post("/v1/affiliate/track", {
1773
+ code,
1774
+ referralUrl
1775
+ });
1776
+ }
1777
+ };
1778
+
1779
+ // src/early-access.ts
1780
+ var EarlyAccessClient = class {
1781
+ constructor(http, appId) {
1782
+ this.http = http;
1783
+ this.appId = appId;
1784
+ }
1785
+ /**
1786
+ * Submit an early access / waitlist signup.
1787
+ * This is a public endpoint - no auth required.
1788
+ *
1789
+ * @example
1790
+ * ```typescript
1791
+ * // Basic signup
1792
+ * const signup = await stackbe.earlyAccess.signup({
1793
+ * email: 'user@example.com',
1794
+ * });
1795
+ *
1796
+ * // With additional info
1797
+ * const signup = await stackbe.earlyAccess.signup({
1798
+ * email: 'user@example.com',
1799
+ * name: 'John Doe',
1800
+ * note: 'Interested in enterprise features',
1801
+ * metadata: { source: 'landing_page', campaign: 'launch' },
1802
+ * });
1803
+ *
1804
+ * console.log(`Signup ID: ${signup.id}`);
1805
+ * ```
1806
+ */
1807
+ async signup(options) {
1808
+ return this.http.post(
1809
+ `/v1/apps/${this.appId}/early-access/signups`,
1810
+ options
1811
+ );
1812
+ }
1813
+ // ==================== Admin Methods ====================
1814
+ /**
1815
+ * List early access signups.
1816
+ * Requires API key (admin).
1817
+ *
1818
+ * @example
1819
+ * ```typescript
1820
+ * // Get all signups
1821
+ * const { items, total } = await stackbe.earlyAccess.list();
1822
+ *
1823
+ * // Filter by status
1824
+ * const newSignups = await stackbe.earlyAccess.list({ status: 'new' });
1825
+ *
1826
+ * // Search by email
1827
+ * const results = await stackbe.earlyAccess.list({ search: 'example.com' });
1828
+ *
1829
+ * // Paginate
1830
+ * const page2 = await stackbe.earlyAccess.list({ offset: 50, limit: 50 });
1831
+ * ```
1832
+ */
1833
+ async list(options = {}) {
1834
+ const params = {};
1835
+ if (options.status) params.status = options.status;
1836
+ if (options.search) params.search = options.search;
1837
+ if (options.limit) params.limit = options.limit;
1838
+ if (options.offset) params.offset = options.offset;
1839
+ return this.http.get(
1840
+ `/v1/apps/${this.appId}/early-access/signups`,
1841
+ params
1842
+ );
1843
+ }
1844
+ /**
1845
+ * Get a specific early access signup.
1846
+ * Requires API key (admin).
1847
+ *
1848
+ * @example
1849
+ * ```typescript
1850
+ * const signup = await stackbe.earlyAccess.get('signup_123');
1851
+ * console.log(`${signup.email} - ${signup.status}`);
1852
+ * ```
1853
+ */
1854
+ async get(signupId) {
1855
+ return this.http.get(
1856
+ `/v1/apps/${this.appId}/early-access/signups/${signupId}`
1857
+ );
1858
+ }
1859
+ /**
1860
+ * Update the status of an early access signup.
1861
+ * Requires API key (admin).
1862
+ *
1863
+ * @example
1864
+ * ```typescript
1865
+ * // Mark as invited
1866
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'invited');
1867
+ *
1868
+ * // Mark as converted (user signed up)
1869
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'converted');
1870
+ *
1871
+ * // Archive
1872
+ * await stackbe.earlyAccess.updateStatus('signup_123', 'archived');
1873
+ * ```
1874
+ */
1875
+ async updateStatus(signupId, status) {
1876
+ return this.http.patch(
1877
+ `/v1/apps/${this.appId}/early-access/signups/${signupId}`,
1878
+ { status }
1879
+ );
1880
+ }
1881
+ };
1882
+
1660
1883
  // src/client.ts
1661
1884
  var DEFAULT_BASE_URL = "https://api.stackbe.io";
1662
1885
  var DEFAULT_TIMEOUT = 3e4;
@@ -1720,6 +1943,8 @@ var StackBE = class {
1720
1943
  this.plans = new PlansClient(this.http);
1721
1944
  this.products = new ProductsClient(this.http, config.appId);
1722
1945
  this.featureRequests = new FeatureRequestsClient(this.http, config.appId);
1946
+ this.affiliates = new AffiliatesClient(this.http);
1947
+ this.earlyAccess = new EarlyAccessClient(this.http, config.appId);
1723
1948
  }
1724
1949
  /**
1725
1950
  * Create a middleware for Express that tracks usage automatically.
@@ -1852,9 +2077,11 @@ var StackBE = class {
1852
2077
  }
1853
2078
  };
1854
2079
  export {
2080
+ AffiliatesClient,
1855
2081
  AuthClient,
1856
2082
  CheckoutClient,
1857
2083
  CustomersClient,
2084
+ EarlyAccessClient,
1858
2085
  EntitlementsClient,
1859
2086
  FeatureRequestsClient,
1860
2087
  OrganizationsClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbe/sdk",
3
- "version": "0.7.4",
3
+ "version": "0.8.1",
4
4
  "description": "Official JavaScript/TypeScript SDK for StackBE - the billing backend for your side project",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",