@revenuecat/purchases-js 0.8.0 → 0.10.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.
@@ -180,6 +180,11 @@ export declare interface GetOfferingsParams {
180
180
  * If not specified, the default currency will be used.
181
181
  */
182
182
  readonly currency?: string;
183
+ /**
184
+ * The identifier of the offering to fetch.
185
+ * Can be a string identifier or one of the predefined keywords.
186
+ */
187
+ readonly offeringIdentifier?: string | OfferingKeyword;
183
188
  }
184
189
 
185
190
  /**
@@ -230,6 +235,17 @@ export declare enum LogLevel {
230
235
  Verbose = 5
231
236
  }
232
237
 
238
+ /**
239
+ * Represents a possible option to purchase a non-subscription product.
240
+ * @public
241
+ */
242
+ export declare interface NonSubscriptionOption extends PurchaseOption {
243
+ /**
244
+ * The base price for the product.
245
+ */
246
+ readonly basePrice: Price;
247
+ }
248
+
233
249
  /**
234
250
  * An offering is a collection of {@link Package} available for the user to purchase.
235
251
  * For more info see https://docs.revenuecat.com/docs/entitlements
@@ -290,6 +306,16 @@ export declare interface Offering {
290
306
  readonly weekly: Package | null;
291
307
  }
292
308
 
309
+ /**
310
+ * Keywords for identifying specific offerings in the {@link Purchases.getOfferings} method.
311
+ */
312
+ export declare enum OfferingKeyword {
313
+ /**
314
+ * The current offering.
315
+ */
316
+ Current = "current"
317
+ }
318
+
293
319
  /**
294
320
  * This class contains all the offerings configured in RevenueCat dashboard.
295
321
  * For more info see https://docs.revenuecat.com/docs/entitlements
@@ -297,13 +323,15 @@ export declare interface Offering {
297
323
  */
298
324
  export declare interface Offerings {
299
325
  /**
300
- * Dictionary of all {@link Offering} objects keyed by their identifier.
326
+ * Dictionary containing all {@link Offering} objects, keyed by their identifier.
301
327
  */
302
328
  readonly all: {
303
329
  [offeringId: string]: Offering;
304
330
  };
305
331
  /**
306
332
  * Current offering configured in the RevenueCat dashboard.
333
+ * It can be `null` if no current offering is configured or if a specific offering
334
+ * was requested that is not the current one.
307
335
  */
308
336
  readonly current: Offering | null;
309
337
  }
@@ -501,13 +529,17 @@ export declare interface Product {
501
529
  */
502
530
  readonly description: string | null;
503
531
  /**
504
- * Price of the product. In the case of subscriptions, this will match the
505
- * default option's base phase price.
532
+ * Price of the product. This will match the default option's base phase price
533
+ * in subscriptions or the price in non-subscriptions.
506
534
  */
507
535
  readonly currentPrice: Price;
536
+ /**
537
+ * The type of product.
538
+ */
539
+ readonly productType: ProductType;
508
540
  /**
509
541
  * The period duration for a subscription product. This will match the default
510
- * option's base phase period duration.
542
+ * option's base phase period duration. Null for non-subscriptions.
511
543
  */
512
544
  readonly normalPeriodDuration: string | null;
513
545
  /**
@@ -524,13 +556,14 @@ export declare interface Product {
524
556
  */
525
557
  readonly defaultPurchaseOption: PurchaseOption;
526
558
  /**
527
- * The default subscription option for this product. Null if no subscription
528
- * options are available like in the case of consumables and non-consumables.
559
+ * The default subscription option for this product.
560
+ * Null if no subscription options are available like in the case of consumables and non-consumables.
529
561
  */
530
562
  readonly defaultSubscriptionOption: SubscriptionOption | null;
531
563
  /**
532
564
  * A dictionary with all the possible subscription options available for this
533
565
  * product. Each key contains the key to be used when executing a purchase.
566
+ * Will be empty for non-subscriptions
534
567
  *
535
568
  * If retrieved through getOfferings the offers are only the ones the customer is
536
569
  * entitled to.
@@ -538,6 +571,30 @@ export declare interface Product {
538
571
  readonly subscriptionOptions: {
539
572
  [optionId: string]: SubscriptionOption;
540
573
  };
574
+ /**
575
+ * The default non-subscription option for this product.
576
+ * Null in the case of subscriptions.
577
+ */
578
+ readonly defaultNonSubscriptionOption: NonSubscriptionOption | null;
579
+ }
580
+
581
+ /**
582
+ * Possible product types
583
+ * @public
584
+ */
585
+ export declare enum ProductType {
586
+ /**
587
+ * A product that is an auto-renewing subscription.
588
+ */
589
+ Subscription = "subscription",
590
+ /**
591
+ * A product that does not renew and can be consumed to be purchased again.
592
+ */
593
+ Consumable = "consumable",
594
+ /**
595
+ * A product that does not renew and can only be purchased once.
596
+ */
597
+ NonConsumable = "non_consumable"
541
598
  }
542
599
 
543
600
  /**
@@ -623,6 +680,7 @@ export declare class Purchases {
623
680
  /**
624
681
  * Fetch the configured offerings for this user. You can configure these
625
682
  * in the RevenueCat dashboard.
683
+ * @param params - The parameters object to customise the offerings fetch. Check {@link GetOfferingsParams}
626
684
  */
627
685
  getOfferings(params?: GetOfferingsParams): Promise<Offerings>;
628
686
  /**
@@ -739,6 +797,7 @@ export declare class Purchases {
739
797
 
740
798
  /**
741
799
  * Extra information that is available in certain types of errors.
800
+ * @public
742
801
  */
743
802
  export declare interface PurchasesErrorExtra {
744
803
  /**