@stigg/js-client-sdk 1.13.2 → 1.14.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.
@@ -3,6 +3,7 @@ import SdkConfigurationApi from './SdkConfigurationApi';
3
3
  import PaywallApi from './PaywallApi';
4
4
  import CustomersApi from './CustomersApi';
5
5
  import CouponsApi from './CouponsApi';
6
+ import SubscriptionEstimationsApi from './SubscriptionEstimationsApi';
6
7
  import MockPaywallApi from './MockPaywallApi';
7
8
  import { EdgeApiClient } from './EdgeApiClient';
8
9
  declare class ApiGateway {
@@ -11,6 +12,7 @@ declare class ApiGateway {
11
12
  mockPaywall: MockPaywallApi;
12
13
  customers: CustomersApi;
13
14
  coupons: CouponsApi;
15
+ subscriptionEstimations: SubscriptionEstimationsApi;
14
16
  constructor(client: ApolloClient<NormalizedCacheObject>, edgeApiClient: EdgeApiClient | null);
15
17
  }
16
18
  export default ApiGateway;
@@ -1,7 +1,7 @@
1
+ import { GetPaywallQuery } from '@stigg/api-client-js/src/generated/sdk';
1
2
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
3
  import { WidgetType } from './generated/types';
3
4
  import { EdgeApiClient } from './EdgeApiClient';
4
- import { GetPaywallQuery } from '@stigg/api-client-js/src/generated/sdk';
5
5
  export declare const TYPOGRAPHY_CONFIGURATION: import("graphql/language/ast").DocumentNode;
6
6
  export declare const PAYWALL_CONFIGURATION: import("graphql/language/ast").DocumentNode;
7
7
  export declare type GetPaywallProps = {
@@ -0,0 +1,10 @@
1
+ import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
+ import { EstimateSubscription, EstimateSubscriptionUpdate } from '../models';
3
+ import { EstimateSubscriptionMutation, EstimateSubscriptionUpdateMutation } 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
+ }
10
+ export default SubscriptionEstimationsApi;
@@ -770,6 +770,17 @@ export declare type DiscardPackageDraftInput = {
770
770
  environmentId: Scalars['String'];
771
771
  refId: Scalars['String'];
772
772
  };
773
+ /** The type of the discount duration */
774
+ export declare enum DiscountDurationType {
775
+ Forever = "FOREVER",
776
+ Once = "ONCE",
777
+ Repeating = "REPEATING"
778
+ }
779
+ /** The type of the discount */
780
+ export declare enum DiscountType {
781
+ Fixed = "FIXED",
782
+ Percentage = "PERCENTAGE"
783
+ }
773
784
  export declare type EntitlementCheckRequested = {
774
785
  customerId: Scalars['String'];
775
786
  entitlementCheckResult: EntitlementCheckResult;
@@ -1279,6 +1290,7 @@ export declare type InitiateCheckoutInput = {
1279
1290
  addons?: InputMaybe<Array<SubscriptionAddonInput>>;
1280
1291
  allowPromoCodes?: InputMaybe<Scalars['Boolean']>;
1281
1292
  allowTaxIdCollection?: InputMaybe<Scalars['Boolean']>;
1293
+ billingCountryCode?: InputMaybe<Scalars['String']>;
1282
1294
  billingPeriod: BillingPeriod;
1283
1295
  cancelUrl: Scalars['String'];
1284
1296
  collectBillingAddress?: InputMaybe<Scalars['Boolean']>;
@@ -1882,12 +1894,14 @@ export declare type ProvisionCustomerSubscriptionInput = {
1882
1894
  additionalMetaData?: InputMaybe<Scalars['JSON']>;
1883
1895
  addons?: InputMaybe<Array<SubscriptionAddonInput>>;
1884
1896
  awaitPaymentConfirmation?: InputMaybe<Scalars['Boolean']>;
1897
+ billingCountryCode?: InputMaybe<Scalars['String']>;
1885
1898
  billingInformation?: InputMaybe<SubscriptionBillingInfo>;
1886
1899
  billingPeriod?: InputMaybe<BillingPeriod>;
1887
1900
  planId: Scalars['String'];
1888
1901
  priceUnitAmount?: InputMaybe<Scalars['Float']>;
1889
1902
  promotionCode?: InputMaybe<Scalars['String']>;
1890
1903
  refId?: InputMaybe<Scalars['String']>;
1904
+ resourceId?: InputMaybe<Scalars['String']>;
1891
1905
  startDate?: InputMaybe<Scalars['DateTime']>;
1892
1906
  subscriptionId?: InputMaybe<Scalars['String']>;
1893
1907
  };
@@ -1895,6 +1909,7 @@ export declare type ProvisionSubscription = {
1895
1909
  additionalMetaData?: InputMaybe<Scalars['JSON']>;
1896
1910
  addons?: InputMaybe<Array<SubscriptionAddonInput>>;
1897
1911
  awaitPaymentConfirmation?: InputMaybe<Scalars['Boolean']>;
1912
+ billingCountryCode?: InputMaybe<Scalars['String']>;
1898
1913
  billingInformation?: InputMaybe<SubscriptionBillingInfo>;
1899
1914
  billingPeriod?: InputMaybe<BillingPeriod>;
1900
1915
  checkoutOptions?: InputMaybe<CheckoutOptions>;
@@ -1903,6 +1918,7 @@ export declare type ProvisionSubscription = {
1903
1918
  priceUnitAmount?: InputMaybe<Scalars['Float']>;
1904
1919
  promotionCode?: InputMaybe<Scalars['String']>;
1905
1920
  refId?: InputMaybe<Scalars['String']>;
1921
+ resourceId?: InputMaybe<Scalars['String']>;
1906
1922
  skipTrial?: InputMaybe<Scalars['Boolean']>;
1907
1923
  startDate?: InputMaybe<Scalars['DateTime']>;
1908
1924
  subscriptionId?: InputMaybe<Scalars['String']>;
@@ -1911,6 +1927,7 @@ export declare type ProvisionSubscriptionInput = {
1911
1927
  additionalMetaData?: InputMaybe<Scalars['JSON']>;
1912
1928
  addons?: InputMaybe<Array<SubscriptionAddonInput>>;
1913
1929
  awaitPaymentConfirmation?: InputMaybe<Scalars['Boolean']>;
1930
+ billingCountryCode?: InputMaybe<Scalars['String']>;
1914
1931
  billingInformation?: InputMaybe<SubscriptionBillingInfo>;
1915
1932
  billingPeriod?: InputMaybe<BillingPeriod>;
1916
1933
  checkoutOptions?: InputMaybe<CheckoutOptions>;
@@ -1919,6 +1936,7 @@ export declare type ProvisionSubscriptionInput = {
1919
1936
  priceUnitAmount?: InputMaybe<Scalars['Float']>;
1920
1937
  promotionCode?: InputMaybe<Scalars['String']>;
1921
1938
  refId?: InputMaybe<Scalars['String']>;
1939
+ resourceId?: InputMaybe<Scalars['String']>;
1922
1940
  skipTrial?: InputMaybe<Scalars['Boolean']>;
1923
1941
  startDate?: InputMaybe<Scalars['DateTime']>;
1924
1942
  subscriptionId?: InputMaybe<Scalars['String']>;
@@ -2263,6 +2281,7 @@ export declare type SubscriptionInput = {
2263
2281
  additionalMetaData?: InputMaybe<Scalars['JSON']>;
2264
2282
  addons?: InputMaybe<Array<SubscriptionAddonInput>>;
2265
2283
  awaitPaymentConfirmation?: InputMaybe<Scalars['Boolean']>;
2284
+ billingCountryCode?: InputMaybe<Scalars['String']>;
2266
2285
  billingId?: InputMaybe<Scalars['String']>;
2267
2286
  billingInformation?: InputMaybe<SubscriptionBillingInfo>;
2268
2287
  billingPeriod?: InputMaybe<BillingPeriod>;
@@ -2277,6 +2296,7 @@ export declare type SubscriptionInput = {
2277
2296
  priceUnitAmount?: InputMaybe<Scalars['Float']>;
2278
2297
  promotionCode?: InputMaybe<Scalars['String']>;
2279
2298
  refId?: InputMaybe<Scalars['String']>;
2299
+ resourceId?: InputMaybe<Scalars['String']>;
2280
2300
  startDate?: InputMaybe<Scalars['DateTime']>;
2281
2301
  subscriptionEntitlements?: InputMaybe<Array<SubscriptionEntitlementInput>>;
2282
2302
  subscriptionId?: InputMaybe<Scalars['String']>;
@@ -2649,6 +2669,7 @@ export declare type UsageMeasurementCreateInput = {
2649
2669
  customerId: Scalars['String'];
2650
2670
  environmentId?: InputMaybe<Scalars['String']>;
2651
2671
  featureId: Scalars['String'];
2672
+ resourceId?: InputMaybe<Scalars['String']>;
2652
2673
  value: Scalars['Float'];
2653
2674
  };
2654
2675
  export declare type UsageMeasurementFilter = {
@@ -3153,4 +3174,79 @@ export declare type SdkConfigurationQuery = {
3153
3174
  isWidgetWatermarkEnabled?: boolean | null | undefined;
3154
3175
  } | null | undefined;
3155
3176
  };
3177
+ export declare type SubscriptionPreviewFragment = {
3178
+ __typename?: 'SubscriptionPreview';
3179
+ subTotal: {
3180
+ __typename?: 'Money';
3181
+ amount: number;
3182
+ currency: Currency;
3183
+ };
3184
+ total: {
3185
+ __typename?: 'Money';
3186
+ amount: number;
3187
+ currency: Currency;
3188
+ };
3189
+ billingPeriodRange: {
3190
+ __typename?: 'DateRange';
3191
+ start?: any | null | undefined;
3192
+ end?: any | null | undefined;
3193
+ };
3194
+ discount?: {
3195
+ __typename?: 'SubscriptionPreviewDiscountDTO';
3196
+ type: DiscountType;
3197
+ value: number;
3198
+ durationType: DiscountDurationType;
3199
+ durationInMonths?: number | null | undefined;
3200
+ } | null | undefined;
3201
+ subscription?: {
3202
+ __typename?: 'SubscriptionPricePreviewDTO';
3203
+ subTotal: {
3204
+ __typename?: 'Money';
3205
+ amount: number;
3206
+ currency: Currency;
3207
+ };
3208
+ total: {
3209
+ __typename?: 'Money';
3210
+ amount: number;
3211
+ currency: Currency;
3212
+ };
3213
+ } | null | undefined;
3214
+ proration?: {
3215
+ __typename?: 'SubscriptionPreviewProrations';
3216
+ prorationDate: any;
3217
+ credit: {
3218
+ __typename?: 'Money';
3219
+ amount: number;
3220
+ currency: Currency;
3221
+ };
3222
+ debit: {
3223
+ __typename?: 'Money';
3224
+ amount: number;
3225
+ currency: Currency;
3226
+ };
3227
+ netAmount: {
3228
+ __typename?: 'Money';
3229
+ amount: number;
3230
+ currency: Currency;
3231
+ };
3232
+ } | null | undefined;
3233
+ };
3234
+ export declare type EstimateSubscriptionMutationVariables = Exact<{
3235
+ input: EstimateSubscriptionInput;
3236
+ }>;
3237
+ export declare type EstimateSubscriptionMutation = {
3238
+ __typename?: 'Mutation';
3239
+ estimateSubscription: {
3240
+ __typename?: 'SubscriptionPreview';
3241
+ } & SubscriptionPreviewFragment;
3242
+ };
3243
+ export declare type EstimateSubscriptionUpdateMutationVariables = Exact<{
3244
+ input: EstimateSubscriptionUpdateInput;
3245
+ }>;
3246
+ export declare type EstimateSubscriptionUpdateMutation = {
3247
+ __typename?: 'Mutation';
3248
+ estimateSubscriptionUpdate: {
3249
+ __typename?: 'SubscriptionPreview';
3250
+ } & SubscriptionPreviewFragment;
3251
+ };
3156
3252
  export {};
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BooleanEntitlement, Coupon, Customer, Entitlement, GetBooleanEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Subscription, WaitForCheckoutCompleted, CustomerPortal, Paywall } from './models';
1
+ import { BooleanEntitlement, Coupon, Customer, Entitlement, GetBooleanEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Subscription, WaitForCheckoutCompleted, CustomerPortal, Paywall, EstimateSubscription, SubscriptionPreview, EstimateSubscriptionUpdate } from './models';
2
2
  import { ClientConfiguration } from './configuration';
3
3
  import { EventNames, Events } from './services/eventEmitter';
4
4
  export interface StiggClient {
@@ -19,6 +19,8 @@ export interface StiggClient {
19
19
  addListener: <K extends EventNames>(eventName: K, callback: Events[K]) => void;
20
20
  removeListener: <K extends EventNames>(eventName: K, callback: Events[K]) => void;
21
21
  getCustomerPortal(): Promise<CustomerPortal>;
22
+ estimateSubscription(estimateSubscription: EstimateSubscription): Promise<SubscriptionPreview>;
23
+ estimateSubscriptionUpdate(estimateSubscriptionUpdate: EstimateSubscriptionUpdate): Promise<SubscriptionPreview>;
22
24
  }
23
25
  export declare class Stigg implements StiggClient {
24
26
  private readonly apiGateway;
@@ -127,6 +129,18 @@ export declare class Stigg implements StiggClient {
127
129
  * @returns {Promise<Entitlement[]>}
128
130
  */
129
131
  getEntitlements(): Promise<Entitlement[]>;
132
+ /**
133
+ * Estimate subscription
134
+ * @return {Promise<SubscriptionPreview>} Preview of the subscription.
135
+ * @param {EstimateSubscription} estimateSubscription
136
+ */
137
+ estimateSubscription(estimateSubscription: EstimateSubscription): Promise<SubscriptionPreview>;
138
+ /**
139
+ * Estimate subscription update
140
+ * @return {Promise<SubscriptionPreview>} Preview of the subscription.
141
+ * @param {EstimateSubscriptionUpdate} estimateSubscriptionUpdate
142
+ */
143
+ estimateSubscriptionUpdate(estimateSubscriptionUpdate: EstimateSubscriptionUpdate): Promise<SubscriptionPreview>;
130
144
  /**
131
145
  * Waits for a subscription to be activated after a completed checkout.
132
146
  * This method should be called on page load after the customer is redirected to the success URL.