@stigg/js-client-sdk 2.2.0 → 2.4.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
@@ -350,6 +350,18 @@ export declare type EstimateSubscriptionUpdate = {
350
350
  addons?: SubscriptionEstimationAddon[];
351
351
  promotionCode?: string;
352
352
  };
353
+ export declare type FetchUsageHistory = {
354
+ customerId: string;
355
+ resourceId?: string;
356
+ featureId: string;
357
+ startDate: Date;
358
+ endDate?: Date;
359
+ };
360
+ export declare type UsageHistoryPoint = {
361
+ date: Date;
362
+ value: number;
363
+ isResetPoint: boolean;
364
+ };
353
365
  /** @hidden */
354
366
  export declare class CustomerModel implements Customer {
355
367
  id: string;
@@ -1,10 +1,12 @@
1
1
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { GetCustomerPortalByRefIdQuery, GetCustomerByIdQuery, GetActiveSubscriptionsQuery } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { GetCustomerPortalByRefIdQuery, GetCustomerByIdQuery, GetActiveSubscriptionsQuery, UsageHistoryQuery } from '@stigg/api-client-js/src/generated/sdk';
3
+ import { FetchUsageHistory } from '../models';
3
4
  declare class CustomersApi {
4
5
  private readonly client;
5
6
  constructor(client: ApolloClient<NormalizedCacheObject>);
6
7
  getCustomer(customerId: string): Promise<import("@apollo/client/core").ApolloQueryResult<GetCustomerByIdQuery>>;
7
8
  getActiveSubscriptions(customerId: string, resourceId?: string): Promise<import("@apollo/client/core").ApolloQueryResult<GetActiveSubscriptionsQuery>>;
8
9
  getCustomerPortal(customerId: string, resourceId: string | undefined): Promise<import("@apollo/client/core").ApolloQueryResult<GetCustomerPortalByRefIdQuery>>;
10
+ fetchUsageHistory({ customerId, resourceId, endDate, startDate, featureId }: FetchUsageHistory): Promise<import("@apollo/client/core").ApolloQueryResult<UsageHistoryQuery>>;
9
11
  }
10
12
  export default CustomersApi;
@@ -1,4 +1,4 @@
1
- import { BooleanEntitlement, Coupon, Customer, Entitlement, GetBooleanEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Subscription, WaitForCheckoutCompleted, CustomerPortal, Paywall, EstimateSubscription, SubscriptionPreview, EstimateSubscriptionUpdate, GetCustomerPortal, GetActiveSubscriptions } from './models';
1
+ import { BooleanEntitlement, Coupon, Customer, Entitlement, GetBooleanEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Subscription, WaitForCheckoutCompleted, CustomerPortal, Paywall, EstimateSubscription, SubscriptionPreview, EstimateSubscriptionUpdate, GetCustomerPortal, GetActiveSubscriptions, FetchUsageHistory, UsageHistoryPoint } from './models';
2
2
  import { ClientConfiguration } from './configuration';
3
3
  import { EventNames, Events } from './services/eventEmitter';
4
4
  export interface StiggClient {
@@ -144,6 +144,12 @@ export declare class Stigg implements StiggClient {
144
144
  * @returns {Promise<CustomerPortal>}
145
145
  */
146
146
  getCustomerPortal({ resourceId }?: GetCustomerPortal): Promise<CustomerPortal>;
147
+ /**
148
+ * Fetch customer usage history of a feature.
149
+ * @return {Promise<UsageHistoryPoint[]>} Array of usage history as data points.
150
+ * @param fetchUsageHistory
151
+ */
152
+ fetchUsageHistory(fetchUsageHistory: FetchUsageHistory): Promise<UsageHistoryPoint[] | undefined>;
147
153
  /**
148
154
  * Get a list of entitlements
149
155
  *
@@ -350,6 +350,18 @@ export declare type EstimateSubscriptionUpdate = {
350
350
  addons?: SubscriptionEstimationAddon[];
351
351
  promotionCode?: string;
352
352
  };
353
+ export declare type FetchUsageHistory = {
354
+ customerId: string;
355
+ resourceId?: string;
356
+ featureId: string;
357
+ startDate: Date;
358
+ endDate?: Date;
359
+ };
360
+ export declare type UsageHistoryPoint = {
361
+ date: Date;
362
+ value: number;
363
+ isResetPoint: boolean;
364
+ };
353
365
  /** @hidden */
354
366
  export declare class CustomerModel implements Customer {
355
367
  id: string;
@@ -1,5 +1,5 @@
1
- import { CustomerFragment, EntitlementFragment, GetPaywallQuery, SubscriptionFragment, SubscriptionPreviewFragment, EntitlementCheckResult, GetCouponsQuery, GetMockPaywallQuery, CustomerResourceFragment, CustomerPortalFragment } from '@stigg/api-client-js/src/generated/sdk';
2
- import { BooleanEntitlement, BooleanEntitlementFallback, Coupon, Customer, CustomerPortal, CustomerResource, MeteredEntitlement, MeteredEntitlementFallback, Money, NumericEntitlement, NumericEntitlementFallback, Paywall, Plan, Subscription, SubscriptionPreview, SubscriptionPreviewDiscount } from '../models';
1
+ import { CustomerFragment, EntitlementFragment, GetPaywallQuery, SubscriptionFragment, SubscriptionPreviewFragment, EntitlementCheckResult, GetCouponsQuery, GetMockPaywallQuery, CustomerResourceFragment, CustomerPortalFragment, UsageHistoryFragment } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { BooleanEntitlement, BooleanEntitlementFallback, Coupon, Customer, CustomerPortal, CustomerResource, MeteredEntitlement, MeteredEntitlementFallback, Money, NumericEntitlement, NumericEntitlementFallback, Paywall, Plan, Subscription, SubscriptionPreview, SubscriptionPreviewDiscount, UsageHistoryPoint } from '../models';
3
3
  import CachedEntitlement from '../services/cachedEntitlement';
4
4
  import { Decision } from '../services/entitlementDecisionService';
5
5
  export declare class ModelMapper {
@@ -42,4 +42,5 @@ export declare class ModelMapper {
42
42
  mapSubscriptions(activeSubscriptions: Array<{
43
43
  __typename?: 'CustomerSubscription';
44
44
  } & SubscriptionFragment>): Subscription[];
45
+ mapUsageHistory(usageHistory: UsageHistoryFragment): UsageHistoryPoint[];
45
46
  }
@@ -1,5 +1,5 @@
1
- import { CustomerFragment, EntitlementFragment, GetPaywallQuery, SubscriptionFragment, SubscriptionPreviewFragment, EntitlementCheckResult, GetCouponsQuery, GetMockPaywallQuery, CustomerResourceFragment, CustomerPortalFragment } from '@stigg/api-client-js/src/generated/sdk';
2
- import { BooleanEntitlement, BooleanEntitlementFallback, Coupon, Customer, CustomerPortal, CustomerResource, MeteredEntitlement, MeteredEntitlementFallback, Money, NumericEntitlement, NumericEntitlementFallback, Paywall, Plan, Subscription, SubscriptionPreview, SubscriptionPreviewDiscount } from '../models';
1
+ import { CustomerFragment, EntitlementFragment, GetPaywallQuery, SubscriptionFragment, SubscriptionPreviewFragment, EntitlementCheckResult, GetCouponsQuery, GetMockPaywallQuery, CustomerResourceFragment, CustomerPortalFragment, UsageHistoryFragment } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { BooleanEntitlement, BooleanEntitlementFallback, Coupon, Customer, CustomerPortal, CustomerResource, MeteredEntitlement, MeteredEntitlementFallback, Money, NumericEntitlement, NumericEntitlementFallback, Paywall, Plan, Subscription, SubscriptionPreview, SubscriptionPreviewDiscount, UsageHistoryPoint } from '../models';
3
3
  import CachedEntitlement from '../services/cachedEntitlement';
4
4
  import { Decision } from '../services/entitlementDecisionService';
5
5
  export declare class ModelMapper {
@@ -42,4 +42,5 @@ export declare class ModelMapper {
42
42
  mapSubscriptions(activeSubscriptions: Array<{
43
43
  __typename?: 'CustomerSubscription';
44
44
  } & SubscriptionFragment>): Subscription[];
45
+ mapUsageHistory(usageHistory: UsageHistoryFragment): UsageHistoryPoint[];
45
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigg/js-client-sdk",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Stigg client-side SDK for Browser",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@apollo/client": "^3.4.17",
30
30
  "@sentry/browser": "^7.11.1",
31
- "@stigg/api-client-js": "0.455.1",
31
+ "@stigg/api-client-js": "0.466.0",
32
32
  "cross-fetch": "^3.1.6",
33
33
  "fetch-retry": "^5.0.6",
34
34
  "husky": "^7.0.4",