@namiml/web-sdk 1.6.1 → 1.6.2

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 { TDevice } from "../types/device";
3
3
  import { NamiCampaign } from "../types/externals/campaign";
4
4
  export declare class CampaignRuleRepository {
5
5
  currentFormFactor: TDevice;
6
+ splitPosition: number;
6
7
  static instance: CampaignRuleRepository;
7
8
  constructor(cFormFactor: TDevice);
8
9
  fetchCampaignRules(paywalls: IPaywall[]): Promise<NamiCampaign[]>;
@@ -7,4 +7,6 @@ export declare class DeviceRepository {
7
7
  updateDeviceField<T>(key: string, value: T): Promise<Device | null>;
8
8
  private requestAPIData;
9
9
  private isEqualDevices;
10
+ getOrCreateAnonymousUUID(): string;
11
+ private getAnonymousUUID;
10
12
  }
@@ -54,6 +54,9 @@ export declare class StorageService {
54
54
  clearSessionId(): void;
55
55
  setPurchaseChannel(channel?: string): void;
56
56
  getPurchaseChannel(): string | null;
57
+ getAnonymousUUID(): string | null;
58
+ setAnonymousUUID(uuid: string): void;
59
+ clearAnonymousUUID(): void;
57
60
  /**
58
61
  * Set an item in localStorage.
59
62
  * @param {string} key - The key under which to store the data.
@@ -60,6 +60,7 @@ export type TTextComponent = TBaseComponent & {
60
60
  linkColor?: string;
61
61
  dateTimeFormat?: string;
62
62
  blur?: number | null;
63
+ capitalize?: boolean;
63
64
  };
64
65
  export type TTextLikeComponent = TTextComponent | TTextListComponent | TSymbolComponent;
65
66
  export type TTextListComponent = Omit<TTextComponent, "component" | "text"> & {
@@ -85,3 +86,13 @@ export type TConditionalComponent = TBaseComponent & {
85
86
  assertions?: TTestObject[];
86
87
  orAssertions?: TTestObject[] | undefined;
87
88
  };
89
+ export type TQRCodeComponent = TBaseComponent & {
90
+ component: "qrCode";
91
+ url: string;
92
+ height: number | string;
93
+ width: number | string;
94
+ color?: string;
95
+ fillColor?: string;
96
+ borderWidth?: number;
97
+ borderColor?: string;
98
+ };
@@ -1,5 +1,5 @@
1
1
  import { TButtonContainer, TCarouselContainer, TCarouselSlide, TCollapseContainer, TFlexProductContainer, TPlayPauseButton, TProductContainer, TResponsiveGrid, TStack, TVolumeButton, UserAction } from "./containers";
2
- import { TConditionalComponent, TImageComponent, TSegmentPicker, TSegmentPickerItem, TSpacerComponent, TSvgImageComponent, TSymbolComponent, TTextComponent, TTextListComponent, TVideoComponent } from "./elements";
2
+ import { TConditionalComponent, TImageComponent, TQRCodeComponent, TSegmentPicker, TSegmentPickerItem, TSpacerComponent, TSvgImageComponent, TSymbolComponent, TTextComponent, TTextListComponent, TVideoComponent } from "./elements";
3
3
  export interface TBaseComponent {
4
4
  id?: string;
5
5
  title?: string;
@@ -68,7 +68,7 @@ export interface TBaseComponent {
68
68
  fixedWidth?: number | "fitContent";
69
69
  hidden?: boolean;
70
70
  }
71
- export type TComponent = TButtonContainer | TContainer | TTextListComponent | TTextComponent | TSpacerComponent | TImageComponent | TSvgImageComponent | TSymbolComponent | TCarouselContainer | TProductContainer | TFlexProductContainer | TStack | TConditionalComponent | TSegmentPicker | TSegmentPickerItem | TVideoComponent | TCollapseContainer | TResponsiveGrid | TVolumeButton | TPlayPauseButton;
71
+ export type TComponent = TButtonContainer | TContainer | TTextListComponent | TTextComponent | TSpacerComponent | TImageComponent | TSvgImageComponent | TSymbolComponent | TCarouselContainer | TProductContainer | TFlexProductContainer | TStack | TConditionalComponent | TSegmentPicker | TSegmentPickerItem | TVideoComponent | TCollapseContainer | TResponsiveGrid | TVolumeButton | TPlayPauseButton | TQRCodeComponent;
72
72
  export type DirectionType = "vertical" | "horizontal";
73
73
  export type AlignmentType = "center" | "right" | "left" | "top" | "bottom";
74
74
  export type BorderLocationType = "upperLeft" | "upperRight" | "lowerLeft" | "lowerRight";
@@ -1,4 +1,4 @@
1
- import { NamiCampaign } from "../types/externals/campaign";
1
+ import { NamiAnonymousCampaign } from "../types/externals/campaign";
2
2
  import { IPaywall } from "./paywall";
3
3
  import { PaywallSKU } from "./sku";
4
4
  export interface IConfig {
@@ -11,8 +11,12 @@ export type InitialConfig = {
11
11
  platform_config?: IConfig;
12
12
  products?: PaywallSKU[];
13
13
  paywalls?: IPaywall[];
14
- campaign_rules?: NamiCampaign[];
14
+ campaign_rules?: NamiAnonymousCampaign[];
15
15
  };
16
+ export type InitialConfigCompressed = {
17
+ initial_config: string;
18
+ };
19
+ export declare const isInitialConfigCompressed: (config: InitialConfig | InitialConfigCompressed) => config is InitialConfigCompressed;
16
20
  export type NamiConfigurationState = {
17
21
  sdkInitialized: boolean;
18
22
  configureState: string;
@@ -19,6 +19,7 @@ export interface Device {
19
19
  vendor_id: string;
20
20
  }
21
21
  export interface DevicePayload {
22
+ id?: string;
22
23
  os_version: string;
23
24
  os_name: string;
24
25
  browser_name: string;
@@ -1,5 +1,30 @@
1
1
  import { CampaignRuleConversionEventType, FormFactor } from "../campaign";
2
2
  import { NamiFlowDTO, NamiFlowWithObject } from "../flow";
3
+ /**
4
+ * @type NamiCampaignSegment
5
+ * Represents a segment within a campaign.
6
+ */
7
+ export interface NamiCampaignSegment {
8
+ form_factors: FormFactor[];
9
+ paywall?: string | null;
10
+ flow?: NamiFlowDTO | null;
11
+ segment: string;
12
+ split: number;
13
+ conversion_event_type?: CampaignRuleConversionEventType | null;
14
+ conversion_event_url?: string | null;
15
+ }
16
+ /**
17
+ * @type NamiAnonymousCampaign
18
+ * Represents the anonymous campaign in Nami.
19
+ */
20
+ export interface NamiAnonymousCampaign {
21
+ rule: string;
22
+ name: string;
23
+ type: string | NamiCampaignRuleType;
24
+ value?: string | null;
25
+ external_segment: string | null;
26
+ segments: NamiCampaignSegment[];
27
+ }
3
28
  /**
4
29
  * @type NamiCampaign
5
30
  * Represents the campaign in Nami.
@@ -1,22 +1,13 @@
1
- import { IConfig } from "../config";
1
+ import { InitialConfig, InitialConfigCompressed } from "../config";
2
2
  import { NamiLanguageCodes } from "./languages";
3
3
  import { NamiLogLevel } from "./loglevel";
4
- import { IPaywall } from "../paywall";
5
- import { PaywallSKU } from "../sku";
6
- import { NamiCampaign } from "./campaign";
7
4
  /**
8
5
  * @type NamiInitialConfig
9
6
  *
10
7
  * Defines the structure of the initial configuration that can be provided
11
8
  * when setting up the Nami SDK.
12
9
  */
13
- export type NamiInitialConfig = {
14
- appConfig?: IConfig;
15
- platform_config?: IConfig;
16
- products?: PaywallSKU[];
17
- paywalls?: IPaywall[];
18
- campaign_rules?: NamiCampaign[];
19
- };
10
+ export type NamiInitialConfig = InitialConfig | InitialConfigCompressed;
20
11
  /**
21
12
  * @type NamiConfiguration
22
13
  * This is needed to configure and initialize the SDK via [Nami.configure]
@@ -30,4 +30,16 @@ export declare const NamiFlowManager: {
30
30
  * It signals to continue to the next step in the flow sequence.
31
31
  */
32
32
  resume: any;
33
+ /**
34
+ * Finishes the current flow programmatically.
35
+ *
36
+ * This can be used to end the flow at any point, typically after a handoff or custom logic.
37
+ */
38
+ finish: any;
39
+ /**
40
+ * Checks if a flow is currently open.
41
+ *
42
+ * @returns {boolean} - True if a flow is open, false otherwise.
43
+ */
44
+ isFlowOpen: any;
33
45
  };
@@ -16,6 +16,10 @@ export interface PaywallSKU extends SKU {
16
16
  [key: string]: any;
17
17
  };
18
18
  product_details?: NamiProductDetails | null;
19
+ offer_id?: string | null;
20
+ offer_type?: string | null;
21
+ offer_ref_id?: string | null;
22
+ computed_signature?: string | null;
19
23
  }
20
24
  export type AppleProduct = unknown;
21
25
  export type GoogleProduct = unknown;
@@ -1,6 +1,8 @@
1
- import { ExtendedPlatformInfo } from "../types/config";
1
+ import { ExtendedPlatformInfo, InitialConfig, InitialConfigCompressed } from "../types/config";
2
2
  export declare const getBaseUrl: (namiCommands?: string[]) => string;
3
3
  export declare const getExtendedClientInfo: (namiCommands: string[]) => ExtendedPlatformInfo;
4
4
  export declare const hasCapability: (capability: string) => boolean;
5
5
  export declare const hasPurchaseManagement: (messagePrefix?: string) => boolean;
6
6
  export declare const shouldValidateProductGroups: () => boolean;
7
+ export declare function tryParseJson(str: string): InitialConfig | InitialConfigCompressed | undefined;
8
+ export declare function tryParseB64Gzip(str: string): InitialConfig | undefined;
@@ -1 +1 @@
1
- export declare const NAMI_SDK_VERSION: string, PRODUCTION: string, DEVELOPMENT: string, PLATFORM_ID_REQUIRED: string, DEVICE_ID_REQUIRED: string, EXTERNAL_ID_REQUIRED: string, SDK_NOT_INITIALIZED: string, CAMPAIGN_NOT_AVAILABLE: string, FLOW_SCREENS_NOT_AVAILABLE: string, UNABLE_TO_UPDATE_CDP_ID: string, ANONYMOUS_MODE_ALREADY_ON: string, ANONYMOUS_MODE_ALREADY_OFF: string, ANONYMOUS_MODE_LOGIN_NOT_ALLOWED: string, SESSION_REQUIRED: string, DEVICE_ID_NOT_SET: string, AUTH_DEVICE: string, NAMI_CONFIGURATION: string, NAMI_PROFILE: string, API_CONFIG: string, API_CAMPAIGN_RULES: string, API_PAYWALLS: string, API_PRODUCTS: string, API_ACTIVE_ENTITLEMENTS: string, SERVER_NAMI_ENTITLEMENTS: string, INITIAL_APP_CONFIG: string, INITIAL_CAMPAIGN_RULES: string, INITIAL_PAYWALLS: string, INITIAL_PRODUCTS: string, LOCAL_NAMI_ENTITLEMENTS: string, CUSTOMER_ATTRIBUTES_KEY_PREFIX: string, NAMI_CUSTOMER_JOURNEY_STATE: string, ANONYMOUS_MODE: string, KEY_SESSION_COUNTER: string, INITIAL_SESSION_COUNTER_VALUE: number, NAMI_LAST_IMPRESSION_ID: string, NAMI_PURCHASE_IMPRESSION_ID: string, NAMI_SESSION_ID: string, NAMI_LANGUAGE_CODE: string, NAMI_PURCHASE_CHANNEL: string, API_VERSION: any, BASE_URL_PATH: string, BASE_URL: string, BASE_STAGING_URL: string, CUSTOM_HOST_PREFIX: string, USE_STAGING_API: string, EXTENDED_CLIENT_INFO_PREFIX: string, EXTENDED_CLIENT_INFO_DELIMITER: string, VALIDATE_PRODUCT_GROUPS: string, EXTENDED_PLATFORM: string, EXTENDED_PLATFORM_VERSION: string, API_MAX_CALLS_LIMIT: number, API_RETRY_DELAY_SEC: number, API_TIMEOUT_LIMIT: number, DEVICE_API_TIMEOUT_LIMIT: number, STATUS_SUCCESS: number, STATUS_BAD_REQUEST: number, STATUS_NOT_FOUND: number, STATUS_INTERNAL_SERVER_ERROR: number, INITIAL_SUCCESS: string, RECONFIG_SUCCESS: string, ALREADY_CONFIGURED: string, AVAILABLE_CAMPAIGNS_CHANGED: string, PAYWALL_ACTION_EVENT: string, AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED: string, CUSTOMER_JOURNEY_STATE_CHANGED: string, SKU_TEXT_REGEX: RegExp, VAR_REGEX: RegExp, HTML_REGEX: RegExp, SMART_TEXT_PATTERN: string, CORS_PROXY_URL: string, CORS_PROXY_URL_LOCAL: string;
1
+ export declare const NAMI_SDK_VERSION: string, PRODUCTION: string, DEVELOPMENT: string, PLATFORM_ID_REQUIRED: string, DEVICE_ID_REQUIRED: string, EXTERNAL_ID_REQUIRED: string, SDK_NOT_INITIALIZED: string, CAMPAIGN_NOT_AVAILABLE: string, FLOW_SCREENS_NOT_AVAILABLE: string, UNABLE_TO_UPDATE_CDP_ID: string, ANONYMOUS_MODE_ALREADY_ON: string, ANONYMOUS_MODE_ALREADY_OFF: string, ANONYMOUS_MODE_LOGIN_NOT_ALLOWED: string, SESSION_REQUIRED: string, DEVICE_ID_NOT_SET: string, AUTH_DEVICE: string, NAMI_CONFIGURATION: string, NAMI_PROFILE: string, API_CONFIG: string, API_CAMPAIGN_RULES: string, API_PAYWALLS: string, API_PRODUCTS: string, API_ACTIVE_ENTITLEMENTS: string, SERVER_NAMI_ENTITLEMENTS: string, INITIAL_APP_CONFIG: string, INITIAL_CAMPAIGN_RULES: string, INITIAL_PAYWALLS: string, INITIAL_PRODUCTS: string, LOCAL_NAMI_ENTITLEMENTS: string, CUSTOMER_ATTRIBUTES_KEY_PREFIX: string, NAMI_CUSTOMER_JOURNEY_STATE: string, ANONYMOUS_MODE: string, ANONYMOUS_UUID: string, KEY_SESSION_COUNTER: string, INITIAL_SESSION_COUNTER_VALUE: number, NAMI_LAST_IMPRESSION_ID: string, NAMI_PURCHASE_IMPRESSION_ID: string, NAMI_SESSION_ID: string, NAMI_LANGUAGE_CODE: string, NAMI_PURCHASE_CHANNEL: string, API_VERSION: any, BASE_URL_PATH: string, BASE_URL: string, BASE_STAGING_URL: string, CUSTOM_HOST_PREFIX: string, USE_STAGING_API: string, EXTENDED_CLIENT_INFO_PREFIX: string, EXTENDED_CLIENT_INFO_DELIMITER: string, VALIDATE_PRODUCT_GROUPS: string, EXTENDED_PLATFORM: string, EXTENDED_PLATFORM_VERSION: string, API_MAX_CALLS_LIMIT: number, API_RETRY_DELAY_SEC: number, API_TIMEOUT_LIMIT: number, DEVICE_API_TIMEOUT_LIMIT: number, STATUS_SUCCESS: number, STATUS_BAD_REQUEST: number, STATUS_NOT_FOUND: number, STATUS_CONFLICT: number, STATUS_INTERNAL_SERVER_ERROR: number, INITIAL_SUCCESS: string, RECONFIG_SUCCESS: string, ALREADY_CONFIGURED: string, AVAILABLE_CAMPAIGNS_CHANGED: string, PAYWALL_ACTION_EVENT: string, AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED: string, CUSTOMER_JOURNEY_STATE_CHANGED: string, SKU_TEXT_REGEX: RegExp, VAR_REGEX: RegExp, HTML_REGEX: RegExp, SMART_TEXT_PATTERN: string, CORS_PROXY_URL: string, CORS_PROXY_URL_LOCAL: string;
@@ -2,3 +2,5 @@ import { DevicePayload, TDevice } from "../types/device";
2
2
  export declare const getDeviceData: (namiCommands?: string[]) => DevicePayload;
3
3
  export declare const getDeviceFormFactor: () => TDevice;
4
4
  export declare function getDeviceScaleFactor(formFactor?: string): number;
5
+ export declare function generateUUID(): string;
6
+ export declare function audienceSplitPosition(uuid: string): number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@namiml/web-sdk",
3
3
  "type": "module",
4
- "version": "1.6.1",
4
+ "version": "1.6.2",
5
5
  "source": "src/nami-web.ts",
6
6
  "description": "Nami Web SDK makes subscriptions & in-app purchases easy, with powerful built-in paywalls and A/B testing",
7
7
  "scripts": {
@@ -56,6 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@eslint/js": "^9.2.0",
58
58
  "@open-wc/testing": "^4.0.0",
59
+ "@rollup/plugin-commonjs": "^28.0.6",
59
60
  "@rollup/plugin-node-resolve": "^15.2.3",
60
61
  "@rollup/plugin-replace": "^5.0.5",
61
62
  "@rollup/plugin-terser": "^0.4.4",
@@ -63,6 +64,9 @@
63
64
  "@types/jest": "^29.5.12",
64
65
  "@types/lodash-es": "^4.17.4",
65
66
  "@types/node": "^22.2.0",
67
+ "@types/pako": "^2",
68
+ "@types/qrcode": "^1",
69
+ "buffer": "^6.0.3",
66
70
  "eslint": "^9.2.0",
67
71
  "jest": "^29.7.0",
68
72
  "jest-environment-jsdom": "^29.7.0",
@@ -86,6 +90,8 @@
86
90
  "lit": "^3.1.3",
87
91
  "lodash-es": "^4.17.21",
88
92
  "marked": "^12.0.2",
93
+ "pako": "^2.1.0",
94
+ "qrcode": "^1.5.4",
89
95
  "swiper": "^11.1.12"
90
96
  },
91
97
  "homepage": "https://www.namiml.com",