@revenuecat/purchases-typescript-internal 19.14.1 → 19.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.
@@ -8,7 +8,7 @@ export type Store = "PLAY_STORE" | "APP_STORE" | "STRIPE" | "MAC_APP_STORE" | "P
8
8
  * The supported ownership types for an entitlement.
9
9
  * @public
10
10
  */
11
- export type OwnershipType = "PURCHASED" | "FAMILY_SHARED" | "UNKNOWN";
11
+ export type OwnershipType = "PURCHASED" | "FAMILY_SHARED" | "ASSIGNED" | "UNKNOWN";
12
12
  /**
13
13
  * The supported period types for an entitlement.
14
14
  * @public
@@ -107,6 +107,7 @@ export interface PurchasesEntitlementInfo {
107
107
  * Supported ownership types for an entitlement.
108
108
  * PURCHASED if the purchase was made directly by this user.
109
109
  * FAMILY_SHARED if the purchase has been shared to this user by a family member.
110
+ * ASSIGNED if the purchase has been assigned to this user through an organization.
110
111
  * UNKNOWN if the purchase has no or an unknown ownership type.
111
112
  */
112
113
  readonly ownershipType: OwnershipType;
@@ -296,6 +297,7 @@ export interface PurchasesSubscriptionInfo {
296
297
  * How the Customer received access to this subscription:
297
298
  * - [OwnershipType.PURCHASED]: The customer bought the subscription.
298
299
  * - [OwnershipType.FAMILY_SHARED]: The Customer has access to the product via their family.
300
+ * - [OwnershipType.ASSIGNED]: The Customer has been assigned access to the product through an organization.
299
301
  */
300
302
  readonly ownershipType: OwnershipType;
301
303
  /**
package/dist/errors.d.ts CHANGED
@@ -37,3 +37,12 @@ export declare class UninitializedPurchasesError extends Error {
37
37
  export declare class UnsupportedPlatformError extends Error {
38
38
  constructor();
39
39
  }
40
+ /**
41
+ * Returns whether the given value is a {@link PurchasesError} thrown by the SDK.
42
+ *
43
+ * A value qualifies when its schema matches {@link PurchasesError} and its `code` is one of the
44
+ * {@link PURCHASES_ERROR_CODE} values.
45
+ *
46
+ * @public
47
+ */
48
+ export declare function isPurchasesError(error: unknown): error is PurchasesError;
package/dist/errors.js CHANGED
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.UnsupportedPlatformError = exports.UninitializedPurchasesError = exports.PURCHASES_ERROR_CODE = void 0;
19
+ exports.isPurchasesError = isPurchasesError;
19
20
  /* tslint:disable:max-classes-per-file */
20
21
  var error_codes_1 = require("./generated/error-codes");
21
22
  Object.defineProperty(exports, "PURCHASES_ERROR_CODE", { enumerable: true, get: function () { return error_codes_1.PURCHASES_ERROR_CODE; } });
@@ -49,3 +50,34 @@ var UnsupportedPlatformError = /** @class */ (function (_super) {
49
50
  return UnsupportedPlatformError;
50
51
  }(Error));
51
52
  exports.UnsupportedPlatformError = UnsupportedPlatformError;
53
+ /**
54
+ * Returns whether the given value is a {@link PurchasesError} thrown by the SDK.
55
+ *
56
+ * A value qualifies when its schema matches {@link PurchasesError} and its `code` is one of the
57
+ * {@link PURCHASES_ERROR_CODE} values.
58
+ *
59
+ * @public
60
+ */
61
+ function isPurchasesError(error) {
62
+ if (typeof error !== "object" || error === null) {
63
+ return false;
64
+ }
65
+ if (!("code" in error) || typeof error.code !== "string") {
66
+ return false;
67
+ }
68
+ if (!("message" in error) || typeof error.message !== "string") {
69
+ return false;
70
+ }
71
+ if (!("userInfo" in error) || typeof error.userInfo !== "object" || error.userInfo == null) {
72
+ return false;
73
+ }
74
+ if (!(("readableErrorCode") in error.userInfo) || typeof error.userInfo.readableErrorCode !== "string") {
75
+ return false;
76
+ }
77
+ if (!("underlyingErrorMessage" in error) || typeof error.underlyingErrorMessage !== "string") {
78
+ return false;
79
+ }
80
+ var code = error.code;
81
+ var knownErrorCodes = new Set(Object.values(error_codes_1.PURCHASES_ERROR_CODE));
82
+ return typeof code === "string" && knownErrorCodes.has(code);
83
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@revenuecat/purchases-typescript-internal",
3
3
  "title": "Purchases typescript internal shared code",
4
- "version": "19.14.1",
4
+ "version": "19.15.0",
5
5
  "description": "Typescript code to be used by RevenueCat's hybrid SDKs. Not meant for external usage.",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",