@stigg/js-client-sdk 3.82.0 → 3.83.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
@@ -65,6 +65,32 @@ export declare const NUMERIC_DEFAULT_FALLBACK_ENTITLEMENT: NumericEntitlement;
65
65
  export declare const METERED_DEFAULT_FALLBACK_ENTITLEMENT: MeteredEntitlement;
66
66
  /** @internal */
67
67
  export declare const ENUM_DEFAULT_FALLBACK_ENTITLEMENT: EnumEntitlement;
68
+ export interface CreditEntitlement {
69
+ hasAccess: boolean;
70
+ isFallback: boolean;
71
+ accessDeniedReason?: AccessDeniedReason;
72
+ currency: {
73
+ currencyId: string;
74
+ };
75
+ usageLimit: number;
76
+ currentUsage: number;
77
+ remaining: number;
78
+ }
79
+ /** @internal */
80
+ export declare const CREDIT_DEFAULT_FALLBACK_ENTITLEMENT: CreditEntitlement;
81
+ export declare type GetCreditEntitlement = {
82
+ currencyId: string;
83
+ resourceId?: string;
84
+ options?: CreditEntitlementOptions;
85
+ };
86
+ export declare type CreditEntitlementOptions = {
87
+ fallback?: CreditEntitlementFallback;
88
+ };
89
+ export declare type CreditEntitlementFallback = {
90
+ hasAccess?: boolean;
91
+ usageLimit?: number;
92
+ currentUsage?: number;
93
+ };
68
94
  export declare type PackageEntitlement = {
69
95
  usageLimit: number;
70
96
  feature?: EntitlementFeature;
@@ -1,10 +1,11 @@
1
1
  import { Stigg, StiggClient } from './clients';
2
- import { ApplySubscriptionResults, AutomaticRechargeConfiguration, BooleanEntitlement, Coupon, CreditsBalanceSummaryFragment, CreditUsageFragment, Customer, CustomerPortal, Entitlement, EntitlementsState, EnumEntitlement, GetAutomaticRechargeConfigurationInput, GetBooleanEntitlement, GetCheckoutStateResults, GetCreditGrantsResult, GetCreditLedgerResult, GetEnumEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetSubscriptionsResult, MeteredEntitlement, NumericEntitlement, PaymentSessionFragment, Paywall, SaveAutomaticRechargeConfigurationInput, SlimSubscriptionFragmentV2Fragment, Subscription, SubscriptionInvoicePreviewFragment, SubscriptionPreview, SubscriptionPreviewV2, UsageHistoryPoint, UsageHistoryV2Fragment } from './models';
2
+ import { ApplySubscriptionResults, AutomaticRechargeConfiguration, BooleanEntitlement, Coupon, CreditEntitlement, CreditsBalanceSummaryFragment, CreditUsageFragment, Customer, CustomerPortal, Entitlement, EntitlementsState, EnumEntitlement, GetAutomaticRechargeConfigurationInput, GetBooleanEntitlement, GetCheckoutStateResults, GetCreditEntitlement, GetCreditGrantsResult, GetCreditLedgerResult, GetEnumEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetSubscriptionsResult, MeteredEntitlement, NumericEntitlement, PaymentSessionFragment, Paywall, SaveAutomaticRechargeConfigurationInput, 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
+ getCreditEntitlement({ currencyId, options }: GetCreditEntitlement): CreditEntitlement;
8
9
  getEntitlements(): Promise<Entitlement[]>;
9
10
  getEntitlementsState(): Promise<EntitlementsState>;
10
11
  addListener(): void;
@@ -1,4 +1,4 @@
1
- import CachedEntitlement, { CachedEntitlementsState } from './cachedEntitlement';
1
+ import CachedEntitlement, { CachedCreditEntitlement, CachedEntitlementsState } from './cachedEntitlement';
2
2
  export interface CacheService {
3
3
  isLoaded(): boolean;
4
4
  getLastUpdate(): Date | null;
@@ -9,4 +9,6 @@ export interface CacheService {
9
9
  getEntitlements(): CachedEntitlementsState;
10
10
  validateFeature(featureId: string): boolean;
11
11
  setFeatures(features: string[]): void;
12
+ getCreditEntitlement(currencyId: string): CachedCreditEntitlement | null;
13
+ setCreditEntitlements(creditEntitlements: Map<string, CachedCreditEntitlement>): void;
12
14
  }
@@ -26,3 +26,18 @@ export default class CachedEntitlement {
26
26
  readonly featureUsage: EntitlementUsage;
27
27
  constructor(calculatedEntitlement: CalculatedEntitlement, featureUsage: EntitlementUsage);
28
28
  }
29
+ export interface CachedCreditEntitlementData {
30
+ currencyId: string;
31
+ isGranted: boolean;
32
+ accessDeniedReason?: AccessDeniedReason;
33
+ usageLimit: number;
34
+ currentUsage: number;
35
+ }
36
+ export declare class CachedCreditEntitlement {
37
+ readonly currencyId: string;
38
+ readonly isGranted: boolean;
39
+ readonly accessDeniedReason?: AccessDeniedReason;
40
+ readonly usageLimit: number;
41
+ readonly currentUsage: number;
42
+ constructor(data: CachedCreditEntitlementData);
43
+ }
@@ -1,6 +1,7 @@
1
- import CachedEntitlement from './cachedEntitlement';
1
+ import CachedEntitlement, { CachedCreditEntitlement } from './cachedEntitlement';
2
2
  import { AccessDeniedReason } from '../models';
3
3
  export declare class EntitlementDecisionService {
4
+ static decideCreditEntitlementPolicy(creditEntitlement?: CachedCreditEntitlement | null): Decision;
4
5
  static decideEntitlementPolicy(entitlement?: CachedEntitlement | null, requestUsage?: number, requestedValues?: string[]): Decision;
5
6
  }
6
7
  export interface Decision {
@@ -1,6 +1,6 @@
1
1
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
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';
2
+ import { EntitlementsStateAccessDeniedReason, EntitlementUnionFragment } from '@stigg/api-client-js/src/generated/sdk';
3
+ import { BooleanEntitlement, BooleanEntitlementOptions, CreditEntitlement, 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';
@@ -22,9 +22,10 @@ export declare class EntitlementsService {
22
22
  getMeteredEntitlement(featureId: string, fallbackEntitlement: MeteredEntitlement, options?: MeteredEntitlementOptions): MeteredEntitlement;
23
23
  private handleUsagePeriodOver;
24
24
  getEnumEntitlement(featureId: string, fallbackEntitlement: EnumEntitlement, options?: EnumEntitlementOptions): EnumEntitlement;
25
+ getCreditEntitlement(currencyId: string, fallbackEntitlement: CreditEntitlement): CreditEntitlement;
25
26
  loadEntitlements(skipEdge?: boolean): Promise<void>;
26
27
  private loadEntitlementsFromRemote;
27
- protected storeFetchedEntitlementsInCache(entitlements: EntitlementFragment[], accessDeniedReason: EntitlementsStateAccessDeniedReason | null): void;
28
+ protected storeFetchedEntitlementsInCache(entitlements: EntitlementUnionFragment[], accessDeniedReason: EntitlementsStateAccessDeniedReason | null): void;
28
29
  private getLastEntitlementsUpdate;
29
30
  private getEntitlement;
30
31
  getEntitlementsState(): Promise<EntitlementsState>;
@@ -1,8 +1,9 @@
1
1
  import { CacheService } from './cacheService';
2
- import CachedEntitlement, { CachedEntitlementsState } from './cachedEntitlement';
2
+ import CachedEntitlement, { CachedCreditEntitlement, CachedEntitlementsState } from './cachedEntitlement';
3
3
  export declare class InMemoryCacheService implements CacheService {
4
4
  private readonly ttlMs;
5
5
  private entitlementsState;
6
+ private creditEntitlements;
6
7
  private lastUpdate;
7
8
  private lastChecked;
8
9
  private features;
@@ -16,4 +17,6 @@ export declare class InMemoryCacheService implements CacheService {
16
17
  getLastUpdate(): Date | null;
17
18
  isLoaded(): boolean;
18
19
  isOutdated(): boolean;
20
+ getCreditEntitlement(currencyId: string): CachedCreditEntitlement | null;
21
+ setCreditEntitlements(creditEntitlements: Map<string, CachedCreditEntitlement>): void;
19
22
  }
@@ -1,6 +1,6 @@
1
1
  import { 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, GetCreditLedgerResult, AutomaticRechargeConfiguration, GetAutomaticRechargeConfigurationInput, SaveAutomaticRechargeConfigurationInput, EntitlementsState } from './models';
3
+ import { ApplySubscription, ApplySubscriptionResults, BooleanEntitlement, Coupon, CreditEntitlement, Customer, CustomerPortal, Entitlement, EstimateSubscription, EstimateSubscriptionUpdate, FetchUsageHistory, GetActiveSubscriptions, GetBooleanEntitlement, GetCheckoutStateResults, GetCheckoutState, GetCreditEntitlement, 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, GetCreditLedgerResult, AutomaticRechargeConfiguration, GetAutomaticRechargeConfigurationInput, SaveAutomaticRechargeConfigurationInput, EntitlementsState } from './models';
4
4
  import { EventNames, Events } from './services/eventEmitter';
5
5
  import { LoggerService } from './services/loggerService';
6
6
  export interface StiggClient {
@@ -12,6 +12,7 @@ export interface StiggClient {
12
12
  getNumericEntitlement: (params: GetNumericEntitlement) => NumericEntitlement;
13
13
  getMeteredEntitlement: (params: GetMeteredEntitlement) => MeteredEntitlement;
14
14
  getEnumEntitlement: (params: GetEnumEntitlement) => EnumEntitlement;
15
+ getCreditEntitlement: (params: GetCreditEntitlement) => CreditEntitlement;
15
16
  fetchUsageHistory: (params: FetchUsageHistory) => Promise<UsageHistoryPoint[] | undefined>;
16
17
  setCustomerId: (customerId: string, customerToken?: string | null, resourceId?: string | null) => Promise<void>;
17
18
  clearCustomer: () => void;
@@ -154,6 +155,15 @@ export declare class Stigg implements StiggClient {
154
155
  * @return {EnumEntitlement} enum entitlement
155
156
  */
156
157
  getEnumEntitlement({ featureId, options, resourceId }: GetEnumEntitlement): EnumEntitlement;
158
+ /**
159
+ * Get credit entitlement for a customer by currency ID
160
+ *
161
+ * @param {string} currencyId
162
+ * @param {string} resourceId
163
+ * @param {CreditEntitlementOptions} options
164
+ * @return {CreditEntitlement} credit entitlement
165
+ */
166
+ getCreditEntitlement({ currencyId, options, resourceId }: GetCreditEntitlement): CreditEntitlement;
157
167
  /**
158
168
  * Get paywall data for rendering the paywall
159
169
  * @deprecated *Optional* `productId` is now deprecated and will be changed to a *required* field soon.
@@ -65,6 +65,32 @@ export declare const NUMERIC_DEFAULT_FALLBACK_ENTITLEMENT: NumericEntitlement;
65
65
  export declare const METERED_DEFAULT_FALLBACK_ENTITLEMENT: MeteredEntitlement;
66
66
  /** @internal */
67
67
  export declare const ENUM_DEFAULT_FALLBACK_ENTITLEMENT: EnumEntitlement;
68
+ export interface CreditEntitlement {
69
+ hasAccess: boolean;
70
+ isFallback: boolean;
71
+ accessDeniedReason?: AccessDeniedReason;
72
+ currency: {
73
+ currencyId: string;
74
+ };
75
+ usageLimit: number;
76
+ currentUsage: number;
77
+ remaining: number;
78
+ }
79
+ /** @internal */
80
+ export declare const CREDIT_DEFAULT_FALLBACK_ENTITLEMENT: CreditEntitlement;
81
+ export declare type GetCreditEntitlement = {
82
+ currencyId: string;
83
+ resourceId?: string;
84
+ options?: CreditEntitlementOptions;
85
+ };
86
+ export declare type CreditEntitlementOptions = {
87
+ fallback?: CreditEntitlementFallback;
88
+ };
89
+ export declare type CreditEntitlementFallback = {
90
+ hasAccess?: boolean;
91
+ usageLimit?: number;
92
+ currentUsage?: number;
93
+ };
68
94
  export declare type PackageEntitlement = {
69
95
  usageLimit: number;
70
96
  feature?: EntitlementFeature;
@@ -1,10 +1,11 @@
1
1
  import { Stigg, StiggClient } from './clients';
2
- import { ApplySubscriptionResults, AutomaticRechargeConfiguration, BooleanEntitlement, Coupon, CreditsBalanceSummaryFragment, CreditUsageFragment, Customer, CustomerPortal, Entitlement, EntitlementsState, EnumEntitlement, GetAutomaticRechargeConfigurationInput, GetBooleanEntitlement, GetCheckoutStateResults, GetCreditGrantsResult, GetCreditLedgerResult, GetEnumEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetSubscriptionsResult, MeteredEntitlement, NumericEntitlement, PaymentSessionFragment, Paywall, SaveAutomaticRechargeConfigurationInput, SlimSubscriptionFragmentV2Fragment, Subscription, SubscriptionInvoicePreviewFragment, SubscriptionPreview, SubscriptionPreviewV2, UsageHistoryPoint, UsageHistoryV2Fragment } from './models';
2
+ import { ApplySubscriptionResults, AutomaticRechargeConfiguration, BooleanEntitlement, Coupon, CreditEntitlement, CreditsBalanceSummaryFragment, CreditUsageFragment, Customer, CustomerPortal, Entitlement, EntitlementsState, EnumEntitlement, GetAutomaticRechargeConfigurationInput, GetBooleanEntitlement, GetCheckoutStateResults, GetCreditEntitlement, GetCreditGrantsResult, GetCreditLedgerResult, GetEnumEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetSubscriptionsResult, MeteredEntitlement, NumericEntitlement, PaymentSessionFragment, Paywall, SaveAutomaticRechargeConfigurationInput, 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
+ getCreditEntitlement({ currencyId, options }: GetCreditEntitlement): CreditEntitlement;
8
9
  getEntitlements(): Promise<Entitlement[]>;
9
10
  getEntitlementsState(): Promise<EntitlementsState>;
10
11
  addListener(): void;
@@ -1,4 +1,4 @@
1
- import CachedEntitlement, { CachedEntitlementsState } from './cachedEntitlement';
1
+ import CachedEntitlement, { CachedCreditEntitlement, CachedEntitlementsState } from './cachedEntitlement';
2
2
  export interface CacheService {
3
3
  isLoaded(): boolean;
4
4
  getLastUpdate(): Date | null;
@@ -9,4 +9,6 @@ export interface CacheService {
9
9
  getEntitlements(): CachedEntitlementsState;
10
10
  validateFeature(featureId: string): boolean;
11
11
  setFeatures(features: string[]): void;
12
+ getCreditEntitlement(currencyId: string): CachedCreditEntitlement | null;
13
+ setCreditEntitlements(creditEntitlements: Map<string, CachedCreditEntitlement>): void;
12
14
  }
@@ -26,3 +26,18 @@ export default class CachedEntitlement {
26
26
  readonly featureUsage: EntitlementUsage;
27
27
  constructor(calculatedEntitlement: CalculatedEntitlement, featureUsage: EntitlementUsage);
28
28
  }
29
+ export interface CachedCreditEntitlementData {
30
+ currencyId: string;
31
+ isGranted: boolean;
32
+ accessDeniedReason?: AccessDeniedReason;
33
+ usageLimit: number;
34
+ currentUsage: number;
35
+ }
36
+ export declare class CachedCreditEntitlement {
37
+ readonly currencyId: string;
38
+ readonly isGranted: boolean;
39
+ readonly accessDeniedReason?: AccessDeniedReason;
40
+ readonly usageLimit: number;
41
+ readonly currentUsage: number;
42
+ constructor(data: CachedCreditEntitlementData);
43
+ }
@@ -1,6 +1,7 @@
1
- import CachedEntitlement from './cachedEntitlement';
1
+ import CachedEntitlement, { CachedCreditEntitlement } from './cachedEntitlement';
2
2
  import { AccessDeniedReason } from '../models';
3
3
  export declare class EntitlementDecisionService {
4
+ static decideCreditEntitlementPolicy(creditEntitlement?: CachedCreditEntitlement | null): Decision;
4
5
  static decideEntitlementPolicy(entitlement?: CachedEntitlement | null, requestUsage?: number, requestedValues?: string[]): Decision;
5
6
  }
6
7
  export interface Decision {
@@ -1,6 +1,6 @@
1
1
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
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';
2
+ import { EntitlementsStateAccessDeniedReason, EntitlementUnionFragment } from '@stigg/api-client-js/src/generated/sdk';
3
+ import { BooleanEntitlement, BooleanEntitlementOptions, CreditEntitlement, 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';
@@ -22,9 +22,10 @@ export declare class EntitlementsService {
22
22
  getMeteredEntitlement(featureId: string, fallbackEntitlement: MeteredEntitlement, options?: MeteredEntitlementOptions): MeteredEntitlement;
23
23
  private handleUsagePeriodOver;
24
24
  getEnumEntitlement(featureId: string, fallbackEntitlement: EnumEntitlement, options?: EnumEntitlementOptions): EnumEntitlement;
25
+ getCreditEntitlement(currencyId: string, fallbackEntitlement: CreditEntitlement): CreditEntitlement;
25
26
  loadEntitlements(skipEdge?: boolean): Promise<void>;
26
27
  private loadEntitlementsFromRemote;
27
- protected storeFetchedEntitlementsInCache(entitlements: EntitlementFragment[], accessDeniedReason: EntitlementsStateAccessDeniedReason | null): void;
28
+ protected storeFetchedEntitlementsInCache(entitlements: EntitlementUnionFragment[], accessDeniedReason: EntitlementsStateAccessDeniedReason | null): void;
28
29
  private getLastEntitlementsUpdate;
29
30
  private getEntitlement;
30
31
  getEntitlementsState(): Promise<EntitlementsState>;
@@ -1,8 +1,9 @@
1
1
  import { CacheService } from './cacheService';
2
- import CachedEntitlement, { CachedEntitlementsState } from './cachedEntitlement';
2
+ import CachedEntitlement, { CachedCreditEntitlement, CachedEntitlementsState } from './cachedEntitlement';
3
3
  export declare class InMemoryCacheService implements CacheService {
4
4
  private readonly ttlMs;
5
5
  private entitlementsState;
6
+ private creditEntitlements;
6
7
  private lastUpdate;
7
8
  private lastChecked;
8
9
  private features;
@@ -16,4 +17,6 @@ export declare class InMemoryCacheService implements CacheService {
16
17
  getLastUpdate(): Date | null;
17
18
  isLoaded(): boolean;
18
19
  isOutdated(): boolean;
20
+ getCreditEntitlement(currencyId: string): CachedCreditEntitlement | null;
21
+ setCreditEntitlements(creditEntitlements: Map<string, CachedCreditEntitlement>): void;
19
22
  }
@@ -1,6 +1,6 @@
1
- import { ApplySubscriptionMutation, CustomerFragment, CustomerPortalFragment, CustomerResourceFragment, EntitlementFragment, CheckoutStateFragment, GetCouponsQuery, GetMockPaywallQuery, GetPaywallQuery, SubscriptionFragment, SubscriptionPreviewFragment, UsageHistoryFragment, SubscriptionPreviewV2Fragment, SubscriptionPreviewInvoiceFragment, ImmediateSubscriptionPreviewInvoiceFragment, SlimCustomerFragment } from '@stigg/api-client-js/src/generated/sdk';
2
- import { BooleanEntitlement, ApplySubscriptionResults, Coupon, Customer, CustomerPortal, CustomerResource, GetCheckoutStateResults, EnumEntitlement, MeteredEntitlement, Money, NumericEntitlement, Paywall, Plan, Subscription, SubscriptionPreview, SubscriptionPreviewDiscount, UsageHistoryPoint, SubscriptionPreviewV2, SubscriptionPreviewInvoice, SlimCustomer, SubscriptionPreviewCredits } from '../models';
3
- import CachedEntitlement from '../services/cachedEntitlement';
1
+ import { ApplySubscriptionMutation, CustomerFragment, CustomerPortalFragment, CustomerResourceFragment, CheckoutStateFragment, GetCouponsQuery, GetMockPaywallQuery, GetPaywallQuery, SubscriptionFragment, SubscriptionPreviewFragment, UsageHistoryFragment, SubscriptionPreviewV2Fragment, SubscriptionPreviewInvoiceFragment, ImmediateSubscriptionPreviewInvoiceFragment, SlimCustomerFragment, CreditEntitlementFragment, EntitlementUnionFragment, FeatureEntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { BooleanEntitlement, ApplySubscriptionResults, Coupon, Customer, CustomerPortal, CustomerResource, GetCheckoutStateResults, EnumEntitlement, MeteredEntitlement, Money, NumericEntitlement, Paywall, Plan, Subscription, SubscriptionPreview, SubscriptionPreviewDiscount, UsageHistoryPoint, SubscriptionPreviewV2, SubscriptionPreviewInvoice, SlimCustomer, SubscriptionPreviewCredits, CreditEntitlement } from '../models';
3
+ import CachedEntitlement, { CachedCreditEntitlement } from '../services/cachedEntitlement';
4
4
  import { Decision } from '../services/entitlementDecisionService';
5
5
  export declare class ModelMapper {
6
6
  mapBooleanEntitlement(entitlement: CachedEntitlement, decision: Decision): BooleanEntitlement;
@@ -8,8 +8,7 @@ export declare class ModelMapper {
8
8
  mapMeteredEntitlement(entitlement: CachedEntitlement, decision: Decision, requestedUsage?: number): MeteredEntitlement;
9
9
  mapEnumEntitlement(entitlement: CachedEntitlement, decision: Decision, requestedValues?: string[]): EnumEntitlement;
10
10
  mapEntitlement(entitlement: CachedEntitlement, decision: Decision, requestedUsage?: number): BooleanEntitlement;
11
- mapCachedEntitlement(entitlement: EntitlementFragment): CachedEntitlement;
12
- mapCachedEntitlements(updatedEntitlements: EntitlementFragment[]): Map<string, CachedEntitlement>;
11
+ mapCachedEntitlement(entitlement: FeatureEntitlementFragment): CachedEntitlement;
13
12
  mapPlans(resultData: GetPaywallQuery): Plan[];
14
13
  mapPaywall(resultData: GetPaywallQuery): Paywall;
15
14
  mapMockPlans(resultData: GetMockPaywallQuery): Paywall;
@@ -50,4 +49,10 @@ export declare class ModelMapper {
50
49
  private getPriceCurrency;
51
50
  private mapCompatiblePackageGroups;
52
51
  private mapDependencyAddon;
52
+ mapCachedCreditEntitlement(creditEntitlement: CreditEntitlementFragment): CachedCreditEntitlement;
53
+ mapCachedEntitlements(entitlements: EntitlementUnionFragment[]): {
54
+ featureEntitlements: Map<string, CachedEntitlement>;
55
+ creditEntitlements: Map<string, CachedCreditEntitlement>;
56
+ };
57
+ mapCreditEntitlement(cachedCreditEntitlement: CachedCreditEntitlement, decision: Decision): CreditEntitlement;
53
58
  }
@@ -1,6 +1,6 @@
1
- import { ApplySubscriptionMutation, CustomerFragment, CustomerPortalFragment, CustomerResourceFragment, EntitlementFragment, CheckoutStateFragment, GetCouponsQuery, GetMockPaywallQuery, GetPaywallQuery, SubscriptionFragment, SubscriptionPreviewFragment, UsageHistoryFragment, SubscriptionPreviewV2Fragment, SubscriptionPreviewInvoiceFragment, ImmediateSubscriptionPreviewInvoiceFragment, SlimCustomerFragment } from '@stigg/api-client-js/src/generated/sdk';
2
- import { BooleanEntitlement, ApplySubscriptionResults, Coupon, Customer, CustomerPortal, CustomerResource, GetCheckoutStateResults, EnumEntitlement, MeteredEntitlement, Money, NumericEntitlement, Paywall, Plan, Subscription, SubscriptionPreview, SubscriptionPreviewDiscount, UsageHistoryPoint, SubscriptionPreviewV2, SubscriptionPreviewInvoice, SlimCustomer, SubscriptionPreviewCredits } from '../models';
3
- import CachedEntitlement from '../services/cachedEntitlement';
1
+ import { ApplySubscriptionMutation, CustomerFragment, CustomerPortalFragment, CustomerResourceFragment, CheckoutStateFragment, GetCouponsQuery, GetMockPaywallQuery, GetPaywallQuery, SubscriptionFragment, SubscriptionPreviewFragment, UsageHistoryFragment, SubscriptionPreviewV2Fragment, SubscriptionPreviewInvoiceFragment, ImmediateSubscriptionPreviewInvoiceFragment, SlimCustomerFragment, CreditEntitlementFragment, EntitlementUnionFragment, FeatureEntitlementFragment } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { BooleanEntitlement, ApplySubscriptionResults, Coupon, Customer, CustomerPortal, CustomerResource, GetCheckoutStateResults, EnumEntitlement, MeteredEntitlement, Money, NumericEntitlement, Paywall, Plan, Subscription, SubscriptionPreview, SubscriptionPreviewDiscount, UsageHistoryPoint, SubscriptionPreviewV2, SubscriptionPreviewInvoice, SlimCustomer, SubscriptionPreviewCredits, CreditEntitlement } from '../models';
3
+ import CachedEntitlement, { CachedCreditEntitlement } from '../services/cachedEntitlement';
4
4
  import { Decision } from '../services/entitlementDecisionService';
5
5
  export declare class ModelMapper {
6
6
  mapBooleanEntitlement(entitlement: CachedEntitlement, decision: Decision): BooleanEntitlement;
@@ -8,8 +8,7 @@ export declare class ModelMapper {
8
8
  mapMeteredEntitlement(entitlement: CachedEntitlement, decision: Decision, requestedUsage?: number): MeteredEntitlement;
9
9
  mapEnumEntitlement(entitlement: CachedEntitlement, decision: Decision, requestedValues?: string[]): EnumEntitlement;
10
10
  mapEntitlement(entitlement: CachedEntitlement, decision: Decision, requestedUsage?: number): BooleanEntitlement;
11
- mapCachedEntitlement(entitlement: EntitlementFragment): CachedEntitlement;
12
- mapCachedEntitlements(updatedEntitlements: EntitlementFragment[]): Map<string, CachedEntitlement>;
11
+ mapCachedEntitlement(entitlement: FeatureEntitlementFragment): CachedEntitlement;
13
12
  mapPlans(resultData: GetPaywallQuery): Plan[];
14
13
  mapPaywall(resultData: GetPaywallQuery): Paywall;
15
14
  mapMockPlans(resultData: GetMockPaywallQuery): Paywall;
@@ -50,4 +49,10 @@ export declare class ModelMapper {
50
49
  private getPriceCurrency;
51
50
  private mapCompatiblePackageGroups;
52
51
  private mapDependencyAddon;
52
+ mapCachedCreditEntitlement(creditEntitlement: CreditEntitlementFragment): CachedCreditEntitlement;
53
+ mapCachedEntitlements(entitlements: EntitlementUnionFragment[]): {
54
+ featureEntitlements: Map<string, CachedEntitlement>;
55
+ creditEntitlements: Map<string, CachedCreditEntitlement>;
56
+ };
57
+ mapCreditEntitlement(cachedCreditEntitlement: CachedCreditEntitlement, decision: Decision): CreditEntitlement;
53
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigg/js-client-sdk",
3
- "version": "3.82.0",
3
+ "version": "3.83.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": "5.131.3",
40
+ "@stigg/api-client-js": "5.164.0",
41
41
  "cross-fetch": "^3.1.6",
42
42
  "dayjs": "^1.11.13",
43
43
  "fetch-retry": "^5.0.6",