@stackbe/sdk 0.14.0 → 0.15.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 CHANGED
@@ -627,6 +627,70 @@ type CustomerCreatedEvent = WebhookEvent<'customer_created', CustomerWebhookPayl
627
627
  type CustomerUpdatedEvent = WebhookEvent<'customer_updated', CustomerWebhookPayload>;
628
628
  /** Union of all webhook event types */
629
629
  type AnyWebhookEvent = SubscriptionCreatedEvent | SubscriptionUpdatedEvent | SubscriptionCancelledEvent | SubscriptionRenewedEvent | TrialStartedEvent | TrialEndedEvent | PaymentSucceededEvent | PaymentFailedEvent | CustomerCreatedEvent | CustomerUpdatedEvent;
630
+ interface DealRegistration {
631
+ id: string;
632
+ affiliateId: string;
633
+ programId: string;
634
+ leadEmail: string;
635
+ leadName?: string | null;
636
+ notes?: string | null;
637
+ status: 'pending' | 'approved' | 'converted' | 'expired' | 'rejected';
638
+ expiresAt: string;
639
+ approvedAt?: string | null;
640
+ convertedAt?: string | null;
641
+ rejectedAt?: string | null;
642
+ rejectionReason?: string | null;
643
+ convertedCustomerId?: string | null;
644
+ convertedSubscriptionId?: string | null;
645
+ createdAt: string;
646
+ updatedAt: string;
647
+ }
648
+ interface PartnerDashboard {
649
+ affiliate: {
650
+ id: string;
651
+ code: string;
652
+ type: string;
653
+ status: string;
654
+ totalEarned: number;
655
+ pendingBalance: number;
656
+ paidOut: number;
657
+ totalReferrals: number;
658
+ totalConversions: number;
659
+ };
660
+ tier?: {
661
+ id: string;
662
+ name: string;
663
+ level: number;
664
+ commissionRate: number;
665
+ commissionType: string;
666
+ } | null;
667
+ earningsBySource: {
668
+ link: number;
669
+ coupon: number;
670
+ deal: number;
671
+ };
672
+ recentCommissions: Array<{
673
+ id: string;
674
+ amount: number;
675
+ currency: string;
676
+ status: string;
677
+ createdAt: string;
678
+ }>;
679
+ activeDeals: Array<{
680
+ id: string;
681
+ leadEmail: string;
682
+ status: string;
683
+ expiresAt: string;
684
+ createdAt: string;
685
+ }>;
686
+ coupons: Array<{
687
+ id: string;
688
+ code: string;
689
+ discountType: string;
690
+ discountValue: number;
691
+ timesRedeemed: number;
692
+ }>;
693
+ }
630
694
 
631
695
  declare class UsageClient {
632
696
  private http;
@@ -2277,6 +2341,7 @@ interface AffiliateInfo {
2277
2341
  enrolled: boolean;
2278
2342
  id?: string;
2279
2343
  code?: string;
2344
+ type?: 'affiliate' | 'referral' | 'reseller';
2280
2345
  status?: 'active' | 'suspended' | 'pending';
2281
2346
  totalEarned?: number;
2282
2347
  pendingBalance?: number;
@@ -2288,6 +2353,7 @@ interface AffiliateInfo {
2288
2353
  interface AffiliateEnrollment {
2289
2354
  id: string;
2290
2355
  code: string;
2356
+ type: string;
2291
2357
  status: string;
2292
2358
  createdAt: string;
2293
2359
  }
@@ -2320,6 +2386,20 @@ interface EnrollOptions {
2320
2386
  code?: string;
2321
2387
  /** PayPal email for payouts */
2322
2388
  payoutEmail?: string;
2389
+ /** Partner type (default: 'affiliate') */
2390
+ type?: 'affiliate' | 'referral' | 'reseller';
2391
+ }
2392
+ interface RegisterDealOptions {
2393
+ /** Email of the lead */
2394
+ leadEmail: string;
2395
+ /** Name of the lead */
2396
+ leadName?: string;
2397
+ /** Notes about the deal */
2398
+ notes?: string;
2399
+ }
2400
+ interface DealListResponse {
2401
+ deals: DealRegistration[];
2402
+ total: number;
2323
2403
  }
2324
2404
  declare class AffiliatesClient {
2325
2405
  private http;
@@ -2327,86 +2407,66 @@ declare class AffiliatesClient {
2327
2407
  /**
2328
2408
  * Get the current customer's affiliate info.
2329
2409
  * 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
2410
  */
2343
2411
  get(): Promise<AffiliateInfo>;
2344
2412
  /**
2345
- * Enroll the current customer as an affiliate.
2413
+ * Enroll the current customer as an affiliate/partner.
2346
2414
  * Requires customer session token.
2347
2415
  *
2348
2416
  * @example
2349
2417
  * ```typescript
2350
- * // Enroll with auto-generated code
2351
- * const affiliate = await stackbe.affiliates.enroll();
2418
+ * const affiliate = await stackbe.affiliates.enroll({ type: 'referral' });
2352
2419
  * 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
2420
  * ```
2360
2421
  */
2361
2422
  enroll(options?: EnrollOptions): Promise<AffiliateEnrollment>;
2362
2423
  /**
2363
2424
  * Get affiliate statistics.
2364
2425
  * 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
2426
  */
2378
2427
  getStats(): Promise<AffiliateStats>;
2379
2428
  /**
2380
2429
  * Get affiliate commission history.
2381
2430
  * Requires customer session token.
2431
+ */
2432
+ getCommissions(): Promise<AffiliateCommissionsResponse>;
2433
+ /**
2434
+ * Track a referral click (store token for attribution).
2435
+ * Requires API key.
2436
+ */
2437
+ trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
2438
+ /**
2439
+ * Get the full partner dashboard with stats, earnings by source, deals, and coupons.
2440
+ * Requires customer session token.
2382
2441
  *
2383
2442
  * @example
2384
2443
  * ```typescript
2385
- * const { commissions, total } = await stackbe.affiliates.getCommissions();
2386
- *
2387
- * commissions.forEach((c) => {
2388
- * console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
2389
- * });
2444
+ * const dashboard = await stackbe.affiliates.getDashboard();
2445
+ * console.log(`Link earnings: $${dashboard.earningsBySource.link}`);
2446
+ * console.log(`Coupon earnings: $${dashboard.earningsBySource.coupon}`);
2447
+ * console.log(`Deal earnings: $${dashboard.earningsBySource.deal}`);
2390
2448
  * ```
2391
2449
  */
2392
- getCommissions(): Promise<AffiliateCommissionsResponse>;
2450
+ getDashboard(): Promise<PartnerDashboard>;
2393
2451
  /**
2394
- * Track a referral click (store token for attribution).
2395
- * Call this when a user lands on your site with a referral code.
2396
- * Requires API key.
2452
+ * Register a deal (lead attribution).
2453
+ * Requires customer session token and active partner enrollment.
2397
2454
  *
2398
2455
  * @example
2399
2456
  * ```typescript
2400
- * // In your landing page handler
2401
- * const refCode = req.query.ref;
2402
- * if (refCode) {
2403
- * const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
2404
- * // Store token in cookie for attribution on signup
2405
- * res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
2406
- * }
2457
+ * const deal = await stackbe.affiliates.registerDeal({
2458
+ * leadEmail: 'prospect@company.com',
2459
+ * leadName: 'John Smith',
2460
+ * notes: 'Met at conference, interested in Pro plan',
2461
+ * });
2407
2462
  * ```
2408
2463
  */
2409
- trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
2464
+ registerDeal(options: RegisterDealOptions): Promise<DealRegistration>;
2465
+ /**
2466
+ * List the current partner's deal registrations.
2467
+ * Requires customer session token.
2468
+ */
2469
+ listDeals(): Promise<DealListResponse>;
2410
2470
  }
2411
2471
 
2412
2472
  interface EarlyAccessSignup {
package/dist/index.d.ts CHANGED
@@ -627,6 +627,70 @@ type CustomerCreatedEvent = WebhookEvent<'customer_created', CustomerWebhookPayl
627
627
  type CustomerUpdatedEvent = WebhookEvent<'customer_updated', CustomerWebhookPayload>;
628
628
  /** Union of all webhook event types */
629
629
  type AnyWebhookEvent = SubscriptionCreatedEvent | SubscriptionUpdatedEvent | SubscriptionCancelledEvent | SubscriptionRenewedEvent | TrialStartedEvent | TrialEndedEvent | PaymentSucceededEvent | PaymentFailedEvent | CustomerCreatedEvent | CustomerUpdatedEvent;
630
+ interface DealRegistration {
631
+ id: string;
632
+ affiliateId: string;
633
+ programId: string;
634
+ leadEmail: string;
635
+ leadName?: string | null;
636
+ notes?: string | null;
637
+ status: 'pending' | 'approved' | 'converted' | 'expired' | 'rejected';
638
+ expiresAt: string;
639
+ approvedAt?: string | null;
640
+ convertedAt?: string | null;
641
+ rejectedAt?: string | null;
642
+ rejectionReason?: string | null;
643
+ convertedCustomerId?: string | null;
644
+ convertedSubscriptionId?: string | null;
645
+ createdAt: string;
646
+ updatedAt: string;
647
+ }
648
+ interface PartnerDashboard {
649
+ affiliate: {
650
+ id: string;
651
+ code: string;
652
+ type: string;
653
+ status: string;
654
+ totalEarned: number;
655
+ pendingBalance: number;
656
+ paidOut: number;
657
+ totalReferrals: number;
658
+ totalConversions: number;
659
+ };
660
+ tier?: {
661
+ id: string;
662
+ name: string;
663
+ level: number;
664
+ commissionRate: number;
665
+ commissionType: string;
666
+ } | null;
667
+ earningsBySource: {
668
+ link: number;
669
+ coupon: number;
670
+ deal: number;
671
+ };
672
+ recentCommissions: Array<{
673
+ id: string;
674
+ amount: number;
675
+ currency: string;
676
+ status: string;
677
+ createdAt: string;
678
+ }>;
679
+ activeDeals: Array<{
680
+ id: string;
681
+ leadEmail: string;
682
+ status: string;
683
+ expiresAt: string;
684
+ createdAt: string;
685
+ }>;
686
+ coupons: Array<{
687
+ id: string;
688
+ code: string;
689
+ discountType: string;
690
+ discountValue: number;
691
+ timesRedeemed: number;
692
+ }>;
693
+ }
630
694
 
631
695
  declare class UsageClient {
632
696
  private http;
@@ -2277,6 +2341,7 @@ interface AffiliateInfo {
2277
2341
  enrolled: boolean;
2278
2342
  id?: string;
2279
2343
  code?: string;
2344
+ type?: 'affiliate' | 'referral' | 'reseller';
2280
2345
  status?: 'active' | 'suspended' | 'pending';
2281
2346
  totalEarned?: number;
2282
2347
  pendingBalance?: number;
@@ -2288,6 +2353,7 @@ interface AffiliateInfo {
2288
2353
  interface AffiliateEnrollment {
2289
2354
  id: string;
2290
2355
  code: string;
2356
+ type: string;
2291
2357
  status: string;
2292
2358
  createdAt: string;
2293
2359
  }
@@ -2320,6 +2386,20 @@ interface EnrollOptions {
2320
2386
  code?: string;
2321
2387
  /** PayPal email for payouts */
2322
2388
  payoutEmail?: string;
2389
+ /** Partner type (default: 'affiliate') */
2390
+ type?: 'affiliate' | 'referral' | 'reseller';
2391
+ }
2392
+ interface RegisterDealOptions {
2393
+ /** Email of the lead */
2394
+ leadEmail: string;
2395
+ /** Name of the lead */
2396
+ leadName?: string;
2397
+ /** Notes about the deal */
2398
+ notes?: string;
2399
+ }
2400
+ interface DealListResponse {
2401
+ deals: DealRegistration[];
2402
+ total: number;
2323
2403
  }
2324
2404
  declare class AffiliatesClient {
2325
2405
  private http;
@@ -2327,86 +2407,66 @@ declare class AffiliatesClient {
2327
2407
  /**
2328
2408
  * Get the current customer's affiliate info.
2329
2409
  * 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
2410
  */
2343
2411
  get(): Promise<AffiliateInfo>;
2344
2412
  /**
2345
- * Enroll the current customer as an affiliate.
2413
+ * Enroll the current customer as an affiliate/partner.
2346
2414
  * Requires customer session token.
2347
2415
  *
2348
2416
  * @example
2349
2417
  * ```typescript
2350
- * // Enroll with auto-generated code
2351
- * const affiliate = await stackbe.affiliates.enroll();
2418
+ * const affiliate = await stackbe.affiliates.enroll({ type: 'referral' });
2352
2419
  * 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
2420
  * ```
2360
2421
  */
2361
2422
  enroll(options?: EnrollOptions): Promise<AffiliateEnrollment>;
2362
2423
  /**
2363
2424
  * Get affiliate statistics.
2364
2425
  * 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
2426
  */
2378
2427
  getStats(): Promise<AffiliateStats>;
2379
2428
  /**
2380
2429
  * Get affiliate commission history.
2381
2430
  * Requires customer session token.
2431
+ */
2432
+ getCommissions(): Promise<AffiliateCommissionsResponse>;
2433
+ /**
2434
+ * Track a referral click (store token for attribution).
2435
+ * Requires API key.
2436
+ */
2437
+ trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
2438
+ /**
2439
+ * Get the full partner dashboard with stats, earnings by source, deals, and coupons.
2440
+ * Requires customer session token.
2382
2441
  *
2383
2442
  * @example
2384
2443
  * ```typescript
2385
- * const { commissions, total } = await stackbe.affiliates.getCommissions();
2386
- *
2387
- * commissions.forEach((c) => {
2388
- * console.log(`$${(c.amount / 100).toFixed(2)} - ${c.status}`);
2389
- * });
2444
+ * const dashboard = await stackbe.affiliates.getDashboard();
2445
+ * console.log(`Link earnings: $${dashboard.earningsBySource.link}`);
2446
+ * console.log(`Coupon earnings: $${dashboard.earningsBySource.coupon}`);
2447
+ * console.log(`Deal earnings: $${dashboard.earningsBySource.deal}`);
2390
2448
  * ```
2391
2449
  */
2392
- getCommissions(): Promise<AffiliateCommissionsResponse>;
2450
+ getDashboard(): Promise<PartnerDashboard>;
2393
2451
  /**
2394
- * Track a referral click (store token for attribution).
2395
- * Call this when a user lands on your site with a referral code.
2396
- * Requires API key.
2452
+ * Register a deal (lead attribution).
2453
+ * Requires customer session token and active partner enrollment.
2397
2454
  *
2398
2455
  * @example
2399
2456
  * ```typescript
2400
- * // In your landing page handler
2401
- * const refCode = req.query.ref;
2402
- * if (refCode) {
2403
- * const { token, expiresInDays } = await stackbe.affiliates.trackReferral(refCode);
2404
- * // Store token in cookie for attribution on signup
2405
- * res.cookie('ref_token', token, { maxAge: expiresInDays * 24 * 60 * 60 * 1000 });
2406
- * }
2457
+ * const deal = await stackbe.affiliates.registerDeal({
2458
+ * leadEmail: 'prospect@company.com',
2459
+ * leadName: 'John Smith',
2460
+ * notes: 'Met at conference, interested in Pro plan',
2461
+ * });
2407
2462
  * ```
2408
2463
  */
2409
- trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
2464
+ registerDeal(options: RegisterDealOptions): Promise<DealRegistration>;
2465
+ /**
2466
+ * List the current partner's deal registrations.
2467
+ * Requires customer session token.
2468
+ */
2469
+ listDeals(): Promise<DealListResponse>;
2410
2470
  }
2411
2471
 
2412
2472
  interface EarlyAccessSignup {
package/dist/index.js CHANGED
@@ -2259,37 +2259,18 @@ var AffiliatesClient = class {
2259
2259
  /**
2260
2260
  * Get the current customer's affiliate info.
2261
2261
  * 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
2262
  */
2275
2263
  async get() {
2276
2264
  return this.http.get("/v1/affiliate");
2277
2265
  }
2278
2266
  /**
2279
- * Enroll the current customer as an affiliate.
2267
+ * Enroll the current customer as an affiliate/partner.
2280
2268
  * Requires customer session token.
2281
2269
  *
2282
2270
  * @example
2283
2271
  * ```typescript
2284
- * // Enroll with auto-generated code
2285
- * const affiliate = await stackbe.affiliates.enroll();
2272
+ * const affiliate = await stackbe.affiliates.enroll({ type: 'referral' });
2286
2273
  * 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
2274
  * ```
2294
2275
  */
2295
2276
  async enroll(options = {}) {
@@ -2298,18 +2279,6 @@ var AffiliatesClient = class {
2298
2279
  /**
2299
2280
  * Get affiliate statistics.
2300
2281
  * 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
2282
  */
2314
2283
  async getStats() {
2315
2284
  return this.http.get("/v1/affiliate/stats");
@@ -2317,34 +2286,13 @@ var AffiliatesClient = class {
2317
2286
  /**
2318
2287
  * Get affiliate commission history.
2319
2288
  * 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
2289
  */
2330
2290
  async getCommissions() {
2331
2291
  return this.http.get("/v1/affiliate/commissions");
2332
2292
  }
2333
2293
  /**
2334
2294
  * Track a referral click (store token for attribution).
2335
- * Call this when a user lands on your site with a referral code.
2336
2295
  * 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
2296
  */
2349
2297
  async trackReferral(code, referralUrl) {
2350
2298
  return this.http.post("/v1/affiliate/track", {
@@ -2352,6 +2300,44 @@ var AffiliatesClient = class {
2352
2300
  referralUrl
2353
2301
  });
2354
2302
  }
2303
+ /**
2304
+ * Get the full partner dashboard with stats, earnings by source, deals, and coupons.
2305
+ * Requires customer session token.
2306
+ *
2307
+ * @example
2308
+ * ```typescript
2309
+ * const dashboard = await stackbe.affiliates.getDashboard();
2310
+ * console.log(`Link earnings: $${dashboard.earningsBySource.link}`);
2311
+ * console.log(`Coupon earnings: $${dashboard.earningsBySource.coupon}`);
2312
+ * console.log(`Deal earnings: $${dashboard.earningsBySource.deal}`);
2313
+ * ```
2314
+ */
2315
+ async getDashboard() {
2316
+ return this.http.get("/v1/affiliate/dashboard");
2317
+ }
2318
+ /**
2319
+ * Register a deal (lead attribution).
2320
+ * Requires customer session token and active partner enrollment.
2321
+ *
2322
+ * @example
2323
+ * ```typescript
2324
+ * const deal = await stackbe.affiliates.registerDeal({
2325
+ * leadEmail: 'prospect@company.com',
2326
+ * leadName: 'John Smith',
2327
+ * notes: 'Met at conference, interested in Pro plan',
2328
+ * });
2329
+ * ```
2330
+ */
2331
+ async registerDeal(options) {
2332
+ return this.http.post("/v1/affiliate/deals", options);
2333
+ }
2334
+ /**
2335
+ * List the current partner's deal registrations.
2336
+ * Requires customer session token.
2337
+ */
2338
+ async listDeals() {
2339
+ return this.http.get("/v1/affiliate/deals");
2340
+ }
2355
2341
  };
2356
2342
 
2357
2343
  // src/early-access.ts
package/dist/index.mjs CHANGED
@@ -2217,37 +2217,18 @@ var AffiliatesClient = class {
2217
2217
  /**
2218
2218
  * Get the current customer's affiliate info.
2219
2219
  * 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
2220
  */
2233
2221
  async get() {
2234
2222
  return this.http.get("/v1/affiliate");
2235
2223
  }
2236
2224
  /**
2237
- * Enroll the current customer as an affiliate.
2225
+ * Enroll the current customer as an affiliate/partner.
2238
2226
  * Requires customer session token.
2239
2227
  *
2240
2228
  * @example
2241
2229
  * ```typescript
2242
- * // Enroll with auto-generated code
2243
- * const affiliate = await stackbe.affiliates.enroll();
2230
+ * const affiliate = await stackbe.affiliates.enroll({ type: 'referral' });
2244
2231
  * 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
2232
  * ```
2252
2233
  */
2253
2234
  async enroll(options = {}) {
@@ -2256,18 +2237,6 @@ var AffiliatesClient = class {
2256
2237
  /**
2257
2238
  * Get affiliate statistics.
2258
2239
  * 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
2240
  */
2272
2241
  async getStats() {
2273
2242
  return this.http.get("/v1/affiliate/stats");
@@ -2275,34 +2244,13 @@ var AffiliatesClient = class {
2275
2244
  /**
2276
2245
  * Get affiliate commission history.
2277
2246
  * 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
2247
  */
2288
2248
  async getCommissions() {
2289
2249
  return this.http.get("/v1/affiliate/commissions");
2290
2250
  }
2291
2251
  /**
2292
2252
  * Track a referral click (store token for attribution).
2293
- * Call this when a user lands on your site with a referral code.
2294
2253
  * 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
2254
  */
2307
2255
  async trackReferral(code, referralUrl) {
2308
2256
  return this.http.post("/v1/affiliate/track", {
@@ -2310,6 +2258,44 @@ var AffiliatesClient = class {
2310
2258
  referralUrl
2311
2259
  });
2312
2260
  }
2261
+ /**
2262
+ * Get the full partner dashboard with stats, earnings by source, deals, and coupons.
2263
+ * Requires customer session token.
2264
+ *
2265
+ * @example
2266
+ * ```typescript
2267
+ * const dashboard = await stackbe.affiliates.getDashboard();
2268
+ * console.log(`Link earnings: $${dashboard.earningsBySource.link}`);
2269
+ * console.log(`Coupon earnings: $${dashboard.earningsBySource.coupon}`);
2270
+ * console.log(`Deal earnings: $${dashboard.earningsBySource.deal}`);
2271
+ * ```
2272
+ */
2273
+ async getDashboard() {
2274
+ return this.http.get("/v1/affiliate/dashboard");
2275
+ }
2276
+ /**
2277
+ * Register a deal (lead attribution).
2278
+ * Requires customer session token and active partner enrollment.
2279
+ *
2280
+ * @example
2281
+ * ```typescript
2282
+ * const deal = await stackbe.affiliates.registerDeal({
2283
+ * leadEmail: 'prospect@company.com',
2284
+ * leadName: 'John Smith',
2285
+ * notes: 'Met at conference, interested in Pro plan',
2286
+ * });
2287
+ * ```
2288
+ */
2289
+ async registerDeal(options) {
2290
+ return this.http.post("/v1/affiliate/deals", options);
2291
+ }
2292
+ /**
2293
+ * List the current partner's deal registrations.
2294
+ * Requires customer session token.
2295
+ */
2296
+ async listDeals() {
2297
+ return this.http.get("/v1/affiliate/deals");
2298
+ }
2313
2299
  };
2314
2300
 
2315
2301
  // src/early-access.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbe/sdk",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Official JavaScript/TypeScript SDK for StackBE - the billing backend for your side project",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",