@stigg/js-client-sdk 0.37.0 → 0.39.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.
@@ -1,8 +1,10 @@
1
1
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
+ import SdkConfigurationApi from './SdkConfigurationApi';
2
3
  import PaywallApi from './PaywallApi';
3
4
  import CustomersApi from './CustomersApi';
4
5
  import CouponsApi from './CouponsApi';
5
6
  declare class ApiGateway {
7
+ sdkConfiguration: SdkConfigurationApi;
6
8
  paywall: PaywallApi;
7
9
  customers: CustomersApi;
8
10
  coupons: CouponsApi;
@@ -0,0 +1,10 @@
1
+ import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
+ declare class SdkConfigurationApi {
3
+ private readonly client;
4
+ constructor(client: ApolloClient<NormalizedCacheObject>);
5
+ getSdkConfiguration(): Promise<{
6
+ __typename?: "SdkConfiguration" | undefined;
7
+ sentryDsn?: string | null | undefined;
8
+ } | null | undefined>;
9
+ }
10
+ export default SdkConfigurationApi;
@@ -45,7 +45,7 @@ export declare type AddonCreateInput = {
45
45
  billingId?: InputMaybe<Scalars['String']>;
46
46
  description?: InputMaybe<Scalars['String']>;
47
47
  displayName: Scalars['String'];
48
- environmentId: Scalars['String'];
48
+ environmentId?: InputMaybe<Scalars['String']>;
49
49
  productId: Scalars['String'];
50
50
  refId?: InputMaybe<Scalars['String']>;
51
51
  status?: InputMaybe<PackageStatus>;
@@ -126,7 +126,7 @@ export declare type ArchiveCouponInput = {
126
126
  refId: Scalars['String'];
127
127
  };
128
128
  export declare type ArchivePlanInput = {
129
- environmentId: Scalars['String'];
129
+ environmentId?: InputMaybe<Scalars['String']>;
130
130
  id: Scalars['String'];
131
131
  };
132
132
  export declare type AttachCustomerPaymentMethodInput = {
@@ -280,7 +280,7 @@ export declare type CreateCouponInput = {
280
280
  additionalMetaData?: InputMaybe<Scalars['JSON']>;
281
281
  description?: InputMaybe<Scalars['String']>;
282
282
  discountValue: Scalars['Float'];
283
- environmentId: Scalars['String'];
283
+ environmentId?: InputMaybe<Scalars['String']>;
284
284
  name: Scalars['String'];
285
285
  refId: Scalars['String'];
286
286
  type: CouponType;
@@ -354,7 +354,9 @@ export declare type CursorPaging = {
354
354
  export declare type CustomerBillingInfo = {
355
355
  billingAddress?: InputMaybe<Address>;
356
356
  currency?: InputMaybe<Currency>;
357
+ invoiceCustomFields?: InputMaybe<Scalars['JSON']>;
357
358
  language?: InputMaybe<Scalars['String']>;
359
+ paymentMethodId?: InputMaybe<Scalars['String']>;
358
360
  shippingAddress?: InputMaybe<Address>;
359
361
  taxIds?: InputMaybe<Array<TaxExempt>>;
360
362
  timezone?: InputMaybe<Scalars['String']>;
@@ -530,19 +532,19 @@ export declare type DefaultTrialConfigInputDto = {
530
532
  duration?: InputMaybe<Scalars['Float']>;
531
533
  units?: InputMaybe<TrialPeriodUnits>;
532
534
  };
533
- export declare type DeleteOneAddonInput = {
534
- /** The id of the record to delete. */
535
+ export declare type DeleteCustomerInput = {
536
+ environmentId?: InputMaybe<Scalars['String']>;
535
537
  id: Scalars['String'];
536
538
  };
537
- export declare type DeleteOneCustomerInput = {
538
- /** The id of the record to delete. */
539
+ export declare type DeleteFeatureInput = {
540
+ environmentId?: InputMaybe<Scalars['String']>;
539
541
  id: Scalars['String'];
540
542
  };
541
- export declare type DeleteOneEnvironmentInput = {
543
+ export declare type DeleteOneAddonInput = {
542
544
  /** The id of the record to delete. */
543
545
  id: Scalars['String'];
544
546
  };
545
- export declare type DeleteOneFeatureInput = {
547
+ export declare type DeleteOneEnvironmentInput = {
546
548
  /** The id of the record to delete. */
547
549
  id: Scalars['String'];
548
550
  };
@@ -638,6 +640,8 @@ export declare enum ErrorCode {
638
640
  ArchivedCouponCantBeApplied = "ArchivedCouponCantBeApplied",
639
641
  BadUserInput = "BadUserInput",
640
642
  BillingPeriodMissingError = "BillingPeriodMissingError",
643
+ CannotDeleteCustomerError = "CannotDeleteCustomerError",
644
+ CannotDeleteFeatureError = "CannotDeleteFeatureError",
641
645
  CheckoutIsNotSupported = "CheckoutIsNotSupported",
642
646
  CouponNotFound = "CouponNotFound",
643
647
  CustomerHasNoPaymentMethod = "CustomerHasNoPaymentMethod",
@@ -661,6 +665,7 @@ export declare enum ErrorCode {
661
665
  InvalidMemberDelete = "InvalidMemberDelete",
662
666
  InvalidQuantity = "InvalidQuantity",
663
667
  InvalidSubscriptionStatus = "InvalidSubscriptionStatus",
668
+ InvalidUpdatePriceUnitAmountError = "InvalidUpdatePriceUnitAmountError",
664
669
  InvalidUsageValueForIncrementalFeatureError = "InvalidUsageValueForIncrementalFeatureError",
665
670
  MemberInvitationError = "MemberInvitationError",
666
671
  MemberNotFound = "MemberNotFound",
@@ -698,8 +703,10 @@ export declare enum EventLogType {
698
703
  CouponArchived = "COUPON_ARCHIVED",
699
704
  CouponCreated = "COUPON_CREATED",
700
705
  CouponUpdated = "COUPON_UPDATED",
706
+ CreateSubscriptionFailed = "CREATE_SUBSCRIPTION_FAILED",
701
707
  CustomerCreated = "CUSTOMER_CREATED",
702
708
  CustomerDeleted = "CUSTOMER_DELETED",
709
+ CustomerPaymentFailed = "CUSTOMER_PAYMENT_FAILED",
703
710
  CustomerUpdated = "CUSTOMER_UPDATED",
704
711
  EntitlementsUpdated = "ENTITLEMENTS_UPDATED",
705
712
  EntitlementDenied = "ENTITLEMENT_DENIED",
@@ -728,7 +735,8 @@ export declare enum EventLogType {
728
735
  SubscriptionTrialExpired = "SUBSCRIPTION_TRIAL_EXPIRED",
729
736
  SubscriptionTrialStarted = "SUBSCRIPTION_TRIAL_STARTED",
730
737
  SubscriptionUpdated = "SUBSCRIPTION_UPDATED",
731
- SubscriptionUsageUpdated = "SUBSCRIPTION_USAGE_UPDATED"
738
+ SubscriptionUsageUpdated = "SUBSCRIPTION_USAGE_UPDATED",
739
+ SyncFailed = "SYNC_FAILED"
732
740
  }
733
741
  export declare type FeatureFilter = {
734
742
  and?: InputMaybe<Array<FeatureFilter>>;
@@ -936,6 +944,7 @@ export declare type InitiateCheckoutInput = {
936
944
  environmentId?: InputMaybe<Scalars['String']>;
937
945
  planId: Scalars['String'];
938
946
  successUrl: Scalars['String'];
947
+ unitQuantity?: InputMaybe<Scalars['Int']>;
939
948
  };
940
949
  export declare type IntFieldComparison = {
941
950
  between?: InputMaybe<IntFieldComparisonBetween>;
@@ -1198,7 +1207,7 @@ export declare type PlanCreateInput = {
1198
1207
  billingId?: InputMaybe<Scalars['String']>;
1199
1208
  description?: InputMaybe<Scalars['String']>;
1200
1209
  displayName: Scalars['String'];
1201
- environmentId: Scalars['String'];
1210
+ environmentId?: InputMaybe<Scalars['String']>;
1202
1211
  parentPlanId?: InputMaybe<Scalars['String']>;
1203
1212
  productId: Scalars['String'];
1204
1213
  refId?: InputMaybe<Scalars['String']>;
@@ -1527,6 +1536,10 @@ export declare enum SortNulls {
1527
1536
  NullsFirst = "NULLS_FIRST",
1528
1537
  NullsLast = "NULLS_LAST"
1529
1538
  }
1539
+ export declare enum SourceType {
1540
+ JsClientSdk = "JS_CLIENT_SDK",
1541
+ NodeServerSdk = "NODE_SERVER_SDK"
1542
+ }
1530
1543
  export declare type StringFieldComparison = {
1531
1544
  eq?: InputMaybe<Scalars['String']>;
1532
1545
  gt?: InputMaybe<Scalars['String']>;
@@ -1633,6 +1646,9 @@ export declare enum SubscriptionAddonSortFields {
1633
1646
  Quantity = "quantity",
1634
1647
  UpdatedAt = "updatedAt"
1635
1648
  }
1649
+ export declare type SubscriptionBillingInfo = {
1650
+ taxRateIds?: InputMaybe<Array<Scalars['String']>>;
1651
+ };
1636
1652
  /** Subscription cancellation status */
1637
1653
  export declare enum SubscriptionCancelReason {
1638
1654
  CancelledByBilling = "CancelledByBilling",
@@ -1663,7 +1679,7 @@ export declare type SubscriptionCancelReasonFilterComparison = {
1663
1679
  };
1664
1680
  export declare type SubscriptionCancellationInput = {
1665
1681
  endDate?: InputMaybe<Scalars['DateTime']>;
1666
- environmentId: Scalars['String'];
1682
+ environmentId?: InputMaybe<Scalars['String']>;
1667
1683
  subscriptionCancellationTime?: InputMaybe<SubscriptionCancellationTime>;
1668
1684
  subscriptionRefId: Scalars['String'];
1669
1685
  };
@@ -1686,12 +1702,13 @@ export declare type SubscriptionInput = {
1686
1702
  addons?: InputMaybe<Array<SubscriptionAddonInput>>;
1687
1703
  awaitPaymentConfirmation?: InputMaybe<Scalars['Boolean']>;
1688
1704
  billingId?: InputMaybe<Scalars['String']>;
1705
+ billingInformation?: InputMaybe<SubscriptionBillingInfo>;
1689
1706
  billingPeriod?: InputMaybe<BillingPeriod>;
1690
1707
  crmId?: InputMaybe<Scalars['String']>;
1691
1708
  currentBillingPeriodEnd?: InputMaybe<Scalars['DateTime']>;
1692
1709
  customerId: Scalars['String'];
1693
1710
  endDate?: InputMaybe<Scalars['DateTime']>;
1694
- environmentId: Scalars['String'];
1711
+ environmentId?: InputMaybe<Scalars['String']>;
1695
1712
  isCustomPriceSubscription?: InputMaybe<Scalars['Boolean']>;
1696
1713
  isOverridingTrialConfig?: InputMaybe<Scalars['Boolean']>;
1697
1714
  isTrial?: InputMaybe<Scalars['Boolean']>;
@@ -1967,6 +1984,7 @@ export declare type UpdateSubscriptionInput = {
1967
1984
  additionalMetaData?: InputMaybe<Scalars['JSON']>;
1968
1985
  environmentId?: InputMaybe<Scalars['String']>;
1969
1986
  refId: Scalars['String'];
1987
+ unitQuantity?: InputMaybe<Scalars['Float']>;
1970
1988
  };
1971
1989
  export declare type UsageHistoryInput = {
1972
1990
  customerRefId: Scalars['String'];
@@ -2440,6 +2458,16 @@ export declare type GetPlansQuery = {
2440
2458
  }>;
2441
2459
  };
2442
2460
  };
2461
+ export declare type SdkConfigurationQueryVariables = Exact<{
2462
+ [key: string]: never;
2463
+ }>;
2464
+ export declare type SdkConfigurationQuery = {
2465
+ __typename?: 'Query';
2466
+ sdkConfiguration?: {
2467
+ __typename?: 'SdkConfiguration';
2468
+ sentryDsn?: string | null | undefined;
2469
+ } | null | undefined;
2470
+ };
2443
2471
  export declare type PriceFragment = {
2444
2472
  __typename?: 'Price';
2445
2473
  billingModel: BillingModel;
package/dist/client.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Customer, Entitlement, Plan, BooleanEntitlement, NumericEntitlement, MeteredEntitlement, GetBooleanEntitlement, GetNumericEntitlement, GetMeteredEntitlement, GetPaywall, Coupon } from './models';
1
+ import { BooleanEntitlement, Coupon, Customer, Entitlement, GetBooleanEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Plan, Subscription, WaitForCheckoutCompleted } from './models';
2
2
  import { ClientConfiguration } from './configuration';
3
3
  export interface StiggClient {
4
+ isCustomerLoaded: boolean;
4
5
  getBooleanEntitlement: (params: GetBooleanEntitlement) => BooleanEntitlement;
5
6
  getNumericEntitlement: (params: GetNumericEntitlement) => NumericEntitlement;
6
7
  getMeteredEntitlement: (params: GetMeteredEntitlement) => MeteredEntitlement;
@@ -9,6 +10,7 @@ export interface StiggClient {
9
10
  getCustomer: () => Promise<Customer>;
10
11
  getEntitlements: () => Promise<Entitlement[]>;
11
12
  refresh: () => Promise<void>;
13
+ waitForCheckoutCompleted(params?: WaitForCheckoutCompleted): Promise<Subscription | null>;
12
14
  }
13
15
  export declare class Stigg implements StiggClient {
14
16
  private readonly apiGateway;
@@ -26,6 +28,8 @@ export declare class Stigg implements StiggClient {
26
28
  * @returns The new client instance.
27
29
  */
28
30
  static initialize(configuration: ClientConfiguration): Promise<StiggClient | null>;
31
+ private static initializeSdk;
32
+ get isCustomerLoaded(): boolean;
29
33
  /**
30
34
  * Set the customer ID, usually after the customer signs in or restores a session
31
35
  */
@@ -78,5 +82,14 @@ export declare class Stigg implements StiggClient {
78
82
  * @returns {Promise<Entitlement[]>}
79
83
  */
80
84
  getEntitlements(): Promise<Entitlement[]>;
81
- private withErrorHandling;
85
+ /**
86
+ * Waits for a subscription to be activated after a completed checkout.
87
+ * This method should be called on page load after the customer is redirected to the success URL.
88
+ * Returns the new subscription.
89
+ *
90
+ * @returns {Promise<Subscription | null>}
91
+ * @param timeoutMs
92
+ * @param refreshOnComplete should refresh entitlements if subscription was found
93
+ */
94
+ waitForCheckoutCompleted({ timeoutMs, refreshOnComplete, }?: WaitForCheckoutCompleted): Promise<Subscription | null>;
82
95
  }
@@ -1,4 +1,7 @@
1
+ import { SourceType } from './api/generated/types';
1
2
  import { LogConfiguration, LoggerService } from './services/loggerService';
3
+ export declare const SDK_SOURCE_TYPE = SourceType.JsClientSdk;
4
+ export declare const SDK_NAME = "js-client-sdk";
2
5
  export declare type ClientConfiguration = {
3
6
  apiKey: string;
4
7
  baseUri?: string;