@stackbe/sdk 0.7.3 → 0.8.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.mts +258 -4
- package/dist/index.d.ts +258 -4
- package/dist/index.js +217 -1
- package/dist/index.mjs +215 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1432,10 +1432,11 @@ interface ListFeatureRequestsOptions {
|
|
|
1432
1432
|
offset?: number;
|
|
1433
1433
|
}
|
|
1434
1434
|
interface FeatureRequestListResponse {
|
|
1435
|
-
|
|
1435
|
+
items: FeatureRequest[];
|
|
1436
1436
|
total: number;
|
|
1437
1437
|
limit: number;
|
|
1438
|
-
|
|
1438
|
+
page: number;
|
|
1439
|
+
hasMore: boolean;
|
|
1439
1440
|
}
|
|
1440
1441
|
interface InterestedCustomer {
|
|
1441
1442
|
customerId: string;
|
|
@@ -1484,13 +1485,16 @@ declare class FeatureRequestsClient {
|
|
|
1484
1485
|
* @example
|
|
1485
1486
|
* ```typescript
|
|
1486
1487
|
* // Get all feature requests
|
|
1487
|
-
* const {
|
|
1488
|
+
* const { items, total, hasMore } = await stackbe.featureRequests.list();
|
|
1488
1489
|
*
|
|
1489
1490
|
* // Filter by status
|
|
1490
1491
|
* const planned = await stackbe.featureRequests.list({ status: 'planned' });
|
|
1491
1492
|
*
|
|
1492
1493
|
* // Sort by votes
|
|
1493
1494
|
* const popular = await stackbe.featureRequests.list({ sortBy: 'votes' });
|
|
1495
|
+
*
|
|
1496
|
+
* // Paginate
|
|
1497
|
+
* const page2 = await stackbe.featureRequests.list({ offset: 50, limit: 50 });
|
|
1494
1498
|
* ```
|
|
1495
1499
|
*/
|
|
1496
1500
|
list(options?: ListFeatureRequestsOptions): Promise<FeatureRequestListResponse>;
|
|
@@ -1649,6 +1653,252 @@ declare class FeatureRequestsClient {
|
|
|
1649
1653
|
getCustomerActivity(customerId: string): Promise<CustomerFeatureActivity>;
|
|
1650
1654
|
}
|
|
1651
1655
|
|
|
1656
|
+
interface AffiliateInfo {
|
|
1657
|
+
enrolled: boolean;
|
|
1658
|
+
id?: string;
|
|
1659
|
+
code?: string;
|
|
1660
|
+
status?: 'active' | 'suspended' | 'pending';
|
|
1661
|
+
totalEarned?: number;
|
|
1662
|
+
pendingBalance?: number;
|
|
1663
|
+
paidOut?: number;
|
|
1664
|
+
totalReferrals?: number;
|
|
1665
|
+
totalConversions?: number;
|
|
1666
|
+
createdAt?: string;
|
|
1667
|
+
}
|
|
1668
|
+
interface AffiliateEnrollment {
|
|
1669
|
+
id: string;
|
|
1670
|
+
code: string;
|
|
1671
|
+
status: string;
|
|
1672
|
+
createdAt: string;
|
|
1673
|
+
}
|
|
1674
|
+
interface AffiliateStats {
|
|
1675
|
+
enrolled: boolean;
|
|
1676
|
+
totalEarned: number;
|
|
1677
|
+
pendingBalance: number;
|
|
1678
|
+
paidOut: number;
|
|
1679
|
+
totalReferrals: number;
|
|
1680
|
+
totalConversions: number;
|
|
1681
|
+
}
|
|
1682
|
+
interface AffiliateCommission {
|
|
1683
|
+
id: string;
|
|
1684
|
+
amount: number;
|
|
1685
|
+
currency: string;
|
|
1686
|
+
status: 'pending' | 'approved' | 'paid' | 'rejected';
|
|
1687
|
+
createdAt: string;
|
|
1688
|
+
referredCustomerEmail?: string;
|
|
1689
|
+
}
|
|
1690
|
+
interface AffiliateCommissionsResponse {
|
|
1691
|
+
commissions: AffiliateCommission[];
|
|
1692
|
+
total: number;
|
|
1693
|
+
}
|
|
1694
|
+
interface TrackReferralResponse {
|
|
1695
|
+
token: string;
|
|
1696
|
+
expiresInDays: number;
|
|
1697
|
+
}
|
|
1698
|
+
interface EnrollOptions {
|
|
1699
|
+
/** Preferred referral code (auto-generated if not provided) */
|
|
1700
|
+
code?: string;
|
|
1701
|
+
/** PayPal email for payouts */
|
|
1702
|
+
payoutEmail?: string;
|
|
1703
|
+
}
|
|
1704
|
+
declare class AffiliatesClient {
|
|
1705
|
+
private http;
|
|
1706
|
+
constructor(http: HttpClient);
|
|
1707
|
+
/**
|
|
1708
|
+
* Get the current customer's affiliate info.
|
|
1709
|
+
* Requires customer session token.
|
|
1710
|
+
*
|
|
1711
|
+
* @example
|
|
1712
|
+
* ```typescript
|
|
1713
|
+
* const affiliate = await stackbe.affiliates.get();
|
|
1714
|
+
*
|
|
1715
|
+
* if (affiliate.enrolled) {
|
|
1716
|
+
* console.log(`Your referral code: ${affiliate.code}`);
|
|
1717
|
+
* console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
|
|
1718
|
+
* } else {
|
|
1719
|
+
* console.log('Not enrolled in affiliate program');
|
|
1720
|
+
* }
|
|
1721
|
+
* ```
|
|
1722
|
+
*/
|
|
1723
|
+
get(): Promise<AffiliateInfo>;
|
|
1724
|
+
/**
|
|
1725
|
+
* Enroll the current customer as an affiliate.
|
|
1726
|
+
* Requires customer session token.
|
|
1727
|
+
*
|
|
1728
|
+
* @example
|
|
1729
|
+
* ```typescript
|
|
1730
|
+
* // Enroll with auto-generated code
|
|
1731
|
+
* const affiliate = await stackbe.affiliates.enroll();
|
|
1732
|
+
* console.log(`Your referral code: ${affiliate.code}`);
|
|
1733
|
+
*
|
|
1734
|
+
* // Enroll with custom code
|
|
1735
|
+
* const affiliate = await stackbe.affiliates.enroll({
|
|
1736
|
+
* code: 'MYCODE',
|
|
1737
|
+
* payoutEmail: 'payouts@example.com',
|
|
1738
|
+
* });
|
|
1739
|
+
* ```
|
|
1740
|
+
*/
|
|
1741
|
+
enroll(options?: EnrollOptions): Promise<AffiliateEnrollment>;
|
|
1742
|
+
/**
|
|
1743
|
+
* Get affiliate statistics.
|
|
1744
|
+
* Requires customer session token.
|
|
1745
|
+
*
|
|
1746
|
+
* @example
|
|
1747
|
+
* ```typescript
|
|
1748
|
+
* const stats = await stackbe.affiliates.getStats();
|
|
1749
|
+
*
|
|
1750
|
+
* if (stats.enrolled) {
|
|
1751
|
+
* console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
|
|
1752
|
+
* console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
|
|
1753
|
+
* console.log(`Referrals: ${stats.totalReferrals}`);
|
|
1754
|
+
* console.log(`Conversions: ${stats.totalConversions}`);
|
|
1755
|
+
* }
|
|
1756
|
+
* ```
|
|
1757
|
+
*/
|
|
1758
|
+
getStats(): Promise<AffiliateStats>;
|
|
1759
|
+
/**
|
|
1760
|
+
* Get affiliate commission history.
|
|
1761
|
+
* Requires customer session token.
|
|
1762
|
+
*
|
|
1763
|
+
* @example
|
|
1764
|
+
* ```typescript
|
|
1765
|
+
* const { commissions, total } = await stackbe.affiliates.getCommissions();
|
|
1766
|
+
*
|
|
1767
|
+
* commissions.forEach((c) => {
|
|
1768
|
+
* console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
|
|
1769
|
+
* });
|
|
1770
|
+
* ```
|
|
1771
|
+
*/
|
|
1772
|
+
getCommissions(): Promise<AffiliateCommissionsResponse>;
|
|
1773
|
+
/**
|
|
1774
|
+
* Track a referral click (store token for attribution).
|
|
1775
|
+
* Call this when a user lands on your site with a referral code.
|
|
1776
|
+
* Requires API key.
|
|
1777
|
+
*
|
|
1778
|
+
* @example
|
|
1779
|
+
* ```typescript
|
|
1780
|
+
* // In your landing page handler
|
|
1781
|
+
* const refCode = req.query.ref;
|
|
1782
|
+
* if (refCode) {
|
|
1783
|
+
* const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
|
|
1784
|
+
* // Store token in cookie for attribution on signup
|
|
1785
|
+
* res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
|
|
1786
|
+
* }
|
|
1787
|
+
* ```
|
|
1788
|
+
*/
|
|
1789
|
+
trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
interface EarlyAccessSignup {
|
|
1793
|
+
id: string;
|
|
1794
|
+
status: 'new' | 'invited' | 'converted' | 'archived';
|
|
1795
|
+
email: string;
|
|
1796
|
+
name?: string;
|
|
1797
|
+
createdAt: string;
|
|
1798
|
+
}
|
|
1799
|
+
interface CreateEarlyAccessSignupOptions {
|
|
1800
|
+
email: string;
|
|
1801
|
+
name?: string;
|
|
1802
|
+
note?: string;
|
|
1803
|
+
metadata?: Record<string, any>;
|
|
1804
|
+
}
|
|
1805
|
+
interface EarlyAccessSignupListResponse {
|
|
1806
|
+
items: Array<{
|
|
1807
|
+
id: string;
|
|
1808
|
+
email: string;
|
|
1809
|
+
name?: string;
|
|
1810
|
+
status: string;
|
|
1811
|
+
metadata?: Record<string, any>;
|
|
1812
|
+
createdAt: string;
|
|
1813
|
+
}>;
|
|
1814
|
+
page: number;
|
|
1815
|
+
limit: number;
|
|
1816
|
+
total: number;
|
|
1817
|
+
hasMore: boolean;
|
|
1818
|
+
}
|
|
1819
|
+
interface ListEarlyAccessOptions {
|
|
1820
|
+
status?: 'new' | 'invited' | 'converted' | 'archived';
|
|
1821
|
+
search?: string;
|
|
1822
|
+
limit?: number;
|
|
1823
|
+
offset?: number;
|
|
1824
|
+
}
|
|
1825
|
+
declare class EarlyAccessClient {
|
|
1826
|
+
private http;
|
|
1827
|
+
private appId;
|
|
1828
|
+
constructor(http: HttpClient, appId: string);
|
|
1829
|
+
/**
|
|
1830
|
+
* Submit an early access / waitlist signup.
|
|
1831
|
+
* This is a public endpoint - no auth required.
|
|
1832
|
+
*
|
|
1833
|
+
* @example
|
|
1834
|
+
* ```typescript
|
|
1835
|
+
* // Basic signup
|
|
1836
|
+
* const signup = await stackbe.earlyAccess.signup({
|
|
1837
|
+
* email: 'user@example.com',
|
|
1838
|
+
* });
|
|
1839
|
+
*
|
|
1840
|
+
* // With additional info
|
|
1841
|
+
* const signup = await stackbe.earlyAccess.signup({
|
|
1842
|
+
* email: 'user@example.com',
|
|
1843
|
+
* name: 'John Doe',
|
|
1844
|
+
* note: 'Interested in enterprise features',
|
|
1845
|
+
* metadata: { source: 'landing_page', campaign: 'launch' },
|
|
1846
|
+
* });
|
|
1847
|
+
*
|
|
1848
|
+
* console.log(`Signup ID: ${signup.id}`);
|
|
1849
|
+
* ```
|
|
1850
|
+
*/
|
|
1851
|
+
signup(options: CreateEarlyAccessSignupOptions): Promise<EarlyAccessSignup>;
|
|
1852
|
+
/**
|
|
1853
|
+
* List early access signups.
|
|
1854
|
+
* Requires API key (admin).
|
|
1855
|
+
*
|
|
1856
|
+
* @example
|
|
1857
|
+
* ```typescript
|
|
1858
|
+
* // Get all signups
|
|
1859
|
+
* const { items, total } = await stackbe.earlyAccess.list();
|
|
1860
|
+
*
|
|
1861
|
+
* // Filter by status
|
|
1862
|
+
* const newSignups = await stackbe.earlyAccess.list({ status: 'new' });
|
|
1863
|
+
*
|
|
1864
|
+
* // Search by email
|
|
1865
|
+
* const results = await stackbe.earlyAccess.list({ search: 'example.com' });
|
|
1866
|
+
*
|
|
1867
|
+
* // Paginate
|
|
1868
|
+
* const page2 = await stackbe.earlyAccess.list({ offset: 50, limit: 50 });
|
|
1869
|
+
* ```
|
|
1870
|
+
*/
|
|
1871
|
+
list(options?: ListEarlyAccessOptions): Promise<EarlyAccessSignupListResponse>;
|
|
1872
|
+
/**
|
|
1873
|
+
* Get a specific early access signup.
|
|
1874
|
+
* Requires API key (admin).
|
|
1875
|
+
*
|
|
1876
|
+
* @example
|
|
1877
|
+
* ```typescript
|
|
1878
|
+
* const signup = await stackbe.earlyAccess.get('signup_123');
|
|
1879
|
+
* console.log(`${signup.email} - ${signup.status}`);
|
|
1880
|
+
* ```
|
|
1881
|
+
*/
|
|
1882
|
+
get(signupId: string): Promise<EarlyAccessSignup>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Update the status of an early access signup.
|
|
1885
|
+
* Requires API key (admin).
|
|
1886
|
+
*
|
|
1887
|
+
* @example
|
|
1888
|
+
* ```typescript
|
|
1889
|
+
* // Mark as invited
|
|
1890
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'invited');
|
|
1891
|
+
*
|
|
1892
|
+
* // Mark as converted (user signed up)
|
|
1893
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'converted');
|
|
1894
|
+
*
|
|
1895
|
+
* // Archive
|
|
1896
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'archived');
|
|
1897
|
+
* ```
|
|
1898
|
+
*/
|
|
1899
|
+
updateStatus(signupId: string, status: 'new' | 'invited' | 'converted' | 'archived'): Promise<EarlyAccessSignup>;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1652
1902
|
declare class StackBE {
|
|
1653
1903
|
private http;
|
|
1654
1904
|
private appId;
|
|
@@ -1672,6 +1922,10 @@ declare class StackBE {
|
|
|
1672
1922
|
readonly products: ProductsClient;
|
|
1673
1923
|
/** Feature requests and voting */
|
|
1674
1924
|
readonly featureRequests: FeatureRequestsClient;
|
|
1925
|
+
/** Affiliate program (customer-facing) */
|
|
1926
|
+
readonly affiliates: AffiliatesClient;
|
|
1927
|
+
/** Early access / waitlist signups */
|
|
1928
|
+
readonly earlyAccess: EarlyAccessClient;
|
|
1675
1929
|
/**
|
|
1676
1930
|
* Create a new StackBE client.
|
|
1677
1931
|
*
|
|
@@ -1772,4 +2026,4 @@ declare class StackBE {
|
|
|
1772
2026
|
}): (req: any, res: any, next: any) => Promise<any>;
|
|
1773
2027
|
}
|
|
1774
2028
|
|
|
1775
|
-
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 };
|
|
2029
|
+
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
|
@@ -1432,10 +1432,11 @@ interface ListFeatureRequestsOptions {
|
|
|
1432
1432
|
offset?: number;
|
|
1433
1433
|
}
|
|
1434
1434
|
interface FeatureRequestListResponse {
|
|
1435
|
-
|
|
1435
|
+
items: FeatureRequest[];
|
|
1436
1436
|
total: number;
|
|
1437
1437
|
limit: number;
|
|
1438
|
-
|
|
1438
|
+
page: number;
|
|
1439
|
+
hasMore: boolean;
|
|
1439
1440
|
}
|
|
1440
1441
|
interface InterestedCustomer {
|
|
1441
1442
|
customerId: string;
|
|
@@ -1484,13 +1485,16 @@ declare class FeatureRequestsClient {
|
|
|
1484
1485
|
* @example
|
|
1485
1486
|
* ```typescript
|
|
1486
1487
|
* // Get all feature requests
|
|
1487
|
-
* const {
|
|
1488
|
+
* const { items, total, hasMore } = await stackbe.featureRequests.list();
|
|
1488
1489
|
*
|
|
1489
1490
|
* // Filter by status
|
|
1490
1491
|
* const planned = await stackbe.featureRequests.list({ status: 'planned' });
|
|
1491
1492
|
*
|
|
1492
1493
|
* // Sort by votes
|
|
1493
1494
|
* const popular = await stackbe.featureRequests.list({ sortBy: 'votes' });
|
|
1495
|
+
*
|
|
1496
|
+
* // Paginate
|
|
1497
|
+
* const page2 = await stackbe.featureRequests.list({ offset: 50, limit: 50 });
|
|
1494
1498
|
* ```
|
|
1495
1499
|
*/
|
|
1496
1500
|
list(options?: ListFeatureRequestsOptions): Promise<FeatureRequestListResponse>;
|
|
@@ -1649,6 +1653,252 @@ declare class FeatureRequestsClient {
|
|
|
1649
1653
|
getCustomerActivity(customerId: string): Promise<CustomerFeatureActivity>;
|
|
1650
1654
|
}
|
|
1651
1655
|
|
|
1656
|
+
interface AffiliateInfo {
|
|
1657
|
+
enrolled: boolean;
|
|
1658
|
+
id?: string;
|
|
1659
|
+
code?: string;
|
|
1660
|
+
status?: 'active' | 'suspended' | 'pending';
|
|
1661
|
+
totalEarned?: number;
|
|
1662
|
+
pendingBalance?: number;
|
|
1663
|
+
paidOut?: number;
|
|
1664
|
+
totalReferrals?: number;
|
|
1665
|
+
totalConversions?: number;
|
|
1666
|
+
createdAt?: string;
|
|
1667
|
+
}
|
|
1668
|
+
interface AffiliateEnrollment {
|
|
1669
|
+
id: string;
|
|
1670
|
+
code: string;
|
|
1671
|
+
status: string;
|
|
1672
|
+
createdAt: string;
|
|
1673
|
+
}
|
|
1674
|
+
interface AffiliateStats {
|
|
1675
|
+
enrolled: boolean;
|
|
1676
|
+
totalEarned: number;
|
|
1677
|
+
pendingBalance: number;
|
|
1678
|
+
paidOut: number;
|
|
1679
|
+
totalReferrals: number;
|
|
1680
|
+
totalConversions: number;
|
|
1681
|
+
}
|
|
1682
|
+
interface AffiliateCommission {
|
|
1683
|
+
id: string;
|
|
1684
|
+
amount: number;
|
|
1685
|
+
currency: string;
|
|
1686
|
+
status: 'pending' | 'approved' | 'paid' | 'rejected';
|
|
1687
|
+
createdAt: string;
|
|
1688
|
+
referredCustomerEmail?: string;
|
|
1689
|
+
}
|
|
1690
|
+
interface AffiliateCommissionsResponse {
|
|
1691
|
+
commissions: AffiliateCommission[];
|
|
1692
|
+
total: number;
|
|
1693
|
+
}
|
|
1694
|
+
interface TrackReferralResponse {
|
|
1695
|
+
token: string;
|
|
1696
|
+
expiresInDays: number;
|
|
1697
|
+
}
|
|
1698
|
+
interface EnrollOptions {
|
|
1699
|
+
/** Preferred referral code (auto-generated if not provided) */
|
|
1700
|
+
code?: string;
|
|
1701
|
+
/** PayPal email for payouts */
|
|
1702
|
+
payoutEmail?: string;
|
|
1703
|
+
}
|
|
1704
|
+
declare class AffiliatesClient {
|
|
1705
|
+
private http;
|
|
1706
|
+
constructor(http: HttpClient);
|
|
1707
|
+
/**
|
|
1708
|
+
* Get the current customer's affiliate info.
|
|
1709
|
+
* Requires customer session token.
|
|
1710
|
+
*
|
|
1711
|
+
* @example
|
|
1712
|
+
* ```typescript
|
|
1713
|
+
* const affiliate = await stackbe.affiliates.get();
|
|
1714
|
+
*
|
|
1715
|
+
* if (affiliate.enrolled) {
|
|
1716
|
+
* console.log(`Your referral code: ${affiliate.code}`);
|
|
1717
|
+
* console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
|
|
1718
|
+
* } else {
|
|
1719
|
+
* console.log('Not enrolled in affiliate program');
|
|
1720
|
+
* }
|
|
1721
|
+
* ```
|
|
1722
|
+
*/
|
|
1723
|
+
get(): Promise<AffiliateInfo>;
|
|
1724
|
+
/**
|
|
1725
|
+
* Enroll the current customer as an affiliate.
|
|
1726
|
+
* Requires customer session token.
|
|
1727
|
+
*
|
|
1728
|
+
* @example
|
|
1729
|
+
* ```typescript
|
|
1730
|
+
* // Enroll with auto-generated code
|
|
1731
|
+
* const affiliate = await stackbe.affiliates.enroll();
|
|
1732
|
+
* console.log(`Your referral code: ${affiliate.code}`);
|
|
1733
|
+
*
|
|
1734
|
+
* // Enroll with custom code
|
|
1735
|
+
* const affiliate = await stackbe.affiliates.enroll({
|
|
1736
|
+
* code: 'MYCODE',
|
|
1737
|
+
* payoutEmail: 'payouts@example.com',
|
|
1738
|
+
* });
|
|
1739
|
+
* ```
|
|
1740
|
+
*/
|
|
1741
|
+
enroll(options?: EnrollOptions): Promise<AffiliateEnrollment>;
|
|
1742
|
+
/**
|
|
1743
|
+
* Get affiliate statistics.
|
|
1744
|
+
* Requires customer session token.
|
|
1745
|
+
*
|
|
1746
|
+
* @example
|
|
1747
|
+
* ```typescript
|
|
1748
|
+
* const stats = await stackbe.affiliates.getStats();
|
|
1749
|
+
*
|
|
1750
|
+
* if (stats.enrolled) {
|
|
1751
|
+
* console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
|
|
1752
|
+
* console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
|
|
1753
|
+
* console.log(`Referrals: ${stats.totalReferrals}`);
|
|
1754
|
+
* console.log(`Conversions: ${stats.totalConversions}`);
|
|
1755
|
+
* }
|
|
1756
|
+
* ```
|
|
1757
|
+
*/
|
|
1758
|
+
getStats(): Promise<AffiliateStats>;
|
|
1759
|
+
/**
|
|
1760
|
+
* Get affiliate commission history.
|
|
1761
|
+
* Requires customer session token.
|
|
1762
|
+
*
|
|
1763
|
+
* @example
|
|
1764
|
+
* ```typescript
|
|
1765
|
+
* const { commissions, total } = await stackbe.affiliates.getCommissions();
|
|
1766
|
+
*
|
|
1767
|
+
* commissions.forEach((c) => {
|
|
1768
|
+
* console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
|
|
1769
|
+
* });
|
|
1770
|
+
* ```
|
|
1771
|
+
*/
|
|
1772
|
+
getCommissions(): Promise<AffiliateCommissionsResponse>;
|
|
1773
|
+
/**
|
|
1774
|
+
* Track a referral click (store token for attribution).
|
|
1775
|
+
* Call this when a user lands on your site with a referral code.
|
|
1776
|
+
* Requires API key.
|
|
1777
|
+
*
|
|
1778
|
+
* @example
|
|
1779
|
+
* ```typescript
|
|
1780
|
+
* // In your landing page handler
|
|
1781
|
+
* const refCode = req.query.ref;
|
|
1782
|
+
* if (refCode) {
|
|
1783
|
+
* const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
|
|
1784
|
+
* // Store token in cookie for attribution on signup
|
|
1785
|
+
* res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
|
|
1786
|
+
* }
|
|
1787
|
+
* ```
|
|
1788
|
+
*/
|
|
1789
|
+
trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
interface EarlyAccessSignup {
|
|
1793
|
+
id: string;
|
|
1794
|
+
status: 'new' | 'invited' | 'converted' | 'archived';
|
|
1795
|
+
email: string;
|
|
1796
|
+
name?: string;
|
|
1797
|
+
createdAt: string;
|
|
1798
|
+
}
|
|
1799
|
+
interface CreateEarlyAccessSignupOptions {
|
|
1800
|
+
email: string;
|
|
1801
|
+
name?: string;
|
|
1802
|
+
note?: string;
|
|
1803
|
+
metadata?: Record<string, any>;
|
|
1804
|
+
}
|
|
1805
|
+
interface EarlyAccessSignupListResponse {
|
|
1806
|
+
items: Array<{
|
|
1807
|
+
id: string;
|
|
1808
|
+
email: string;
|
|
1809
|
+
name?: string;
|
|
1810
|
+
status: string;
|
|
1811
|
+
metadata?: Record<string, any>;
|
|
1812
|
+
createdAt: string;
|
|
1813
|
+
}>;
|
|
1814
|
+
page: number;
|
|
1815
|
+
limit: number;
|
|
1816
|
+
total: number;
|
|
1817
|
+
hasMore: boolean;
|
|
1818
|
+
}
|
|
1819
|
+
interface ListEarlyAccessOptions {
|
|
1820
|
+
status?: 'new' | 'invited' | 'converted' | 'archived';
|
|
1821
|
+
search?: string;
|
|
1822
|
+
limit?: number;
|
|
1823
|
+
offset?: number;
|
|
1824
|
+
}
|
|
1825
|
+
declare class EarlyAccessClient {
|
|
1826
|
+
private http;
|
|
1827
|
+
private appId;
|
|
1828
|
+
constructor(http: HttpClient, appId: string);
|
|
1829
|
+
/**
|
|
1830
|
+
* Submit an early access / waitlist signup.
|
|
1831
|
+
* This is a public endpoint - no auth required.
|
|
1832
|
+
*
|
|
1833
|
+
* @example
|
|
1834
|
+
* ```typescript
|
|
1835
|
+
* // Basic signup
|
|
1836
|
+
* const signup = await stackbe.earlyAccess.signup({
|
|
1837
|
+
* email: 'user@example.com',
|
|
1838
|
+
* });
|
|
1839
|
+
*
|
|
1840
|
+
* // With additional info
|
|
1841
|
+
* const signup = await stackbe.earlyAccess.signup({
|
|
1842
|
+
* email: 'user@example.com',
|
|
1843
|
+
* name: 'John Doe',
|
|
1844
|
+
* note: 'Interested in enterprise features',
|
|
1845
|
+
* metadata: { source: 'landing_page', campaign: 'launch' },
|
|
1846
|
+
* });
|
|
1847
|
+
*
|
|
1848
|
+
* console.log(`Signup ID: ${signup.id}`);
|
|
1849
|
+
* ```
|
|
1850
|
+
*/
|
|
1851
|
+
signup(options: CreateEarlyAccessSignupOptions): Promise<EarlyAccessSignup>;
|
|
1852
|
+
/**
|
|
1853
|
+
* List early access signups.
|
|
1854
|
+
* Requires API key (admin).
|
|
1855
|
+
*
|
|
1856
|
+
* @example
|
|
1857
|
+
* ```typescript
|
|
1858
|
+
* // Get all signups
|
|
1859
|
+
* const { items, total } = await stackbe.earlyAccess.list();
|
|
1860
|
+
*
|
|
1861
|
+
* // Filter by status
|
|
1862
|
+
* const newSignups = await stackbe.earlyAccess.list({ status: 'new' });
|
|
1863
|
+
*
|
|
1864
|
+
* // Search by email
|
|
1865
|
+
* const results = await stackbe.earlyAccess.list({ search: 'example.com' });
|
|
1866
|
+
*
|
|
1867
|
+
* // Paginate
|
|
1868
|
+
* const page2 = await stackbe.earlyAccess.list({ offset: 50, limit: 50 });
|
|
1869
|
+
* ```
|
|
1870
|
+
*/
|
|
1871
|
+
list(options?: ListEarlyAccessOptions): Promise<EarlyAccessSignupListResponse>;
|
|
1872
|
+
/**
|
|
1873
|
+
* Get a specific early access signup.
|
|
1874
|
+
* Requires API key (admin).
|
|
1875
|
+
*
|
|
1876
|
+
* @example
|
|
1877
|
+
* ```typescript
|
|
1878
|
+
* const signup = await stackbe.earlyAccess.get('signup_123');
|
|
1879
|
+
* console.log(`${signup.email} - ${signup.status}`);
|
|
1880
|
+
* ```
|
|
1881
|
+
*/
|
|
1882
|
+
get(signupId: string): Promise<EarlyAccessSignup>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Update the status of an early access signup.
|
|
1885
|
+
* Requires API key (admin).
|
|
1886
|
+
*
|
|
1887
|
+
* @example
|
|
1888
|
+
* ```typescript
|
|
1889
|
+
* // Mark as invited
|
|
1890
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'invited');
|
|
1891
|
+
*
|
|
1892
|
+
* // Mark as converted (user signed up)
|
|
1893
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'converted');
|
|
1894
|
+
*
|
|
1895
|
+
* // Archive
|
|
1896
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'archived');
|
|
1897
|
+
* ```
|
|
1898
|
+
*/
|
|
1899
|
+
updateStatus(signupId: string, status: 'new' | 'invited' | 'converted' | 'archived'): Promise<EarlyAccessSignup>;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1652
1902
|
declare class StackBE {
|
|
1653
1903
|
private http;
|
|
1654
1904
|
private appId;
|
|
@@ -1672,6 +1922,10 @@ declare class StackBE {
|
|
|
1672
1922
|
readonly products: ProductsClient;
|
|
1673
1923
|
/** Feature requests and voting */
|
|
1674
1924
|
readonly featureRequests: FeatureRequestsClient;
|
|
1925
|
+
/** Affiliate program (customer-facing) */
|
|
1926
|
+
readonly affiliates: AffiliatesClient;
|
|
1927
|
+
/** Early access / waitlist signups */
|
|
1928
|
+
readonly earlyAccess: EarlyAccessClient;
|
|
1675
1929
|
/**
|
|
1676
1930
|
* Create a new StackBE client.
|
|
1677
1931
|
*
|
|
@@ -1772,4 +2026,4 @@ declare class StackBE {
|
|
|
1772
2026
|
}): (req: any, res: any, next: any) => Promise<any>;
|
|
1773
2027
|
}
|
|
1774
2028
|
|
|
1775
|
-
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 };
|
|
2029
|
+
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,
|
|
@@ -1490,13 +1492,16 @@ var FeatureRequestsClient = class {
|
|
|
1490
1492
|
* @example
|
|
1491
1493
|
* ```typescript
|
|
1492
1494
|
* // Get all feature requests
|
|
1493
|
-
* const {
|
|
1495
|
+
* const { items, total, hasMore } = await stackbe.featureRequests.list();
|
|
1494
1496
|
*
|
|
1495
1497
|
* // Filter by status
|
|
1496
1498
|
* const planned = await stackbe.featureRequests.list({ status: 'planned' });
|
|
1497
1499
|
*
|
|
1498
1500
|
* // Sort by votes
|
|
1499
1501
|
* const popular = await stackbe.featureRequests.list({ sortBy: 'votes' });
|
|
1502
|
+
*
|
|
1503
|
+
* // Paginate
|
|
1504
|
+
* const page2 = await stackbe.featureRequests.list({ offset: 50, limit: 50 });
|
|
1500
1505
|
* ```
|
|
1501
1506
|
*/
|
|
1502
1507
|
async list(options = {}) {
|
|
@@ -1691,6 +1696,213 @@ var FeatureRequestsClient = class {
|
|
|
1691
1696
|
}
|
|
1692
1697
|
};
|
|
1693
1698
|
|
|
1699
|
+
// src/affiliates.ts
|
|
1700
|
+
var AffiliatesClient = class {
|
|
1701
|
+
constructor(http) {
|
|
1702
|
+
this.http = http;
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Get the current customer's affiliate info.
|
|
1706
|
+
* Requires customer session token.
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* ```typescript
|
|
1710
|
+
* const affiliate = await stackbe.affiliates.get();
|
|
1711
|
+
*
|
|
1712
|
+
* if (affiliate.enrolled) {
|
|
1713
|
+
* console.log(`Your referral code: ${affiliate.code}`);
|
|
1714
|
+
* console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
|
|
1715
|
+
* } else {
|
|
1716
|
+
* console.log('Not enrolled in affiliate program');
|
|
1717
|
+
* }
|
|
1718
|
+
* ```
|
|
1719
|
+
*/
|
|
1720
|
+
async get() {
|
|
1721
|
+
return this.http.get("/v1/affiliate");
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Enroll the current customer as an affiliate.
|
|
1725
|
+
* Requires customer session token.
|
|
1726
|
+
*
|
|
1727
|
+
* @example
|
|
1728
|
+
* ```typescript
|
|
1729
|
+
* // Enroll with auto-generated code
|
|
1730
|
+
* const affiliate = await stackbe.affiliates.enroll();
|
|
1731
|
+
* console.log(`Your referral code: ${affiliate.code}`);
|
|
1732
|
+
*
|
|
1733
|
+
* // Enroll with custom code
|
|
1734
|
+
* const affiliate = await stackbe.affiliates.enroll({
|
|
1735
|
+
* code: 'MYCODE',
|
|
1736
|
+
* payoutEmail: 'payouts@example.com',
|
|
1737
|
+
* });
|
|
1738
|
+
* ```
|
|
1739
|
+
*/
|
|
1740
|
+
async enroll(options = {}) {
|
|
1741
|
+
return this.http.post("/v1/affiliate/enroll", options);
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Get affiliate statistics.
|
|
1745
|
+
* Requires customer session token.
|
|
1746
|
+
*
|
|
1747
|
+
* @example
|
|
1748
|
+
* ```typescript
|
|
1749
|
+
* const stats = await stackbe.affiliates.getStats();
|
|
1750
|
+
*
|
|
1751
|
+
* if (stats.enrolled) {
|
|
1752
|
+
* console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
|
|
1753
|
+
* console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
|
|
1754
|
+
* console.log(`Referrals: ${stats.totalReferrals}`);
|
|
1755
|
+
* console.log(`Conversions: ${stats.totalConversions}`);
|
|
1756
|
+
* }
|
|
1757
|
+
* ```
|
|
1758
|
+
*/
|
|
1759
|
+
async getStats() {
|
|
1760
|
+
return this.http.get("/v1/affiliate/stats");
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Get affiliate commission history.
|
|
1764
|
+
* Requires customer session token.
|
|
1765
|
+
*
|
|
1766
|
+
* @example
|
|
1767
|
+
* ```typescript
|
|
1768
|
+
* const { commissions, total } = await stackbe.affiliates.getCommissions();
|
|
1769
|
+
*
|
|
1770
|
+
* commissions.forEach((c) => {
|
|
1771
|
+
* console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
|
|
1772
|
+
* });
|
|
1773
|
+
* ```
|
|
1774
|
+
*/
|
|
1775
|
+
async getCommissions() {
|
|
1776
|
+
return this.http.get("/v1/affiliate/commissions");
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Track a referral click (store token for attribution).
|
|
1780
|
+
* Call this when a user lands on your site with a referral code.
|
|
1781
|
+
* Requires API key.
|
|
1782
|
+
*
|
|
1783
|
+
* @example
|
|
1784
|
+
* ```typescript
|
|
1785
|
+
* // In your landing page handler
|
|
1786
|
+
* const refCode = req.query.ref;
|
|
1787
|
+
* if (refCode) {
|
|
1788
|
+
* const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
|
|
1789
|
+
* // Store token in cookie for attribution on signup
|
|
1790
|
+
* res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
|
|
1791
|
+
* }
|
|
1792
|
+
* ```
|
|
1793
|
+
*/
|
|
1794
|
+
async trackReferral(code, referralUrl) {
|
|
1795
|
+
return this.http.post("/v1/affiliate/track", {
|
|
1796
|
+
code,
|
|
1797
|
+
referralUrl
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
|
|
1802
|
+
// src/early-access.ts
|
|
1803
|
+
var EarlyAccessClient = class {
|
|
1804
|
+
constructor(http, appId) {
|
|
1805
|
+
this.http = http;
|
|
1806
|
+
this.appId = appId;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Submit an early access / waitlist signup.
|
|
1810
|
+
* This is a public endpoint - no auth required.
|
|
1811
|
+
*
|
|
1812
|
+
* @example
|
|
1813
|
+
* ```typescript
|
|
1814
|
+
* // Basic signup
|
|
1815
|
+
* const signup = await stackbe.earlyAccess.signup({
|
|
1816
|
+
* email: 'user@example.com',
|
|
1817
|
+
* });
|
|
1818
|
+
*
|
|
1819
|
+
* // With additional info
|
|
1820
|
+
* const signup = await stackbe.earlyAccess.signup({
|
|
1821
|
+
* email: 'user@example.com',
|
|
1822
|
+
* name: 'John Doe',
|
|
1823
|
+
* note: 'Interested in enterprise features',
|
|
1824
|
+
* metadata: { source: 'landing_page', campaign: 'launch' },
|
|
1825
|
+
* });
|
|
1826
|
+
*
|
|
1827
|
+
* console.log(`Signup ID: ${signup.id}`);
|
|
1828
|
+
* ```
|
|
1829
|
+
*/
|
|
1830
|
+
async signup(options) {
|
|
1831
|
+
return this.http.post(
|
|
1832
|
+
`/v1/apps/${this.appId}/early-access/signups`,
|
|
1833
|
+
options
|
|
1834
|
+
);
|
|
1835
|
+
}
|
|
1836
|
+
// ==================== Admin Methods ====================
|
|
1837
|
+
/**
|
|
1838
|
+
* List early access signups.
|
|
1839
|
+
* Requires API key (admin).
|
|
1840
|
+
*
|
|
1841
|
+
* @example
|
|
1842
|
+
* ```typescript
|
|
1843
|
+
* // Get all signups
|
|
1844
|
+
* const { items, total } = await stackbe.earlyAccess.list();
|
|
1845
|
+
*
|
|
1846
|
+
* // Filter by status
|
|
1847
|
+
* const newSignups = await stackbe.earlyAccess.list({ status: 'new' });
|
|
1848
|
+
*
|
|
1849
|
+
* // Search by email
|
|
1850
|
+
* const results = await stackbe.earlyAccess.list({ search: 'example.com' });
|
|
1851
|
+
*
|
|
1852
|
+
* // Paginate
|
|
1853
|
+
* const page2 = await stackbe.earlyAccess.list({ offset: 50, limit: 50 });
|
|
1854
|
+
* ```
|
|
1855
|
+
*/
|
|
1856
|
+
async list(options = {}) {
|
|
1857
|
+
const params = {};
|
|
1858
|
+
if (options.status) params.status = options.status;
|
|
1859
|
+
if (options.search) params.search = options.search;
|
|
1860
|
+
if (options.limit) params.limit = options.limit;
|
|
1861
|
+
if (options.offset) params.offset = options.offset;
|
|
1862
|
+
return this.http.get(
|
|
1863
|
+
`/v1/apps/${this.appId}/early-access/signups`,
|
|
1864
|
+
params
|
|
1865
|
+
);
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Get a specific early access signup.
|
|
1869
|
+
* Requires API key (admin).
|
|
1870
|
+
*
|
|
1871
|
+
* @example
|
|
1872
|
+
* ```typescript
|
|
1873
|
+
* const signup = await stackbe.earlyAccess.get('signup_123');
|
|
1874
|
+
* console.log(`${signup.email} - ${signup.status}`);
|
|
1875
|
+
* ```
|
|
1876
|
+
*/
|
|
1877
|
+
async get(signupId) {
|
|
1878
|
+
return this.http.get(
|
|
1879
|
+
`/v1/apps/${this.appId}/early-access/signups/${signupId}`
|
|
1880
|
+
);
|
|
1881
|
+
}
|
|
1882
|
+
/**
|
|
1883
|
+
* Update the status of an early access signup.
|
|
1884
|
+
* Requires API key (admin).
|
|
1885
|
+
*
|
|
1886
|
+
* @example
|
|
1887
|
+
* ```typescript
|
|
1888
|
+
* // Mark as invited
|
|
1889
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'invited');
|
|
1890
|
+
*
|
|
1891
|
+
* // Mark as converted (user signed up)
|
|
1892
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'converted');
|
|
1893
|
+
*
|
|
1894
|
+
* // Archive
|
|
1895
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'archived');
|
|
1896
|
+
* ```
|
|
1897
|
+
*/
|
|
1898
|
+
async updateStatus(signupId, status) {
|
|
1899
|
+
return this.http.patch(
|
|
1900
|
+
`/v1/apps/${this.appId}/early-access/signups/${signupId}`,
|
|
1901
|
+
{ status }
|
|
1902
|
+
);
|
|
1903
|
+
}
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1694
1906
|
// src/client.ts
|
|
1695
1907
|
var DEFAULT_BASE_URL = "https://api.stackbe.io";
|
|
1696
1908
|
var DEFAULT_TIMEOUT = 3e4;
|
|
@@ -1754,6 +1966,8 @@ var StackBE = class {
|
|
|
1754
1966
|
this.plans = new PlansClient(this.http);
|
|
1755
1967
|
this.products = new ProductsClient(this.http, config.appId);
|
|
1756
1968
|
this.featureRequests = new FeatureRequestsClient(this.http, config.appId);
|
|
1969
|
+
this.affiliates = new AffiliatesClient(this.http);
|
|
1970
|
+
this.earlyAccess = new EarlyAccessClient(this.http, config.appId);
|
|
1757
1971
|
}
|
|
1758
1972
|
/**
|
|
1759
1973
|
* Create a middleware for Express that tracks usage automatically.
|
|
@@ -1887,9 +2101,11 @@ var StackBE = class {
|
|
|
1887
2101
|
};
|
|
1888
2102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1889
2103
|
0 && (module.exports = {
|
|
2104
|
+
AffiliatesClient,
|
|
1890
2105
|
AuthClient,
|
|
1891
2106
|
CheckoutClient,
|
|
1892
2107
|
CustomersClient,
|
|
2108
|
+
EarlyAccessClient,
|
|
1893
2109
|
EntitlementsClient,
|
|
1894
2110
|
FeatureRequestsClient,
|
|
1895
2111
|
OrganizationsClient,
|
package/dist/index.mjs
CHANGED
|
@@ -1453,13 +1453,16 @@ var FeatureRequestsClient = class {
|
|
|
1453
1453
|
* @example
|
|
1454
1454
|
* ```typescript
|
|
1455
1455
|
* // Get all feature requests
|
|
1456
|
-
* const {
|
|
1456
|
+
* const { items, total, hasMore } = await stackbe.featureRequests.list();
|
|
1457
1457
|
*
|
|
1458
1458
|
* // Filter by status
|
|
1459
1459
|
* const planned = await stackbe.featureRequests.list({ status: 'planned' });
|
|
1460
1460
|
*
|
|
1461
1461
|
* // Sort by votes
|
|
1462
1462
|
* const popular = await stackbe.featureRequests.list({ sortBy: 'votes' });
|
|
1463
|
+
*
|
|
1464
|
+
* // Paginate
|
|
1465
|
+
* const page2 = await stackbe.featureRequests.list({ offset: 50, limit: 50 });
|
|
1463
1466
|
* ```
|
|
1464
1467
|
*/
|
|
1465
1468
|
async list(options = {}) {
|
|
@@ -1654,6 +1657,213 @@ var FeatureRequestsClient = class {
|
|
|
1654
1657
|
}
|
|
1655
1658
|
};
|
|
1656
1659
|
|
|
1660
|
+
// src/affiliates.ts
|
|
1661
|
+
var AffiliatesClient = class {
|
|
1662
|
+
constructor(http) {
|
|
1663
|
+
this.http = http;
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* Get the current customer's affiliate info.
|
|
1667
|
+
* Requires customer session token.
|
|
1668
|
+
*
|
|
1669
|
+
* @example
|
|
1670
|
+
* ```typescript
|
|
1671
|
+
* const affiliate = await stackbe.affiliates.get();
|
|
1672
|
+
*
|
|
1673
|
+
* if (affiliate.enrolled) {
|
|
1674
|
+
* console.log(`Your referral code: ${affiliate.code}`);
|
|
1675
|
+
* console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
|
|
1676
|
+
* } else {
|
|
1677
|
+
* console.log('Not enrolled in affiliate program');
|
|
1678
|
+
* }
|
|
1679
|
+
* ```
|
|
1680
|
+
*/
|
|
1681
|
+
async get() {
|
|
1682
|
+
return this.http.get("/v1/affiliate");
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Enroll the current customer as an affiliate.
|
|
1686
|
+
* Requires customer session token.
|
|
1687
|
+
*
|
|
1688
|
+
* @example
|
|
1689
|
+
* ```typescript
|
|
1690
|
+
* // Enroll with auto-generated code
|
|
1691
|
+
* const affiliate = await stackbe.affiliates.enroll();
|
|
1692
|
+
* console.log(`Your referral code: ${affiliate.code}`);
|
|
1693
|
+
*
|
|
1694
|
+
* // Enroll with custom code
|
|
1695
|
+
* const affiliate = await stackbe.affiliates.enroll({
|
|
1696
|
+
* code: 'MYCODE',
|
|
1697
|
+
* payoutEmail: 'payouts@example.com',
|
|
1698
|
+
* });
|
|
1699
|
+
* ```
|
|
1700
|
+
*/
|
|
1701
|
+
async enroll(options = {}) {
|
|
1702
|
+
return this.http.post("/v1/affiliate/enroll", options);
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Get affiliate statistics.
|
|
1706
|
+
* Requires customer session token.
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* ```typescript
|
|
1710
|
+
* const stats = await stackbe.affiliates.getStats();
|
|
1711
|
+
*
|
|
1712
|
+
* if (stats.enrolled) {
|
|
1713
|
+
* console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
|
|
1714
|
+
* console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
|
|
1715
|
+
* console.log(`Referrals: ${stats.totalReferrals}`);
|
|
1716
|
+
* console.log(`Conversions: ${stats.totalConversions}`);
|
|
1717
|
+
* }
|
|
1718
|
+
* ```
|
|
1719
|
+
*/
|
|
1720
|
+
async getStats() {
|
|
1721
|
+
return this.http.get("/v1/affiliate/stats");
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Get affiliate commission history.
|
|
1725
|
+
* Requires customer session token.
|
|
1726
|
+
*
|
|
1727
|
+
* @example
|
|
1728
|
+
* ```typescript
|
|
1729
|
+
* const { commissions, total } = await stackbe.affiliates.getCommissions();
|
|
1730
|
+
*
|
|
1731
|
+
* commissions.forEach((c) => {
|
|
1732
|
+
* console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
|
|
1733
|
+
* });
|
|
1734
|
+
* ```
|
|
1735
|
+
*/
|
|
1736
|
+
async getCommissions() {
|
|
1737
|
+
return this.http.get("/v1/affiliate/commissions");
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Track a referral click (store token for attribution).
|
|
1741
|
+
* Call this when a user lands on your site with a referral code.
|
|
1742
|
+
* Requires API key.
|
|
1743
|
+
*
|
|
1744
|
+
* @example
|
|
1745
|
+
* ```typescript
|
|
1746
|
+
* // In your landing page handler
|
|
1747
|
+
* const refCode = req.query.ref;
|
|
1748
|
+
* if (refCode) {
|
|
1749
|
+
* const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
|
|
1750
|
+
* // Store token in cookie for attribution on signup
|
|
1751
|
+
* res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
|
|
1752
|
+
* }
|
|
1753
|
+
* ```
|
|
1754
|
+
*/
|
|
1755
|
+
async trackReferral(code, referralUrl) {
|
|
1756
|
+
return this.http.post("/v1/affiliate/track", {
|
|
1757
|
+
code,
|
|
1758
|
+
referralUrl
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1763
|
+
// src/early-access.ts
|
|
1764
|
+
var EarlyAccessClient = class {
|
|
1765
|
+
constructor(http, appId) {
|
|
1766
|
+
this.http = http;
|
|
1767
|
+
this.appId = appId;
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
* Submit an early access / waitlist signup.
|
|
1771
|
+
* This is a public endpoint - no auth required.
|
|
1772
|
+
*
|
|
1773
|
+
* @example
|
|
1774
|
+
* ```typescript
|
|
1775
|
+
* // Basic signup
|
|
1776
|
+
* const signup = await stackbe.earlyAccess.signup({
|
|
1777
|
+
* email: 'user@example.com',
|
|
1778
|
+
* });
|
|
1779
|
+
*
|
|
1780
|
+
* // With additional info
|
|
1781
|
+
* const signup = await stackbe.earlyAccess.signup({
|
|
1782
|
+
* email: 'user@example.com',
|
|
1783
|
+
* name: 'John Doe',
|
|
1784
|
+
* note: 'Interested in enterprise features',
|
|
1785
|
+
* metadata: { source: 'landing_page', campaign: 'launch' },
|
|
1786
|
+
* });
|
|
1787
|
+
*
|
|
1788
|
+
* console.log(`Signup ID: ${signup.id}`);
|
|
1789
|
+
* ```
|
|
1790
|
+
*/
|
|
1791
|
+
async signup(options) {
|
|
1792
|
+
return this.http.post(
|
|
1793
|
+
`/v1/apps/${this.appId}/early-access/signups`,
|
|
1794
|
+
options
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
// ==================== Admin Methods ====================
|
|
1798
|
+
/**
|
|
1799
|
+
* List early access signups.
|
|
1800
|
+
* Requires API key (admin).
|
|
1801
|
+
*
|
|
1802
|
+
* @example
|
|
1803
|
+
* ```typescript
|
|
1804
|
+
* // Get all signups
|
|
1805
|
+
* const { items, total } = await stackbe.earlyAccess.list();
|
|
1806
|
+
*
|
|
1807
|
+
* // Filter by status
|
|
1808
|
+
* const newSignups = await stackbe.earlyAccess.list({ status: 'new' });
|
|
1809
|
+
*
|
|
1810
|
+
* // Search by email
|
|
1811
|
+
* const results = await stackbe.earlyAccess.list({ search: 'example.com' });
|
|
1812
|
+
*
|
|
1813
|
+
* // Paginate
|
|
1814
|
+
* const page2 = await stackbe.earlyAccess.list({ offset: 50, limit: 50 });
|
|
1815
|
+
* ```
|
|
1816
|
+
*/
|
|
1817
|
+
async list(options = {}) {
|
|
1818
|
+
const params = {};
|
|
1819
|
+
if (options.status) params.status = options.status;
|
|
1820
|
+
if (options.search) params.search = options.search;
|
|
1821
|
+
if (options.limit) params.limit = options.limit;
|
|
1822
|
+
if (options.offset) params.offset = options.offset;
|
|
1823
|
+
return this.http.get(
|
|
1824
|
+
`/v1/apps/${this.appId}/early-access/signups`,
|
|
1825
|
+
params
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Get a specific early access signup.
|
|
1830
|
+
* Requires API key (admin).
|
|
1831
|
+
*
|
|
1832
|
+
* @example
|
|
1833
|
+
* ```typescript
|
|
1834
|
+
* const signup = await stackbe.earlyAccess.get('signup_123');
|
|
1835
|
+
* console.log(`${signup.email} - ${signup.status}`);
|
|
1836
|
+
* ```
|
|
1837
|
+
*/
|
|
1838
|
+
async get(signupId) {
|
|
1839
|
+
return this.http.get(
|
|
1840
|
+
`/v1/apps/${this.appId}/early-access/signups/${signupId}`
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Update the status of an early access signup.
|
|
1845
|
+
* Requires API key (admin).
|
|
1846
|
+
*
|
|
1847
|
+
* @example
|
|
1848
|
+
* ```typescript
|
|
1849
|
+
* // Mark as invited
|
|
1850
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'invited');
|
|
1851
|
+
*
|
|
1852
|
+
* // Mark as converted (user signed up)
|
|
1853
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'converted');
|
|
1854
|
+
*
|
|
1855
|
+
* // Archive
|
|
1856
|
+
* await stackbe.earlyAccess.updateStatus('signup_123', 'archived');
|
|
1857
|
+
* ```
|
|
1858
|
+
*/
|
|
1859
|
+
async updateStatus(signupId, status) {
|
|
1860
|
+
return this.http.patch(
|
|
1861
|
+
`/v1/apps/${this.appId}/early-access/signups/${signupId}`,
|
|
1862
|
+
{ status }
|
|
1863
|
+
);
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1866
|
+
|
|
1657
1867
|
// src/client.ts
|
|
1658
1868
|
var DEFAULT_BASE_URL = "https://api.stackbe.io";
|
|
1659
1869
|
var DEFAULT_TIMEOUT = 3e4;
|
|
@@ -1717,6 +1927,8 @@ var StackBE = class {
|
|
|
1717
1927
|
this.plans = new PlansClient(this.http);
|
|
1718
1928
|
this.products = new ProductsClient(this.http, config.appId);
|
|
1719
1929
|
this.featureRequests = new FeatureRequestsClient(this.http, config.appId);
|
|
1930
|
+
this.affiliates = new AffiliatesClient(this.http);
|
|
1931
|
+
this.earlyAccess = new EarlyAccessClient(this.http, config.appId);
|
|
1720
1932
|
}
|
|
1721
1933
|
/**
|
|
1722
1934
|
* Create a middleware for Express that tracks usage automatically.
|
|
@@ -1849,9 +2061,11 @@ var StackBE = class {
|
|
|
1849
2061
|
}
|
|
1850
2062
|
};
|
|
1851
2063
|
export {
|
|
2064
|
+
AffiliatesClient,
|
|
1852
2065
|
AuthClient,
|
|
1853
2066
|
CheckoutClient,
|
|
1854
2067
|
CustomersClient,
|
|
2068
|
+
EarlyAccessClient,
|
|
1855
2069
|
EntitlementsClient,
|
|
1856
2070
|
FeatureRequestsClient,
|
|
1857
2071
|
OrganizationsClient,
|
package/package.json
CHANGED