@stigg/js-client-sdk 3.68.0 → 3.69.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 +12 -2
- package/dist/index.esm.js +12 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +5 -1
- package/dist/offlineClient.d.ts +2 -1
- package/dist/services/cacheService.d.ts +3 -3
- package/dist/services/cachedEntitlement.d.ts +6 -1
- package/dist/services/entitlementsService.d.ts +4 -4
- package/dist/services/inMemoryCacheService.d.ts +4 -4
- package/dist/src/api/EdgeApiClient.d.ts +2 -2
- package/dist/src/api/EntitlementsApi.d.ts +2 -2
- package/dist/src/client.d.ts +12 -2
- package/dist/src/models.d.ts +5 -1
- package/dist/src/offlineClient.d.ts +2 -1
- package/dist/src/services/cacheService.d.ts +3 -3
- package/dist/src/services/cachedEntitlement.d.ts +6 -1
- package/dist/src/services/entitlementsService.d.ts +4 -4
- package/dist/src/services/inMemoryCacheService.d.ts +4 -4
- package/package.json +2 -2
package/dist/models.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BillingModel, BillingPeriod, Currency, PricingType, PromotionalEntitlementStatus, SubscriptionStatus, SubscriptionQueryFragment, TrialPeriodUnits, ExperimentGroupType, CustomerPortalEntitlementFragment, CustomerPortalPromotionalEntitlementFragment, CustomerPortalSubscriptionFragment, CustomerPortalSubscriptionAddonFragment, CustomerPortalBillingInformationFragment, PaywallConfigurationFragment, CustomerPortalConfigurationFragment, WidgetType, CustomerPortalSubscriptionScheduledUpdateDataFragment, DiscountType, DiscountDurationType, PackageEntitlementFragment, PageInfoFragment, PaywallCurrencyFragment, FeatureType, MeterType, EntitlementResetPeriod, AccessDeniedReason, PaywallCalculatedPricePointsFragment, SubscriptionInvoiceFragment, PaymentCollection, PlanFragment, BillingVendorIdentifier, TiersMode, SubscriptionFutureUpdateDataFragment, PriceTierFragment, TotalPriceFragment, CheckoutConfigurationFragment, TypographyConfigurationFragment, BillingAddress, ScheduleStrategy, PaymentCollectionMethod, BudgetConfigurationInput, SubscriptionProrationBehavior, PaymentSessionInput, CreditBalanceSummaryInput, StripeCheckoutCredentialsFragment, ZuoraCheckoutCredentialsFragment, GetCreditGrantsInput as GetCreditGrantsInputGenerated, CreditLedgerInput, CreditUsageInput, CreditGrantFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
1
|
+
import { BillingModel, BillingPeriod, Currency, PricingType, PromotionalEntitlementStatus, SubscriptionStatus, SubscriptionQueryFragment, TrialPeriodUnits, ExperimentGroupType, CustomerPortalEntitlementFragment, CustomerPortalPromotionalEntitlementFragment, CustomerPortalSubscriptionFragment, CustomerPortalSubscriptionAddonFragment, CustomerPortalBillingInformationFragment, PaywallConfigurationFragment, CustomerPortalConfigurationFragment, WidgetType, CustomerPortalSubscriptionScheduledUpdateDataFragment, DiscountType, DiscountDurationType, PackageEntitlementFragment, PageInfoFragment, PaywallCurrencyFragment, FeatureType, MeterType, EntitlementResetPeriod, AccessDeniedReason, PaywallCalculatedPricePointsFragment, SubscriptionInvoiceFragment, PaymentCollection, PlanFragment, BillingVendorIdentifier, TiersMode, SubscriptionFutureUpdateDataFragment, PriceTierFragment, TotalPriceFragment, CheckoutConfigurationFragment, TypographyConfigurationFragment, BillingAddress, ScheduleStrategy, PaymentCollectionMethod, BudgetConfigurationInput, SubscriptionProrationBehavior, PaymentSessionInput, CreditBalanceSummaryInput, StripeCheckoutCredentialsFragment, ZuoraCheckoutCredentialsFragment, GetCreditGrantsInput as GetCreditGrantsInputGenerated, CreditLedgerInput, CreditUsageInput, CreditGrantFragment, EntitlementsStateAccessDeniedReason } from '@stigg/api-client-js/src/generated/sdk';
|
|
2
2
|
export * from '@stigg/api-client-js/src/generated/sdk';
|
|
3
3
|
interface Metadata {
|
|
4
4
|
[key: string]: string;
|
|
@@ -53,6 +53,10 @@ export interface MeteredEntitlement extends BaseEntitlement {
|
|
|
53
53
|
resetSettings?: ResetSettings;
|
|
54
54
|
}
|
|
55
55
|
export declare type Entitlement = BooleanEntitlement | NumericEntitlement | MeteredEntitlement;
|
|
56
|
+
export declare type EntitlementsState = {
|
|
57
|
+
entitlements: Entitlement[];
|
|
58
|
+
accessDeniedReason: EntitlementsStateAccessDeniedReason | null;
|
|
59
|
+
};
|
|
56
60
|
/** @internal */
|
|
57
61
|
export declare const BOOLEAN_DEFAULT_FALLBACK_ENTITLEMENT: BooleanEntitlement;
|
|
58
62
|
/** @internal */
|
package/dist/offlineClient.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Stigg, StiggClient } from './clients';
|
|
2
|
-
import { ApplySubscriptionResults, BooleanEntitlement, Coupon, CreditLedgerFragment, CreditsBalanceSummaryFragment, CreditUsageFragment, Customer, CustomerPortal, Entitlement, EnumEntitlement, GetBooleanEntitlement, GetCheckoutStateResults, GetCreditGrantsResult, GetEnumEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetSubscriptionsResult, MeteredEntitlement, NumericEntitlement, PaymentSessionFragment, Paywall, SlimSubscriptionFragmentV2Fragment, Subscription, SubscriptionInvoicePreviewFragment, SubscriptionPreview, SubscriptionPreviewV2, UsageHistoryPoint, UsageHistoryV2Fragment } from './models';
|
|
2
|
+
import { ApplySubscriptionResults, BooleanEntitlement, Coupon, CreditLedgerFragment, CreditsBalanceSummaryFragment, CreditUsageFragment, Customer, CustomerPortal, Entitlement, EntitlementsState, EnumEntitlement, GetBooleanEntitlement, GetCheckoutStateResults, GetCreditGrantsResult, GetEnumEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetSubscriptionsResult, MeteredEntitlement, NumericEntitlement, PaymentSessionFragment, Paywall, SlimSubscriptionFragmentV2Fragment, Subscription, SubscriptionInvoicePreviewFragment, SubscriptionPreview, SubscriptionPreviewV2, UsageHistoryPoint, UsageHistoryV2Fragment } from './models';
|
|
3
3
|
export declare class OfflineStigg extends Stigg {
|
|
4
4
|
getBooleanEntitlement({ featureId, options }: GetBooleanEntitlement): BooleanEntitlement;
|
|
5
5
|
getMeteredEntitlement({ featureId, options }: GetMeteredEntitlement): MeteredEntitlement;
|
|
6
6
|
getNumericEntitlement({ featureId, options }: GetNumericEntitlement): NumericEntitlement;
|
|
7
7
|
getEnumEntitlement({ featureId, options }: GetEnumEntitlement): EnumEntitlement;
|
|
8
8
|
getEntitlements(): Promise<Entitlement[]>;
|
|
9
|
+
getEntitlementsState(): Promise<EntitlementsState>;
|
|
9
10
|
addListener(): void;
|
|
10
11
|
clearCustomer(): void;
|
|
11
12
|
clearResource(): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import CachedEntitlement from './cachedEntitlement';
|
|
1
|
+
import CachedEntitlement, { CachedEntitlementsState } from './cachedEntitlement';
|
|
2
2
|
export interface CacheService {
|
|
3
3
|
isLoaded(): boolean;
|
|
4
4
|
getLastUpdate(): Date | null;
|
|
5
5
|
updateLastChecked(): void;
|
|
6
6
|
isOutdated(): boolean;
|
|
7
|
-
setEntitlements(
|
|
7
|
+
setEntitlements(entitlementsState: CachedEntitlementsState, lastUpdate: Date): void;
|
|
8
8
|
getEntitlement(featureId: string): CachedEntitlement | null;
|
|
9
|
-
getEntitlements():
|
|
9
|
+
getEntitlements(): CachedEntitlementsState;
|
|
10
10
|
validateFeature(featureId: string): boolean;
|
|
11
11
|
setFeatures(features: string[]): void;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntitlementFeature, EntitlementResetPeriod } from '../models';
|
|
2
|
-
import { AccessDeniedReason, ResetPeriodConfigurationFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
2
|
+
import { AccessDeniedReason, EntitlementsStateAccessDeniedReason, ResetPeriodConfigurationFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
3
|
export interface CalculatedEntitlement {
|
|
4
4
|
usageLimit?: number | null;
|
|
5
5
|
hasUnlimitedUsage: boolean;
|
|
@@ -16,6 +16,11 @@ export interface EntitlementUsage {
|
|
|
16
16
|
resetPeriod?: EntitlementResetPeriod | null;
|
|
17
17
|
resetPeriodConfiguration?: ResetPeriodConfigurationFragment | null;
|
|
18
18
|
}
|
|
19
|
+
export declare class CachedEntitlementsState {
|
|
20
|
+
readonly entitlements: Map<string, CachedEntitlement>;
|
|
21
|
+
readonly accessDeniedReason: EntitlementsStateAccessDeniedReason | null;
|
|
22
|
+
constructor(entitlements: Map<string, CachedEntitlement>, accessDeniedReason: EntitlementsStateAccessDeniedReason | null);
|
|
23
|
+
}
|
|
19
24
|
export default class CachedEntitlement {
|
|
20
25
|
readonly calculatedEntitlement: CalculatedEntitlement;
|
|
21
26
|
readonly featureUsage: EntitlementUsage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
|
|
2
|
-
import { EntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
|
-
import { BooleanEntitlement, BooleanEntitlementOptions, EnumEntitlement, EnumEntitlementOptions, MeteredEntitlement, MeteredEntitlementOptions, NumericEntitlement, NumericEntitlementOptions } from '../models';
|
|
2
|
+
import { EntitlementFragment, EntitlementsStateAccessDeniedReason } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
|
+
import { BooleanEntitlement, BooleanEntitlementOptions, EntitlementsState, EnumEntitlement, EnumEntitlementOptions, MeteredEntitlement, MeteredEntitlementOptions, NumericEntitlement, NumericEntitlementOptions } from '../models';
|
|
4
4
|
import CachedEntitlement from './cachedEntitlement';
|
|
5
5
|
import { CacheService } from './cacheService';
|
|
6
6
|
import { LoggerService } from './loggerService';
|
|
@@ -24,10 +24,10 @@ export declare class EntitlementsService {
|
|
|
24
24
|
getEnumEntitlement(featureId: string, fallbackEntitlement: EnumEntitlement, options?: EnumEntitlementOptions): EnumEntitlement;
|
|
25
25
|
loadEntitlements(skipEdge?: boolean): Promise<void>;
|
|
26
26
|
private loadEntitlementsFromRemote;
|
|
27
|
-
protected storeFetchedEntitlementsInCache(entitlements: EntitlementFragment[]): void;
|
|
27
|
+
protected storeFetchedEntitlementsInCache(entitlements: EntitlementFragment[], accessDeniedReason: EntitlementsStateAccessDeniedReason | null): void;
|
|
28
28
|
private getLastEntitlementsUpdate;
|
|
29
29
|
private getEntitlement;
|
|
30
|
-
|
|
30
|
+
getEntitlementsState(): Promise<EntitlementsState>;
|
|
31
31
|
private renewOutdatedCache;
|
|
32
32
|
renewOutdatedCacheInBackground(): void;
|
|
33
33
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CacheService } from './cacheService';
|
|
2
|
-
import CachedEntitlement from './cachedEntitlement';
|
|
2
|
+
import CachedEntitlement, { CachedEntitlementsState } from './cachedEntitlement';
|
|
3
3
|
export declare class InMemoryCacheService implements CacheService {
|
|
4
4
|
private readonly ttlMs;
|
|
5
|
-
private
|
|
5
|
+
private entitlementsState;
|
|
6
6
|
private lastUpdate;
|
|
7
7
|
private lastChecked;
|
|
8
8
|
private features;
|
|
@@ -11,8 +11,8 @@ export declare class InMemoryCacheService implements CacheService {
|
|
|
11
11
|
validateFeature(featureId: string): boolean;
|
|
12
12
|
setFeatures: (features: string[]) => Set<string>;
|
|
13
13
|
updateLastChecked(): void;
|
|
14
|
-
setEntitlements(
|
|
15
|
-
getEntitlements():
|
|
14
|
+
setEntitlements(entitlementsState: CachedEntitlementsState, lastUpdate: Date): void;
|
|
15
|
+
getEntitlements(): CachedEntitlementsState;
|
|
16
16
|
getLastUpdate(): Date | null;
|
|
17
17
|
isLoaded(): boolean;
|
|
18
18
|
isOutdated(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApolloQueryResult } from '@apollo/client/core';
|
|
2
|
-
import { GetActiveSubscriptionsListQuery,
|
|
2
|
+
import { GetActiveSubscriptionsListQuery, GetEntitlementsStateQuery, GetPaywallQuery, GetSdkConfigurationQuery } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
3
|
declare type EdgeApiClientConfiguration = {
|
|
4
4
|
apiKey: string;
|
|
5
5
|
baseEdgeUri: string;
|
|
@@ -13,7 +13,7 @@ export declare class EdgeApiClient {
|
|
|
13
13
|
customerToken?: string | null;
|
|
14
14
|
}): EdgeApiClient | null;
|
|
15
15
|
getPaywall(productId?: string, billingCountryCode?: string, includeHiddenPlans?: boolean): Promise<ApolloQueryResult<GetPaywallQuery>>;
|
|
16
|
-
|
|
16
|
+
getEntitlementsState(customerId: string, resourceId: string | undefined): Promise<ApolloQueryResult<GetEntitlementsStateQuery>>;
|
|
17
17
|
getActiveSubscriptionsList(customerId: string, resourceId: string | string[] | undefined): Promise<ApolloQueryResult<GetActiveSubscriptionsListQuery>>;
|
|
18
18
|
getSdkConfiguration(): Promise<ApolloQueryResult<GetSdkConfigurationQuery>>;
|
|
19
19
|
private get;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
|
|
2
2
|
import { EdgeApiClient } from './EdgeApiClient';
|
|
3
|
-
import {
|
|
3
|
+
import { GetEntitlementsStateQuery } from '@stigg/api-client-js/src/generated/sdk';
|
|
4
4
|
declare class EntitlementsApi {
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly edgeApiClient;
|
|
7
7
|
constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
|
|
8
|
-
|
|
8
|
+
getEntitlementsState(customerId: string, skipEdge?: boolean, resourceId?: string): Promise<import("@apollo/client/core").ApolloQueryResult<GetEntitlementsStateQuery>>;
|
|
9
9
|
}
|
|
10
10
|
export default EntitlementsApi;
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CreditLedgerFragment, CreditsBalanceSummaryFragment, CreditUsageFragment, PaymentSessionFragment, SlimSubscriptionFragmentV2Fragment, SubscriptionInvoicePreviewFragment, UsageHistoryV2Fragment, UsageHistoryV2Input } from '@stigg/api-client-js/src/generated/sdk';
|
|
2
2
|
import { ClientConfiguration } from './configuration';
|
|
3
|
-
import { ApplySubscription, ApplySubscriptionResults, BooleanEntitlement, Coupon, Customer, CustomerPortal, Entitlement, EstimateSubscription, EstimateSubscriptionUpdate, FetchUsageHistory, GetActiveSubscriptions, GetBooleanEntitlement, GetCheckoutStateResults, GetCheckoutState, GetCustomerPortal, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, GetSubscription, MeteredEntitlement, NumericEntitlement, Paywall, PreviewSubscription, Subscription, SubscriptionPreview, SubscriptionPreviewV2, UsageHistoryPoint, WaitForCheckoutCompleted, PreviewNextInvoice, GetSubscriptionsParams, GetSubscriptionsResult, EnumEntitlement, GetEnumEntitlement, CreatePaymentSessionInput, GetCreditBalanceInput, GetCreditGrantsInput, GetCreditLedgerInput, GetCreditUsageInput, GetCreditGrantsResult } from './models';
|
|
3
|
+
import { ApplySubscription, ApplySubscriptionResults, BooleanEntitlement, Coupon, Customer, CustomerPortal, Entitlement, EstimateSubscription, EstimateSubscriptionUpdate, FetchUsageHistory, GetActiveSubscriptions, GetBooleanEntitlement, GetCheckoutStateResults, GetCheckoutState, GetCustomerPortal, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, GetSubscription, MeteredEntitlement, NumericEntitlement, Paywall, PreviewSubscription, Subscription, SubscriptionPreview, SubscriptionPreviewV2, UsageHistoryPoint, WaitForCheckoutCompleted, PreviewNextInvoice, GetSubscriptionsParams, GetSubscriptionsResult, EnumEntitlement, GetEnumEntitlement, CreatePaymentSessionInput, GetCreditBalanceInput, GetCreditGrantsInput, GetCreditLedgerInput, GetCreditUsageInput, GetCreditGrantsResult, EntitlementsState } from './models';
|
|
4
4
|
import { EventNames, Events } from './services/eventEmitter';
|
|
5
5
|
import { LoggerService } from './services/loggerService';
|
|
6
6
|
export interface StiggClient {
|
|
@@ -26,7 +26,11 @@ export interface StiggClient {
|
|
|
26
26
|
getActiveSubscriptionsList(params?: GetActiveSubscriptions): Promise<SlimSubscriptionFragmentV2Fragment[]>;
|
|
27
27
|
getSubscription(params: GetSubscription): Promise<Subscription>;
|
|
28
28
|
getCoupons(): Promise<Coupon[]>;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Use {@link getEntitlementsState} instead
|
|
31
|
+
*/
|
|
29
32
|
getEntitlements: (resourceId?: string) => Promise<Entitlement[]>;
|
|
33
|
+
getEntitlementsState: (resourceId?: string) => Promise<EntitlementsState>;
|
|
30
34
|
refresh: () => Promise<void>;
|
|
31
35
|
waitForCheckoutCompleted(params?: WaitForCheckoutCompleted): Promise<Subscription | null>;
|
|
32
36
|
waitForInitialization(): Promise<StiggClient>;
|
|
@@ -194,10 +198,16 @@ export declare class Stigg implements StiggClient {
|
|
|
194
198
|
fetchUsageHistory(fetchUsageHistory: FetchUsageHistory): Promise<UsageHistoryPoint[] | undefined>;
|
|
195
199
|
/**
|
|
196
200
|
* Get a list of entitlements
|
|
197
|
-
*
|
|
201
|
+
* @deprecated Use getEntitlementsState instead.
|
|
198
202
|
* @returns {Promise<Entitlement[]>}
|
|
199
203
|
*/
|
|
200
204
|
getEntitlements(resourceId?: string): Promise<Entitlement[]>;
|
|
205
|
+
/**
|
|
206
|
+
* Get a list of entitlements alongside an access denied reason if applicable.
|
|
207
|
+
*
|
|
208
|
+
* @returns {Promise<EntitlementsState>}
|
|
209
|
+
*/
|
|
210
|
+
getEntitlementsState(resourceId?: string): Promise<EntitlementsState>;
|
|
201
211
|
/**
|
|
202
212
|
* Estimate subscription
|
|
203
213
|
* @return {Promise<SubscriptionPreview>} Preview of the subscription.
|
package/dist/src/models.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BillingModel, BillingPeriod, Currency, PricingType, PromotionalEntitlementStatus, SubscriptionStatus, SubscriptionQueryFragment, TrialPeriodUnits, ExperimentGroupType, CustomerPortalEntitlementFragment, CustomerPortalPromotionalEntitlementFragment, CustomerPortalSubscriptionFragment, CustomerPortalSubscriptionAddonFragment, CustomerPortalBillingInformationFragment, PaywallConfigurationFragment, CustomerPortalConfigurationFragment, WidgetType, CustomerPortalSubscriptionScheduledUpdateDataFragment, DiscountType, DiscountDurationType, PackageEntitlementFragment, PageInfoFragment, PaywallCurrencyFragment, FeatureType, MeterType, EntitlementResetPeriod, AccessDeniedReason, PaywallCalculatedPricePointsFragment, SubscriptionInvoiceFragment, PaymentCollection, PlanFragment, BillingVendorIdentifier, TiersMode, SubscriptionFutureUpdateDataFragment, PriceTierFragment, TotalPriceFragment, CheckoutConfigurationFragment, TypographyConfigurationFragment, BillingAddress, ScheduleStrategy, PaymentCollectionMethod, BudgetConfigurationInput, SubscriptionProrationBehavior, PaymentSessionInput, CreditBalanceSummaryInput, StripeCheckoutCredentialsFragment, ZuoraCheckoutCredentialsFragment, GetCreditGrantsInput as GetCreditGrantsInputGenerated, CreditLedgerInput, CreditUsageInput, CreditGrantFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
1
|
+
import { BillingModel, BillingPeriod, Currency, PricingType, PromotionalEntitlementStatus, SubscriptionStatus, SubscriptionQueryFragment, TrialPeriodUnits, ExperimentGroupType, CustomerPortalEntitlementFragment, CustomerPortalPromotionalEntitlementFragment, CustomerPortalSubscriptionFragment, CustomerPortalSubscriptionAddonFragment, CustomerPortalBillingInformationFragment, PaywallConfigurationFragment, CustomerPortalConfigurationFragment, WidgetType, CustomerPortalSubscriptionScheduledUpdateDataFragment, DiscountType, DiscountDurationType, PackageEntitlementFragment, PageInfoFragment, PaywallCurrencyFragment, FeatureType, MeterType, EntitlementResetPeriod, AccessDeniedReason, PaywallCalculatedPricePointsFragment, SubscriptionInvoiceFragment, PaymentCollection, PlanFragment, BillingVendorIdentifier, TiersMode, SubscriptionFutureUpdateDataFragment, PriceTierFragment, TotalPriceFragment, CheckoutConfigurationFragment, TypographyConfigurationFragment, BillingAddress, ScheduleStrategy, PaymentCollectionMethod, BudgetConfigurationInput, SubscriptionProrationBehavior, PaymentSessionInput, CreditBalanceSummaryInput, StripeCheckoutCredentialsFragment, ZuoraCheckoutCredentialsFragment, GetCreditGrantsInput as GetCreditGrantsInputGenerated, CreditLedgerInput, CreditUsageInput, CreditGrantFragment, EntitlementsStateAccessDeniedReason } from '@stigg/api-client-js/src/generated/sdk';
|
|
2
2
|
export * from '@stigg/api-client-js/src/generated/sdk';
|
|
3
3
|
interface Metadata {
|
|
4
4
|
[key: string]: string;
|
|
@@ -53,6 +53,10 @@ export interface MeteredEntitlement extends BaseEntitlement {
|
|
|
53
53
|
resetSettings?: ResetSettings;
|
|
54
54
|
}
|
|
55
55
|
export declare type Entitlement = BooleanEntitlement | NumericEntitlement | MeteredEntitlement;
|
|
56
|
+
export declare type EntitlementsState = {
|
|
57
|
+
entitlements: Entitlement[];
|
|
58
|
+
accessDeniedReason: EntitlementsStateAccessDeniedReason | null;
|
|
59
|
+
};
|
|
56
60
|
/** @internal */
|
|
57
61
|
export declare const BOOLEAN_DEFAULT_FALLBACK_ENTITLEMENT: BooleanEntitlement;
|
|
58
62
|
/** @internal */
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Stigg, StiggClient } from './clients';
|
|
2
|
-
import { ApplySubscriptionResults, BooleanEntitlement, Coupon, CreditLedgerFragment, CreditsBalanceSummaryFragment, CreditUsageFragment, Customer, CustomerPortal, Entitlement, EnumEntitlement, GetBooleanEntitlement, GetCheckoutStateResults, GetCreditGrantsResult, GetEnumEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetSubscriptionsResult, MeteredEntitlement, NumericEntitlement, PaymentSessionFragment, Paywall, SlimSubscriptionFragmentV2Fragment, Subscription, SubscriptionInvoicePreviewFragment, SubscriptionPreview, SubscriptionPreviewV2, UsageHistoryPoint, UsageHistoryV2Fragment } from './models';
|
|
2
|
+
import { ApplySubscriptionResults, BooleanEntitlement, Coupon, CreditLedgerFragment, CreditsBalanceSummaryFragment, CreditUsageFragment, Customer, CustomerPortal, Entitlement, EntitlementsState, EnumEntitlement, GetBooleanEntitlement, GetCheckoutStateResults, GetCreditGrantsResult, GetEnumEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetSubscriptionsResult, MeteredEntitlement, NumericEntitlement, PaymentSessionFragment, Paywall, SlimSubscriptionFragmentV2Fragment, Subscription, SubscriptionInvoicePreviewFragment, SubscriptionPreview, SubscriptionPreviewV2, UsageHistoryPoint, UsageHistoryV2Fragment } from './models';
|
|
3
3
|
export declare class OfflineStigg extends Stigg {
|
|
4
4
|
getBooleanEntitlement({ featureId, options }: GetBooleanEntitlement): BooleanEntitlement;
|
|
5
5
|
getMeteredEntitlement({ featureId, options }: GetMeteredEntitlement): MeteredEntitlement;
|
|
6
6
|
getNumericEntitlement({ featureId, options }: GetNumericEntitlement): NumericEntitlement;
|
|
7
7
|
getEnumEntitlement({ featureId, options }: GetEnumEntitlement): EnumEntitlement;
|
|
8
8
|
getEntitlements(): Promise<Entitlement[]>;
|
|
9
|
+
getEntitlementsState(): Promise<EntitlementsState>;
|
|
9
10
|
addListener(): void;
|
|
10
11
|
clearCustomer(): void;
|
|
11
12
|
clearResource(): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import CachedEntitlement from './cachedEntitlement';
|
|
1
|
+
import CachedEntitlement, { CachedEntitlementsState } from './cachedEntitlement';
|
|
2
2
|
export interface CacheService {
|
|
3
3
|
isLoaded(): boolean;
|
|
4
4
|
getLastUpdate(): Date | null;
|
|
5
5
|
updateLastChecked(): void;
|
|
6
6
|
isOutdated(): boolean;
|
|
7
|
-
setEntitlements(
|
|
7
|
+
setEntitlements(entitlementsState: CachedEntitlementsState, lastUpdate: Date): void;
|
|
8
8
|
getEntitlement(featureId: string): CachedEntitlement | null;
|
|
9
|
-
getEntitlements():
|
|
9
|
+
getEntitlements(): CachedEntitlementsState;
|
|
10
10
|
validateFeature(featureId: string): boolean;
|
|
11
11
|
setFeatures(features: string[]): void;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntitlementFeature, EntitlementResetPeriod } from '../models';
|
|
2
|
-
import { AccessDeniedReason, ResetPeriodConfigurationFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
2
|
+
import { AccessDeniedReason, EntitlementsStateAccessDeniedReason, ResetPeriodConfigurationFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
3
|
export interface CalculatedEntitlement {
|
|
4
4
|
usageLimit?: number | null;
|
|
5
5
|
hasUnlimitedUsage: boolean;
|
|
@@ -16,6 +16,11 @@ export interface EntitlementUsage {
|
|
|
16
16
|
resetPeriod?: EntitlementResetPeriod | null;
|
|
17
17
|
resetPeriodConfiguration?: ResetPeriodConfigurationFragment | null;
|
|
18
18
|
}
|
|
19
|
+
export declare class CachedEntitlementsState {
|
|
20
|
+
readonly entitlements: Map<string, CachedEntitlement>;
|
|
21
|
+
readonly accessDeniedReason: EntitlementsStateAccessDeniedReason | null;
|
|
22
|
+
constructor(entitlements: Map<string, CachedEntitlement>, accessDeniedReason: EntitlementsStateAccessDeniedReason | null);
|
|
23
|
+
}
|
|
19
24
|
export default class CachedEntitlement {
|
|
20
25
|
readonly calculatedEntitlement: CalculatedEntitlement;
|
|
21
26
|
readonly featureUsage: EntitlementUsage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
|
|
2
|
-
import { EntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
|
-
import { BooleanEntitlement, BooleanEntitlementOptions, EnumEntitlement, EnumEntitlementOptions, MeteredEntitlement, MeteredEntitlementOptions, NumericEntitlement, NumericEntitlementOptions } from '../models';
|
|
2
|
+
import { EntitlementFragment, EntitlementsStateAccessDeniedReason } from '@stigg/api-client-js/src/generated/sdk';
|
|
3
|
+
import { BooleanEntitlement, BooleanEntitlementOptions, EntitlementsState, EnumEntitlement, EnumEntitlementOptions, MeteredEntitlement, MeteredEntitlementOptions, NumericEntitlement, NumericEntitlementOptions } from '../models';
|
|
4
4
|
import CachedEntitlement from './cachedEntitlement';
|
|
5
5
|
import { CacheService } from './cacheService';
|
|
6
6
|
import { LoggerService } from './loggerService';
|
|
@@ -24,10 +24,10 @@ export declare class EntitlementsService {
|
|
|
24
24
|
getEnumEntitlement(featureId: string, fallbackEntitlement: EnumEntitlement, options?: EnumEntitlementOptions): EnumEntitlement;
|
|
25
25
|
loadEntitlements(skipEdge?: boolean): Promise<void>;
|
|
26
26
|
private loadEntitlementsFromRemote;
|
|
27
|
-
protected storeFetchedEntitlementsInCache(entitlements: EntitlementFragment[]): void;
|
|
27
|
+
protected storeFetchedEntitlementsInCache(entitlements: EntitlementFragment[], accessDeniedReason: EntitlementsStateAccessDeniedReason | null): void;
|
|
28
28
|
private getLastEntitlementsUpdate;
|
|
29
29
|
private getEntitlement;
|
|
30
|
-
|
|
30
|
+
getEntitlementsState(): Promise<EntitlementsState>;
|
|
31
31
|
private renewOutdatedCache;
|
|
32
32
|
renewOutdatedCacheInBackground(): void;
|
|
33
33
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CacheService } from './cacheService';
|
|
2
|
-
import CachedEntitlement from './cachedEntitlement';
|
|
2
|
+
import CachedEntitlement, { CachedEntitlementsState } from './cachedEntitlement';
|
|
3
3
|
export declare class InMemoryCacheService implements CacheService {
|
|
4
4
|
private readonly ttlMs;
|
|
5
|
-
private
|
|
5
|
+
private entitlementsState;
|
|
6
6
|
private lastUpdate;
|
|
7
7
|
private lastChecked;
|
|
8
8
|
private features;
|
|
@@ -11,8 +11,8 @@ export declare class InMemoryCacheService implements CacheService {
|
|
|
11
11
|
validateFeature(featureId: string): boolean;
|
|
12
12
|
setFeatures: (features: string[]) => Set<string>;
|
|
13
13
|
updateLastChecked(): void;
|
|
14
|
-
setEntitlements(
|
|
15
|
-
getEntitlements():
|
|
14
|
+
setEntitlements(entitlementsState: CachedEntitlementsState, lastUpdate: Date): void;
|
|
15
|
+
getEntitlements(): CachedEntitlementsState;
|
|
16
16
|
getLastUpdate(): Date | null;
|
|
17
17
|
isLoaded(): boolean;
|
|
18
18
|
isOutdated(): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stigg/js-client-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.69.0",
|
|
4
4
|
"description": "Stigg client-side SDK for Browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@apollo/client": "^3.4.17",
|
|
39
39
|
"@sentry/browser": "^7.11.1",
|
|
40
|
-
"@stigg/api-client-js": "
|
|
40
|
+
"@stigg/api-client-js": "5.18.0",
|
|
41
41
|
"cross-fetch": "^3.1.6",
|
|
42
42
|
"dayjs": "^1.11.13",
|
|
43
43
|
"fetch-retry": "^5.0.6",
|