pocketsflow 1.1.0 → 1.2.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
@@ -281,272 +281,77 @@ interface Subscription {
281
281
  interface ListSubscriptionsParams extends PaginationParams, DateRangeParams {
282
282
  status?: 'active' | 'canceled' | 'paused';
283
283
  }
284
- /** A subscription OFFER — a recurring product you sell. */
284
+ /** A subscription offer — a recurring product you sell. */
285
285
  interface SubscriptionOffer {
286
286
  _id: string;
287
287
  userId: string;
288
288
  name: string;
289
+ subtitle?: string;
289
290
  description?: string;
290
291
  price: number;
291
292
  currency?: string;
292
293
  frequency: 'weekly' | 'monthly' | 'yearly';
294
+ trialPeriod?: number;
293
295
  published?: boolean;
296
+ redirectBackUrl?: string;
294
297
  slug?: string;
295
298
  thumbnail?: string;
299
+ images?: string[];
296
300
  testMode: boolean;
297
301
  createdAt: string;
298
302
  updatedAt?: string;
299
303
  }
300
- /** Whop-sourced live membership status. */
301
- type SubscriberStatus = 'incomplete' | 'incomplete_expired' | 'trialing' | 'active' | 'past_due' | 'canceled' | 'unpaid' | 'succeeded' | 'refunded' | 'paused';
302
- /** A subscriber — a buyer's membership in one of your subscription offers. */
303
- interface Subscriber {
304
- _id: string;
305
- buyerEmail: string;
306
- /** Native portal link. The id pair is the capability — no login required. */
307
- portalUrl?: string;
308
- status: SubscriberStatus;
309
- active: boolean;
310
- /** The Whop PLAN id for this subscriber */
311
- whopSubscriptionId?: string;
312
- /** The Whop MEMBERSHIP id — drives the native portal cancel/resume actions */
313
- whopMembershipId?: string;
314
- cancelAtPeriodEnd?: boolean;
315
- subscriptionId: string;
316
- firstName?: string;
317
- lastName?: string;
318
- country?: string;
319
- createdAt: string;
320
- /** The joined subscription offer */
321
- subscription?: {
322
- _id: string;
323
- name: string;
324
- price: number;
325
- frequency: 'weekly' | 'monthly' | 'yearly';
326
- } | null;
327
- }
328
- interface ListSubscribersParams extends PaginationParams {
329
- status?: SubscriberStatus;
330
- buyerEmail?: string;
331
- /** Alias for buyerEmail */
332
- email?: string;
333
- /** Filter by subscription offer id */
334
- subscriptionId?: string;
335
- }
336
- interface SubscribersResponse {
337
- subscribers: Subscriber[];
338
- pagination: {
339
- totalCount: number;
340
- totalPages: number;
341
- currentPage: number;
342
- pageSize: number;
343
- hasMore: boolean;
344
- };
345
- }
346
- interface SubscriberDetail {
347
- subscriber: Subscriber;
348
- /** The subscription offer */
349
- subscription: SubscriptionOffer | null;
350
- /** The buyer's customer record */
351
- customer: Customer | null;
352
- status: SubscriberStatus;
353
- /** Every subscription payment (initial + renewals) for this subscriber */
354
- payments: Payment[];
355
- /** Only present when `live: true` — null if the live lookup failed */
356
- whopMembership?: Record<string, any> | null;
357
- }
358
- /** Native subscriber portal payload (no authentication required). */
359
- interface SubscriberPortalData {
360
- subscription?: SubscriptionOffer | null;
361
- subscriber?: Subscriber | null;
362
- payments?: Payment[];
363
- [key: string]: any;
364
- }
365
- /**
366
- * A single payment (a `Sale`). Covers BOTH one-time product purchases
367
- * (`isSubscription: false`) and subscription payments — the initial charge and
368
- * every renewal (`isSubscription: true`).
369
- */
370
- interface Payment {
371
- _id: string;
372
- isSubscription: boolean;
373
- /** Subscription payments only: `initial` activates the membership, `renewal` after */
374
- billingReason?: 'initial' | 'renewal';
375
- /** Charged amount (after tax), in the payment currency */
376
- amount: number;
377
- grossAmount?: number;
378
- amountBeforeTax?: number;
379
- taxAmount?: number;
380
- currency: string;
381
- buyerEmail: string;
382
- firstName?: string;
383
- lastName?: string;
384
- isRefunded: boolean;
385
- isDisputed: boolean;
386
- /** Empty on subscription payments — use `subscriptionId` instead */
387
- productId?: string;
388
- /** Empty on one-time product purchases */
389
- subscriptionId?: string;
390
- whopPaymentId?: string;
391
- whopPlanId?: string;
392
- whopMembershipId?: string;
393
- createdAt: string;
394
- }
395
- interface ListPaymentsParams extends PaginationParams, DateRangeParams {
396
- /** `one_time`, `subscription`, or `all` (default) */
397
- type?: 'one_time' | 'subscription' | 'all';
398
- productId?: string;
399
- /** Filter by subscription offer id */
400
- subscriptionId?: string;
401
- }
402
- interface PaymentsResponse {
403
- payments: Payment[];
404
- pagination: {
405
- totalCount: number;
406
- totalPages: number;
407
- currentPage: number;
408
- pageSize: number;
409
- hasMore: boolean;
410
- };
411
- }
412
- interface PaymentDetail {
413
- payment: Payment & {
414
- /** Net to the seller (amountBeforeTax − affiliateCut − stripeFee) */
415
- net?: number;
416
- /** Processor fee (Stripe or PayPal) */
417
- fee?: number;
418
- /** The raw stored Whop payment payload captured on the webhook */
419
- metadata?: Record<string, any>;
420
- };
421
- /** One-time purchases only; null for subscription payments */
422
- product: Product | null;
423
- /** Subscription payments only; null for one-time purchases */
424
- subscription: SubscriptionOffer | null;
425
- customer: Customer | null;
426
- whop?: Record<string, any>;
427
- /** Only present when `live: true` — null if the live lookup failed */
428
- whopLive?: Record<string, any> | null;
429
- }
430
- interface CreatorPageLink {
431
- title?: string;
432
- url?: string;
433
- order?: number;
434
- [key: string]: any;
435
- }
436
- interface CreatorPage {
437
- _id: string;
438
- userId: string;
439
- creatorName?: string;
440
- creatorBio?: string;
441
- username?: string;
442
- socialLinks?: CreatorPageLink[];
443
- regularLinks?: CreatorPageLink[];
444
- theme?: string;
445
- themeV2?: Record<string, any>;
446
- gaMeasurementId?: string;
447
- subscriberForm?: Record<string, any>;
448
- bookingEnabled?: boolean;
449
- bookingButtonLabel?: string;
450
- template?: string;
451
- createdAt: string;
452
- updatedAt?: string;
453
- }
454
- interface CreateCreatorPageParams {
455
- creatorName?: string;
456
- creatorBio?: string;
457
- username?: string;
458
- socialLinks?: CreatorPageLink[];
459
- regularLinks?: CreatorPageLink[];
460
- theme?: string;
461
- themeV2?: Record<string, any>;
462
- gaMeasurementId?: string;
463
- subscriberForm?: Record<string, any>;
464
- bookingEnabled?: boolean;
465
- bookingButtonLabel?: string;
466
- template?: string;
467
- }
468
- type UpdateCreatorPageParams = CreateCreatorPageParams;
469
- interface UploadImageResponse {
470
- imageUrl: string;
471
- }
472
- type NewsletterPostStatus = 'draft' | 'scheduled' | 'sending' | 'sent' | 'failed' | 'automation';
473
- interface NewsletterPost {
474
- _id: string;
475
- creatorId: string;
476
- name: string;
477
- subject?: string;
478
- preview?: string;
479
- fromName?: string;
480
- fromEmail: string;
481
- replyToEmail?: string;
482
- contentHtml?: string;
483
- contentJson?: any;
484
- status: NewsletterPostStatus;
485
- scheduledAt?: string;
486
- scheduledTimezone?: string;
487
- sentAt?: string;
488
- sendToAll?: boolean;
489
- tags?: string[];
490
- subscriberIds?: string[];
491
- source?: 'dashboard' | 'api';
492
- createdAt: string;
493
- updatedAt: string;
494
- }
495
- interface CreateNewsletterPostParams {
496
- /** Internal post name (required) */
304
+ interface CreateSubscriptionOfferParams {
305
+ /** Subscription offer name (required) */
497
306
  name: string;
498
- /** Required before the post can leave `draft` */
499
- subject?: string;
500
- /** Required before the post can leave `draft` */
501
- preview?: string;
502
- /** Required before the post can leave `draft` */
503
- fromName?: string;
504
- /** Defaults to your configured sender */
505
- fromEmail?: string;
506
- replyToEmail?: string;
507
- /** Required before the post can leave `draft` */
508
- contentHtml?: string;
509
- contentJson?: any;
510
- status?: NewsletterPostStatus;
511
- scheduledAt?: string;
512
- scheduledTimezone?: string;
513
- sendToAll?: boolean;
514
- tags?: string[];
515
- subscriberIds?: string[];
516
- }
517
- type UpdateNewsletterPostParams = Partial<CreateNewsletterPostParams>;
518
- interface SendNewsletterPostResponse {
519
- message: string;
520
- post: NewsletterPost;
521
- }
522
- interface SendEmailParams {
523
- /** Recipient(s) — 1 to 100 addresses */
524
- to: string | string[];
525
- subject: string;
526
- /** Required unless `text` is provided */
527
- html?: string;
528
- /** Used to generate `html` when `html` is omitted */
529
- text?: string;
530
- fromName?: string;
531
- replyTo?: string;
532
- preview?: string;
533
- }
534
- interface SendEmailResponse {
535
- /** The id of the post created for this send */
536
- id: string;
537
- /** Recipients the send was accepted for */
538
- accepted: string[];
539
- status: 'sent';
540
- }
541
- interface NewsletterSubscriber {
542
- _id: string;
543
- userId: string;
544
- email: string;
545
- name?: string;
546
- status: 'active' | 'unsubscribed';
547
- tags?: string[];
548
- createdAt: string;
549
- updatedAt: string;
307
+ /** Recurring price in USD (required) */
308
+ price: number;
309
+ /** Billing frequency (required) */
310
+ frequency: 'weekly' | 'monthly' | 'yearly';
311
+ /** Short offer subtitle */
312
+ subtitle?: string;
313
+ /** Offer description */
314
+ description?: string;
315
+ /** Trial duration in days */
316
+ trialPeriod?: number;
317
+ /** Whether the offer is published */
318
+ published?: boolean;
319
+ /** Return URL used by the customer billing portal */
320
+ redirectBackUrl?: string;
321
+ /** Offer URL slug */
322
+ slug?: string;
323
+ /** Thumbnail URL */
324
+ thumbnail?: string;
325
+ /** Offer image URLs */
326
+ images?: string[];
327
+ /** Whether the offer is backed by a downloadable file */
328
+ isFile?: boolean;
329
+ /** File URL or uploaded file reference */
330
+ file?: string | Record<string, unknown>;
331
+ /** External offer URL */
332
+ url?: string;
333
+ /** Checkout copy and seller-facing configuration */
334
+ checkoutText?: string;
335
+ refundPolicy?: string;
336
+ callbackUrl?: string;
337
+ hasCallbackUrl?: boolean;
338
+ hasFirstName?: boolean;
339
+ hasLastName?: boolean;
340
+ portalText?: string;
341
+ privacyPolicy?: string;
342
+ termsOfService?: string;
343
+ ctaText?: string;
344
+ thankYouText?: string;
345
+ hasProductPage?: boolean;
346
+ showSales?: boolean;
347
+ showReviews?: boolean;
348
+ maxPrice?: number;
349
+ minPrice?: number;
350
+ design?: Record<string, unknown>;
351
+ colors?: Record<string, unknown>;
352
+ pageStyle?: Record<string, unknown>;
353
+ checkoutStyle?: Record<string, unknown>;
354
+ checkoutColors?: Record<string, unknown>;
550
355
  }
551
356
  interface Webhook {
552
357
  _id: string;
@@ -647,12 +452,8 @@ declare class Pocketsflow {
647
452
  discounts: DiscountsResource;
648
453
  upsells: UpsellsResource;
649
454
  subscriptions: SubscriptionsResource;
455
+ /** Subscription offers (recurring products), distinct from buyer memberships. */
650
456
  subscriptionOffers: SubscriptionOffersResource;
651
- subscribers: SubscribersResource;
652
- payments: PaymentsResource;
653
- creatorPages: CreatorPagesResource;
654
- images: ImagesResource;
655
- newsletters: NewslettersResource;
656
457
  webhooks: WebhooksResource;
657
458
  users: UsersResource;
658
459
  checkout: CheckoutResource;
@@ -726,10 +527,6 @@ declare class DiscountsResource {
726
527
  delete(id: string): Promise<{
727
528
  message: string;
728
529
  }>;
729
- /** Validate a discount code against a product and get the resulting price */
730
- apply(discountCode: string, productId: string): Promise<any>;
731
- /** Check whether a product has any discounts */
732
- checkProduct(productId: string): Promise<any>;
733
530
  }
734
531
  declare class UpsellsResource {
735
532
  private client;
@@ -747,14 +544,6 @@ declare class UpsellsResource {
747
544
  message: string;
748
545
  }>;
749
546
  }
750
- /**
751
- * Legacy subscriber access via the Orders endpoints, kept for v1 compatibility.
752
- *
753
- * Prefer `subscribers` (buyers) and `subscriptionOffers` (the recurring
754
- * products you sell) — they cover pause/resume and filtering, which these do
755
- * not. Note `cancel`/`refund` here key off the Stripe subscription id, whereas
756
- * `subscribers.cancel` accepts the subscriber `_id` or Whop membership id.
757
- */
758
547
  declare class SubscriptionsResource {
759
548
  private client;
760
549
  constructor(client: Pocketsflow);
@@ -771,10 +560,7 @@ declare class SubscriptionsResource {
771
560
  message: string;
772
561
  }>;
773
562
  }
774
- /**
775
- * Your subscription OFFERS — the recurring products you sell.
776
- * To work with your buyers instead, use `subscribers`.
777
- */
563
+ /** Your subscription offers — the recurring products you sell. */
778
564
  declare class SubscriptionOffersResource {
779
565
  private client;
780
566
  constructor(client: Pocketsflow);
@@ -782,144 +568,8 @@ declare class SubscriptionOffersResource {
782
568
  list(): Promise<SubscriptionOffer[]>;
783
569
  /** Get a subscription offer by ID */
784
570
  get(id: string): Promise<SubscriptionOffer>;
785
- }
786
- /**
787
- * Your subscribers — buyers with a membership in one of your subscription
788
- * offers. `id` accepts either the subscriber's `_id` or its Whop membership id.
789
- */
790
- declare class SubscribersResource {
791
- private client;
792
- constructor(client: Pocketsflow);
793
- /** List subscribers */
794
- list(params?: ListSubscribersParams): Promise<SubscribersResponse>;
795
- /**
796
- * Get a subscriber with its full payment history.
797
- * Pass `live` to also fetch the authoritative membership from Whop; the
798
- * lookup degrades gracefully and never fails the request.
799
- */
800
- get(id: string, options?: {
801
- live?: boolean;
802
- }): Promise<SubscriberDetail>;
803
- /** Cancel a subscriber's subscription */
804
- cancel(id: string): Promise<{
805
- success: boolean;
806
- message?: string;
807
- }>;
808
- /** Pause a subscriber's subscription */
809
- pause(id: string): Promise<{
810
- success: boolean;
811
- message?: string;
812
- }>;
813
- /** Resume a paused subscription */
814
- resume(id: string): Promise<{
815
- success: boolean;
816
- message?: string;
817
- }>;
818
- /**
819
- * Read the native subscriber portal payload. The `subscriptionId` +
820
- * `subscriberId` pair is itself the capability — these portal endpoints are
821
- * unauthenticated, so the API key is not required to call them.
822
- */
823
- portal(subscriptionId: string, subscriberId: string): Promise<SubscriberPortalData>;
824
- /** Cancel a membership through the native portal */
825
- portalCancel(subscriberId: string): Promise<{
826
- success?: boolean;
827
- message?: string;
828
- }>;
829
- /** Resume a pending cancellation through the native portal */
830
- portalResume(subscriberId: string): Promise<{
831
- success?: boolean;
832
- message?: string;
833
- }>;
834
- }
835
- /**
836
- * The unified payment ledger — one-time purchases AND subscription payments
837
- * (the initial charge plus every renewal).
838
- */
839
- declare class PaymentsResource {
840
- private client;
841
- constructor(client: Pocketsflow);
842
- /** List payments */
843
- list(params?: ListPaymentsParams): Promise<PaymentsResponse>;
844
- /**
845
- * Get a payment by ID. Pass `live` to also fetch the authoritative payment
846
- * from Whop; the lookup degrades gracefully and never fails the request.
847
- */
848
- get(id: string, options?: {
849
- live?: boolean;
850
- }): Promise<PaymentDetail>;
851
- }
852
- /** Your Link in Bio page. */
853
- declare class CreatorPagesResource {
854
- private client;
855
- constructor(client: Pocketsflow);
856
- /** Get your Link in Bio page */
857
- get(): Promise<CreatorPage>;
858
- /** Create your Link in Bio page. Fails if one already exists — use `update`. */
859
- create(params: CreateCreatorPageParams): Promise<CreatorPage>;
860
- /** Update your Link in Bio page (partial) */
861
- update(params: UpdateCreatorPageParams): Promise<CreatorPage>;
862
- /** Delete your Link in Bio page */
863
- delete(): Promise<{
864
- message: string;
865
- }>;
866
- /** Check whether a username is available */
867
- checkUsername(username: string): Promise<any>;
868
- /** Set your Link in Bio username */
869
- updateUsername(username: string): Promise<CreatorPage>;
870
- }
871
- /** Image uploads. */
872
- declare class ImagesResource {
873
- private client;
874
- constructor(client: Pocketsflow);
875
- /**
876
- * Upload an image and get back its hosted URL.
877
- *
878
- * `file` accepts anything FormData can hold — a Blob/File, or a Buffer in
879
- * Node 18+. `filename` is used when the value carries no name of its own.
880
- */
881
- upload(file: Blob | Uint8Array | ArrayBuffer, filename?: string): Promise<UploadImageResponse>;
882
- }
883
- /** Newsletter posts and subscribers. */
884
- declare class NewslettersResource {
885
- private client;
886
- posts: NewsletterPostsResource;
887
- subscribers: NewsletterSubscribersResource;
888
- constructor(client: Pocketsflow);
889
- /**
890
- * Send a one-off email to up to 100 recipients.
891
- * Requires a verified sender email. Either `html` or `text` must be given.
892
- */
893
- send(params: SendEmailParams): Promise<SendEmailResponse>;
894
- }
895
- declare class NewsletterPostsResource {
896
- private client;
897
- constructor(client: Pocketsflow);
898
- /** List all posts, newest first */
899
- list(): Promise<NewsletterPost[]>;
900
- /** Get a post by ID */
901
- get(id: string): Promise<NewsletterPost>;
902
- /**
903
- * Create a post. Leaving `draft` requires `subject`, `preview`, `fromName`
904
- * and `contentHtml` to be set.
905
- */
906
- create(params: CreateNewsletterPostParams): Promise<NewsletterPost>;
907
- /** Update a post. Posts that have already been sent cannot be edited. */
908
- update(id: string, params: UpdateNewsletterPostParams): Promise<NewsletterPost>;
909
- /** Delete a post */
910
- delete(id: string): Promise<NewsletterPost>;
911
- /** Queue a post for sending to its subscribers */
912
- send(id: string): Promise<SendNewsletterPostResponse>;
913
- }
914
- declare class NewsletterSubscribersResource {
915
- private client;
916
- constructor(client: Pocketsflow);
917
- /** List all subscribers, newest first */
918
- list(): Promise<NewsletterSubscriber[]>;
919
- /** Get a subscriber by ID */
920
- get(id: string): Promise<NewsletterSubscriber>;
921
- /** Remove a subscriber */
922
- delete(id: string): Promise<NewsletterSubscriber>;
571
+ /** Create a subscription offer */
572
+ create(params: CreateSubscriptionOfferParams): Promise<SubscriptionOffer>;
923
573
  }
924
574
  declare class WebhooksResource {
925
575
  private client;
@@ -966,4 +616,4 @@ declare class RefundsResource {
966
616
  create(params: CreateRefundParams): Promise<Refund>;
967
617
  }
968
618
 
969
- export { type ApiError, type CheckoutSession, type CreateCheckoutParams, type CreateCreatorPageParams, type CreateDiscountParams, type CreateNewsletterPostParams, type CreateProductParams, type CreateRefundParams, type CreateUpsellParams, type CreateVariantParams, type CreateWebhookParams, type CreatorPage, type CreatorPageLink, type Customer, type DateRangeParams, type Discount, type ListCustomersParams, type ListOrdersParams, type ListPaymentsParams, type ListReviewsParams, type ListSubscribersParams, type ListSubscriptionsParams, type NewsletterPost, type NewsletterPostStatus, type NewsletterSubscriber, type Order, type OrdersResponse, type PaginatedResponse, type PaginationParams, type Payment, type PaymentDetail, type PaymentsResponse, Pocketsflow, type PocketsflowConfig, PocketsflowError, type Product, type ProductFile, type ProductVariant, type Refund, type Review, type SendEmailParams, type SendEmailResponse, type SendNewsletterPostResponse, type Subscriber, type SubscriberDetail, type SubscriberPortalData, type SubscriberStatus, type SubscribersResponse, type Subscription, type SubscriptionOffer, type UpdateCreatorPageParams, type UpdateDiscountParams, type UpdateNewsletterPostParams, type UpdateProductParams, type UpdateUpsellParams, type UpdateUserParams, type UpdateWebhookParams, type UploadImageResponse, type Upsell, type UpsellsResponse, type User, type Webhook, type WebhookEvent };
619
+ export { type ApiError, type CheckoutSession, type CreateCheckoutParams, type CreateDiscountParams, type CreateProductParams, type CreateRefundParams, type CreateSubscriptionOfferParams, type CreateUpsellParams, type CreateVariantParams, type CreateWebhookParams, type Customer, type DateRangeParams, type Discount, type ListCustomersParams, type ListOrdersParams, type ListReviewsParams, type ListSubscriptionsParams, type Order, type OrdersResponse, type PaginatedResponse, type PaginationParams, Pocketsflow, type PocketsflowConfig, PocketsflowError, type Product, type ProductFile, type ProductVariant, type Refund, type Review, type Subscription, type SubscriptionOffer, type UpdateDiscountParams, type UpdateProductParams, type UpdateUpsellParams, type UpdateUserParams, type UpdateWebhookParams, type Upsell, type UpsellsResponse, type User, type Webhook, type WebhookEvent };