@stackbe/sdk 0.15.1 → 0.15.4

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
@@ -2398,6 +2398,32 @@ interface TrackReferralResponse {
2398
2398
  token: string;
2399
2399
  expiresInDays: number;
2400
2400
  }
2401
+ interface PartnerApplicationOptions {
2402
+ /** Applicant email address */
2403
+ email: string;
2404
+ /** Applicant name */
2405
+ name: string;
2406
+ /** Company or business name */
2407
+ company?: string;
2408
+ /** Website URL */
2409
+ website?: string;
2410
+ /** Why they want to become a partner */
2411
+ reason?: string;
2412
+ }
2413
+ interface PartnerApplicationResponse {
2414
+ id: string;
2415
+ status: 'pending';
2416
+ message: string;
2417
+ }
2418
+ interface ApplicationStatusResponse {
2419
+ applied: boolean;
2420
+ id?: string;
2421
+ status?: 'pending' | 'approved' | 'rejected';
2422
+ rejectionReason?: string | null;
2423
+ createdAt?: string;
2424
+ reviewedAt?: string | null;
2425
+ affiliateId?: string | null;
2426
+ }
2401
2427
  interface EnrollOptions {
2402
2428
  /** Preferred referral code (auto-generated if not provided) */
2403
2429
  code?: string;
@@ -2418,14 +2444,31 @@ interface DealListResponse {
2418
2444
  deals: DealRegistration[];
2419
2445
  total: number;
2420
2446
  }
2447
+ interface PortalLinkResponse {
2448
+ /** URL to the hosted partner portal page */
2449
+ url: string;
2450
+ /** Token expiration time (e.g. "24h") */
2451
+ expiresIn: string;
2452
+ }
2421
2453
  declare class AffiliatesClient {
2422
2454
  private http;
2423
2455
  constructor(http: HttpClient);
2424
2456
  /**
2425
- * Get the current customer's affiliate info.
2426
- * Requires customer session token.
2457
+ * Get affiliate info for a customer.
2458
+ *
2459
+ * - With customer session token: returns info for the authenticated customer.
2460
+ * - With API key + customerId: server-side lookup (no session token needed).
2461
+ *
2462
+ * @example
2463
+ * ```typescript
2464
+ * // Client-side (with session token)
2465
+ * const info = await stackbe.affiliates.get();
2466
+ *
2467
+ * // Server-side (with API key)
2468
+ * const info = await stackbe.affiliates.get('cust_123');
2469
+ * ```
2427
2470
  */
2428
- get(): Promise<AffiliateInfo>;
2471
+ get(customerId?: string): Promise<AffiliateInfo>;
2429
2472
  /**
2430
2473
  * Enroll the current customer as an affiliate/partner.
2431
2474
  * Requires customer session token.
@@ -2447,11 +2490,52 @@ declare class AffiliatesClient {
2447
2490
  * Requires customer session token.
2448
2491
  */
2449
2492
  getCommissions(): Promise<AffiliateCommissionsResponse>;
2493
+ /**
2494
+ * Apply to become a partner. No account required — just an API key.
2495
+ * The application will be reviewed by the app admin.
2496
+ *
2497
+ * @example
2498
+ * ```typescript
2499
+ * const result = await stackbe.affiliates.apply({
2500
+ * email: 'partner@example.com',
2501
+ * name: 'Jane Smith',
2502
+ * company: 'Acme Inc',
2503
+ * website: 'https://acme.com',
2504
+ * reason: 'I have a large audience in the SaaS space',
2505
+ * });
2506
+ * console.log(result.status); // 'pending'
2507
+ * ```
2508
+ */
2509
+ apply(options: PartnerApplicationOptions): Promise<PartnerApplicationResponse>;
2510
+ /**
2511
+ * Check the status of a partner application by email.
2512
+ * Requires API key only (no account needed).
2513
+ *
2514
+ * @example
2515
+ * ```typescript
2516
+ * const status = await stackbe.affiliates.getApplicationStatus('partner@example.com');
2517
+ * if (status.applied && status.status === 'approved') {
2518
+ * console.log('Application approved!');
2519
+ * }
2520
+ * ```
2521
+ */
2522
+ getApplicationStatus(email: string): Promise<ApplicationStatusResponse>;
2450
2523
  /**
2451
2524
  * Track a referral click (store token for attribution).
2452
2525
  * Requires API key.
2453
2526
  */
2454
2527
  trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
2528
+ /**
2529
+ * Get a link to the hosted partner portal (valid 24 hours).
2530
+ * Requires customer session token and active partner enrollment.
2531
+ *
2532
+ * @example
2533
+ * ```typescript
2534
+ * const { url } = await stackbe.affiliates.getPortalLink();
2535
+ * // Redirect partner to `url` or display in UI
2536
+ * ```
2537
+ */
2538
+ getPortalLink(): Promise<PortalLinkResponse>;
2455
2539
  /**
2456
2540
  * Get the full partner dashboard with stats, earnings by source, deals, and coupons.
2457
2541
  * Requires customer session token.
@@ -3066,4 +3150,4 @@ declare class StackBE {
3066
3150
  }): (req: any, res: any, next: any) => Promise<any>;
3067
3151
  }
3068
3152
 
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 };
3153
+ 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 PortalLinkResponse, 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
@@ -2398,6 +2398,32 @@ interface TrackReferralResponse {
2398
2398
  token: string;
2399
2399
  expiresInDays: number;
2400
2400
  }
2401
+ interface PartnerApplicationOptions {
2402
+ /** Applicant email address */
2403
+ email: string;
2404
+ /** Applicant name */
2405
+ name: string;
2406
+ /** Company or business name */
2407
+ company?: string;
2408
+ /** Website URL */
2409
+ website?: string;
2410
+ /** Why they want to become a partner */
2411
+ reason?: string;
2412
+ }
2413
+ interface PartnerApplicationResponse {
2414
+ id: string;
2415
+ status: 'pending';
2416
+ message: string;
2417
+ }
2418
+ interface ApplicationStatusResponse {
2419
+ applied: boolean;
2420
+ id?: string;
2421
+ status?: 'pending' | 'approved' | 'rejected';
2422
+ rejectionReason?: string | null;
2423
+ createdAt?: string;
2424
+ reviewedAt?: string | null;
2425
+ affiliateId?: string | null;
2426
+ }
2401
2427
  interface EnrollOptions {
2402
2428
  /** Preferred referral code (auto-generated if not provided) */
2403
2429
  code?: string;
@@ -2418,14 +2444,31 @@ interface DealListResponse {
2418
2444
  deals: DealRegistration[];
2419
2445
  total: number;
2420
2446
  }
2447
+ interface PortalLinkResponse {
2448
+ /** URL to the hosted partner portal page */
2449
+ url: string;
2450
+ /** Token expiration time (e.g. "24h") */
2451
+ expiresIn: string;
2452
+ }
2421
2453
  declare class AffiliatesClient {
2422
2454
  private http;
2423
2455
  constructor(http: HttpClient);
2424
2456
  /**
2425
- * Get the current customer's affiliate info.
2426
- * Requires customer session token.
2457
+ * Get affiliate info for a customer.
2458
+ *
2459
+ * - With customer session token: returns info for the authenticated customer.
2460
+ * - With API key + customerId: server-side lookup (no session token needed).
2461
+ *
2462
+ * @example
2463
+ * ```typescript
2464
+ * // Client-side (with session token)
2465
+ * const info = await stackbe.affiliates.get();
2466
+ *
2467
+ * // Server-side (with API key)
2468
+ * const info = await stackbe.affiliates.get('cust_123');
2469
+ * ```
2427
2470
  */
2428
- get(): Promise<AffiliateInfo>;
2471
+ get(customerId?: string): Promise<AffiliateInfo>;
2429
2472
  /**
2430
2473
  * Enroll the current customer as an affiliate/partner.
2431
2474
  * Requires customer session token.
@@ -2447,11 +2490,52 @@ declare class AffiliatesClient {
2447
2490
  * Requires customer session token.
2448
2491
  */
2449
2492
  getCommissions(): Promise<AffiliateCommissionsResponse>;
2493
+ /**
2494
+ * Apply to become a partner. No account required — just an API key.
2495
+ * The application will be reviewed by the app admin.
2496
+ *
2497
+ * @example
2498
+ * ```typescript
2499
+ * const result = await stackbe.affiliates.apply({
2500
+ * email: 'partner@example.com',
2501
+ * name: 'Jane Smith',
2502
+ * company: 'Acme Inc',
2503
+ * website: 'https://acme.com',
2504
+ * reason: 'I have a large audience in the SaaS space',
2505
+ * });
2506
+ * console.log(result.status); // 'pending'
2507
+ * ```
2508
+ */
2509
+ apply(options: PartnerApplicationOptions): Promise<PartnerApplicationResponse>;
2510
+ /**
2511
+ * Check the status of a partner application by email.
2512
+ * Requires API key only (no account needed).
2513
+ *
2514
+ * @example
2515
+ * ```typescript
2516
+ * const status = await stackbe.affiliates.getApplicationStatus('partner@example.com');
2517
+ * if (status.applied && status.status === 'approved') {
2518
+ * console.log('Application approved!');
2519
+ * }
2520
+ * ```
2521
+ */
2522
+ getApplicationStatus(email: string): Promise<ApplicationStatusResponse>;
2450
2523
  /**
2451
2524
  * Track a referral click (store token for attribution).
2452
2525
  * Requires API key.
2453
2526
  */
2454
2527
  trackReferral(code: string, referralUrl?: string): Promise<TrackReferralResponse>;
2528
+ /**
2529
+ * Get a link to the hosted partner portal (valid 24 hours).
2530
+ * Requires customer session token and active partner enrollment.
2531
+ *
2532
+ * @example
2533
+ * ```typescript
2534
+ * const { url } = await stackbe.affiliates.getPortalLink();
2535
+ * // Redirect partner to `url` or display in UI
2536
+ * ```
2537
+ */
2538
+ getPortalLink(): Promise<PortalLinkResponse>;
2455
2539
  /**
2456
2540
  * Get the full partner dashboard with stats, earnings by source, deals, and coupons.
2457
2541
  * Requires customer session token.
@@ -3066,4 +3150,4 @@ declare class StackBE {
3066
3150
  }): (req: any, res: any, next: any) => Promise<any>;
3067
3151
  }
3068
3152
 
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 };
3153
+ 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 PortalLinkResponse, 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
@@ -2258,10 +2258,24 @@ var AffiliatesClient = class {
2258
2258
  this.http = http;
2259
2259
  }
2260
2260
  /**
2261
- * Get the current customer's affiliate info.
2262
- * Requires customer session token.
2261
+ * Get affiliate info for a customer.
2262
+ *
2263
+ * - With customer session token: returns info for the authenticated customer.
2264
+ * - With API key + customerId: server-side lookup (no session token needed).
2265
+ *
2266
+ * @example
2267
+ * ```typescript
2268
+ * // Client-side (with session token)
2269
+ * const info = await stackbe.affiliates.get();
2270
+ *
2271
+ * // Server-side (with API key)
2272
+ * const info = await stackbe.affiliates.get('cust_123');
2273
+ * ```
2263
2274
  */
2264
- async get() {
2275
+ async get(customerId) {
2276
+ if (customerId) {
2277
+ return this.http.get(`/v1/affiliate/by-customer/${customerId}`);
2278
+ }
2265
2279
  return this.http.get("/v1/affiliate");
2266
2280
  }
2267
2281
  /**
@@ -2291,6 +2305,40 @@ var AffiliatesClient = class {
2291
2305
  async getCommissions() {
2292
2306
  return this.http.get("/v1/affiliate/commissions");
2293
2307
  }
2308
+ /**
2309
+ * Apply to become a partner. No account required — just an API key.
2310
+ * The application will be reviewed by the app admin.
2311
+ *
2312
+ * @example
2313
+ * ```typescript
2314
+ * const result = await stackbe.affiliates.apply({
2315
+ * email: 'partner@example.com',
2316
+ * name: 'Jane Smith',
2317
+ * company: 'Acme Inc',
2318
+ * website: 'https://acme.com',
2319
+ * reason: 'I have a large audience in the SaaS space',
2320
+ * });
2321
+ * console.log(result.status); // 'pending'
2322
+ * ```
2323
+ */
2324
+ async apply(options) {
2325
+ return this.http.post("/v1/affiliate/apply", options);
2326
+ }
2327
+ /**
2328
+ * Check the status of a partner application by email.
2329
+ * Requires API key only (no account needed).
2330
+ *
2331
+ * @example
2332
+ * ```typescript
2333
+ * const status = await stackbe.affiliates.getApplicationStatus('partner@example.com');
2334
+ * if (status.applied && status.status === 'approved') {
2335
+ * console.log('Application approved!');
2336
+ * }
2337
+ * ```
2338
+ */
2339
+ async getApplicationStatus(email) {
2340
+ return this.http.get("/v1/affiliate/apply/status", { email });
2341
+ }
2294
2342
  /**
2295
2343
  * Track a referral click (store token for attribution).
2296
2344
  * Requires API key.
@@ -2301,6 +2349,19 @@ var AffiliatesClient = class {
2301
2349
  referralUrl
2302
2350
  });
2303
2351
  }
2352
+ /**
2353
+ * Get a link to the hosted partner portal (valid 24 hours).
2354
+ * Requires customer session token and active partner enrollment.
2355
+ *
2356
+ * @example
2357
+ * ```typescript
2358
+ * const { url } = await stackbe.affiliates.getPortalLink();
2359
+ * // Redirect partner to `url` or display in UI
2360
+ * ```
2361
+ */
2362
+ async getPortalLink() {
2363
+ return this.http.get("/v1/affiliate/portal-link");
2364
+ }
2304
2365
  /**
2305
2366
  * Get the full partner dashboard with stats, earnings by source, deals, and coupons.
2306
2367
  * Requires customer session token.
package/dist/index.mjs CHANGED
@@ -2216,10 +2216,24 @@ var AffiliatesClient = class {
2216
2216
  this.http = http;
2217
2217
  }
2218
2218
  /**
2219
- * Get the current customer's affiliate info.
2220
- * Requires customer session token.
2219
+ * Get affiliate info for a customer.
2220
+ *
2221
+ * - With customer session token: returns info for the authenticated customer.
2222
+ * - With API key + customerId: server-side lookup (no session token needed).
2223
+ *
2224
+ * @example
2225
+ * ```typescript
2226
+ * // Client-side (with session token)
2227
+ * const info = await stackbe.affiliates.get();
2228
+ *
2229
+ * // Server-side (with API key)
2230
+ * const info = await stackbe.affiliates.get('cust_123');
2231
+ * ```
2221
2232
  */
2222
- async get() {
2233
+ async get(customerId) {
2234
+ if (customerId) {
2235
+ return this.http.get(`/v1/affiliate/by-customer/${customerId}`);
2236
+ }
2223
2237
  return this.http.get("/v1/affiliate");
2224
2238
  }
2225
2239
  /**
@@ -2249,6 +2263,40 @@ var AffiliatesClient = class {
2249
2263
  async getCommissions() {
2250
2264
  return this.http.get("/v1/affiliate/commissions");
2251
2265
  }
2266
+ /**
2267
+ * Apply to become a partner. No account required — just an API key.
2268
+ * The application will be reviewed by the app admin.
2269
+ *
2270
+ * @example
2271
+ * ```typescript
2272
+ * const result = await stackbe.affiliates.apply({
2273
+ * email: 'partner@example.com',
2274
+ * name: 'Jane Smith',
2275
+ * company: 'Acme Inc',
2276
+ * website: 'https://acme.com',
2277
+ * reason: 'I have a large audience in the SaaS space',
2278
+ * });
2279
+ * console.log(result.status); // 'pending'
2280
+ * ```
2281
+ */
2282
+ async apply(options) {
2283
+ return this.http.post("/v1/affiliate/apply", options);
2284
+ }
2285
+ /**
2286
+ * Check the status of a partner application by email.
2287
+ * Requires API key only (no account needed).
2288
+ *
2289
+ * @example
2290
+ * ```typescript
2291
+ * const status = await stackbe.affiliates.getApplicationStatus('partner@example.com');
2292
+ * if (status.applied && status.status === 'approved') {
2293
+ * console.log('Application approved!');
2294
+ * }
2295
+ * ```
2296
+ */
2297
+ async getApplicationStatus(email) {
2298
+ return this.http.get("/v1/affiliate/apply/status", { email });
2299
+ }
2252
2300
  /**
2253
2301
  * Track a referral click (store token for attribution).
2254
2302
  * Requires API key.
@@ -2259,6 +2307,19 @@ var AffiliatesClient = class {
2259
2307
  referralUrl
2260
2308
  });
2261
2309
  }
2310
+ /**
2311
+ * Get a link to the hosted partner portal (valid 24 hours).
2312
+ * Requires customer session token and active partner enrollment.
2313
+ *
2314
+ * @example
2315
+ * ```typescript
2316
+ * const { url } = await stackbe.affiliates.getPortalLink();
2317
+ * // Redirect partner to `url` or display in UI
2318
+ * ```
2319
+ */
2320
+ async getPortalLink() {
2321
+ return this.http.get("/v1/affiliate/portal-link");
2322
+ }
2262
2323
  /**
2263
2324
  * Get the full partner dashboard with stats, earnings by source, deals, and coupons.
2264
2325
  * Requires customer session token.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbe/sdk",
3
- "version": "0.15.1",
3
+ "version": "0.15.4",
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",