@stigg/js-client-sdk 0.22.1 → 0.24.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,62 @@ 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
+ * Creates an instance of Stigg client.
23
+ *
24
+ * @param configuration configuration settings.
25
+ * @returns The new client instance.
26
+ */
27
+ static initialize(configuration: ClientConfiguration): Promise<StiggClient | null>;
28
+ /**
29
+ * Set the customer ID, usually after the customer signs in or restores a session
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
+ */
39
+ getBooleanEntitlement({ featureId, options }: GetBooleanEntitlement): BooleanEntitlement;
40
+ /**
41
+ * Get numeric entitlement of feature for a customer
42
+ *
43
+ * @param {string} featureId
44
+ * @param {NumericEntitlementOptions} options
45
+ * @return {NumericEntitlement} numeric entitlement
46
+ */
47
+ getNumericEntitlement({ featureId, options }: GetNumericEntitlement): NumericEntitlement;
48
+ /**
49
+ * Get metered entitlement of feature for a customer
50
+ *
51
+ * @param {string} featureId
52
+ * @param {MeteredEntitlementOptions} options
53
+ * @return {MeteredEntitlement} metered entitlement
54
+ */
55
+ getMeteredEntitlement({ featureId, options }: GetMeteredEntitlement): MeteredEntitlement;
56
+ /**
57
+ * Get a list of plans for rendering the paywall
58
+ *
59
+ * @returns {Promise<Plan[]>}
60
+ */
61
+ getPaywall({ productId }?: GetPaywall): Promise<Plan[]>;
62
+ /**
63
+ * Get a customer
64
+ *
65
+ * @returns {Promise<Customer>}
66
+ */
24
67
  getCustomer(): Promise<Customer>;
25
- getEntitlements(): Promise<Entitlement[] | never[]>;
68
+ /**
69
+ * Get a list of entitlements
70
+ *
71
+ * @returns {Promise<Entitlement[]>}
72
+ */
73
+ getEntitlements(): Promise<Entitlement[]>;
74
+ private withErrorHandling;
26
75
  }
@@ -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;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { ClientConfiguration } from './configuration';
2
2
  export { StiggClient } from './client';
3
+ export { LogLevel, LogConfiguration, Logger } from './services/loggerService';
3
4
  export * from './models';
4
5
  export { Stigg as default } from './client';