@stigg/js-client-sdk 3.18.0 → 3.20.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
@@ -146,6 +146,9 @@ export declare type GetPaywall = {
146
146
  billingCountryCode?: string;
147
147
  includeHiddenPlans?: boolean;
148
148
  };
149
+ export declare type GetSubscription = {
150
+ subscriptionId: string;
151
+ };
149
152
  export declare type GetActiveSubscriptions = {
150
153
  resourceId?: string | string[];
151
154
  };
@@ -1,11 +1,15 @@
1
1
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { GetCustomerPortalByRefIdQuery, GetCustomerByIdQuery, GetActiveSubscriptionsQuery, GetUsageHistoryQuery } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { GetCustomerPortalByRefIdQuery, GetCustomerByIdQuery, GetActiveSubscriptionsQuery, GetActiveSubscriptionsListQuery, GetSubscriptionQuery, GetUsageHistoryQuery } from '@stigg/api-client-js/src/generated/sdk';
3
3
  import { FetchUsageHistory } from '../models';
4
+ import { EdgeApiClient } from './EdgeApiClient';
4
5
  declare class CustomersApi {
5
6
  private readonly client;
6
- constructor(client: ApolloClient<NormalizedCacheObject>);
7
+ private readonly edgeApiClient;
8
+ constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
7
9
  getCustomer(customerId: string): Promise<import("@apollo/client/core").ApolloQueryResult<GetCustomerByIdQuery>>;
8
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>>;
9
13
  getCustomerPortal(customerId: string, resourceId: string | undefined, productId: string | undefined): Promise<import("@apollo/client/core").ApolloQueryResult<GetCustomerPortalByRefIdQuery>>;
10
14
  fetchUsageHistory({ customerId, resourceId, endDate, startDate, featureId }: FetchUsageHistory): Promise<import("@apollo/client/core").ApolloQueryResult<GetUsageHistoryQuery>>;
11
15
  }
@@ -1,5 +1,5 @@
1
1
  import { ApolloQueryResult } from '@apollo/client/core';
2
- import { GetEntitlementsQuery, GetPaywallQuery, GetSdkConfigurationQuery } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { GetActiveSubscriptionsListQuery, GetEntitlementsQuery, GetPaywallQuery, GetSdkConfigurationQuery } from '@stigg/api-client-js/src/generated/sdk';
3
3
  declare type EdgeApiClientConfiguration = {
4
4
  apiKey: string;
5
5
  baseEdgeUri: string;
@@ -14,6 +14,7 @@ export declare class EdgeApiClient {
14
14
  }): EdgeApiClient | null;
15
15
  getPaywall(productId?: string, billingCountryCode?: string, includeHiddenPlans?: boolean): Promise<ApolloQueryResult<GetPaywallQuery>>;
16
16
  getEntitlements(customerId: string, resourceId: string | undefined): Promise<ApolloQueryResult<GetEntitlementsQuery>>;
17
+ getActiveSubscriptionsList(customerId: string, resourceId: string | string[] | undefined): Promise<ApolloQueryResult<GetActiveSubscriptionsListQuery>>;
17
18
  getSdkConfiguration(): Promise<ApolloQueryResult<GetSdkConfigurationQuery>>;
18
19
  private get;
19
20
  }
@@ -1,5 +1,6 @@
1
+ import { SlimSubscriptionFragmentV2Fragment } from '@stigg/api-client-js/src/generated/sdk';
1
2
  import { ClientConfiguration } from './configuration';
2
- import { BooleanEntitlement, Coupon, Customer, CustomerPortal, Entitlement, EstimateSubscription, EstimateSubscriptionUpdate, FetchUsageHistory, GetActiveSubscriptions, GetBooleanEntitlement, GetCheckoutStateResults, GetCheckoutState, GetCustomerPortal, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Paywall, Subscription, SubscriptionPreview, UsageHistoryPoint, WaitForCheckoutCompleted, ApplySubscription, ApplySubscriptionResults, PreviewSubscription, SubscriptionPreviewV2 } 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 } from './models';
3
4
  import { EventNames, Events } from './services/eventEmitter';
4
5
  export interface StiggClient {
5
6
  isCustomerLoaded: boolean;
@@ -18,6 +19,8 @@ export interface StiggClient {
18
19
  getCheckoutState: (params: GetCheckoutState) => Promise<GetCheckoutStateResults>;
19
20
  applySubscription: (params: ApplySubscription) => Promise<ApplySubscriptionResults>;
20
21
  getActiveSubscriptions: (params?: GetActiveSubscriptions) => Promise<Subscription[]>;
22
+ getActiveSubscriptionsList(params?: GetActiveSubscriptions): Promise<SlimSubscriptionFragmentV2Fragment[]>;
23
+ getSubscription(params: GetSubscription): Promise<Subscription>;
21
24
  getCoupons(): Promise<Coupon[]>;
22
25
  getEntitlements: (resourceId?: string) => Promise<Entitlement[]>;
23
26
  refresh: () => Promise<void>;
@@ -202,4 +205,16 @@ export declare class Stigg implements StiggClient {
202
205
  */
203
206
  waitForCheckoutCompleted({ timeoutMs, refreshOnComplete, }?: WaitForCheckoutCompleted): Promise<Subscription | null>;
204
207
  getActiveSubscriptions({ resourceId }?: GetActiveSubscriptions): Promise<Subscription[]>;
208
+ /**
209
+ * @description Get customer's active subscriptions, for extended subscription data use {@link getSubscription}
210
+ * @return {Promise<SlimSubscriptionFragmentV2Fragment[]>} List of active subscriptions
211
+ * @param resourceId - optional resource id, if not provided global resources will be fetched.
212
+ */
213
+ getActiveSubscriptionsList({ resourceId }?: GetActiveSubscriptions): Promise<SlimSubscriptionFragmentV2Fragment[]>;
214
+ /**
215
+ * Get subscription
216
+ * @return {Promise<Subscription>} the subscription data
217
+ * @param subscriptionId - subscription id
218
+ */
219
+ getSubscription({ subscriptionId }: GetSubscription): Promise<Subscription>;
205
220
  }
@@ -146,6 +146,9 @@ export declare type GetPaywall = {
146
146
  billingCountryCode?: string;
147
147
  includeHiddenPlans?: boolean;
148
148
  };
149
+ export declare type GetSubscription = {
150
+ subscriptionId: string;
151
+ };
149
152
  export declare type GetActiveSubscriptions = {
150
153
  resourceId?: string | string[];
151
154
  };
@@ -25,7 +25,7 @@ export declare class ModelMapper {
25
25
  private mapCompatibleAddons;
26
26
  private mapPackageEntitlement;
27
27
  private mapPromotionalEntitlement;
28
- private mapSubscription;
28
+ mapSubscription(subscription: SubscriptionFragment): Subscription;
29
29
  private mapLatestInvoice;
30
30
  private mapDate;
31
31
  private mapAddon;
@@ -25,7 +25,7 @@ export declare class ModelMapper {
25
25
  private mapCompatibleAddons;
26
26
  private mapPackageEntitlement;
27
27
  private mapPromotionalEntitlement;
28
- private mapSubscription;
28
+ mapSubscription(subscription: SubscriptionFragment): Subscription;
29
29
  private mapLatestInvoice;
30
30
  private mapDate;
31
31
  private mapAddon;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigg/js-client-sdk",
3
- "version": "3.18.0",
3
+ "version": "3.20.0",
4
4
  "description": "Stigg client-side SDK for Browser",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@apollo/client": "^3.4.17",
30
30
  "@sentry/browser": "^7.11.1",
31
- "@stigg/api-client-js": "1.222.0",
31
+ "@stigg/api-client-js": "1.233.0",
32
32
  "cross-fetch": "^3.1.6",
33
33
  "fetch-retry": "^5.0.6",
34
34
  "husky": "^7.0.4",