@stigg/js-client-sdk 1.25.0 → 1.27.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/models.d.ts CHANGED
@@ -156,14 +156,17 @@ export declare type DefaultTrialConfig = {
156
156
  export declare type GetBooleanEntitlement = {
157
157
  featureId: string;
158
158
  options?: BooleanEntitlementOptions;
159
+ resourceId?: string;
159
160
  };
160
161
  export declare type GetNumericEntitlement = {
161
162
  featureId: string;
162
163
  options?: NumericEntitlementOptions;
164
+ resourceId?: string;
163
165
  };
164
166
  export declare type GetMeteredEntitlement = {
165
167
  featureId: string;
166
168
  options?: MeteredEntitlementOptions;
169
+ resourceId?: string;
167
170
  };
168
171
  export declare type GetPaywall = {
169
172
  productId?: string;
@@ -223,6 +226,7 @@ export declare type ExperimentInfo = {
223
226
  export declare type Subscription = {
224
227
  id: string;
225
228
  status: SubscriptionStatus;
229
+ resourceId?: string;
226
230
  plan: Plan;
227
231
  price: SubscriptionPrice | null;
228
232
  pricingType: PricingType;
@@ -348,6 +352,7 @@ export declare type EstimateSubscription = {
348
352
  unitQuantity?: number;
349
353
  billingInformation?: SubscriptionBillingInfo;
350
354
  promotionCode?: string;
355
+ skipTrial?: boolean;
351
356
  };
352
357
  export declare type EstimateSubscriptionUpdate = {
353
358
  subscriptionId: string;
@@ -6,5 +6,5 @@ export declare class EntitlementCheckReportingService {
6
6
  private readonly customerId;
7
7
  private readonly loggerService;
8
8
  constructor(entitlementsApi: EntitlementsApi, customerId: string, loggerService: LoggerService);
9
- reportEntitlementCheckRequested(featureId: string, entitlement: EntitlementCheckResult, requestedUsage?: number): void;
9
+ reportEntitlementCheckRequested(featureId: string, entitlement: EntitlementCheckResult, requestedUsage?: number, resourceId?: string): void;
10
10
  }
@@ -22,15 +22,15 @@ export declare class EntitlementsService {
22
22
  restartPolling(intervalMs: number): void;
23
23
  refresh(): Promise<void>;
24
24
  get isInitialized(): boolean;
25
- getBooleanEntitlement(featureId: string, fallbackEntitlement: BooleanEntitlement, options?: BooleanEntitlementOptions): BooleanEntitlement;
26
- getNumericEntitlement(featureId: string, fallbackEntitlement: NumericEntitlement, options?: NumericEntitlementOptions): NumericEntitlement;
27
- getMeteredEntitlement(featureId: string, fallbackEntitlement: MeteredEntitlement, options?: MeteredEntitlementOptions): MeteredEntitlement;
25
+ getBooleanEntitlement(featureId: string, fallbackEntitlement: BooleanEntitlement, resourceId?: string, options?: BooleanEntitlementOptions): BooleanEntitlement;
26
+ getNumericEntitlement(featureId: string, fallbackEntitlement: NumericEntitlement, resourceId?: string, options?: NumericEntitlementOptions): NumericEntitlement;
27
+ getMeteredEntitlement(featureId: string, fallbackEntitlement: MeteredEntitlement, resourceId?: string, options?: MeteredEntitlementOptions): MeteredEntitlement;
28
28
  private tryTrackEntitlementCheck;
29
29
  loadEntitlements(skipEdge?: boolean): Promise<void>;
30
30
  private loadEntitlementsFromRemote;
31
31
  protected storeFetchedEntitlementsInCache(entitlements: EntitlementFragment[]): void;
32
32
  private getLastEntitlementsUpdate;
33
- getEntitlements(): Promise<BooleanEntitlement[]>;
33
+ getEntitlements(resourceId: string | null): Promise<BooleanEntitlement[]>;
34
34
  }
35
35
  export declare type GetEntitlementResult = {
36
36
  entitlement: CachedEntitlement | null;
@@ -9,6 +9,6 @@ declare class EntitlementsApi {
9
9
  pollEntitlements(customerId: string, interval: number): import("../utils/ObservablePoller").ObservablePoller<GetEntitlementsQuery> | import("@apollo/client/core").ObservableQuery<GetEntitlementsQuery, import("@stigg/api-client-js/src/generated/sdk").Exact<{
10
10
  query: import("@stigg/api-client-js/src/generated/sdk").FetchEntitlementsQuery;
11
11
  }>>;
12
- reportEntitlementRequested(featureId: string, customerId: string, entitlementCheckResult: EntitlementCheckResult, requestedUsage?: number): Promise<void>;
12
+ reportEntitlementRequested(featureId: string, customerId: string, entitlementCheckResult: EntitlementCheckResult, resourceId?: string, requestedUsage?: number): Promise<void>;
13
13
  }
14
14
  export default EntitlementsApi;
@@ -12,7 +12,7 @@ export interface StiggClient {
12
12
  getPaywall: (params?: GetPaywall) => Promise<Paywall>;
13
13
  getCustomer: () => Promise<Customer>;
14
14
  getCoupons(): Promise<Coupon[]>;
15
- getEntitlements: () => Promise<Entitlement[]>;
15
+ getEntitlements: (resourceId?: string) => Promise<Entitlement[]>;
16
16
  refresh: () => Promise<void>;
17
17
  waitForCheckoutCompleted(params?: WaitForCheckoutCompleted): Promise<Subscription | null>;
18
18
  waitForInitialization(): Promise<StiggClient>;
@@ -80,24 +80,31 @@ export declare class Stigg implements StiggClient {
80
80
  refresh(): Promise<void>;
81
81
  /**
82
82
  * Get boolean entitlement of feature for a customer
83
+ *
84
+ * @param {string} featureId
85
+ * @param {string} resourceId
86
+ * @param {BooleanEntitlementOptions} options
87
+ * @return {BooleanEntitlement} boolean entitlement
83
88
  */
84
- getBooleanEntitlement({ featureId, options }: GetBooleanEntitlement): BooleanEntitlement;
89
+ getBooleanEntitlement({ featureId, options, resourceId }: GetBooleanEntitlement): BooleanEntitlement;
85
90
  /**
86
91
  * Get numeric entitlement of feature for a customer
87
92
  *
88
93
  * @param {string} featureId
94
+ * @param {string} resourceId
89
95
  * @param {NumericEntitlementOptions} options
90
96
  * @return {NumericEntitlement} numeric entitlement
91
97
  */
92
- getNumericEntitlement({ featureId, options }: GetNumericEntitlement): NumericEntitlement;
98
+ getNumericEntitlement({ featureId, options, resourceId }: GetNumericEntitlement): NumericEntitlement;
93
99
  /**
94
100
  * Get metered entitlement of feature for a customer
95
101
  *
96
102
  * @param {string} featureId
103
+ * @param {string} resourceId
97
104
  * @param {MeteredEntitlementOptions} options
98
105
  * @return {MeteredEntitlement} metered entitlement
99
106
  */
100
- getMeteredEntitlement({ featureId, options }: GetMeteredEntitlement): MeteredEntitlement;
107
+ getMeteredEntitlement({ featureId, options, resourceId }: GetMeteredEntitlement): MeteredEntitlement;
101
108
  /**
102
109
  * Get paywall data for rendering the paywall
103
110
  * @deprecated *Optional* `productId` is now deprecated and will be changed to a *required* field soon.
@@ -126,9 +133,10 @@ export declare class Stigg implements StiggClient {
126
133
  /**
127
134
  * Get a list of entitlements
128
135
  *
136
+ * @param {string} resourceId
129
137
  * @returns {Promise<Entitlement[]>}
130
138
  */
131
- getEntitlements(): Promise<Entitlement[]>;
139
+ getEntitlements(resourceId?: string): Promise<Entitlement[]>;
132
140
  /**
133
141
  * Estimate subscription
134
142
  * @return {Promise<SubscriptionPreview>} Preview of the subscription.
@@ -156,14 +156,17 @@ export declare type DefaultTrialConfig = {
156
156
  export declare type GetBooleanEntitlement = {
157
157
  featureId: string;
158
158
  options?: BooleanEntitlementOptions;
159
+ resourceId?: string;
159
160
  };
160
161
  export declare type GetNumericEntitlement = {
161
162
  featureId: string;
162
163
  options?: NumericEntitlementOptions;
164
+ resourceId?: string;
163
165
  };
164
166
  export declare type GetMeteredEntitlement = {
165
167
  featureId: string;
166
168
  options?: MeteredEntitlementOptions;
169
+ resourceId?: string;
167
170
  };
168
171
  export declare type GetPaywall = {
169
172
  productId?: string;
@@ -223,6 +226,7 @@ export declare type ExperimentInfo = {
223
226
  export declare type Subscription = {
224
227
  id: string;
225
228
  status: SubscriptionStatus;
229
+ resourceId?: string;
226
230
  plan: Plan;
227
231
  price: SubscriptionPrice | null;
228
232
  pricingType: PricingType;
@@ -348,6 +352,7 @@ export declare type EstimateSubscription = {
348
352
  unitQuantity?: number;
349
353
  billingInformation?: SubscriptionBillingInfo;
350
354
  promotionCode?: string;
355
+ skipTrial?: boolean;
351
356
  };
352
357
  export declare type EstimateSubscriptionUpdate = {
353
358
  subscriptionId: string;
@@ -6,5 +6,5 @@ export declare class EntitlementCheckReportingService {
6
6
  private readonly customerId;
7
7
  private readonly loggerService;
8
8
  constructor(entitlementsApi: EntitlementsApi, customerId: string, loggerService: LoggerService);
9
- reportEntitlementCheckRequested(featureId: string, entitlement: EntitlementCheckResult, requestedUsage?: number): void;
9
+ reportEntitlementCheckRequested(featureId: string, entitlement: EntitlementCheckResult, requestedUsage?: number, resourceId?: string): void;
10
10
  }
@@ -22,15 +22,15 @@ export declare class EntitlementsService {
22
22
  restartPolling(intervalMs: number): void;
23
23
  refresh(): Promise<void>;
24
24
  get isInitialized(): boolean;
25
- getBooleanEntitlement(featureId: string, fallbackEntitlement: BooleanEntitlement, options?: BooleanEntitlementOptions): BooleanEntitlement;
26
- getNumericEntitlement(featureId: string, fallbackEntitlement: NumericEntitlement, options?: NumericEntitlementOptions): NumericEntitlement;
27
- getMeteredEntitlement(featureId: string, fallbackEntitlement: MeteredEntitlement, options?: MeteredEntitlementOptions): MeteredEntitlement;
25
+ getBooleanEntitlement(featureId: string, fallbackEntitlement: BooleanEntitlement, resourceId?: string, options?: BooleanEntitlementOptions): BooleanEntitlement;
26
+ getNumericEntitlement(featureId: string, fallbackEntitlement: NumericEntitlement, resourceId?: string, options?: NumericEntitlementOptions): NumericEntitlement;
27
+ getMeteredEntitlement(featureId: string, fallbackEntitlement: MeteredEntitlement, resourceId?: string, options?: MeteredEntitlementOptions): MeteredEntitlement;
28
28
  private tryTrackEntitlementCheck;
29
29
  loadEntitlements(skipEdge?: boolean): Promise<void>;
30
30
  private loadEntitlementsFromRemote;
31
31
  protected storeFetchedEntitlementsInCache(entitlements: EntitlementFragment[]): void;
32
32
  private getLastEntitlementsUpdate;
33
- getEntitlements(): Promise<BooleanEntitlement[]>;
33
+ getEntitlements(resourceId: string | null): Promise<BooleanEntitlement[]>;
34
34
  }
35
35
  export declare type GetEntitlementResult = {
36
36
  entitlement: CachedEntitlement | null;
@@ -0,0 +1,5 @@
1
+ import { EntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
2
+ import CachedEntitlement from '../services/cachedEntitlement';
3
+ export declare const buildCacheKeyFromEntitlement: (entitlement: EntitlementFragment) => string;
4
+ export declare const buildCacheKey: (featureId: string, resourceId?: string | null | undefined) => string;
5
+ export declare const filterEntitlementsByResourceId: (entitlements: Map<string, CachedEntitlement>, resourceId: string | null) => Array<[entitlementKey: string, entitlement: CachedEntitlement]>;
@@ -0,0 +1,5 @@
1
+ import { EntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
2
+ import CachedEntitlement from '../services/cachedEntitlement';
3
+ export declare const buildCacheKeyFromEntitlement: (entitlement: EntitlementFragment) => string;
4
+ export declare const buildCacheKey: (featureId: string, resourceId?: string | null | undefined) => string;
5
+ export declare const filterEntitlementsByResourceId: (entitlements: Map<string, CachedEntitlement>, resourceId: string | null) => Array<[entitlementKey: string, entitlement: CachedEntitlement]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigg/js-client-sdk",
3
- "version": "1.25.0",
3
+ "version": "1.27.0",
4
4
  "description": "Stigg client-side SDK for Browser",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@apollo/client": "^3.4.17",
30
30
  "@sentry/browser": "^7.11.1",
31
- "@stigg/api-client-js": "0.373.1",
31
+ "@stigg/api-client-js": "0.374.2",
32
32
  "axios": "^1.2.2",
33
33
  "cross-fetch": "^3.1.4",
34
34
  "husky": "^7.0.4",