@stigg/js-client-sdk 0.22.2 → 0.23.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,7 +1,7 @@
1
1
  import { ApolloClient } from '@apollo/client/core';
2
2
  declare type ApolloClientConfiguration = {
3
- sdkKey: string;
3
+ apiKey: string;
4
4
  baseUri: string;
5
5
  };
6
- declare const initApolloClient: ({ sdkKey, baseUri }: Partial<ApolloClientConfiguration>) => ApolloClient<import("@apollo/client/core").NormalizedCacheObject>;
6
+ declare const initApolloClient: ({ apiKey, baseUri }: Partial<ApolloClientConfiguration>) => ApolloClient<import("@apollo/client/core").NormalizedCacheObject>;
7
7
  export default initApolloClient;
package/dist/client.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { EntitlementOptions, Customer, Entitlement, InvalidEntitlement, Plan, FallbackEntitlement } from './models';
1
+ import { Customer, Entitlement, Plan, BooleanEntitlement, NumericEntitlement, MeteredEntitlement, GetBooleanEntitlement, GetNumericEntitlement, GetMeteredEntitlement, GetPaywall } from './models';
2
2
  import { ClientConfiguration } from './configuration';
3
3
  export interface StiggClient {
4
- getEntitlement: <T extends Entitlement>(featureId: string, options?: EntitlementOptions) => T | InvalidEntitlement | FallbackEntitlement;
5
- setCustomerId: (customerId: string) => void;
6
- getPaywall: (productId?: string) => Promise<Plan[]>;
4
+ getBooleanEntitlement: (params: GetBooleanEntitlement) => BooleanEntitlement;
5
+ getNumericEntitlement: (params: GetNumericEntitlement) => NumericEntitlement;
6
+ getMeteredEntitlement: (params: GetMeteredEntitlement) => MeteredEntitlement;
7
+ setCustomerId: (customerId: string) => Promise<void>;
8
+ getPaywall: (params?: GetPaywall) => Promise<Plan[]>;
7
9
  getCustomer: () => Promise<Customer>;
8
10
  getEntitlements: () => Promise<Entitlement[]>;
9
11
  refresh: () => Promise<void>;
@@ -12,15 +14,60 @@ export declare class Stigg implements StiggClient {
12
14
  private readonly apiGateway;
13
15
  private readonly graphClient;
14
16
  private readonly configuration;
17
+ private readonly loggerService;
15
18
  private entitlementsService;
16
19
  private readonly modelMapper;
17
20
  private constructor();
18
- static initialize(configuration: ClientConfiguration): Promise<StiggClient>;
21
+ /**
22
+ * Initialize the SDK
23
+ * @param {ClientConfiguration} configuration
24
+ * @returns {Stigg | null}
25
+ */
26
+ static initialize(configuration: ClientConfiguration): Promise<StiggClient | null>;
27
+ /**
28
+ * Set the customer ID, usually after the customer signs in or restores a session
29
+ * @returns {Promise<void>}
30
+ */
19
31
  setCustomerId(customerId: string): Promise<void>;
32
+ /**
33
+ * Reload entitlements
34
+ */
20
35
  refresh(): Promise<void>;
21
- getEntitlement<T extends Entitlement>(featureId: string, options?: EntitlementOptions): T | InvalidEntitlement | FallbackEntitlement;
22
- private handleNoEntitlementFound;
23
- getPaywall(productId?: string): Promise<Plan[]>;
36
+ /**
37
+ * Get boolean entitlement of feature for a customer
38
+ * @param {string} featureId
39
+ * @param {BooleanEntitlementOptions} options
40
+ * @return {BooleanEntitlement} boolean entitlement
41
+ */
42
+ getBooleanEntitlement({ featureId, options }: GetBooleanEntitlement): BooleanEntitlement;
43
+ /**
44
+ * Get numeric entitlement of feature for a customer
45
+ * @param {string} featureId
46
+ * @param {NumericEntitlementOptions} options
47
+ * @return {NumericEntitlement} numeric entitlement
48
+ */
49
+ getNumericEntitlement({ featureId, options }: GetNumericEntitlement): NumericEntitlement;
50
+ /**
51
+ * Get metered entitlement of feature for a customer
52
+ * @param {string} featureId
53
+ * @param {MeteredEntitlementOptions} options
54
+ * @return {MeteredEntitlement} metered entitlement
55
+ */
56
+ getMeteredEntitlement({ featureId, options }: GetMeteredEntitlement): MeteredEntitlement;
57
+ /**
58
+ * Get a list of plans for rendering the paywall
59
+ * @returns {Promise<Plan[]>}
60
+ */
61
+ getPaywall({ productId }?: GetPaywall): Promise<Plan[]>;
62
+ /**
63
+ * Get a customer
64
+ * @returns {Promise<Customer>}
65
+ */
24
66
  getCustomer(): Promise<Customer>;
25
- getEntitlements(): Promise<Entitlement[] | never[]>;
67
+ /**
68
+ * Get a list of entitlements
69
+ * @returns {Promise<Entitlement[]>}
70
+ */
71
+ getEntitlements(): Promise<Entitlement[]>;
72
+ private withErrorHandling;
26
73
  }
@@ -1,9 +1,11 @@
1
+ import { LogConfiguration, LoggerService } from './services/loggerService';
1
2
  export declare type ClientConfiguration = {
2
- sdkKey: string;
3
+ apiKey: string;
3
4
  baseUri?: string;
4
5
  customerId?: string;
5
6
  entitlementPollingInterval?: number;
7
+ logConfiguration?: LogConfiguration;
6
8
  };
7
- export declare function validateConfiguration(configuration: ClientConfiguration): void;
8
- export declare function withDefaults(configuration: ClientConfiguration): Required<ClientConfiguration>;
9
+ export declare function validateConfiguration(configuration: ClientConfiguration, loggerService: LoggerService): boolean;
10
+ export declare function getConfiguration(configuration: ClientConfiguration): Required<ClientConfiguration>;
9
11
  export declare function ensureCustomerRefIdExists({ customerId }: ClientConfiguration): string;