@stigg/js-client-sdk 1.29.0 → 1.31.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/api/EdgeApiClient.d.ts +2 -2
- package/dist/api/EntitlementsApi.d.ts +2 -2
- package/dist/client.d.ts +16 -7
- package/dist/configuration.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +0 -3
- package/dist/services/entitlementCheckReportingService.d.ts +3 -2
- package/dist/services/entitlementsService.d.ts +8 -12
- package/dist/src/api/EdgeApiClient.d.ts +2 -2
- package/dist/src/api/EntitlementsApi.d.ts +2 -2
- package/dist/src/client.d.ts +16 -7
- package/dist/src/configuration.d.ts +1 -0
- package/dist/src/models.d.ts +0 -3
- package/dist/src/services/entitlementCheckReportingService.d.ts +3 -2
- package/dist/src/services/entitlementsService.d.ts +8 -12
- package/package.json +2 -2
- package/dist/src/utils/cacheKeysHelpers.d.ts +0 -5
- package/dist/utils/cacheKeysHelpers.d.ts +0 -5
package/dist/models.d.ts
CHANGED
|
@@ -156,17 +156,14 @@ export declare type DefaultTrialConfig = {
|
|
|
156
156
|
export declare type GetBooleanEntitlement = {
|
|
157
157
|
featureId: string;
|
|
158
158
|
options?: BooleanEntitlementOptions;
|
|
159
|
-
resourceId?: string;
|
|
160
159
|
};
|
|
161
160
|
export declare type GetNumericEntitlement = {
|
|
162
161
|
featureId: string;
|
|
163
162
|
options?: NumericEntitlementOptions;
|
|
164
|
-
resourceId?: string;
|
|
165
163
|
};
|
|
166
164
|
export declare type GetMeteredEntitlement = {
|
|
167
165
|
featureId: string;
|
|
168
166
|
options?: MeteredEntitlementOptions;
|
|
169
|
-
resourceId?: string;
|
|
170
167
|
};
|
|
171
168
|
export declare type GetPaywall = {
|
|
172
169
|
productId?: string;
|
|
@@ -5,6 +5,7 @@ export declare class EntitlementCheckReportingService {
|
|
|
5
5
|
private readonly entitlementsApi;
|
|
6
6
|
private readonly customerId;
|
|
7
7
|
private readonly loggerService;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
private readonly resourceId?;
|
|
9
|
+
constructor(entitlementsApi: EntitlementsApi, customerId: string, loggerService: LoggerService, resourceId?: string | undefined);
|
|
10
|
+
reportEntitlementCheckRequested(featureId: string, entitlement: EntitlementCheckResult, requestedUsage?: number): void;
|
|
10
11
|
}
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
|
|
2
|
-
import {
|
|
2
|
+
import { EntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
|
+
import { BooleanEntitlement, BooleanEntitlementOptions, MeteredEntitlement, MeteredEntitlementOptions, NumericEntitlement, NumericEntitlementOptions } from '../models';
|
|
3
4
|
import CachedEntitlement from './cachedEntitlement';
|
|
4
5
|
import { CacheService } from './cacheService';
|
|
5
|
-
import { Decision } from './entitlementDecisionService';
|
|
6
6
|
import { LoggerService } from './loggerService';
|
|
7
7
|
import { EdgeApiClient } from '../api/EdgeApiClient';
|
|
8
|
-
import { EntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
9
8
|
export declare class EntitlementsService {
|
|
10
9
|
private readonly customerId;
|
|
11
10
|
private readonly cacheService;
|
|
12
11
|
private loggerService;
|
|
13
12
|
private onEntitlementsUpdated;
|
|
13
|
+
private readonly resourceId?;
|
|
14
14
|
private readonly entitlementsApi;
|
|
15
15
|
private readonly modelMapper;
|
|
16
16
|
private loadingEntitlements;
|
|
17
17
|
private entitlementsPollingObserver;
|
|
18
18
|
private entitlementCheckReportingService;
|
|
19
|
-
constructor(customerId: string, cacheService: CacheService, client: ApolloClient<NormalizedCacheObject>, batchedGraphClient: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null, loggerService: LoggerService, onEntitlementsUpdated: (cachedEntitlements: Map<string, CachedEntitlement>) => void);
|
|
19
|
+
constructor(customerId: string, cacheService: CacheService, client: ApolloClient<NormalizedCacheObject>, batchedGraphClient: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null, loggerService: LoggerService, onEntitlementsUpdated: (cachedEntitlements: Map<string, CachedEntitlement>) => void, resourceId?: string | undefined);
|
|
20
20
|
startPolling(interval: number): void;
|
|
21
21
|
stopPolling(): void;
|
|
22
22
|
restartPolling(intervalMs: number): void;
|
|
23
23
|
refresh(): Promise<void>;
|
|
24
24
|
get isInitialized(): boolean;
|
|
25
|
-
getBooleanEntitlement(featureId: string, fallbackEntitlement: BooleanEntitlement,
|
|
26
|
-
getNumericEntitlement(featureId: string, fallbackEntitlement: NumericEntitlement,
|
|
27
|
-
getMeteredEntitlement(featureId: string, fallbackEntitlement: MeteredEntitlement,
|
|
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;
|
|
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(
|
|
33
|
+
getEntitlements(): Promise<BooleanEntitlement[]>;
|
|
34
34
|
}
|
|
35
|
-
export declare type GetEntitlementResult = {
|
|
36
|
-
entitlement: CachedEntitlement | null;
|
|
37
|
-
decision: Decision;
|
|
38
|
-
};
|
|
@@ -14,9 +14,9 @@ export declare class EdgeApiClient {
|
|
|
14
14
|
customerToken?: string | null;
|
|
15
15
|
}): EdgeApiClient | null;
|
|
16
16
|
getPaywall(productId?: string, billingCountryCode?: string): Promise<ApolloQueryResult<GetPaywallQuery>>;
|
|
17
|
-
getEntitlements(customerId: string): Promise<ApolloQueryResult<GetEntitlementsQuery>>;
|
|
17
|
+
getEntitlements(customerId: string, resourceId: string | undefined): Promise<ApolloQueryResult<GetEntitlementsQuery>>;
|
|
18
18
|
getSdkConfiguration(): Promise<ApolloQueryResult<GetSdkConfigurationQuery>>;
|
|
19
|
-
watchEntitlements(customerId: string, interval: number): ObservablePoller<GetEntitlementsQuery>;
|
|
19
|
+
watchEntitlements(customerId: string, interval: number, resourceId: string | undefined): ObservablePoller<GetEntitlementsQuery>;
|
|
20
20
|
private get;
|
|
21
21
|
}
|
|
22
22
|
export {};
|
|
@@ -5,8 +5,8 @@ declare class EntitlementsApi {
|
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly edgeApiClient;
|
|
7
7
|
constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
|
|
8
|
-
getEntitlements(customerId: string, skipEdge?: boolean): Promise<import("@apollo/client/core").ApolloQueryResult<GetEntitlementsQuery>>;
|
|
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<{
|
|
8
|
+
getEntitlements(customerId: string, skipEdge?: boolean, resourceId?: string): Promise<import("@apollo/client/core").ApolloQueryResult<GetEntitlementsQuery>>;
|
|
9
|
+
pollEntitlements(customerId: string, interval: number, resourceId?: string): 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
12
|
reportEntitlementRequested(featureId: string, customerId: string, entitlementCheckResult: EntitlementCheckResult, resourceId?: string, requestedUsage?: number): Promise<void>;
|
package/dist/src/client.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ export interface StiggClient {
|
|
|
7
7
|
getBooleanEntitlement: (params: GetBooleanEntitlement) => BooleanEntitlement;
|
|
8
8
|
getNumericEntitlement: (params: GetNumericEntitlement) => NumericEntitlement;
|
|
9
9
|
getMeteredEntitlement: (params: GetMeteredEntitlement) => MeteredEntitlement;
|
|
10
|
-
setCustomerId: (customerId: string, customerToken?: string | null) => Promise<void>;
|
|
10
|
+
setCustomerId: (customerId: string, customerToken?: string | null, resourceId?: string | null) => Promise<void>;
|
|
11
11
|
clearCustomer: () => void;
|
|
12
|
+
setResource: (resourceId: string) => Promise<void>;
|
|
13
|
+
clearResource: () => Promise<void>;
|
|
12
14
|
getPaywall: (params?: GetPaywall) => Promise<Paywall>;
|
|
13
15
|
getCustomer: () => Promise<Customer>;
|
|
14
16
|
getCoupons(): Promise<Coupon[]>;
|
|
@@ -69,11 +71,19 @@ export declare class Stigg implements StiggClient {
|
|
|
69
71
|
/**
|
|
70
72
|
* Set the customer ID, usually after the customer signs in or restores a session
|
|
71
73
|
*/
|
|
72
|
-
setCustomerId(customerId: string, customerToken?: string | null): Promise<void>;
|
|
74
|
+
setCustomerId(customerId: string, customerToken?: string | null, resourceId?: string | null): Promise<void>;
|
|
73
75
|
/**
|
|
74
76
|
* Clear the customer ID, usually after the customer signs out
|
|
75
77
|
*/
|
|
76
78
|
clearCustomer(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Set the customer's resource ID, usually after the customer select a specific resource.
|
|
81
|
+
*/
|
|
82
|
+
setResource(resourceId: string): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Unset the customer's resource ID, usually after the customer exit a specific resource.
|
|
85
|
+
*/
|
|
86
|
+
clearResource(): Promise<void>;
|
|
77
87
|
/**
|
|
78
88
|
* Reload entitlements
|
|
79
89
|
*/
|
|
@@ -86,7 +96,7 @@ export declare class Stigg implements StiggClient {
|
|
|
86
96
|
* @param {BooleanEntitlementOptions} options
|
|
87
97
|
* @return {BooleanEntitlement} boolean entitlement
|
|
88
98
|
*/
|
|
89
|
-
getBooleanEntitlement({ featureId, options
|
|
99
|
+
getBooleanEntitlement({ featureId, options }: GetBooleanEntitlement): BooleanEntitlement;
|
|
90
100
|
/**
|
|
91
101
|
* Get numeric entitlement of feature for a customer
|
|
92
102
|
*
|
|
@@ -95,7 +105,7 @@ export declare class Stigg implements StiggClient {
|
|
|
95
105
|
* @param {NumericEntitlementOptions} options
|
|
96
106
|
* @return {NumericEntitlement} numeric entitlement
|
|
97
107
|
*/
|
|
98
|
-
getNumericEntitlement({ featureId, options
|
|
108
|
+
getNumericEntitlement({ featureId, options }: GetNumericEntitlement): NumericEntitlement;
|
|
99
109
|
/**
|
|
100
110
|
* Get metered entitlement of feature for a customer
|
|
101
111
|
*
|
|
@@ -104,7 +114,7 @@ export declare class Stigg implements StiggClient {
|
|
|
104
114
|
* @param {MeteredEntitlementOptions} options
|
|
105
115
|
* @return {MeteredEntitlement} metered entitlement
|
|
106
116
|
*/
|
|
107
|
-
getMeteredEntitlement({ featureId, options
|
|
117
|
+
getMeteredEntitlement({ featureId, options }: GetMeteredEntitlement): MeteredEntitlement;
|
|
108
118
|
/**
|
|
109
119
|
* Get paywall data for rendering the paywall
|
|
110
120
|
* @deprecated *Optional* `productId` is now deprecated and will be changed to a *required* field soon.
|
|
@@ -133,10 +143,9 @@ export declare class Stigg implements StiggClient {
|
|
|
133
143
|
/**
|
|
134
144
|
* Get a list of entitlements
|
|
135
145
|
*
|
|
136
|
-
* @param {string} resourceId
|
|
137
146
|
* @returns {Promise<Entitlement[]>}
|
|
138
147
|
*/
|
|
139
|
-
getEntitlements(
|
|
148
|
+
getEntitlements(): Promise<Entitlement[]>;
|
|
140
149
|
/**
|
|
141
150
|
* Estimate subscription
|
|
142
151
|
* @return {Promise<SubscriptionPreview>} Preview of the subscription.
|
package/dist/src/models.d.ts
CHANGED
|
@@ -156,17 +156,14 @@ export declare type DefaultTrialConfig = {
|
|
|
156
156
|
export declare type GetBooleanEntitlement = {
|
|
157
157
|
featureId: string;
|
|
158
158
|
options?: BooleanEntitlementOptions;
|
|
159
|
-
resourceId?: string;
|
|
160
159
|
};
|
|
161
160
|
export declare type GetNumericEntitlement = {
|
|
162
161
|
featureId: string;
|
|
163
162
|
options?: NumericEntitlementOptions;
|
|
164
|
-
resourceId?: string;
|
|
165
163
|
};
|
|
166
164
|
export declare type GetMeteredEntitlement = {
|
|
167
165
|
featureId: string;
|
|
168
166
|
options?: MeteredEntitlementOptions;
|
|
169
|
-
resourceId?: string;
|
|
170
167
|
};
|
|
171
168
|
export declare type GetPaywall = {
|
|
172
169
|
productId?: string;
|
|
@@ -5,6 +5,7 @@ export declare class EntitlementCheckReportingService {
|
|
|
5
5
|
private readonly entitlementsApi;
|
|
6
6
|
private readonly customerId;
|
|
7
7
|
private readonly loggerService;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
private readonly resourceId?;
|
|
9
|
+
constructor(entitlementsApi: EntitlementsApi, customerId: string, loggerService: LoggerService, resourceId?: string | undefined);
|
|
10
|
+
reportEntitlementCheckRequested(featureId: string, entitlement: EntitlementCheckResult, requestedUsage?: number): void;
|
|
10
11
|
}
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
|
|
2
|
-
import {
|
|
2
|
+
import { EntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
|
+
import { BooleanEntitlement, BooleanEntitlementOptions, MeteredEntitlement, MeteredEntitlementOptions, NumericEntitlement, NumericEntitlementOptions } from '../models';
|
|
3
4
|
import CachedEntitlement from './cachedEntitlement';
|
|
4
5
|
import { CacheService } from './cacheService';
|
|
5
|
-
import { Decision } from './entitlementDecisionService';
|
|
6
6
|
import { LoggerService } from './loggerService';
|
|
7
7
|
import { EdgeApiClient } from '../api/EdgeApiClient';
|
|
8
|
-
import { EntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
9
8
|
export declare class EntitlementsService {
|
|
10
9
|
private readonly customerId;
|
|
11
10
|
private readonly cacheService;
|
|
12
11
|
private loggerService;
|
|
13
12
|
private onEntitlementsUpdated;
|
|
13
|
+
private readonly resourceId?;
|
|
14
14
|
private readonly entitlementsApi;
|
|
15
15
|
private readonly modelMapper;
|
|
16
16
|
private loadingEntitlements;
|
|
17
17
|
private entitlementsPollingObserver;
|
|
18
18
|
private entitlementCheckReportingService;
|
|
19
|
-
constructor(customerId: string, cacheService: CacheService, client: ApolloClient<NormalizedCacheObject>, batchedGraphClient: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null, loggerService: LoggerService, onEntitlementsUpdated: (cachedEntitlements: Map<string, CachedEntitlement>) => void);
|
|
19
|
+
constructor(customerId: string, cacheService: CacheService, client: ApolloClient<NormalizedCacheObject>, batchedGraphClient: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null, loggerService: LoggerService, onEntitlementsUpdated: (cachedEntitlements: Map<string, CachedEntitlement>) => void, resourceId?: string | undefined);
|
|
20
20
|
startPolling(interval: number): void;
|
|
21
21
|
stopPolling(): void;
|
|
22
22
|
restartPolling(intervalMs: number): void;
|
|
23
23
|
refresh(): Promise<void>;
|
|
24
24
|
get isInitialized(): boolean;
|
|
25
|
-
getBooleanEntitlement(featureId: string, fallbackEntitlement: BooleanEntitlement,
|
|
26
|
-
getNumericEntitlement(featureId: string, fallbackEntitlement: NumericEntitlement,
|
|
27
|
-
getMeteredEntitlement(featureId: string, fallbackEntitlement: MeteredEntitlement,
|
|
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;
|
|
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(
|
|
33
|
+
getEntitlements(): Promise<BooleanEntitlement[]>;
|
|
34
34
|
}
|
|
35
|
-
export declare type GetEntitlementResult = {
|
|
36
|
-
entitlement: CachedEntitlement | null;
|
|
37
|
-
decision: Decision;
|
|
38
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stigg/js-client-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.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.
|
|
31
|
+
"@stigg/api-client-js": "0.386.0",
|
|
32
32
|
"axios": "^1.2.2",
|
|
33
33
|
"cross-fetch": "^3.1.4",
|
|
34
34
|
"husky": "^7.0.4",
|
|
@@ -1,5 +0,0 @@
|
|
|
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]>;
|
|
@@ -1,5 +0,0 @@
|
|
|
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]>;
|