@stackbe/sdk 0.14.0 → 0.15.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 +128 -51
- package/dist/index.d.ts +128 -51
- package/dist/index.js +41 -54
- package/dist/index.mjs +41 -54
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -292,6 +292,17 @@ interface SwitchOrganizationResponse {
|
|
|
292
292
|
/** Customer's role in the organization */
|
|
293
293
|
orgRole: 'owner' | 'admin' | 'member';
|
|
294
294
|
}
|
|
295
|
+
/** Lightweight org membership returned in session responses */
|
|
296
|
+
interface OrganizationMembership {
|
|
297
|
+
/** Organization ID */
|
|
298
|
+
id: string;
|
|
299
|
+
/** Organization name */
|
|
300
|
+
name: string;
|
|
301
|
+
/** Organization slug */
|
|
302
|
+
slug: string;
|
|
303
|
+
/** Customer's role in this organization */
|
|
304
|
+
role: 'owner' | 'admin' | 'member';
|
|
305
|
+
}
|
|
295
306
|
interface SessionResponse {
|
|
296
307
|
valid: boolean;
|
|
297
308
|
/** Customer ID */
|
|
@@ -306,6 +317,12 @@ interface SessionResponse {
|
|
|
306
317
|
organizationId?: string;
|
|
307
318
|
/** Role in the organization */
|
|
308
319
|
orgRole?: 'owner' | 'admin' | 'member';
|
|
320
|
+
/**
|
|
321
|
+
* All org memberships for this customer.
|
|
322
|
+
* Included when the app has `enableOrganizations: true`, null otherwise.
|
|
323
|
+
* Use this to build an org-switcher UI without an extra API call.
|
|
324
|
+
*/
|
|
325
|
+
organizations?: OrganizationMembership[] | null;
|
|
309
326
|
/** Customer details (if included) */
|
|
310
327
|
customer?: Customer;
|
|
311
328
|
/** Current subscription (if any) */
|
|
@@ -627,6 +644,70 @@ type CustomerCreatedEvent = WebhookEvent<'customer_created', CustomerWebhookPayl
|
|
|
627
644
|
type CustomerUpdatedEvent = WebhookEvent<'customer_updated', CustomerWebhookPayload>;
|
|
628
645
|
/** Union of all webhook event types */
|
|
629
646
|
type AnyWebhookEvent = SubscriptionCreatedEvent | SubscriptionUpdatedEvent | SubscriptionCancelledEvent | SubscriptionRenewedEvent | TrialStartedEvent | TrialEndedEvent | PaymentSucceededEvent | PaymentFailedEvent | CustomerCreatedEvent | CustomerUpdatedEvent;
|
|
647
|
+
interface DealRegistration {
|
|
648
|
+
id: string;
|
|
649
|
+
affiliateId: string;
|
|
650
|
+
programId: string;
|
|
651
|
+
leadEmail: string;
|
|
652
|
+
leadName?: string | null;
|
|
653
|
+
notes?: string | null;
|
|
654
|
+
status: 'pending' | 'approved' | 'converted' | 'expired' | 'rejected';
|
|
655
|
+
expiresAt: string;
|
|
656
|
+
approvedAt?: string | null;
|
|
657
|
+
convertedAt?: string | null;
|
|
658
|
+
rejectedAt?: string | null;
|
|
659
|
+
rejectionReason?: string | null;
|
|
660
|
+
convertedCustomerId?: string | null;
|
|
661
|
+
convertedSubscriptionId?: string | null;
|
|
662
|
+
createdAt: string;
|
|
663
|
+
updatedAt: string;
|
|
664
|
+
}
|
|
665
|
+
interface PartnerDashboard {
|
|
666
|
+
affiliate: {
|
|
667
|
+
id: string;
|
|
668
|
+
code: string;
|
|
669
|
+
type: string;
|
|
670
|
+
status: string;
|
|
671
|
+
totalEarned: number;
|
|
672
|
+
pendingBalance: number;
|
|
673
|
+
paidOut: number;
|
|
674
|
+
totalReferrals: number;
|
|
675
|
+
totalConversions: number;
|
|
676
|
+
};
|
|
677
|
+
tier?: {
|
|
678
|
+
id: string;
|
|
679
|
+
name: string;
|
|
680
|
+
level: number;
|
|
681
|
+
commissionRate: number;
|
|
682
|
+
commissionType: string;
|
|
683
|
+
} | null;
|
|
684
|
+
earningsBySource: {
|
|
685
|
+
link: number;
|
|
686
|
+
coupon: number;
|
|
687
|
+
deal: number;
|
|
688
|
+
};
|
|
689
|
+
recentCommissions: Array<{
|
|
690
|
+
id: string;
|
|
691
|
+
amount: number;
|
|
692
|
+
currency: string;
|
|
693
|
+
status: string;
|
|
694
|
+
createdAt: string;
|
|
695
|
+
}>;
|
|
696
|
+
activeDeals: Array<{
|
|
697
|
+
id: string;
|
|
698
|
+
leadEmail: string;
|
|
699
|
+
status: string;
|
|
700
|
+
expiresAt: string;
|
|
701
|
+
createdAt: string;
|
|
702
|
+
}>;
|
|
703
|
+
coupons: Array<{
|
|
704
|
+
id: string;
|
|
705
|
+
code: string;
|
|
706
|
+
discountType: string;
|
|
707
|
+
discountValue: number;
|
|
708
|
+
timesRedeemed: number;
|
|
709
|
+
}>;
|
|
710
|
+
}
|
|
630
711
|
|
|
631
712
|
declare class UsageClient {
|
|
632
713
|
private http;
|
|
@@ -2277,6 +2358,7 @@ interface AffiliateInfo {
|
|
|
2277
2358
|
enrolled: boolean;
|
|
2278
2359
|
id?: string;
|
|
2279
2360
|
code?: string;
|
|
2361
|
+
type?: 'affiliate' | 'referral' | 'reseller';
|
|
2280
2362
|
status?: 'active' | 'suspended' | 'pending';
|
|
2281
2363
|
totalEarned?: number;
|
|
2282
2364
|
pendingBalance?: number;
|
|
@@ -2288,6 +2370,7 @@ interface AffiliateInfo {
|
|
|
2288
2370
|
interface AffiliateEnrollment {
|
|
2289
2371
|
id: string;
|
|
2290
2372
|
code: string;
|
|
2373
|
+
type: string;
|
|
2291
2374
|
status: string;
|
|
2292
2375
|
createdAt: string;
|
|
2293
2376
|
}
|
|
@@ -2320,6 +2403,20 @@ interface EnrollOptions {
|
|
|
2320
2403
|
code?: string;
|
|
2321
2404
|
/** PayPal email for payouts */
|
|
2322
2405
|
payoutEmail?: string;
|
|
2406
|
+
/** Partner type (default: 'affiliate') */
|
|
2407
|
+
type?: 'affiliate' | 'referral' | 'reseller';
|
|
2408
|
+
}
|
|
2409
|
+
interface RegisterDealOptions {
|
|
2410
|
+
/** Email of the lead */
|
|
2411
|
+
leadEmail: string;
|
|
2412
|
+
/** Name of the lead */
|
|
2413
|
+
leadName?: string;
|
|
2414
|
+
/** Notes about the deal */
|
|
2415
|
+
notes?: string;
|
|
2416
|
+
}
|
|
2417
|
+
interface DealListResponse {
|
|
2418
|
+
deals: DealRegistration[];
|
|
2419
|
+
total: number;
|
|
2323
2420
|
}
|
|
2324
2421
|
declare class AffiliatesClient {
|
|
2325
2422
|
private http;
|
|
@@ -2327,86 +2424,66 @@ declare class AffiliatesClient {
|
|
|
2327
2424
|
/**
|
|
2328
2425
|
* Get the current customer's affiliate info.
|
|
2329
2426
|
* Requires customer session token.
|
|
2330
|
-
*
|
|
2331
|
-
* @example
|
|
2332
|
-
* ```typescript
|
|
2333
|
-
* const affiliate = await stackbe.affiliates.get();
|
|
2334
|
-
*
|
|
2335
|
-
* if (affiliate.enrolled) {
|
|
2336
|
-
* console.log(`Your referral code: ${affiliate.code}`);
|
|
2337
|
-
* console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
|
|
2338
|
-
* } else {
|
|
2339
|
-
* console.log('Not enrolled in affiliate program');
|
|
2340
|
-
* }
|
|
2341
|
-
* ```
|
|
2342
2427
|
*/
|
|
2343
2428
|
get(): Promise<AffiliateInfo>;
|
|
2344
2429
|
/**
|
|
2345
|
-
* Enroll the current customer as an affiliate.
|
|
2430
|
+
* Enroll the current customer as an affiliate/partner.
|
|
2346
2431
|
* Requires customer session token.
|
|
2347
2432
|
*
|
|
2348
2433
|
* @example
|
|
2349
2434
|
* ```typescript
|
|
2350
|
-
*
|
|
2351
|
-
* const affiliate = await stackbe.affiliates.enroll();
|
|
2435
|
+
* const affiliate = await stackbe.affiliates.enroll({ type: 'referral' });
|
|
2352
2436
|
* console.log(`Your referral code: ${affiliate.code}`);
|
|
2353
|
-
*
|
|
2354
|
-
* // Enroll with custom code
|
|
2355
|
-
* const affiliate = await stackbe.affiliates.enroll({
|
|
2356
|
-
* code: 'MYCODE',
|
|
2357
|
-
* payoutEmail: 'payouts@example.com',
|
|
2358
|
-
* });
|
|
2359
2437
|
* ```
|
|
2360
2438
|
*/
|
|
2361
2439
|
enroll(options?: EnrollOptions): Promise<AffiliateEnrollment>;
|
|
2362
2440
|
/**
|
|
2363
2441
|
* Get affiliate statistics.
|
|
2364
2442
|
* Requires customer session token.
|
|
2365
|
-
*
|
|
2366
|
-
* @example
|
|
2367
|
-
* ```typescript
|
|
2368
|
-
* const stats = await stackbe.affiliates.getStats();
|
|
2369
|
-
*
|
|
2370
|
-
* if (stats.enrolled) {
|
|
2371
|
-
* console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
|
|
2372
|
-
* console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
|
|
2373
|
-
* console.log(`Referrals: ${stats.totalReferrals}`);
|
|
2374
|
-
* console.log(`Conversions: ${stats.totalConversions}`);
|
|
2375
|
-
* }
|
|
2376
|
-
* ```
|
|
2377
2443
|
*/
|
|
2378
2444
|
getStats(): Promise<AffiliateStats>;
|
|
2379
2445
|
/**
|
|
2380
2446
|
* Get affiliate commission history.
|
|
2381
2447
|
* Requires customer session token.
|
|
2448
|
+
*/
|
|
2449
|
+
getCommissions(): Promise<AffiliateCommissionsResponse>;
|
|
2450
|
+
/**
|
|
2451
|
+
* Track a referral click (store token for attribution).
|
|
2452
|
+
* Requires API key.
|
|
2453
|
+
*/
|
|
2454
|
+
trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
|
|
2455
|
+
/**
|
|
2456
|
+
* Get the full partner dashboard with stats, earnings by source, deals, and coupons.
|
|
2457
|
+
* Requires customer session token.
|
|
2382
2458
|
*
|
|
2383
2459
|
* @example
|
|
2384
2460
|
* ```typescript
|
|
2385
|
-
* const
|
|
2386
|
-
*
|
|
2387
|
-
*
|
|
2388
|
-
*
|
|
2389
|
-
* });
|
|
2461
|
+
* const dashboard = await stackbe.affiliates.getDashboard();
|
|
2462
|
+
* console.log(`Link earnings: $${dashboard.earningsBySource.link}`);
|
|
2463
|
+
* console.log(`Coupon earnings: $${dashboard.earningsBySource.coupon}`);
|
|
2464
|
+
* console.log(`Deal earnings: $${dashboard.earningsBySource.deal}`);
|
|
2390
2465
|
* ```
|
|
2391
2466
|
*/
|
|
2392
|
-
|
|
2467
|
+
getDashboard(): Promise<PartnerDashboard>;
|
|
2393
2468
|
/**
|
|
2394
|
-
*
|
|
2395
|
-
*
|
|
2396
|
-
* Requires API key.
|
|
2469
|
+
* Register a deal (lead attribution).
|
|
2470
|
+
* Requires customer session token and active partner enrollment.
|
|
2397
2471
|
*
|
|
2398
2472
|
* @example
|
|
2399
2473
|
* ```typescript
|
|
2400
|
-
*
|
|
2401
|
-
*
|
|
2402
|
-
*
|
|
2403
|
-
*
|
|
2404
|
-
*
|
|
2405
|
-
* res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
|
|
2406
|
-
* }
|
|
2474
|
+
* const deal = await stackbe.affiliates.registerDeal({
|
|
2475
|
+
* leadEmail: 'prospect@company.com',
|
|
2476
|
+
* leadName: 'John Smith',
|
|
2477
|
+
* notes: 'Met at conference, interested in Pro plan',
|
|
2478
|
+
* });
|
|
2407
2479
|
* ```
|
|
2408
2480
|
*/
|
|
2409
|
-
|
|
2481
|
+
registerDeal(options: RegisterDealOptions): Promise<DealRegistration>;
|
|
2482
|
+
/**
|
|
2483
|
+
* List the current partner's deal registrations.
|
|
2484
|
+
* Requires customer session token.
|
|
2485
|
+
*/
|
|
2486
|
+
listDeals(): Promise<DealListResponse>;
|
|
2410
2487
|
}
|
|
2411
2488
|
|
|
2412
2489
|
interface EarlyAccessSignup {
|
|
@@ -2989,4 +3066,4 @@ declare class StackBE {
|
|
|
2989
3066
|
}): (req: any, res: any, next: any) => Promise<any>;
|
|
2990
3067
|
}
|
|
2991
3068
|
|
|
2992
|
-
export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, AnalyticsClient, type AnalyticsFilterOptions, type AnyWebhookEvent, type AttachPaymentMethodOptions, AuthClient, type BillingPortalSession, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type ChargeResult, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type Coupon, type CouponDiscountType, type CouponDuration, CouponsClient, type CreateCheckoutOptions, type CreateCouponOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type CreateSetupSessionOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerInvoice, type CustomerInvoicesResponse, type CustomerPaymentMethod, type CustomerSubscriptionHistory, type CustomerSubscriptionHistoryResponse, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, type DashboardMetrics, type DunningStatus, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestImage, type FeatureRequestListResponse, FeatureRequestsClient, type FeatureUsagePoint, type GetSubscriptionOptions, type GrowthChartPoint, type GrowthMetrics, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MRRHistoryPoint, type MagicLinkOptions, type MagicLinkResponse, type MigrateToStackbeManagedResult, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentMethod, PaymentMethodsClient, type PaymentSucceededEvent, type PaymentWebhookPayload, type PerformanceMetrics, type Plan, type PlanMetrics, PlansClient, type PopularEndpoint, type Product, ProductsClient, type RequestCountPoint, type RevenueByPlan, type SessionResponse, type SetupSessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionPlan, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type SwitchOrganizationResponse, type TimeRangeOptions, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialMetrics, type TrialStartedEvent, type TrialStatus, type UpcomingInvoice, type UpdateCouponOptions, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type ValidateCouponResult, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
|
|
3069
|
+
export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, AnalyticsClient, type AnalyticsFilterOptions, type AnyWebhookEvent, type AttachPaymentMethodOptions, AuthClient, type BillingPortalSession, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type ChargeResult, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type Coupon, type CouponDiscountType, type CouponDuration, CouponsClient, type CreateCheckoutOptions, type CreateCouponOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type CreateSetupSessionOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerInvoice, type CustomerInvoicesResponse, type CustomerPaymentMethod, type CustomerSubscriptionHistory, type CustomerSubscriptionHistoryResponse, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, type DashboardMetrics, type DunningStatus, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestImage, type FeatureRequestListResponse, FeatureRequestsClient, type FeatureUsagePoint, type GetSubscriptionOptions, type GrowthChartPoint, type GrowthMetrics, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MRRHistoryPoint, type MagicLinkOptions, type MagicLinkResponse, type MigrateToStackbeManagedResult, type Organization, type OrganizationInvite, type OrganizationMember, type OrganizationMembership, OrganizationsClient, type PaymentFailedEvent, type PaymentMethod, PaymentMethodsClient, type PaymentSucceededEvent, type PaymentWebhookPayload, type PerformanceMetrics, type Plan, type PlanMetrics, PlansClient, type PopularEndpoint, type Product, ProductsClient, type RequestCountPoint, type RevenueByPlan, type SessionResponse, type SetupSessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionPlan, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type SwitchOrganizationResponse, type TimeRangeOptions, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialMetrics, type TrialStartedEvent, type TrialStatus, type UpcomingInvoice, type UpdateCouponOptions, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type ValidateCouponResult, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
|
package/dist/index.d.ts
CHANGED
|
@@ -292,6 +292,17 @@ interface SwitchOrganizationResponse {
|
|
|
292
292
|
/** Customer's role in the organization */
|
|
293
293
|
orgRole: 'owner' | 'admin' | 'member';
|
|
294
294
|
}
|
|
295
|
+
/** Lightweight org membership returned in session responses */
|
|
296
|
+
interface OrganizationMembership {
|
|
297
|
+
/** Organization ID */
|
|
298
|
+
id: string;
|
|
299
|
+
/** Organization name */
|
|
300
|
+
name: string;
|
|
301
|
+
/** Organization slug */
|
|
302
|
+
slug: string;
|
|
303
|
+
/** Customer's role in this organization */
|
|
304
|
+
role: 'owner' | 'admin' | 'member';
|
|
305
|
+
}
|
|
295
306
|
interface SessionResponse {
|
|
296
307
|
valid: boolean;
|
|
297
308
|
/** Customer ID */
|
|
@@ -306,6 +317,12 @@ interface SessionResponse {
|
|
|
306
317
|
organizationId?: string;
|
|
307
318
|
/** Role in the organization */
|
|
308
319
|
orgRole?: 'owner' | 'admin' | 'member';
|
|
320
|
+
/**
|
|
321
|
+
* All org memberships for this customer.
|
|
322
|
+
* Included when the app has `enableOrganizations: true`, null otherwise.
|
|
323
|
+
* Use this to build an org-switcher UI without an extra API call.
|
|
324
|
+
*/
|
|
325
|
+
organizations?: OrganizationMembership[] | null;
|
|
309
326
|
/** Customer details (if included) */
|
|
310
327
|
customer?: Customer;
|
|
311
328
|
/** Current subscription (if any) */
|
|
@@ -627,6 +644,70 @@ type CustomerCreatedEvent = WebhookEvent<'customer_created', CustomerWebhookPayl
|
|
|
627
644
|
type CustomerUpdatedEvent = WebhookEvent<'customer_updated', CustomerWebhookPayload>;
|
|
628
645
|
/** Union of all webhook event types */
|
|
629
646
|
type AnyWebhookEvent = SubscriptionCreatedEvent | SubscriptionUpdatedEvent | SubscriptionCancelledEvent | SubscriptionRenewedEvent | TrialStartedEvent | TrialEndedEvent | PaymentSucceededEvent | PaymentFailedEvent | CustomerCreatedEvent | CustomerUpdatedEvent;
|
|
647
|
+
interface DealRegistration {
|
|
648
|
+
id: string;
|
|
649
|
+
affiliateId: string;
|
|
650
|
+
programId: string;
|
|
651
|
+
leadEmail: string;
|
|
652
|
+
leadName?: string | null;
|
|
653
|
+
notes?: string | null;
|
|
654
|
+
status: 'pending' | 'approved' | 'converted' | 'expired' | 'rejected';
|
|
655
|
+
expiresAt: string;
|
|
656
|
+
approvedAt?: string | null;
|
|
657
|
+
convertedAt?: string | null;
|
|
658
|
+
rejectedAt?: string | null;
|
|
659
|
+
rejectionReason?: string | null;
|
|
660
|
+
convertedCustomerId?: string | null;
|
|
661
|
+
convertedSubscriptionId?: string | null;
|
|
662
|
+
createdAt: string;
|
|
663
|
+
updatedAt: string;
|
|
664
|
+
}
|
|
665
|
+
interface PartnerDashboard {
|
|
666
|
+
affiliate: {
|
|
667
|
+
id: string;
|
|
668
|
+
code: string;
|
|
669
|
+
type: string;
|
|
670
|
+
status: string;
|
|
671
|
+
totalEarned: number;
|
|
672
|
+
pendingBalance: number;
|
|
673
|
+
paidOut: number;
|
|
674
|
+
totalReferrals: number;
|
|
675
|
+
totalConversions: number;
|
|
676
|
+
};
|
|
677
|
+
tier?: {
|
|
678
|
+
id: string;
|
|
679
|
+
name: string;
|
|
680
|
+
level: number;
|
|
681
|
+
commissionRate: number;
|
|
682
|
+
commissionType: string;
|
|
683
|
+
} | null;
|
|
684
|
+
earningsBySource: {
|
|
685
|
+
link: number;
|
|
686
|
+
coupon: number;
|
|
687
|
+
deal: number;
|
|
688
|
+
};
|
|
689
|
+
recentCommissions: Array<{
|
|
690
|
+
id: string;
|
|
691
|
+
amount: number;
|
|
692
|
+
currency: string;
|
|
693
|
+
status: string;
|
|
694
|
+
createdAt: string;
|
|
695
|
+
}>;
|
|
696
|
+
activeDeals: Array<{
|
|
697
|
+
id: string;
|
|
698
|
+
leadEmail: string;
|
|
699
|
+
status: string;
|
|
700
|
+
expiresAt: string;
|
|
701
|
+
createdAt: string;
|
|
702
|
+
}>;
|
|
703
|
+
coupons: Array<{
|
|
704
|
+
id: string;
|
|
705
|
+
code: string;
|
|
706
|
+
discountType: string;
|
|
707
|
+
discountValue: number;
|
|
708
|
+
timesRedeemed: number;
|
|
709
|
+
}>;
|
|
710
|
+
}
|
|
630
711
|
|
|
631
712
|
declare class UsageClient {
|
|
632
713
|
private http;
|
|
@@ -2277,6 +2358,7 @@ interface AffiliateInfo {
|
|
|
2277
2358
|
enrolled: boolean;
|
|
2278
2359
|
id?: string;
|
|
2279
2360
|
code?: string;
|
|
2361
|
+
type?: 'affiliate' | 'referral' | 'reseller';
|
|
2280
2362
|
status?: 'active' | 'suspended' | 'pending';
|
|
2281
2363
|
totalEarned?: number;
|
|
2282
2364
|
pendingBalance?: number;
|
|
@@ -2288,6 +2370,7 @@ interface AffiliateInfo {
|
|
|
2288
2370
|
interface AffiliateEnrollment {
|
|
2289
2371
|
id: string;
|
|
2290
2372
|
code: string;
|
|
2373
|
+
type: string;
|
|
2291
2374
|
status: string;
|
|
2292
2375
|
createdAt: string;
|
|
2293
2376
|
}
|
|
@@ -2320,6 +2403,20 @@ interface EnrollOptions {
|
|
|
2320
2403
|
code?: string;
|
|
2321
2404
|
/** PayPal email for payouts */
|
|
2322
2405
|
payoutEmail?: string;
|
|
2406
|
+
/** Partner type (default: 'affiliate') */
|
|
2407
|
+
type?: 'affiliate' | 'referral' | 'reseller';
|
|
2408
|
+
}
|
|
2409
|
+
interface RegisterDealOptions {
|
|
2410
|
+
/** Email of the lead */
|
|
2411
|
+
leadEmail: string;
|
|
2412
|
+
/** Name of the lead */
|
|
2413
|
+
leadName?: string;
|
|
2414
|
+
/** Notes about the deal */
|
|
2415
|
+
notes?: string;
|
|
2416
|
+
}
|
|
2417
|
+
interface DealListResponse {
|
|
2418
|
+
deals: DealRegistration[];
|
|
2419
|
+
total: number;
|
|
2323
2420
|
}
|
|
2324
2421
|
declare class AffiliatesClient {
|
|
2325
2422
|
private http;
|
|
@@ -2327,86 +2424,66 @@ declare class AffiliatesClient {
|
|
|
2327
2424
|
/**
|
|
2328
2425
|
* Get the current customer's affiliate info.
|
|
2329
2426
|
* Requires customer session token.
|
|
2330
|
-
*
|
|
2331
|
-
* @example
|
|
2332
|
-
* ```typescript
|
|
2333
|
-
* const affiliate = await stackbe.affiliates.get();
|
|
2334
|
-
*
|
|
2335
|
-
* if (affiliate.enrolled) {
|
|
2336
|
-
* console.log(`Your referral code: ${affiliate.code}`);
|
|
2337
|
-
* console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
|
|
2338
|
-
* } else {
|
|
2339
|
-
* console.log('Not enrolled in affiliate program');
|
|
2340
|
-
* }
|
|
2341
|
-
* ```
|
|
2342
2427
|
*/
|
|
2343
2428
|
get(): Promise<AffiliateInfo>;
|
|
2344
2429
|
/**
|
|
2345
|
-
* Enroll the current customer as an affiliate.
|
|
2430
|
+
* Enroll the current customer as an affiliate/partner.
|
|
2346
2431
|
* Requires customer session token.
|
|
2347
2432
|
*
|
|
2348
2433
|
* @example
|
|
2349
2434
|
* ```typescript
|
|
2350
|
-
*
|
|
2351
|
-
* const affiliate = await stackbe.affiliates.enroll();
|
|
2435
|
+
* const affiliate = await stackbe.affiliates.enroll({ type: 'referral' });
|
|
2352
2436
|
* console.log(`Your referral code: ${affiliate.code}`);
|
|
2353
|
-
*
|
|
2354
|
-
* // Enroll with custom code
|
|
2355
|
-
* const affiliate = await stackbe.affiliates.enroll({
|
|
2356
|
-
* code: 'MYCODE',
|
|
2357
|
-
* payoutEmail: 'payouts@example.com',
|
|
2358
|
-
* });
|
|
2359
2437
|
* ```
|
|
2360
2438
|
*/
|
|
2361
2439
|
enroll(options?: EnrollOptions): Promise<AffiliateEnrollment>;
|
|
2362
2440
|
/**
|
|
2363
2441
|
* Get affiliate statistics.
|
|
2364
2442
|
* Requires customer session token.
|
|
2365
|
-
*
|
|
2366
|
-
* @example
|
|
2367
|
-
* ```typescript
|
|
2368
|
-
* const stats = await stackbe.affiliates.getStats();
|
|
2369
|
-
*
|
|
2370
|
-
* if (stats.enrolled) {
|
|
2371
|
-
* console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
|
|
2372
|
-
* console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
|
|
2373
|
-
* console.log(`Referrals: ${stats.totalReferrals}`);
|
|
2374
|
-
* console.log(`Conversions: ${stats.totalConversions}`);
|
|
2375
|
-
* }
|
|
2376
|
-
* ```
|
|
2377
2443
|
*/
|
|
2378
2444
|
getStats(): Promise<AffiliateStats>;
|
|
2379
2445
|
/**
|
|
2380
2446
|
* Get affiliate commission history.
|
|
2381
2447
|
* Requires customer session token.
|
|
2448
|
+
*/
|
|
2449
|
+
getCommissions(): Promise<AffiliateCommissionsResponse>;
|
|
2450
|
+
/**
|
|
2451
|
+
* Track a referral click (store token for attribution).
|
|
2452
|
+
* Requires API key.
|
|
2453
|
+
*/
|
|
2454
|
+
trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
|
|
2455
|
+
/**
|
|
2456
|
+
* Get the full partner dashboard with stats, earnings by source, deals, and coupons.
|
|
2457
|
+
* Requires customer session token.
|
|
2382
2458
|
*
|
|
2383
2459
|
* @example
|
|
2384
2460
|
* ```typescript
|
|
2385
|
-
* const
|
|
2386
|
-
*
|
|
2387
|
-
*
|
|
2388
|
-
*
|
|
2389
|
-
* });
|
|
2461
|
+
* const dashboard = await stackbe.affiliates.getDashboard();
|
|
2462
|
+
* console.log(`Link earnings: $${dashboard.earningsBySource.link}`);
|
|
2463
|
+
* console.log(`Coupon earnings: $${dashboard.earningsBySource.coupon}`);
|
|
2464
|
+
* console.log(`Deal earnings: $${dashboard.earningsBySource.deal}`);
|
|
2390
2465
|
* ```
|
|
2391
2466
|
*/
|
|
2392
|
-
|
|
2467
|
+
getDashboard(): Promise<PartnerDashboard>;
|
|
2393
2468
|
/**
|
|
2394
|
-
*
|
|
2395
|
-
*
|
|
2396
|
-
* Requires API key.
|
|
2469
|
+
* Register a deal (lead attribution).
|
|
2470
|
+
* Requires customer session token and active partner enrollment.
|
|
2397
2471
|
*
|
|
2398
2472
|
* @example
|
|
2399
2473
|
* ```typescript
|
|
2400
|
-
*
|
|
2401
|
-
*
|
|
2402
|
-
*
|
|
2403
|
-
*
|
|
2404
|
-
*
|
|
2405
|
-
* res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
|
|
2406
|
-
* }
|
|
2474
|
+
* const deal = await stackbe.affiliates.registerDeal({
|
|
2475
|
+
* leadEmail: 'prospect@company.com',
|
|
2476
|
+
* leadName: 'John Smith',
|
|
2477
|
+
* notes: 'Met at conference, interested in Pro plan',
|
|
2478
|
+
* });
|
|
2407
2479
|
* ```
|
|
2408
2480
|
*/
|
|
2409
|
-
|
|
2481
|
+
registerDeal(options: RegisterDealOptions): Promise<DealRegistration>;
|
|
2482
|
+
/**
|
|
2483
|
+
* List the current partner's deal registrations.
|
|
2484
|
+
* Requires customer session token.
|
|
2485
|
+
*/
|
|
2486
|
+
listDeals(): Promise<DealListResponse>;
|
|
2410
2487
|
}
|
|
2411
2488
|
|
|
2412
2489
|
interface EarlyAccessSignup {
|
|
@@ -2989,4 +3066,4 @@ declare class StackBE {
|
|
|
2989
3066
|
}): (req: any, res: any, next: any) => Promise<any>;
|
|
2990
3067
|
}
|
|
2991
3068
|
|
|
2992
|
-
export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, AnalyticsClient, type AnalyticsFilterOptions, type AnyWebhookEvent, type AttachPaymentMethodOptions, AuthClient, type BillingPortalSession, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type ChargeResult, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type Coupon, type CouponDiscountType, type CouponDuration, CouponsClient, type CreateCheckoutOptions, type CreateCouponOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type CreateSetupSessionOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerInvoice, type CustomerInvoicesResponse, type CustomerPaymentMethod, type CustomerSubscriptionHistory, type CustomerSubscriptionHistoryResponse, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, type DashboardMetrics, type DunningStatus, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestImage, type FeatureRequestListResponse, FeatureRequestsClient, type FeatureUsagePoint, type GetSubscriptionOptions, type GrowthChartPoint, type GrowthMetrics, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MRRHistoryPoint, type MagicLinkOptions, type MagicLinkResponse, type MigrateToStackbeManagedResult, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentMethod, PaymentMethodsClient, type PaymentSucceededEvent, type PaymentWebhookPayload, type PerformanceMetrics, type Plan, type PlanMetrics, PlansClient, type PopularEndpoint, type Product, ProductsClient, type RequestCountPoint, type RevenueByPlan, type SessionResponse, type SetupSessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionPlan, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type SwitchOrganizationResponse, type TimeRangeOptions, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialMetrics, type TrialStartedEvent, type TrialStatus, type UpcomingInvoice, type UpdateCouponOptions, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type ValidateCouponResult, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
|
|
3069
|
+
export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, AnalyticsClient, type AnalyticsFilterOptions, type AnyWebhookEvent, type AttachPaymentMethodOptions, AuthClient, type BillingPortalSession, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type ChargeResult, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type Coupon, type CouponDiscountType, type CouponDuration, CouponsClient, type CreateCheckoutOptions, type CreateCouponOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type CreateSetupSessionOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerInvoice, type CustomerInvoicesResponse, type CustomerPaymentMethod, type CustomerSubscriptionHistory, type CustomerSubscriptionHistoryResponse, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, type DashboardMetrics, type DunningStatus, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestImage, type FeatureRequestListResponse, FeatureRequestsClient, type FeatureUsagePoint, type GetSubscriptionOptions, type GrowthChartPoint, type GrowthMetrics, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MRRHistoryPoint, type MagicLinkOptions, type MagicLinkResponse, type MigrateToStackbeManagedResult, type Organization, type OrganizationInvite, type OrganizationMember, type OrganizationMembership, OrganizationsClient, type PaymentFailedEvent, type PaymentMethod, PaymentMethodsClient, type PaymentSucceededEvent, type PaymentWebhookPayload, type PerformanceMetrics, type Plan, type PlanMetrics, PlansClient, type PopularEndpoint, type Product, ProductsClient, type RequestCountPoint, type RevenueByPlan, type SessionResponse, type SetupSessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionPlan, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type SwitchOrganizationResponse, type TimeRangeOptions, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialMetrics, type TrialStartedEvent, type TrialStatus, type UpcomingInvoice, type UpdateCouponOptions, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type ValidateCouponResult, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
|
package/dist/index.js
CHANGED
|
@@ -1593,6 +1593,7 @@ var AuthClient = class {
|
|
|
1593
1593
|
tenantId: tenantId ?? data.tenantId,
|
|
1594
1594
|
organizationId: data.organizationId ?? organizationId,
|
|
1595
1595
|
orgRole: data.orgRole ?? orgRole,
|
|
1596
|
+
organizations: data.organizations,
|
|
1596
1597
|
customer: data.customer,
|
|
1597
1598
|
subscription: data.subscription,
|
|
1598
1599
|
entitlements: data.entitlements
|
|
@@ -2259,37 +2260,18 @@ var AffiliatesClient = class {
|
|
|
2259
2260
|
/**
|
|
2260
2261
|
* Get the current customer's affiliate info.
|
|
2261
2262
|
* Requires customer session token.
|
|
2262
|
-
*
|
|
2263
|
-
* @example
|
|
2264
|
-
* ```typescript
|
|
2265
|
-
* const affiliate = await stackbe.affiliates.get();
|
|
2266
|
-
*
|
|
2267
|
-
* if (affiliate.enrolled) {
|
|
2268
|
-
* console.log(`Your referral code: ${affiliate.code}`);
|
|
2269
|
-
* console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
|
|
2270
|
-
* } else {
|
|
2271
|
-
* console.log('Not enrolled in affiliate program');
|
|
2272
|
-
* }
|
|
2273
|
-
* ```
|
|
2274
2263
|
*/
|
|
2275
2264
|
async get() {
|
|
2276
2265
|
return this.http.get("/v1/affiliate");
|
|
2277
2266
|
}
|
|
2278
2267
|
/**
|
|
2279
|
-
* Enroll the current customer as an affiliate.
|
|
2268
|
+
* Enroll the current customer as an affiliate/partner.
|
|
2280
2269
|
* Requires customer session token.
|
|
2281
2270
|
*
|
|
2282
2271
|
* @example
|
|
2283
2272
|
* ```typescript
|
|
2284
|
-
*
|
|
2285
|
-
* const affiliate = await stackbe.affiliates.enroll();
|
|
2273
|
+
* const affiliate = await stackbe.affiliates.enroll({ type: 'referral' });
|
|
2286
2274
|
* console.log(`Your referral code: ${affiliate.code}`);
|
|
2287
|
-
*
|
|
2288
|
-
* // Enroll with custom code
|
|
2289
|
-
* const affiliate = await stackbe.affiliates.enroll({
|
|
2290
|
-
* code: 'MYCODE',
|
|
2291
|
-
* payoutEmail: 'payouts@example.com',
|
|
2292
|
-
* });
|
|
2293
2275
|
* ```
|
|
2294
2276
|
*/
|
|
2295
2277
|
async enroll(options = {}) {
|
|
@@ -2298,18 +2280,6 @@ var AffiliatesClient = class {
|
|
|
2298
2280
|
/**
|
|
2299
2281
|
* Get affiliate statistics.
|
|
2300
2282
|
* Requires customer session token.
|
|
2301
|
-
*
|
|
2302
|
-
* @example
|
|
2303
|
-
* ```typescript
|
|
2304
|
-
* const stats = await stackbe.affiliates.getStats();
|
|
2305
|
-
*
|
|
2306
|
-
* if (stats.enrolled) {
|
|
2307
|
-
* console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
|
|
2308
|
-
* console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
|
|
2309
|
-
* console.log(`Referrals: ${stats.totalReferrals}`);
|
|
2310
|
-
* console.log(`Conversions: ${stats.totalConversions}`);
|
|
2311
|
-
* }
|
|
2312
|
-
* ```
|
|
2313
2283
|
*/
|
|
2314
2284
|
async getStats() {
|
|
2315
2285
|
return this.http.get("/v1/affiliate/stats");
|
|
@@ -2317,34 +2287,13 @@ var AffiliatesClient = class {
|
|
|
2317
2287
|
/**
|
|
2318
2288
|
* Get affiliate commission history.
|
|
2319
2289
|
* Requires customer session token.
|
|
2320
|
-
*
|
|
2321
|
-
* @example
|
|
2322
|
-
* ```typescript
|
|
2323
|
-
* const { commissions, total } = await stackbe.affiliates.getCommissions();
|
|
2324
|
-
*
|
|
2325
|
-
* commissions.forEach((c) => {
|
|
2326
|
-
* console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
|
|
2327
|
-
* });
|
|
2328
|
-
* ```
|
|
2329
2290
|
*/
|
|
2330
2291
|
async getCommissions() {
|
|
2331
2292
|
return this.http.get("/v1/affiliate/commissions");
|
|
2332
2293
|
}
|
|
2333
2294
|
/**
|
|
2334
2295
|
* Track a referral click (store token for attribution).
|
|
2335
|
-
* Call this when a user lands on your site with a referral code.
|
|
2336
2296
|
* Requires API key.
|
|
2337
|
-
*
|
|
2338
|
-
* @example
|
|
2339
|
-
* ```typescript
|
|
2340
|
-
* // In your landing page handler
|
|
2341
|
-
* const refCode = req.query.ref;
|
|
2342
|
-
* if (refCode) {
|
|
2343
|
-
* const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
|
|
2344
|
-
* // Store token in cookie for attribution on signup
|
|
2345
|
-
* res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
|
|
2346
|
-
* }
|
|
2347
|
-
* ```
|
|
2348
2297
|
*/
|
|
2349
2298
|
async trackReferral(code, referralUrl) {
|
|
2350
2299
|
return this.http.post("/v1/affiliate/track", {
|
|
@@ -2352,6 +2301,44 @@ var AffiliatesClient = class {
|
|
|
2352
2301
|
referralUrl
|
|
2353
2302
|
});
|
|
2354
2303
|
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Get the full partner dashboard with stats, earnings by source, deals, and coupons.
|
|
2306
|
+
* Requires customer session token.
|
|
2307
|
+
*
|
|
2308
|
+
* @example
|
|
2309
|
+
* ```typescript
|
|
2310
|
+
* const dashboard = await stackbe.affiliates.getDashboard();
|
|
2311
|
+
* console.log(`Link earnings: $${dashboard.earningsBySource.link}`);
|
|
2312
|
+
* console.log(`Coupon earnings: $${dashboard.earningsBySource.coupon}`);
|
|
2313
|
+
* console.log(`Deal earnings: $${dashboard.earningsBySource.deal}`);
|
|
2314
|
+
* ```
|
|
2315
|
+
*/
|
|
2316
|
+
async getDashboard() {
|
|
2317
|
+
return this.http.get("/v1/affiliate/dashboard");
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Register a deal (lead attribution).
|
|
2321
|
+
* Requires customer session token and active partner enrollment.
|
|
2322
|
+
*
|
|
2323
|
+
* @example
|
|
2324
|
+
* ```typescript
|
|
2325
|
+
* const deal = await stackbe.affiliates.registerDeal({
|
|
2326
|
+
* leadEmail: 'prospect@company.com',
|
|
2327
|
+
* leadName: 'John Smith',
|
|
2328
|
+
* notes: 'Met at conference, interested in Pro plan',
|
|
2329
|
+
* });
|
|
2330
|
+
* ```
|
|
2331
|
+
*/
|
|
2332
|
+
async registerDeal(options) {
|
|
2333
|
+
return this.http.post("/v1/affiliate/deals", options);
|
|
2334
|
+
}
|
|
2335
|
+
/**
|
|
2336
|
+
* List the current partner's deal registrations.
|
|
2337
|
+
* Requires customer session token.
|
|
2338
|
+
*/
|
|
2339
|
+
async listDeals() {
|
|
2340
|
+
return this.http.get("/v1/affiliate/deals");
|
|
2341
|
+
}
|
|
2355
2342
|
};
|
|
2356
2343
|
|
|
2357
2344
|
// src/early-access.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1551,6 +1551,7 @@ var AuthClient = class {
|
|
|
1551
1551
|
tenantId: tenantId ?? data.tenantId,
|
|
1552
1552
|
organizationId: data.organizationId ?? organizationId,
|
|
1553
1553
|
orgRole: data.orgRole ?? orgRole,
|
|
1554
|
+
organizations: data.organizations,
|
|
1554
1555
|
customer: data.customer,
|
|
1555
1556
|
subscription: data.subscription,
|
|
1556
1557
|
entitlements: data.entitlements
|
|
@@ -2217,37 +2218,18 @@ var AffiliatesClient = class {
|
|
|
2217
2218
|
/**
|
|
2218
2219
|
* Get the current customer's affiliate info.
|
|
2219
2220
|
* Requires customer session token.
|
|
2220
|
-
*
|
|
2221
|
-
* @example
|
|
2222
|
-
* ```typescript
|
|
2223
|
-
* const affiliate = await stackbe.affiliates.get();
|
|
2224
|
-
*
|
|
2225
|
-
* if (affiliate.enrolled) {
|
|
2226
|
-
* console.log(`Your referral code: ${affiliate.code}`);
|
|
2227
|
-
* console.log(`Earnings: $${(affiliate.totalEarned! / 100).toFixed(2)}`);
|
|
2228
|
-
* } else {
|
|
2229
|
-
* console.log('Not enrolled in affiliate program');
|
|
2230
|
-
* }
|
|
2231
|
-
* ```
|
|
2232
2221
|
*/
|
|
2233
2222
|
async get() {
|
|
2234
2223
|
return this.http.get("/v1/affiliate");
|
|
2235
2224
|
}
|
|
2236
2225
|
/**
|
|
2237
|
-
* Enroll the current customer as an affiliate.
|
|
2226
|
+
* Enroll the current customer as an affiliate/partner.
|
|
2238
2227
|
* Requires customer session token.
|
|
2239
2228
|
*
|
|
2240
2229
|
* @example
|
|
2241
2230
|
* ```typescript
|
|
2242
|
-
*
|
|
2243
|
-
* const affiliate = await stackbe.affiliates.enroll();
|
|
2231
|
+
* const affiliate = await stackbe.affiliates.enroll({ type: 'referral' });
|
|
2244
2232
|
* console.log(`Your referral code: ${affiliate.code}`);
|
|
2245
|
-
*
|
|
2246
|
-
* // Enroll with custom code
|
|
2247
|
-
* const affiliate = await stackbe.affiliates.enroll({
|
|
2248
|
-
* code: 'MYCODE',
|
|
2249
|
-
* payoutEmail: 'payouts@example.com',
|
|
2250
|
-
* });
|
|
2251
2233
|
* ```
|
|
2252
2234
|
*/
|
|
2253
2235
|
async enroll(options = {}) {
|
|
@@ -2256,18 +2238,6 @@ var AffiliatesClient = class {
|
|
|
2256
2238
|
/**
|
|
2257
2239
|
* Get affiliate statistics.
|
|
2258
2240
|
* Requires customer session token.
|
|
2259
|
-
*
|
|
2260
|
-
* @example
|
|
2261
|
-
* ```typescript
|
|
2262
|
-
* const stats = await stackbe.affiliates.getStats();
|
|
2263
|
-
*
|
|
2264
|
-
* if (stats.enrolled) {
|
|
2265
|
-
* console.log(`Total earned: $${(stats.totalEarned / 100).toFixed(2)}`);
|
|
2266
|
-
* console.log(`Pending: $${(stats.pendingBalance / 100).toFixed(2)}`);
|
|
2267
|
-
* console.log(`Referrals: ${stats.totalReferrals}`);
|
|
2268
|
-
* console.log(`Conversions: ${stats.totalConversions}`);
|
|
2269
|
-
* }
|
|
2270
|
-
* ```
|
|
2271
2241
|
*/
|
|
2272
2242
|
async getStats() {
|
|
2273
2243
|
return this.http.get("/v1/affiliate/stats");
|
|
@@ -2275,34 +2245,13 @@ var AffiliatesClient = class {
|
|
|
2275
2245
|
/**
|
|
2276
2246
|
* Get affiliate commission history.
|
|
2277
2247
|
* Requires customer session token.
|
|
2278
|
-
*
|
|
2279
|
-
* @example
|
|
2280
|
-
* ```typescript
|
|
2281
|
-
* const { commissions, total } = await stackbe.affiliates.getCommissions();
|
|
2282
|
-
*
|
|
2283
|
-
* commissions.forEach((c) => {
|
|
2284
|
-
* console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
|
|
2285
|
-
* });
|
|
2286
|
-
* ```
|
|
2287
2248
|
*/
|
|
2288
2249
|
async getCommissions() {
|
|
2289
2250
|
return this.http.get("/v1/affiliate/commissions");
|
|
2290
2251
|
}
|
|
2291
2252
|
/**
|
|
2292
2253
|
* Track a referral click (store token for attribution).
|
|
2293
|
-
* Call this when a user lands on your site with a referral code.
|
|
2294
2254
|
* Requires API key.
|
|
2295
|
-
*
|
|
2296
|
-
* @example
|
|
2297
|
-
* ```typescript
|
|
2298
|
-
* // In your landing page handler
|
|
2299
|
-
* const refCode = req.query.ref;
|
|
2300
|
-
* if (refCode) {
|
|
2301
|
-
* const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
|
|
2302
|
-
* // Store token in cookie for attribution on signup
|
|
2303
|
-
* res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
|
|
2304
|
-
* }
|
|
2305
|
-
* ```
|
|
2306
2255
|
*/
|
|
2307
2256
|
async trackReferral(code, referralUrl) {
|
|
2308
2257
|
return this.http.post("/v1/affiliate/track", {
|
|
@@ -2310,6 +2259,44 @@ var AffiliatesClient = class {
|
|
|
2310
2259
|
referralUrl
|
|
2311
2260
|
});
|
|
2312
2261
|
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Get the full partner dashboard with stats, earnings by source, deals, and coupons.
|
|
2264
|
+
* Requires customer session token.
|
|
2265
|
+
*
|
|
2266
|
+
* @example
|
|
2267
|
+
* ```typescript
|
|
2268
|
+
* const dashboard = await stackbe.affiliates.getDashboard();
|
|
2269
|
+
* console.log(`Link earnings: $${dashboard.earningsBySource.link}`);
|
|
2270
|
+
* console.log(`Coupon earnings: $${dashboard.earningsBySource.coupon}`);
|
|
2271
|
+
* console.log(`Deal earnings: $${dashboard.earningsBySource.deal}`);
|
|
2272
|
+
* ```
|
|
2273
|
+
*/
|
|
2274
|
+
async getDashboard() {
|
|
2275
|
+
return this.http.get("/v1/affiliate/dashboard");
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Register a deal (lead attribution).
|
|
2279
|
+
* Requires customer session token and active partner enrollment.
|
|
2280
|
+
*
|
|
2281
|
+
* @example
|
|
2282
|
+
* ```typescript
|
|
2283
|
+
* const deal = await stackbe.affiliates.registerDeal({
|
|
2284
|
+
* leadEmail: 'prospect@company.com',
|
|
2285
|
+
* leadName: 'John Smith',
|
|
2286
|
+
* notes: 'Met at conference, interested in Pro plan',
|
|
2287
|
+
* });
|
|
2288
|
+
* ```
|
|
2289
|
+
*/
|
|
2290
|
+
async registerDeal(options) {
|
|
2291
|
+
return this.http.post("/v1/affiliate/deals", options);
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* List the current partner's deal registrations.
|
|
2295
|
+
* Requires customer session token.
|
|
2296
|
+
*/
|
|
2297
|
+
async listDeals() {
|
|
2298
|
+
return this.http.get("/v1/affiliate/deals");
|
|
2299
|
+
}
|
|
2313
2300
|
};
|
|
2314
2301
|
|
|
2315
2302
|
// src/early-access.ts
|
package/package.json
CHANGED