@stigg/js-client-sdk 3.85.1 → 3.86.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.
Files changed (55) hide show
  1. package/dist/api/EdgeApiClient.d.ts +1 -1
  2. package/dist/api/MockPaywallApi.d.ts +1 -1
  3. package/dist/api/PaywallApi.d.ts +1 -1
  4. package/dist/api/SubscriptionsApi.d.ts +2 -2
  5. package/dist/api/initApolloClient.d.ts +1 -1
  6. package/dist/configuration.d.ts +1 -1
  7. package/dist/index.esm.js +2 -2
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.js +2 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/models.d.ts +101 -101
  12. package/dist/services/eventEmitter.d.ts +1 -1
  13. package/dist/utils/dateUtils.d.ts +1 -1
  14. package/dist/utils/fetch.d.ts +1 -2
  15. package/dist/utils/isMetered.d.ts +1 -1
  16. package/dist/utils/mapGetEntitlementsFallback.d.ts +5 -5
  17. package/dist/utils/withErrorHandling.d.ts +2 -2
  18. package/package.json +15 -16
  19. package/dist/src/api/ApiGateway.d.ts +0 -28
  20. package/dist/src/api/AutomaticRechargeApi.d.ts +0 -23
  21. package/dist/src/api/CheckoutApi.d.ts +0 -8
  22. package/dist/src/api/CouponsApi.d.ts +0 -8
  23. package/dist/src/api/CreditsApi.d.ts +0 -11
  24. package/dist/src/api/CustomersApi.d.ts +0 -16
  25. package/dist/src/api/EdgeApiClient.d.ts +0 -21
  26. package/dist/src/api/EntitlementsApi.d.ts +0 -10
  27. package/dist/src/api/MockPaywallApi.d.ts +0 -10
  28. package/dist/src/api/PaywallApi.d.ts +0 -18
  29. package/dist/src/api/SdkConfigurationApi.d.ts +0 -10
  30. package/dist/src/api/SubscriptionEstimationsApi.d.ts +0 -12
  31. package/dist/src/api/SubscriptionsApi.d.ts +0 -22
  32. package/dist/src/api/UsageHistoryApi.d.ts +0 -7
  33. package/dist/src/api/initApolloClient.d.ts +0 -11
  34. package/dist/src/client.d.ts +0 -312
  35. package/dist/src/clients.d.ts +0 -2
  36. package/dist/src/configuration.d.ts +0 -28
  37. package/dist/src/index.d.ts +0 -6
  38. package/dist/src/models.d.ts +0 -670
  39. package/dist/src/offlineClient.d.ts +0 -46
  40. package/dist/src/services/cacheService.d.ts +0 -14
  41. package/dist/src/services/cachedEntitlement.d.ts +0 -45
  42. package/dist/src/services/entitlementDecisionService.d.ts +0 -10
  43. package/dist/src/services/entitlementsService.d.ts +0 -34
  44. package/dist/src/services/eventEmitter.d.ts +0 -11
  45. package/dist/src/services/inMemoryCacheService.d.ts +0 -22
  46. package/dist/src/services/initializationStateTracker.d.ts +0 -16
  47. package/dist/src/services/loggerService.d.ts +0 -23
  48. package/dist/src/services/sentryService.d.ts +0 -3
  49. package/dist/src/utils/ModelMapper.d.ts +0 -58
  50. package/dist/src/utils/calculateUsagePeriod.d.ts +0 -5
  51. package/dist/src/utils/dateUtils.d.ts +0 -1
  52. package/dist/src/utils/fetch.d.ts +0 -3
  53. package/dist/src/utils/isMetered.d.ts +0 -7
  54. package/dist/src/utils/mapGetEntitlementsFallback.d.ts +0 -35
  55. package/dist/src/utils/withErrorHandling.d.ts +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigg/js-client-sdk",
3
- "version": "3.85.1",
3
+ "version": "3.86.0",
4
4
  "description": "Stigg client-side SDK for Browser",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -23,8 +23,7 @@
23
23
  "link-sdk": "yarn build && yarn link",
24
24
  "fix": "run-s fix:*",
25
25
  "fix:prettier": "prettier \"src/**/*.ts\" --write",
26
- "fix:lint": "eslint src --ext .ts --fix",
27
- "pretty-quick": "pretty-quick --staged --pattern '**/*.*(js|jsx|ts|tsx)'",
26
+ "fix:lint": "eslint src --fix",
28
27
  "test": "jest --silent",
29
28
  "test:watch": "jest --watch",
30
29
  "test:cov": "jest --coverage",
@@ -48,26 +47,26 @@
48
47
  "devDependencies": {
49
48
  "@commitlint/cli": "^14.1.0",
50
49
  "@commitlint/config-conventional": "^14.1.0",
51
- "@mswjs/interceptors": "^0.19.2",
52
- "@types/jest": "^27.0.2",
50
+ "@eslint/js": "^10.0.1",
51
+ "@mswjs/interceptors": "^0.37",
52
+ "@types/jest": "^30.0.0",
53
53
  "@types/lodash": "^4.14.177",
54
- "@typescript-eslint/eslint-plugin": "^5.4.0",
55
- "@typescript-eslint/parser": "^5.4.0",
56
- "eslint": "^8.2.0",
57
- "eslint-config-prettier": "^8.3.0",
58
- "eslint-plugin-prettier": "^4.0.0",
59
- "jest": "^27.3.1",
54
+ "eslint": "^10.0.0",
55
+ "eslint-config-prettier": "^10.1.8",
56
+ "eslint-plugin-prettier": "^5.5.5",
57
+ "jest": "^30.2.0",
58
+ "jest-environment-jsdom": "^30.2.0",
60
59
  "jest-fetch-mock": "^3.0.3",
61
60
  "lint-staged": "^12.0.2",
62
61
  "msw": "^0.35.0",
63
62
  "npm-run-all": "^4.1.5",
64
- "prettier": "^2.4.1",
65
- "pretty-quick": "^3.1.3",
66
- "ts-jest": "^27.0.7",
63
+ "prettier": "^3.8.1",
64
+ "ts-jest": "^29.4.6",
67
65
  "ts-loader": "^9.2.6",
68
66
  "typedoc": "^0.22.13",
69
67
  "typedoc-plugin-rename-defaults": "^0.4.0",
70
- "typescript": "^4.5.3",
68
+ "typescript": "^5.9.3",
69
+ "typescript-eslint": "^8.56.0",
71
70
  "webpack": "^5.64.1",
72
71
  "webpack-cli": "^4.9.1",
73
72
  "webpack-dev-server": "^4.5.0"
@@ -77,7 +76,7 @@
77
76
  },
78
77
  "lint-staged": {
79
78
  "*.{js,jsx,ts,tsx}": [
80
- "prettier --check",
79
+ "prettier --write",
81
80
  "eslint --cache"
82
81
  ]
83
82
  }
@@ -1,28 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import SdkConfigurationApi from './SdkConfigurationApi';
3
- import PaywallApi from './PaywallApi';
4
- import CustomersApi from './CustomersApi';
5
- import CouponsApi from './CouponsApi';
6
- import SubscriptionsApi from './SubscriptionsApi';
7
- import SubscriptionEstimationsApi from './SubscriptionEstimationsApi';
8
- import MockPaywallApi from './MockPaywallApi';
9
- import { EdgeApiClient } from './EdgeApiClient';
10
- import { UsageHistoryApi } from './UsageHistoryApi';
11
- import CreditsApi from './CreditsApi';
12
- import CheckoutApi from './CheckoutApi';
13
- import AutomaticRechargeApi from './AutomaticRechargeApi';
14
- declare class ApiGateway {
15
- sdkConfiguration: SdkConfigurationApi;
16
- paywall: PaywallApi;
17
- subscriptions: SubscriptionsApi;
18
- mockPaywall: MockPaywallApi;
19
- customers: CustomersApi;
20
- coupons: CouponsApi;
21
- subscriptionEstimations: SubscriptionEstimationsApi;
22
- usageHistoryApi: UsageHistoryApi;
23
- credits: CreditsApi;
24
- checkout: CheckoutApi;
25
- automaticRecharge: AutomaticRechargeApi;
26
- constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
27
- }
28
- export default ApiGateway;
@@ -1,23 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { GetAutomaticRechargeConfigurationQuery, SaveAutomaticRechargeConfigurationMutation, GetAutoRechargeSettingsInput, SaveAutoRechargeSettingsInput } from '@stigg/api-client-js/src/generated/sdk';
3
- /**
4
- * API class for managing automatic recharge configurations.
5
- * Handles GraphQL queries and mutations for automatic recharge settings.
6
- */
7
- declare class AutomaticRechargeApi {
8
- private readonly client;
9
- constructor(client: ApolloClient<NormalizedCacheObject>);
10
- /**
11
- * Retrieves the automatic recharge configuration for a customer and currency.
12
- * @param input - Configuration input containing customerId, currencyId, and environmentId
13
- * @returns Promise with the GraphQL query result containing automatic recharge settings
14
- */
15
- getConfiguration(input: GetAutoRechargeSettingsInput): Promise<import("@apollo/client/core").ApolloQueryResult<GetAutomaticRechargeConfigurationQuery>>;
16
- /**
17
- * Saves (creates or updates) the automatic recharge configuration for a customer and currency.
18
- * @param input - Configuration input containing all automatic recharge settings
19
- * @returns Promise with the GraphQL mutation result containing saved automatic recharge settings
20
- */
21
- saveConfiguration(input: SaveAutoRechargeSettingsInput): Promise<import("@apollo/client/core").FetchResult<SaveAutomaticRechargeConfigurationMutation, Record<string, any>, Record<string, any>>>;
22
- }
23
- export default AutomaticRechargeApi;
@@ -1,8 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { CreatePaymentSessionMutation, PaymentSessionInput } from '@stigg/api-client-js/src/generated/sdk';
3
- declare class CheckoutApi {
4
- private readonly client;
5
- constructor(client: ApolloClient<NormalizedCacheObject>);
6
- createPaymentSession(input: PaymentSessionInput): Promise<import("@apollo/client/core").FetchResult<CreatePaymentSessionMutation, Record<string, any>, Record<string, any>>>;
7
- }
8
- export default CheckoutApi;
@@ -1,8 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { GetCouponsQuery } from '@stigg/api-client-js/src/generated/sdk';
3
- declare class CouponsApi {
4
- private readonly client;
5
- constructor(client: ApolloClient<NormalizedCacheObject>);
6
- getCoupons(): Promise<import("@apollo/client/core").ApolloQueryResult<GetCouponsQuery>>;
7
- }
8
- export default CouponsApi;
@@ -1,11 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { CreditBalanceSummaryInput, CreditLedgerInput, GetCreditBalanceQuery, GetCreditGrantsInput, GetCreditGrantsQuery, GetCreditUsageQuery, CreditUsageInput, GetCreditLedgerQuery } from '@stigg/api-client-js/src/generated/sdk';
3
- declare class CreditsApi {
4
- private readonly client;
5
- constructor(client: ApolloClient<NormalizedCacheObject>);
6
- getCreditBalance(input: CreditBalanceSummaryInput): Promise<import("@apollo/client/core").ApolloQueryResult<GetCreditBalanceQuery>>;
7
- getCreditGrants(input: GetCreditGrantsInput): Promise<import("@apollo/client/core").ApolloQueryResult<GetCreditGrantsQuery>>;
8
- getCreditLedger(input: CreditLedgerInput): Promise<import("@apollo/client/core").ApolloQueryResult<GetCreditLedgerQuery>>;
9
- getCreditUsage(input: CreditUsageInput): Promise<import("@apollo/client/core").ApolloQueryResult<GetCreditUsageQuery>>;
10
- }
11
- export default CreditsApi;
@@ -1,16 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { GetCustomerPortalByRefIdQuery, GetCustomerByIdQuery, GetActiveSubscriptionsQuery, GetActiveSubscriptionsListQuery, GetSubscriptionQuery, GetUsageHistoryQuery } from '@stigg/api-client-js/src/generated/sdk';
3
- import { FetchUsageHistory } from '../models';
4
- import { EdgeApiClient } from './EdgeApiClient';
5
- declare class CustomersApi {
6
- private readonly client;
7
- private readonly edgeApiClient;
8
- constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
9
- getCustomer(customerId: string): Promise<import("@apollo/client/core").ApolloQueryResult<GetCustomerByIdQuery>>;
10
- getActiveSubscriptions(customerId: string, resourceId?: string | string[]): Promise<import("@apollo/client/core").ApolloQueryResult<GetActiveSubscriptionsQuery>>;
11
- getActiveSubscriptionsList(customerId: string, resourceId?: string | string[]): Promise<import("@apollo/client/core").ApolloQueryResult<GetActiveSubscriptionsListQuery>>;
12
- getSubscription(subscriptionId: string): Promise<import("@apollo/client/core").ApolloQueryResult<GetSubscriptionQuery>>;
13
- getCustomerPortal(customerId: string, resourceId: string | undefined, productId: string | undefined): Promise<import("@apollo/client/core").ApolloQueryResult<GetCustomerPortalByRefIdQuery>>;
14
- fetchUsageHistory({ customerId, resourceId, endDate, startDate, featureId }: FetchUsageHistory): Promise<import("@apollo/client/core").ApolloQueryResult<GetUsageHistoryQuery>>;
15
- }
16
- export default CustomersApi;
@@ -1,21 +0,0 @@
1
- import { ApolloQueryResult } from '@apollo/client/core';
2
- import { GetActiveSubscriptionsListQuery, GetEntitlementsStateQuery, GetPaywallQuery, GetSdkConfigurationQuery } from '@stigg/api-client-js/src/generated/sdk';
3
- declare type EdgeApiClientConfiguration = {
4
- apiKey: string;
5
- baseEdgeUri: string;
6
- enableEdge: boolean;
7
- };
8
- export declare class EdgeApiClient {
9
- private readonly config;
10
- private readonly dynamicData;
11
- private constructor();
12
- static create(config: EdgeApiClientConfiguration, dynamicData: {
13
- customerToken?: string | null;
14
- }): EdgeApiClient | null;
15
- getPaywall(productId?: string, billingCountryCode?: string, includeHiddenPlans?: boolean): Promise<ApolloQueryResult<GetPaywallQuery>>;
16
- getEntitlementsState(customerId: string, resourceId: string | undefined): Promise<ApolloQueryResult<GetEntitlementsStateQuery>>;
17
- getActiveSubscriptionsList(customerId: string, resourceId: string | string[] | undefined): Promise<ApolloQueryResult<GetActiveSubscriptionsListQuery>>;
18
- getSdkConfiguration(): Promise<ApolloQueryResult<GetSdkConfigurationQuery>>;
19
- private get;
20
- }
21
- export {};
@@ -1,10 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { EdgeApiClient } from './EdgeApiClient';
3
- import { GetEntitlementsStateQuery } from '@stigg/api-client-js/src/generated/sdk';
4
- declare class EntitlementsApi {
5
- private readonly client;
6
- private readonly edgeApiClient;
7
- constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
8
- getEntitlementsState(customerId: string, skipEdge?: boolean, resourceId?: string): Promise<import("@apollo/client/core").ApolloQueryResult<GetEntitlementsStateQuery>>;
9
- }
10
- export default EntitlementsApi;
@@ -1,10 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { GetMockPaywallQuery } from '@stigg/api-client-js/src/generated/sdk';
3
- import { GetPaywallProps } from './PaywallApi';
4
- declare type GetMockPaywallProps = GetPaywallProps;
5
- declare class MockPaywallApi {
6
- private readonly client;
7
- constructor(client: ApolloClient<NormalizedCacheObject>);
8
- getMockPaywall({ productId, customerId, context }: GetMockPaywallProps): Promise<import("@apollo/client/core").ApolloQueryResult<GetMockPaywallQuery>>;
9
- }
10
- export default MockPaywallApi;
@@ -1,18 +0,0 @@
1
- import { GetPaywallQuery, WidgetType } from '@stigg/api-client-js/src/generated/sdk';
2
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
3
- import { EdgeApiClient } from './EdgeApiClient';
4
- export declare type GetPaywallProps = {
5
- productId?: string;
6
- customerId?: string | null;
7
- resourceId?: string | null;
8
- context?: WidgetType;
9
- billingCountryCode?: string;
10
- includeHiddenPlans?: boolean;
11
- };
12
- declare class PaywallApi {
13
- private readonly client;
14
- private readonly edgeApiClient;
15
- constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
16
- getPaywall({ productId, customerId, resourceId, context, billingCountryCode, includeHiddenPlans }: GetPaywallProps): Promise<import("@apollo/client/core").ApolloQueryResult<GetPaywallQuery>>;
17
- }
18
- export default PaywallApi;
@@ -1,10 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { EdgeApiClient } from './EdgeApiClient';
3
- import { GetSdkConfigurationQuery } from '@stigg/api-client-js/src/generated/sdk';
4
- declare class SdkConfigurationApi {
5
- private readonly client;
6
- private readonly edgeApiClient;
7
- constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
8
- getSdkConfiguration(): Promise<import("@apollo/client/core").ApolloQueryResult<GetSdkConfigurationQuery>>;
9
- }
10
- export default SdkConfigurationApi;
@@ -1,12 +0,0 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { PreviewSubscription, EstimateSubscription, EstimateSubscriptionUpdate, PreviewNextInvoice } from '../models';
3
- import { EstimateSubscriptionMutation, EstimateSubscriptionUpdateMutation, PreviewSubscriptionMutation, PreviewNextInvoiceMutation } from '@stigg/api-client-js/src/generated/sdk';
4
- declare class SubscriptionEstimationsApi {
5
- private readonly client;
6
- constructor(client: ApolloClient<NormalizedCacheObject>);
7
- estimateSubscription(input: EstimateSubscription): Promise<import("@apollo/client/core").FetchResult<EstimateSubscriptionMutation, Record<string, any>, Record<string, any>>>;
8
- estimateSubscriptionUpdate(input: EstimateSubscriptionUpdate): Promise<import("@apollo/client/core").FetchResult<EstimateSubscriptionUpdateMutation, Record<string, any>, Record<string, any>>>;
9
- previewNextInvoice(input: PreviewNextInvoice): Promise<import("@apollo/client/core").FetchResult<PreviewNextInvoiceMutation, Record<string, any>, Record<string, any>>>;
10
- previewSubscription(input: PreviewSubscription): Promise<import("@apollo/client/core").FetchResult<PreviewSubscriptionMutation, Record<string, any>, Record<string, any>>>;
11
- }
12
- export default SubscriptionEstimationsApi;
@@ -1,22 +0,0 @@
1
- import { GetCheckoutStateQuery, ApplySubscriptionMutation, GetSubscriptionsQuery, SubscriptionStatus } from '@stigg/api-client-js/src/generated/sdk';
2
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
3
- import { ApplySubscription, GetCheckoutState } from '../models';
4
- export declare type ApplySubscriptionParams = ApplySubscription & {
5
- customerId: string;
6
- };
7
- export declare type GetCheckoutStateParams = GetCheckoutState & {
8
- customerId: string;
9
- };
10
- declare class SubscriptionsApi {
11
- private readonly client;
12
- constructor(client: ApolloClient<NormalizedCacheObject>);
13
- applySubscription({ customerId, payingCustomerId, planId, paymentMethodId, addons, billableFeatures, billingInformation, billingCountryCode, billingId, billingPeriod, metadata, promotionCode, resourceId, skipTrial, startDate, unitQuantity, scheduleStrategy, }: ApplySubscriptionParams): Promise<import("@apollo/client/core").FetchResult<ApplySubscriptionMutation, Record<string, any>, Record<string, any>>>;
14
- getSubscriptions(customerId?: string, resourceId?: string | string[], status?: SubscriptionStatus | SubscriptionStatus[], productId?: string | string[], pagination?: {
15
- limit?: number;
16
- startingAfter?: string;
17
- endingBefore?: string;
18
- }): Promise<import("@apollo/client/core").ApolloQueryResult<GetSubscriptionsQuery>>;
19
- checkoutState({ customerId, resourceId, planId, billingCountryCode }: GetCheckoutStateParams): Promise<import("@apollo/client/core").ApolloQueryResult<GetCheckoutStateQuery>>;
20
- private mapBillingInformation;
21
- }
22
- export default SubscriptionsApi;
@@ -1,7 +0,0 @@
1
- import { UsageHistoryV2Input, GetUsageHistoryV2Query } from '@stigg/api-client-js/src/generated/sdk';
2
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
3
- export declare class UsageHistoryApi {
4
- private readonly client;
5
- constructor(client: ApolloClient<NormalizedCacheObject>);
6
- getUsageHistoryV2(input: UsageHistoryV2Input): Promise<import("@apollo/client/core").ApolloQueryResult<GetUsageHistoryV2Query>>;
7
- }
@@ -1,11 +0,0 @@
1
- import { ApolloClient } from '@apollo/client/core';
2
- declare type ApolloClientConfiguration = {
3
- apiKey: string;
4
- baseUri: string;
5
- customerId?: string | null;
6
- customerToken?: string | null;
7
- clientName?: string;
8
- clientVersion?: string;
9
- };
10
- declare const initApolloClient: (config: Partial<ApolloClientConfiguration>) => ApolloClient<import("@apollo/client/core").NormalizedCacheObject>;
11
- export default initApolloClient;
@@ -1,312 +0,0 @@
1
- import { CreditsBalanceSummaryFragment, CreditUsageFragment, PaymentSessionFragment, SlimSubscriptionFragmentV2Fragment, SubscriptionInvoicePreviewFragment, UsageHistoryV2Fragment, UsageHistoryV2Input } from '@stigg/api-client-js/src/generated/sdk';
2
- import { ClientConfiguration } from './configuration';
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
- import { EventNames, Events } from './services/eventEmitter';
5
- import { LoggerService } from './services/loggerService';
6
- export interface StiggClient {
7
- isCustomerLoaded: boolean;
8
- isResourceLoaded: boolean;
9
- /** @deprecated Use {@link getShowWatermark} instead */
10
- isWidgetWatermarkEnabled: boolean;
11
- getBooleanEntitlement: (params: GetBooleanEntitlement) => BooleanEntitlement;
12
- getNumericEntitlement: (params: GetNumericEntitlement) => NumericEntitlement;
13
- getMeteredEntitlement: (params: GetMeteredEntitlement) => MeteredEntitlement;
14
- getEnumEntitlement: (params: GetEnumEntitlement) => EnumEntitlement;
15
- getCreditEntitlement: (params: GetCreditEntitlement) => CreditEntitlement;
16
- fetchUsageHistory: (params: FetchUsageHistory) => Promise<UsageHistoryPoint[] | undefined>;
17
- setCustomerId: (customerId: string, customerToken?: string | null, resourceId?: string | null) => Promise<void>;
18
- clearCustomer: () => void;
19
- setResource: (resourceId: string) => Promise<void>;
20
- clearResource: () => void;
21
- getPaywall: (params?: GetPaywall) => Promise<Paywall>;
22
- getCustomer: () => Promise<Customer>;
23
- getCheckoutState: (params: GetCheckoutState) => Promise<GetCheckoutStateResults>;
24
- applySubscription: (params: ApplySubscription) => Promise<ApplySubscriptionResults>;
25
- getSubscriptions(params: GetSubscriptionsParams): Promise<GetSubscriptionsResult>;
26
- getActiveSubscriptions: (params?: GetActiveSubscriptions) => Promise<Subscription[]>;
27
- getActiveSubscriptionsList(params?: GetActiveSubscriptions): Promise<SlimSubscriptionFragmentV2Fragment[]>;
28
- getSubscription(params: GetSubscription): Promise<Subscription>;
29
- getCoupons(): Promise<Coupon[]>;
30
- /**
31
- * @deprecated Use {@link getEntitlementsState} instead
32
- */
33
- getEntitlements: (resourceId?: string) => Promise<Entitlement[]>;
34
- getEntitlementsState: (resourceId?: string) => Promise<EntitlementsState>;
35
- refresh: () => Promise<void>;
36
- waitForCheckoutCompleted(params?: WaitForCheckoutCompleted): Promise<Subscription | null>;
37
- waitForInitialization(): Promise<StiggClient>;
38
- addListener: <K extends EventNames>(eventName: K, callback: Events[K]) => void;
39
- removeListener: <K extends EventNames>(eventName: K, callback: Events[K]) => void;
40
- getCustomerPortal(params?: GetCustomerPortal): Promise<CustomerPortal>;
41
- estimateSubscription(estimateSubscription: EstimateSubscription): Promise<SubscriptionPreview>;
42
- estimateSubscriptionUpdate(estimateSubscriptionUpdate: EstimateSubscriptionUpdate): Promise<SubscriptionPreview>;
43
- previewNextInvoice(previewNextInvoice: PreviewNextInvoice): Promise<SubscriptionInvoicePreviewFragment>;
44
- previewSubscription(previewSubscription: PreviewSubscription): Promise<SubscriptionPreviewV2>;
45
- getUsageHistoryV2(input: UsageHistoryV2Input): Promise<UsageHistoryV2Fragment>;
46
- getCreditBalance(input?: GetCreditBalanceInput): Promise<CreditsBalanceSummaryFragment>;
47
- getCreditGrants(input: GetCreditGrantsInput): Promise<GetCreditGrantsResult>;
48
- getCreditLedger(input?: GetCreditLedgerInput): Promise<GetCreditLedgerResult>;
49
- getCreditUsage(input: GetCreditUsageInput): Promise<CreditUsageFragment>;
50
- createPaymentSession(input: CreatePaymentSessionInput): Promise<PaymentSessionFragment>;
51
- getAutomaticRechargeConfiguration(input: GetAutomaticRechargeConfigurationInput): Promise<AutomaticRechargeConfiguration>;
52
- saveAutomaticRechargeConfiguration(input: SaveAutomaticRechargeConfigurationInput): Promise<AutomaticRechargeConfiguration>;
53
- getShowWatermark(): boolean;
54
- }
55
- export declare class Stigg implements StiggClient {
56
- private readonly apiGateway;
57
- private readonly edgeApiClient;
58
- private readonly graphClient;
59
- protected readonly configuration: Required<ClientConfiguration>;
60
- private readonly loggerService;
61
- private globalEntitlementsService;
62
- private resourceEntitlementsService;
63
- private readonly modelMapper;
64
- private readonly eventEmitter;
65
- private readonly initializationStateTracker;
66
- private showWatermark;
67
- /** @deprecated Use {@link getShowWatermark} instead */
68
- isWidgetWatermarkEnabled: boolean;
69
- protected constructor(configuration: Required<ClientConfiguration>, loggerService: LoggerService);
70
- /**
71
- * Creates an instance of Stigg client.
72
- *
73
- * @param configuration configuration settings.
74
- * @returns The new client instance.
75
- */
76
- static initialize(configuration: ClientConfiguration): StiggClient;
77
- /**
78
- * Returns a Promise that tracks the client's initialization state.
79
- *
80
- * The Promise will be resolved if the client successfully initializes, or rejected if client
81
- * initialization has irrevocably failed.
82
- *
83
- * @returns Stigg client instance.
84
- */
85
- waitForInitialization(): Promise<StiggClient>;
86
- private static initializeSdk;
87
- get isCustomerLoaded(): boolean;
88
- get isResourceLoaded(): boolean;
89
- getShowWatermark(): boolean;
90
- /**
91
- * Add a listener to handle updates of entitlements changes
92
- * @param eventName
93
- * @param listener
94
- */
95
- addListener<K extends EventNames>(eventName: K, listener: Events[K]): void;
96
- /**
97
- * Remove a listener to stop handle updates of entitlements changes
98
- * @param eventName
99
- * @param listener
100
- */
101
- removeListener<K extends EventNames>(eventName: K, listener: Events[K]): void;
102
- /**
103
- * Set the customer ID, usually after the customer signs in or restores a session
104
- */
105
- setCustomerId(customerId: string, customerToken?: string | null, resourceId?: string | null): Promise<void>;
106
- /**
107
- * Clear the customer ID, usually after the customer signs out
108
- */
109
- clearCustomer(): void;
110
- /**
111
- * Set the customer's resource ID, usually after the customer select a specific resource.
112
- */
113
- setResource(resourceId: string): Promise<void>;
114
- /**
115
- * Unset the customer's resource ID, usually after the customer exit a specific resource.
116
- */
117
- clearResource(): void;
118
- /**
119
- * Reload entitlements
120
- */
121
- refresh(): Promise<void>;
122
- /**
123
- * Get boolean entitlement of feature for a customer
124
- *
125
- * @param {string} featureId
126
- * @param {string} resourceId
127
- * @param {BooleanEntitlementOptions} options
128
- * @return {BooleanEntitlement} boolean entitlement
129
- */
130
- getBooleanEntitlement({ featureId, options, resourceId }: GetBooleanEntitlement): BooleanEntitlement;
131
- /**
132
- * Get numeric entitlement of feature for a customer
133
- *
134
- * @param {string} featureId
135
- * @param {string} resourceId
136
- * @param {NumericEntitlementOptions} options
137
- * @return {NumericEntitlement} numeric entitlement
138
- */
139
- getNumericEntitlement({ featureId, options, resourceId }: GetNumericEntitlement): NumericEntitlement;
140
- /**
141
- * Get metered entitlement of feature for a customer
142
- *
143
- * @param {string} featureId
144
- * @param {string} resourceId
145
- * @param {MeteredEntitlementOptions} options
146
- * @return {MeteredEntitlement} metered entitlement
147
- */
148
- getMeteredEntitlement({ featureId, options, resourceId }: GetMeteredEntitlement): MeteredEntitlement;
149
- /**
150
- * Get enum entitlement of feature for a customer
151
- *
152
- * @param {string} featureId
153
- * @param {string} resourceId
154
- * @param {EnumEntitlementOptions} options
155
- * @return {EnumEntitlement} enum entitlement
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;
167
- /**
168
- * Get paywall data for rendering the paywall
169
- * @deprecated *Optional* `productId` is now deprecated and will be changed to a *required* field soon.
170
- *
171
- * @returns {Promise<Paywall>}
172
- */
173
- getPaywall({ productId, resourceId, context, billingCountryCode, includeHiddenPlans, }?: GetPaywall): Promise<Paywall>;
174
- /**
175
- * Get a list of coupons
176
- *
177
- * @returns {Promise<Coupon[]>}
178
- */
179
- getCoupons(): Promise<Coupon[]>;
180
- /**
181
- * Get a customer
182
- *
183
- * @returns {Promise<Customer>}
184
- */
185
- getCustomer(): Promise<Customer>;
186
- /**
187
- * Get a customer portal
188
- *
189
- * @returns {Promise<CustomerPortal>}
190
- */
191
- getCustomerPortal({ resourceId, productId }?: GetCustomerPortal): Promise<CustomerPortal>;
192
- /**
193
- * Get customer checkout details
194
- * @param {GetCheckoutState} parameters
195
- * @returns {Promise<GetCheckoutStateResults>}
196
- */
197
- getCheckoutState({ planId, resourceId, billingCountryCode, }: GetCheckoutState): Promise<GetCheckoutStateResults>;
198
- /**
199
- * Apply subscription changes for a customer
200
- * Update\Provision a subscription for a customer according to the given subscription input
201
- * @param {ApplySubscription} parameters
202
- * @returns {Promise<ApplySubscriptionResults>}
203
- */
204
- applySubscription(applySubscriptionInput: ApplySubscription): Promise<ApplySubscriptionResults>;
205
- /**
206
- * Fetch customer usage history of a feature.
207
- * @return {Promise<UsageHistoryPoint[]>} Array of usage history as data points.
208
- * @param fetchUsageHistory
209
- */
210
- fetchUsageHistory(fetchUsageHistory: FetchUsageHistory): Promise<UsageHistoryPoint[] | undefined>;
211
- /**
212
- * Get a list of entitlements
213
- * @deprecated Use getEntitlementsState instead.
214
- * @returns {Promise<Entitlement[]>}
215
- */
216
- getEntitlements(resourceId?: string): Promise<Entitlement[]>;
217
- /**
218
- * Get a list of entitlements alongside an access denied reason if applicable.
219
- *
220
- * @returns {Promise<EntitlementsState>}
221
- */
222
- getEntitlementsState(resourceId?: string): Promise<EntitlementsState>;
223
- /**
224
- * Estimate subscription
225
- * @return {Promise<SubscriptionPreview>} Preview of the subscription.
226
- * @param {EstimateSubscription} estimateSubscription
227
- */
228
- estimateSubscription(estimateSubscription: EstimateSubscription): Promise<SubscriptionPreview>;
229
- /**
230
- * Estimate subscription update
231
- * @return {Promise<SubscriptionPreview>} Preview of the subscription.
232
- * @param {EstimateSubscriptionUpdate} estimateSubscriptionUpdate
233
- */
234
- estimateSubscriptionUpdate(estimateSubscriptionUpdate: EstimateSubscriptionUpdate): Promise<SubscriptionPreview>;
235
- /**
236
- * Preview the subscription next invoice
237
- * @return {Promise<SubscriptionInvoicePreviewFragment>} Preview of the next invoice.
238
- * @param {PreviewNextInvoice} previewNextInvoice
239
- */
240
- previewNextInvoice(previewNextInvoice: PreviewNextInvoice): Promise<SubscriptionInvoicePreviewFragment>;
241
- /**
242
- * Preview subscription provisioning\updates
243
- * @return {Promise<SubscriptionPreviewV2>} Preview of the subscription.
244
- * @param {PreviewSubscription} previewSubscription
245
- */
246
- previewSubscription(previewSubscription: PreviewSubscription): Promise<SubscriptionPreviewV2>;
247
- /**
248
- * Get customer usage history of a feature.
249
- */
250
- getUsageHistoryV2(input: UsageHistoryV2Input): Promise<UsageHistoryV2Fragment>;
251
- /**
252
- * Waits for a subscription to be activated after a completed checkout.
253
- * This method should be called on page load after the customer is redirected to the success URL.
254
- * Returns the new subscription.
255
- *
256
- * @returns {Promise<Subscription | null>}
257
- * @param timeoutMs
258
- * @param refreshOnComplete should refresh entitlements if subscription was found
259
- */
260
- waitForCheckoutCompleted({ timeoutMs, refreshOnComplete, }?: WaitForCheckoutCompleted): Promise<Subscription | null>;
261
- getSubscriptions(params?: GetSubscriptionsParams): Promise<GetSubscriptionsResult>;
262
- getActiveSubscriptions({ resourceId }?: GetActiveSubscriptions): Promise<Subscription[]>;
263
- /**
264
- * @description Get customer's active subscriptions, for extended subscription data use {@link getSubscription}
265
- * @return {Promise<SlimSubscriptionFragmentV2Fragment[]>} List of active subscriptions
266
- * @param resourceId - optional resource id, if not provided global resources will be fetched.
267
- */
268
- getActiveSubscriptionsList({ resourceId }?: GetActiveSubscriptions): Promise<SlimSubscriptionFragmentV2Fragment[]>;
269
- /**
270
- * Get subscription
271
- * @return {Promise<Subscription>} the subscription data
272
- * @param subscriptionId - subscription id
273
- */
274
- getSubscription({ subscriptionId }: GetSubscription): Promise<Subscription>;
275
- getCreditUsage(input: GetCreditUsageInput): Promise<CreditUsageFragment>;
276
- /**
277
- * Get credit balance
278
- * @return {Promise<CreditsBalanceSummaryFragment>} the credit balance data
279
- * @param input - the input for the credit balance
280
- */
281
- getCreditBalance(input?: GetCreditBalanceInput): Promise<CreditsBalanceSummaryFragment>;
282
- /**
283
- * Get credit grants
284
- * @return {Promise<GetCreditGrantsResult>} paginated result of the credit grants data
285
- * @param input - the input for the credit grants
286
- */
287
- getCreditGrants(input: GetCreditGrantsInput): Promise<GetCreditGrantsResult>;
288
- /**
289
- * Get credit ledger
290
- * @return {Promise<GetCreditLedgerResult>} paginated result of the credit ledger data
291
- * @param input - the input for the credit ledger
292
- */
293
- getCreditLedger(input?: GetCreditLedgerInput): Promise<GetCreditLedgerResult>;
294
- /**
295
- * Create payment session
296
- * @return {Promise<PaymentSessionFragment>} the payment session data
297
- * @param input - the input for the payment session
298
- */
299
- createPaymentSession(input: CreatePaymentSessionInput): Promise<PaymentSessionFragment>;
300
- /**
301
- * Get automatic recharge configuration
302
- * @return {Promise<AutomaticRechargeConfiguration>} the automatic recharge configuration
303
- * @param input - the input for getting automatic recharge configuration
304
- */
305
- getAutomaticRechargeConfiguration(input: GetAutomaticRechargeConfigurationInput): Promise<AutomaticRechargeConfiguration>;
306
- /**
307
- * Save automatic recharge configuration
308
- * @return {Promise<AutomaticRechargeConfiguration>} the saved automatic recharge configuration
309
- * @param input - the input for saving automatic recharge configuration
310
- */
311
- saveAutomaticRechargeConfiguration(input: SaveAutomaticRechargeConfigurationInput): Promise<AutomaticRechargeConfiguration>;
312
- }
@@ -1,2 +0,0 @@
1
- export { OfflineStigg } from './offlineClient';
2
- export { Stigg, StiggClient } from './client';