@namiml/web-sdk 1.3.2 → 1.5.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/components/ContextConsumer.d.ts +1 -1
  3. package/dist/components/ContextProvider.d.ts +7 -7
  4. package/dist/components/Paywall.d.ts +5 -4
  5. package/dist/components/TemplateComponent.d.ts +1 -1
  6. package/dist/components/containers/BackgroundContainer.d.ts +2 -1
  7. package/dist/components/containers/CarouselContainer.d.ts +9 -0
  8. package/dist/components/containers/CollapseContainer.d.ts +1 -1
  9. package/dist/components/containers/Container.d.ts +6 -2
  10. package/dist/components/containers/Content.d.ts +1 -1
  11. package/dist/components/containers/Footer.d.ts +1 -1
  12. package/dist/components/containers/Header.d.ts +1 -1
  13. package/dist/components/containers/ProductContainer.d.ts +1 -1
  14. package/dist/components/containers/ResponsiveGrid.d.ts +17 -0
  15. package/dist/components/elements/Button.d.ts +4 -1
  16. package/dist/components/elements/Image.d.ts +1 -1
  17. package/dist/components/elements/PlayPauseButton.d.ts +15 -0
  18. package/dist/components/elements/SegmentPicker.d.ts +1 -1
  19. package/dist/components/elements/SegmentPickerItem.d.ts +1 -1
  20. package/dist/components/elements/Spacer.d.ts +1 -1
  21. package/dist/components/elements/Text.d.ts +1 -1
  22. package/dist/components/elements/Video.d.ts +2 -1
  23. package/dist/components/elements/VolumeButton.d.ts +15 -0
  24. package/dist/components/index.d.ts +9 -1
  25. package/dist/components/productDetails.d.ts +2 -2
  26. package/dist/components/utils/actionTap.d.ts +2 -2
  27. package/dist/components/utils/dateTIme.d.ts +3 -0
  28. package/dist/components/utils/eventConst.d.ts +1 -1
  29. package/dist/components/utils/helpers.d.ts +9 -6
  30. package/dist/components/utils/impression.d.ts +2 -2
  31. package/dist/components/utils/products.d.ts +4 -3
  32. package/dist/components/utils/state.d.ts +6 -6
  33. package/dist/components/utils/styles.d.ts +5 -3
  34. package/dist/nami/api.d.ts +4 -3
  35. package/dist/nami/campaign.d.ts +36 -10
  36. package/dist/nami/customer.d.ts +58 -14
  37. package/dist/nami/emitter.d.ts +1 -0
  38. package/dist/nami/entitlement.d.ts +22 -5
  39. package/dist/nami/index.d.ts +7 -1
  40. package/dist/nami/namiRefs.d.ts +1 -1
  41. package/dist/nami/paywalls.d.ts +49 -18
  42. package/dist/nami/purchase.d.ts +5 -1
  43. package/dist/nami/utils/campaign.d.ts +2 -2
  44. package/dist/nami/utils/entitlement.d.ts +4 -4
  45. package/dist/nami/utils/paywall.d.ts +1 -1
  46. package/dist/nami/utils/purchase.d.ts +2 -2
  47. package/dist/nami-web.cjs +22 -15
  48. package/dist/nami-web.d.ts +8 -880
  49. package/dist/nami-web.js +22 -15
  50. package/dist/nami-web.mjs +22 -15
  51. package/dist/nami-web.umd.js +22 -15
  52. package/dist/repositories/campaignRule.repository.d.ts +3 -3
  53. package/dist/repositories/config.repository.d.ts +1 -1
  54. package/dist/repositories/customerJourney.repository.d.ts +5 -0
  55. package/dist/repositories/device.repository.d.ts +1 -1
  56. package/dist/repositories/entitlement.repository.d.ts +1 -1
  57. package/dist/repositories/paywall.repository.d.ts +1 -1
  58. package/dist/repositories/products.repository.d.ts +1 -1
  59. package/dist/services/logger.service.d.ts +1 -1
  60. package/dist/services/storage.service.d.ts +7 -1
  61. package/dist/services/video.service.d.ts +17 -0
  62. package/dist/types/components/containers.d.ts +35 -4
  63. package/dist/types/components/elements.d.ts +1 -0
  64. package/dist/types/components/index.d.ts +4 -2
  65. package/dist/types/config.d.ts +2 -2
  66. package/dist/types/customer.d.ts +2 -0
  67. package/dist/types/entitlements.d.ts +2 -0
  68. package/dist/types/externals/campaign.d.ts +9 -1
  69. package/dist/types/externals/config.d.ts +27 -1
  70. package/dist/types/externals/customer.d.ts +18 -0
  71. package/dist/types/externals/entitlement.d.ts +27 -0
  72. package/dist/types/externals/index.d.ts +3 -0
  73. package/dist/types/externals/languages.d.ts +197 -1
  74. package/dist/types/{loglevel.d.ts → externals/loglevel.d.ts} +3 -0
  75. package/dist/types/externals/paywall.d.ts +32 -0
  76. package/dist/types/externals/product.d.ts +4 -0
  77. package/dist/types/externals/purchase.d.ts +24 -0
  78. package/dist/types/externals/sku.d.ts +14 -0
  79. package/dist/types/paywall.d.ts +4 -3
  80. package/dist/types/profile.d.ts +2 -1
  81. package/dist/utils/config.d.ts +2 -1
  82. package/dist/utils/const.d.ts +1 -1
  83. package/dist/utils/device.d.ts +1 -1
  84. package/dist/utils/fonts.d.ts +1 -1
  85. package/package.json +6 -4
  86. /package/dist/types/{errors.d.ts → externals/errors.d.ts} +0 -0
@@ -1,8 +1,11 @@
1
- import { Callback } from "src/types/components/containers";
2
- import { AccountStateAction } from "src/types/profile";
1
+ import { Callback } from "../types/components/containers";
2
+ import { AccountStateAction } from "../types/profile";
3
+ import { NamiCustomerJourneyStateHandler } from "../types/customer";
4
+ import { CustomerJourneyState } from "../types/externals/customer";
3
5
  type AccountStateHandler = (action: AccountStateAction, success: boolean, error?: Error) => void;
4
6
  /**
5
- * NamiCustomerManager provides methods for managing customer-related functionality.
7
+ * @class NamiCustomerManager
8
+ * Provides methods for managing customer-related functionality.
6
9
  */
7
10
  export declare class NamiCustomerManager {
8
11
  static instance: NamiCustomerManager;
@@ -16,35 +19,53 @@ export declare class NamiCustomerManager {
16
19
  /**
17
20
  * Returns the external ID of the currently logged in user.
18
21
  *
19
- * @returns The external ID of the logged in user.
22
+ * @returns {string | undefined} The external ID of the logged in user.
20
23
  */
21
24
  static loggedInId(): string | undefined;
22
25
  /**
23
26
  * Logs in a customer with the specified ID.
24
27
  *
25
28
  * @param id - The ID of the customer to log in. Must be a SHA256 hash or UUID.
26
- * @returns A Promise that resolves when the login is successful.
29
+ * @returns {Promise<void>} A Promise that resolves when the login is successful.
27
30
  */
28
31
  static login(externalId: string): Promise<void>;
32
+ /**
33
+ * This method detaches the whole platform account from the signed in user
34
+ * @returns {Promise<void>} A Promise that resolves when the logout is successful.
35
+ */
29
36
  static logout(): Promise<void>;
37
+ /**
38
+ * This method for connecting the device to a Customer Data Platform identifier
39
+ *
40
+ * Advanced use case. Make sure you have user consent.
41
+ *
42
+ * @param id a value supplied from your CDP platform
43
+ * @returns {Promise<void>} A Promise that resolves when CustomerDataPlatformId will be set.
44
+ */
30
45
  static setCustomerDataPlatformId(id: string): Promise<void>;
46
+ /**
47
+ * This method for clearing the Customer Data Platform identifier linked to this device
48
+ *
49
+ * Advanced use case.
50
+ * @returns {Promise<void>} A Promise that resolves when CustomerDataPlatformId will be cleared.
51
+ */
31
52
  static clearCustomerDataPlatformId(): Promise<void>;
32
53
  /**
33
54
  * Registers a callback function to handle changes in the account state.
34
55
  *
35
56
  * @param callback - The callback function to be registered.
36
- * @returns A function that can be used to unregister the original callback.
57
+ * @returns {Callback} A function that can be used to unregister the original callback.
37
58
  */
38
- static registerAccountStateHandler(callback: AccountStateHandler): Callback;
59
+ static registerAccountStateHandler(handler: AccountStateHandler): Callback;
39
60
  /**
40
61
  * Sets the anonymous mode for the customer.
41
62
  *
42
63
  * @param enabled - A boolean value indicating whether the anonymous mode should be enabled or disabled.
43
- * @returns A Promise that resolves when the anonymous mode is set.
64
+ * @returns {Promise<void>} A Promise that resolves when the anonymous mode is set.
44
65
  */
45
66
  static setAnonymousMode(enabled: boolean): Promise<void>;
46
67
  /**
47
- * Returns whether or not the SDK is currently operating in anonymous mode
68
+ * @returns {boolean} whether or not the SDK is currently operating in anonymous mode
48
69
  */
49
70
  static inAnonymousMode(): boolean;
50
71
  /**
@@ -58,9 +79,15 @@ export declare class NamiCustomerManager {
58
79
  * Retrieves the value for a given key in the on-device customer attribute key/value store.
59
80
  *
60
81
  * @param key - The name of the attribute. For example: `firstName`
61
- * @returns The value of the customer attribute.
82
+ * @returns {string | null} The value of the customer attribute.
62
83
  */
63
84
  static getCustomerAttribute(key: string): string | null;
85
+ /**
86
+ * Retrieves all the customer attribute key/value store.
87
+ *
88
+ * @returns {string | null} The value of the customer attribute.
89
+ */
90
+ static getAllCustomerAttributes(): string[];
64
91
  /**
65
92
  * Clears a value of the given key in the on-device key/value store.
66
93
  *
@@ -69,9 +96,26 @@ export declare class NamiCustomerManager {
69
96
  static clearCustomerAttribute(key: string): void;
70
97
  /**
71
98
  * Clear all customer attributes from the on-device key/value store.
72
- *
73
99
  */
74
100
  static clearAllCustomerAttributes(): void;
101
+ /**
102
+ * @return current customer's journey state.
103
+ */
104
+ static journeyState(): CustomerJourneyState | null;
105
+ /**
106
+ * @return the unique identifier Nami users to identify this device. Please note
107
+ * you should not depend on the device identifier persisting across app re-installs.
108
+ */
109
+ static deviceId(): string;
110
+ /**
111
+ * When there has been an update received to the active entitlements,
112
+ * the Nami SDK will provide notification of that event through
113
+ * this callback with list of active [NamiEntitlement]
114
+ *
115
+ * @param {NamiCustomerJourneyStateHandler} handler - The callback function that will be invoked when the campaign list is updated.
116
+ * @returns {Callback} A function that can be called to unregister the handler.
117
+ */
118
+ static registerJourneyStateHandler(handler: NamiCustomerJourneyStateHandler): Callback | undefined;
75
119
  /**
76
120
  * Private Static Methods
77
121
  */
@@ -82,9 +126,9 @@ export declare class NamiCustomerManager {
82
126
  private get isSDKInitialized();
83
127
  private static updateCustomerDataPlatformId;
84
128
  /**
85
- * Returns whether or not the configured app platform id belongs to an anonymous mode
86
- * capable Nami account.
87
- */
129
+ * @returns whether or not the configured app platform id belongs to an anonymous mode
130
+ * capable Nami account.
131
+ */
88
132
  private static anonymousModeCapability;
89
133
  private static refetchConfig;
90
134
  }
@@ -7,6 +7,7 @@ export declare class NamiEventEmitter {
7
7
  emit(eventName: string, ...args: any[]): void;
8
8
  addListener(eventName: string, listener: (...args: any[]) => void): void;
9
9
  removeListener(eventName: string, listener: (...args: any[]) => void): void;
10
+ removeAllListeners(eventName?: string): void;
10
11
  listeners(eventName: string): any[];
11
12
  listenerCount(eventName: string): number;
12
13
  }
@@ -1,10 +1,14 @@
1
- import { NamiActiveEntitlementsHandler, NamiEntitlement } from "src/types/entitlements";
2
- import { Callback } from "src/types/components/containers";
1
+ import { NamiActiveEntitlementsHandler, NamiEntitlement } from "../types/entitlements";
2
+ import { Callback } from "../types/components/containers";
3
+ /**
4
+ * @class NamiEntitlementManager
5
+ * Contains all methods and objects to work with entitlements in the SDK.
6
+ */
3
7
  export declare class NamiEntitlementManager {
4
8
  static instance: NamiEntitlementManager;
5
9
  private emitter;
6
10
  /**
7
- * @returns list of currently active entitlements
11
+ * @returns {NamiEntitlement[]} A list of currently active entitlements
8
12
  */
9
13
  static active(): NamiEntitlement[];
10
14
  /**
@@ -12,16 +16,29 @@ export declare class NamiEntitlementManager {
12
16
  * and it's not expired.
13
17
  *
14
18
  * @param referenceId - entitlement referenceId
15
- * @returns True if the entitlement is active for given referenceId, false otherwise.
19
+ * @returns {boolean} True if the entitlement is active for given referenceId, false otherwise.
16
20
  */
17
21
  static isEntitlementActive(referenceId: string): boolean;
18
22
  /**
19
23
  * Asks Nami to fetch the latest active entitlements
20
24
  *
21
- * @returns list of NamiEntitlement
25
+ * @returns {Promise<NamiEntitlement[]>} A promise that resolves to a list of NamiEntitlement
22
26
  */
23
27
  static refresh(): Promise<NamiEntitlement[]>;
28
+ /**
29
+ * When there has been an update received to the active entitlements,
30
+ * the Nami SDK will provide notification of that event through
31
+ * this callback with list of active [NamiEntitlement]
32
+ *
33
+ * @param {NamiActiveEntitlementsHandler} handler - The callback function that will be invoked when the campaign list is updated.
34
+ * @returns {Callback} A function that can be called to unregister the handler.
35
+ */
24
36
  static registerActiveEntitlementsHandler(handler: NamiActiveEntitlementsHandler): Callback | undefined;
37
+ /**
38
+ * Clear any provisional entitlement grants, which are entitlements issued on-device only.
39
+ * Useful for development and purchase testing. Not recommended to be called in production.
40
+ */
41
+ static clearProvisionalEntitlementGrants(): void;
25
42
  /**
26
43
  * Private Instance Methods
27
44
  */
@@ -1,8 +1,14 @@
1
- import { NamiConfiguration, NamiConfigurationState } from "src/types/config";
1
+ import { NamiConfiguration, NamiConfigurationState } from "../types/config";
2
2
  export declare class Nami {
3
3
  #private;
4
4
  static instance: Nami;
5
5
  get isInitialized(): boolean;
6
+ /**
7
+ * Configures and initializes the SDK.
8
+ * This method must be called as the first thing before interacting with the SDK.
9
+ * @param with A [NamiConfiguration] object with required values
10
+ * @returns {Promise<NamiConfigurationState>}
11
+ */
6
12
  static configure(options: NamiConfiguration): Promise<NamiConfigurationState>;
7
13
  private static setInitialConfig;
8
14
  private initializeSDK;
@@ -1,4 +1,4 @@
1
- import { NamiConfiguration } from "src/types/config";
1
+ import { NamiConfiguration } from "../types/config";
2
2
  export declare class NamiRefs {
3
3
  static instance: NamiRefs;
4
4
  init(config: NamiConfiguration): Promise<void>;
@@ -1,34 +1,65 @@
1
- import { IPaywall } from "src/types/paywall";
2
- import { NamiProductDetails } from "src/types/externals/product";
3
- import { Callback } from "src/types/components/containers";
4
- import { NamiPurchaseDetails } from "src/types/externals/purchase";
1
+ import { IPaywall } from "../types/paywall";
2
+ import { NamiProductDetails } from "../types/externals/product";
3
+ import { Callback, CloseHandler, DeepLinkUrlHandler, SKUActionHandler } from "../types/components/containers";
4
+ import { NamiPurchaseDetails } from "../types/externals/purchase";
5
+ /**
6
+ * @class NamiPaywallManager
7
+ * Provides methods for managing all aspects of a paywall in the Nami SDK.
8
+ */
5
9
  export declare class NamiPaywallManager {
6
10
  static instance: NamiPaywallManager;
7
11
  private emitter;
8
12
  productDetails: NamiProductDetails[];
13
+ /**
14
+ * @returns {IPaywall[]} a list of Paywall
15
+ */
9
16
  static allPaywalls(): IPaywall[];
17
+ /**
18
+ * Used to set product details when store products are unavailable. For advanced use cases only.
19
+ */
10
20
  static setProductDetails(productDetails: NamiProductDetails[]): void;
21
+ /**
22
+ * Register a callback which would be invoked when user will sign-in
23
+ */
11
24
  static registerSignInHandler(handler: Callback): Callback;
12
- static registerCloseHandler(handler: Callback): Callback;
13
- static registerDeeplinkActionHandler(handler: Callback): Callback;
14
- static registerBuySkuHandler(handler: Callback): Callback;
25
+ /**
26
+ * Register a callback which would be invoked when user close a paywall raised by Nami system
27
+ */
28
+ static registerCloseHandler(handler: CloseHandler): Callback;
29
+ /**
30
+ * Register a callback which would be invoked when user will take action on deeplink
31
+ */
32
+ static registerDeeplinkActionHandler(handler: DeepLinkUrlHandler): Callback;
33
+ /**
34
+ * Register a [NamiBuySkuHandler] which would be invoked when a user triggers
35
+ * a buy sku action on a paywall.
36
+ *
37
+ * Only available for plans where Nami is not handling subscription & IAP management.
38
+ */
39
+ static registerBuySkuHandler(handler: SKUActionHandler): Callback;
40
+ /**
41
+ * Register a callback which would be invoked when user restore a product
42
+ */
15
43
  static registerRestoreHandler(handler: Callback): Callback;
16
44
  /**
17
- * Notify the NamiPaywallManager that a purchase initiated from the
18
- * [NamiBuySkuHandler] is complete. Only available for plans where Nami is
19
- * not handling subscription & IAP management.
20
- */
45
+ * Notify the NamiPaywallManager that a purchase initiated from the
46
+ * [NamiBuySkuHandler] is complete.
47
+ *
48
+ * Only available for plans where Nami is not handling subscription & IAP management.
49
+ *
50
+ * @returns {Promise<void>} A Promise that resolves when buying SKU will be complete.
51
+ */
21
52
  static buySkuComplete(purchase: NamiPurchaseDetails): Promise<void>;
22
53
  /**
23
- Notify the NamiPaywallManager that purchase flow handled by you is cancelled.
24
- Used to disable product purchase-in-progress loading indicators
25
- */
54
+ * Notify the NamiPaywallManager that purchase flow handled by you is cancelled.
55
+ * Used to disable product purchase-in-progress loading indicators
56
+ */
26
57
  static buySkuCancel(): void;
27
58
  /**
28
- * Set the video details for the app supplied video
29
- * @param url The URL of the video
30
- * @param name The name of the video
31
- */
59
+ * Set the video details for the app supplied video
60
+ * @param url The URL of the video
61
+ * @param name The name of the video
62
+ */
32
63
  static setAppSuppliedVideoDetails(url: string, name?: string): void;
33
64
  /**
34
65
  * Private Instance Methods
@@ -1,4 +1,8 @@
1
- import { NamiPurchase } from "src/types/externals/purchase";
1
+ import { NamiPurchase } from "../types/externals/purchase";
2
+ /**
3
+ * @class NamiPurchaseManager
4
+ * Provides methods for managing all aspects of a purchase in the Nami SDK.
5
+ */
2
6
  export declare class NamiPurchaseManager {
3
7
  static instance: NamiPurchaseManager;
4
8
  static allPurchases(): NamiPurchase[];
@@ -1,5 +1,5 @@
1
- import { NamiCampaign } from "src/types/externals/campaign";
2
- import { IPaywall } from "src/types/paywall";
1
+ import { NamiCampaign } from "../../types/externals/campaign";
2
+ import { IPaywall } from "../../types/paywall";
3
3
  export declare const isValidUrl: (label: string) => boolean;
4
4
  export declare const allCampaigns: () => NamiCampaign[];
5
5
  export declare const getPaywallDataFromLabel: (value: string, type?: string) => {
@@ -1,7 +1,7 @@
1
- import { IEntitlements, NamiEntitlement } from "src/types/entitlements";
2
- import { NamiPurchase } from "src/types/externals/purchase";
3
- import { PaywallSKU, SKU } from "src/types/sku";
4
- import { NamiSKU } from "src/types/externals/sku";
1
+ import { IEntitlements, NamiEntitlement } from "../../types/entitlements";
2
+ import { NamiPurchase } from "../../types/externals/purchase";
3
+ import { PaywallSKU, SKU } from "../../types/sku";
4
+ import { NamiSKU } from "../../types/externals/sku";
5
5
  export declare class EntitlementUtils {
6
6
  static instance: EntitlementUtils;
7
7
  refIdToPurchasedSKUs: {
@@ -1,2 +1,2 @@
1
- import { IPaywall } from "src/types/paywall";
1
+ import { IPaywall } from "../../types/paywall";
2
2
  export declare const allPaywalls: () => IPaywall[];
@@ -1,4 +1,4 @@
1
- import { NamiPurchaseCompleteResult } from "src/types/purchase";
2
- import { NamiPurchaseDetails, NamiPurchase } from "src/types/externals/purchase";
1
+ import { NamiPurchaseCompleteResult } from "../../types/purchase";
2
+ import { NamiPurchaseDetails, NamiPurchase } from "../../types/externals/purchase";
3
3
  export declare function toNamiPurchase(purchase: NamiPurchaseDetails): NamiPurchase;
4
4
  export declare function namiBuySKU(skuRefId: string): NamiPurchaseCompleteResult | undefined;