@namiml/web-sdk 1.2.0 → 1.3.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 (58) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/components/ContextProvider.d.ts +13 -5
  3. package/dist/components/Paywall.d.ts +10 -7
  4. package/dist/components/containers/CollapseContainer.d.ts +12 -0
  5. package/dist/components/containers/ProductContainer.d.ts +2 -0
  6. package/dist/components/elements/SegmentPicker.d.ts +1 -1
  7. package/dist/components/elements/SegmentPickerItem.d.ts +0 -3
  8. package/dist/components/elements/Video.d.ts +10 -0
  9. package/dist/components/index.d.ts +5 -1
  10. package/dist/components/productDetails.d.ts +1 -1
  11. package/dist/components/utils/actionTap.d.ts +1 -1
  12. package/dist/components/utils/impression.d.ts +1 -1
  13. package/dist/components/utils/products.d.ts +2 -1
  14. package/dist/components/utils/state.d.ts +1 -1
  15. package/dist/components/utils/styles.d.ts +5 -1
  16. package/dist/core/withRetry.d.ts +2 -1
  17. package/dist/nami/api.d.ts +0 -1
  18. package/dist/nami/campaign.d.ts +11 -20
  19. package/dist/nami/entitlement.d.ts +29 -0
  20. package/dist/nami/namiRefs.d.ts +1 -0
  21. package/dist/nami/paywalls.d.ts +9 -3
  22. package/dist/nami/purchase.d.ts +5 -0
  23. package/dist/nami/utils/campaign.d.ts +8 -0
  24. package/dist/nami/utils/entitlement.d.ts +55 -0
  25. package/dist/nami/utils/paywall.d.ts +2 -0
  26. package/dist/nami/utils/purchase.d.ts +4 -3
  27. package/dist/nami-web.cjs +10 -8
  28. package/dist/nami-web.d.ts +222 -124
  29. package/dist/nami-web.js +12 -10
  30. package/dist/nami-web.mjs +12 -10
  31. package/dist/nami-web.umd.js +13 -11
  32. package/dist/repositories/campaignRule.repository.d.ts +3 -3
  33. package/dist/repositories/entitlement.repository.d.ts +11 -0
  34. package/dist/services/storage.service.d.ts +12 -5
  35. package/dist/types/campaign.d.ts +6 -11
  36. package/dist/types/components/containers.d.ts +8 -4
  37. package/dist/types/components/elements.d.ts +5 -2
  38. package/dist/types/components/index.d.ts +7 -3
  39. package/dist/types/config.d.ts +7 -6
  40. package/dist/types/entitlements.d.ts +19 -0
  41. package/dist/types/externals/campaign.d.ts +19 -0
  42. package/dist/types/externals/config.d.ts +22 -0
  43. package/dist/types/externals/entitlement.d.ts +11 -0
  44. package/dist/types/externals/index.d.ts +8 -0
  45. package/dist/types/externals/languages.d.ts +1 -0
  46. package/dist/types/externals/paywall.d.ts +73 -0
  47. package/dist/types/externals/product.d.ts +28 -0
  48. package/dist/types/externals/purchase.d.ts +18 -0
  49. package/dist/types/externals/sku.d.ts +17 -0
  50. package/dist/types/paywall.d.ts +16 -54
  51. package/dist/types/products.d.ts +0 -28
  52. package/dist/types/purchase.d.ts +15 -28
  53. package/dist/types/sku.d.ts +6 -19
  54. package/dist/utils/const.d.ts +1 -1
  55. package/dist/utils/feature-flags.d.ts +1 -0
  56. package/dist/utils/helpers.d.ts +1 -0
  57. package/package.json +6 -3
  58. package/dist/types/languages.d.ts +0 -1
@@ -1,12 +1,12 @@
1
1
  import { IPaywall } from "src/types/paywall";
2
- import { CampaignRule } from "src/types/campaign";
3
2
  import { TDevice } from "src/types/device";
3
+ import { NamiCampaign } from "src/types/externals/campaign";
4
4
  export declare class CampaignRuleRepository {
5
5
  currentFormFactor: TDevice;
6
6
  static instance: CampaignRuleRepository;
7
7
  constructor(cFormFactor: TDevice);
8
- fetchCampaignRules(paywalls: IPaywall[]): Promise<CampaignRule[]>;
9
- invokeAvailableCampaignsResponseHandler(campaigns?: CampaignRule[]): void;
8
+ fetchCampaignRules(paywalls: IPaywall[]): Promise<NamiCampaign[]>;
9
+ invokeAvailableCampaignsResponseHandler(campaigns?: NamiCampaign[]): void;
10
10
  private getAnonymousCampaigns;
11
11
  private getCampaigns;
12
12
  private fallbackData;
@@ -0,0 +1,11 @@
1
+ import { IEntitlements } from "src/types/entitlements";
2
+ export declare class EntitlementRepository {
3
+ static instance: EntitlementRepository;
4
+ constructor();
5
+ /**
6
+ * Just fetch [ActiveEntitlement] from API and save it in localstorage.
7
+ */
8
+ fetchActiveEntitlements(): Promise<IEntitlements[] | null>;
9
+ private getAPIEntitlements;
10
+ private invokeActiveEntitlementsHandler;
11
+ }
@@ -1,8 +1,9 @@
1
1
  import { Device } from "src/types/device";
2
2
  import { IConfig, NamiConfiguration } from "src/types/config";
3
3
  import { IPaywall } from "src/types/paywall";
4
- import { CampaignRule } from "src/types/campaign";
4
+ import { NamiCampaign } from "src/types/externals/campaign";
5
5
  import { NamiProfile } from "src/types/profile";
6
+ import { IEntitlements, NamiEntitlement } from "src/types/entitlements";
6
7
  import { SKU } from "src/types/sku";
7
8
  declare class StorageService {
8
9
  setDevice(device: Device): void;
@@ -13,12 +14,16 @@ declare class StorageService {
13
14
  clearAnonymousMode(): void;
14
15
  setAppConfig(key: string, config: IConfig): void;
15
16
  getAppConfig(key: string): IConfig | null;
16
- setCampaignRules(key: string, campaignRules: CampaignRule[]): void;
17
- getCampaignRules(key: string): CampaignRule[] | null;
17
+ setCampaignRules(key: string, campaignRules: NamiCampaign[]): void;
18
+ getCampaignRules(key: string): NamiCampaign[] | null;
18
19
  setPaywalls(key: string, paywalls: IPaywall[]): void;
19
20
  getPaywalls(key: string): IPaywall[] | null;
21
+ setActiveEntitlements(key: string, entitlements: IEntitlements[]): void;
22
+ setNamiEntitlements(key: string, entitlements: NamiEntitlement[]): void;
23
+ getNamiEntitlements(key: string): NamiEntitlement[];
20
24
  setProducts(key: string, products: SKU[]): void;
21
25
  getProducts(key: string): SKU[] | null;
26
+ getCachedProducts(): SKU[] | null;
22
27
  setNamiConfig(config: NamiConfiguration): void;
23
28
  getNamiConfig(): NamiConfiguration | null;
24
29
  setCustomerAttribute<T>(attribute: string, value: T): void;
@@ -30,10 +35,12 @@ declare class StorageService {
30
35
  getNamiProfile(): NamiProfile | null;
31
36
  removeNamiProfile(): void;
32
37
  setSessionCounter(): void;
33
- setLastImpressionId(id?: string): void;
38
+ setLastImpressionId(id: string): void;
34
39
  getLastImpressionId(): string;
40
+ setPurchaseImpression(): void;
41
+ getPurchaseImpression(): string;
35
42
  setSessionId(id?: string): void;
36
- getSessionId(): string | null;
43
+ getSessionId(): string;
37
44
  clearSessionId(): void;
38
45
  /**
39
46
  * Set an item in localStorage.
@@ -1,21 +1,16 @@
1
- export interface CampaignRule {
2
- rule: string;
3
- name: string;
4
- paywall: string;
5
- segment: string;
6
- form_factors: FormFactor[];
7
- type: string;
8
- external_segment_id: string;
9
- value: string;
10
- }
1
+ import { NamiCampaign } from "./externals/campaign";
11
2
  export interface FormFactor {
12
3
  form_factor: string;
13
4
  supports_portrait: boolean;
14
5
  supports_landscape: boolean;
15
6
  }
16
- export type AvailableCampaignsResponseHandler = (campaigns: CampaignRule[]) => void;
7
+ export type AvailableCampaignsResponseHandler = (campaigns: NamiCampaign[]) => void;
17
8
  export declare enum CampaignRuleType {
18
9
  DEFAULT = "default",
19
10
  LABEL = "label",
20
11
  URL = "url"
21
12
  }
13
+ export declare enum CampaignRuleConversionEventType {
14
+ DEEPLINK = "deeplink",
15
+ IN_APP = "in_app"
16
+ }
@@ -1,12 +1,10 @@
1
- import { TBaseComponent, TContainer, TTestObject } from ".";
2
- import { NamiSKU } from "../sku";
1
+ import { NamiSKU } from "src/types/externals/sku";
2
+ import { TBaseComponent, TComponent, TContainer, TTestObject } from ".";
3
3
  import { TImageComponent, TSpacerComponent, TTextComponent, TTextListComponent } from "./elements";
4
4
  export type THeaderFooter = (TContainer | TButtonContainer | TSpacerComponent | TTextComponent)[];
5
5
  export type TButtonContainer = TBaseComponent & {
6
6
  id?: string;
7
7
  component: "button";
8
- actionTap?: string;
9
- onTap?: UserAction;
10
8
  sku?: NamiSKU;
11
9
  components: Array<TTextComponent | TTextListComponent | TSpacerComponent | TImageComponent>;
12
10
  screenreaderText?: string;
@@ -65,3 +63,9 @@ export type TProductContainer = Omit<TContainer, "component"> & {
65
63
  export type TStack = Omit<TContainer, "component"> & {
66
64
  component: "stack";
67
65
  };
66
+ export type TCollapseContainer = TBaseComponent & {
67
+ component: "collapseContainer";
68
+ collapseHeader: TContainer;
69
+ components: TComponent[];
70
+ open: "collapse" | "open";
71
+ };
@@ -1,5 +1,4 @@
1
1
  import { AlignmentType, BorderLocationType, TBaseComponent, TComponent, TTestObject } from ".";
2
- import { UserAction } from "./containers";
3
2
  export type TImageComponent = TBaseComponent & {
4
3
  component: "image";
5
4
  url?: string | null;
@@ -9,7 +8,6 @@ export type TImageComponent = TBaseComponent & {
9
8
  export type TSegmentPicker = TBaseComponent & {
10
9
  component: "segmentPicker";
11
10
  components: TSegmentPickerItem[];
12
- onTap?: UserAction;
13
11
  };
14
12
  export type TSegmentPickerItem = TBaseComponent & {
15
13
  component: "segmentPickerItem";
@@ -70,6 +68,11 @@ export type TVideoComponent = TBaseComponent & {
70
68
  url?: string | null;
71
69
  aspectRatio?: number;
72
70
  imageCropping?: "fill" | "fit";
71
+ autoplayVideo?: boolean;
72
+ controlsType?: string;
73
+ fallbackImage?: string;
74
+ loopVideo?: boolean;
75
+ mute?: boolean;
73
76
  };
74
77
  export type TConditionalComponent = TBaseComponent & {
75
78
  component: "condition";
@@ -1,8 +1,10 @@
1
- import { TButtonContainer, TCarouselContainer, TCarouselSlide, TFlexProductContainer, TProductContainer, TStack } from "./containers";
2
- import { TConditionalComponent, TImageComponent, TSegmentPicker, TSegmentPickerItem, TSpacerComponent, TSvgImageComponent, TSymbolComponent, TTextComponent, TTextListComponent } from "./elements";
1
+ import { TButtonContainer, TCarouselContainer, TCarouselSlide, TCollapseContainer, TFlexProductContainer, TProductContainer, TStack, UserAction } from "./containers";
2
+ import { TConditionalComponent, TImageComponent, TSegmentPicker, TSegmentPickerItem, TSpacerComponent, TSvgImageComponent, TSymbolComponent, TTextComponent, TTextListComponent, TVideoComponent } from "./elements";
3
3
  export interface TBaseComponent {
4
4
  id?: string;
5
+ title?: string;
5
6
  component: string;
7
+ namiComponentType?: string;
6
8
  grow?: boolean;
7
9
  flag?: null | string;
8
10
  context?: {
@@ -39,6 +41,7 @@ export interface TBaseComponent {
39
41
  height?: number | string;
40
42
  width?: number | string;
41
43
  dropShadow?: string;
44
+ onTap?: UserAction;
42
45
  refId?: string;
43
46
  _fields?: {
44
47
  [attribute: string]: TFieldSettings;
@@ -59,8 +62,9 @@ export interface TBaseComponent {
59
62
  _fieldOmit?: string[];
60
63
  fixedHeight?: number;
61
64
  fixedWidth?: number | "fitContent";
65
+ hidden?: boolean;
62
66
  }
63
- export type TComponent = TButtonContainer | TContainer | TTextListComponent | TTextComponent | TSpacerComponent | TImageComponent | TSvgImageComponent | TSymbolComponent | TCarouselContainer | TProductContainer | TFlexProductContainer | TStack | TConditionalComponent | TSegmentPicker | TSegmentPickerItem;
67
+ export type TComponent = TButtonContainer | TContainer | TTextListComponent | TTextComponent | TSpacerComponent | TImageComponent | TSvgImageComponent | TSymbolComponent | TCarouselContainer | TProductContainer | TFlexProductContainer | TStack | TConditionalComponent | TSegmentPicker | TSegmentPickerItem | TVideoComponent | TCollapseContainer;
64
68
  export type DirectionType = "vertical" | "horizontal";
65
69
  export type AlignmentType = "center" | "right" | "left" | "top" | "bottom";
66
70
  export type BorderLocationType = "upperLeft" | "upperRight" | "lowerLeft" | "lowerRight";
@@ -1,6 +1,6 @@
1
- import { CampaignRule } from "./campaign";
1
+ import { NamiCampaign } from "src/types/externals/campaign";
2
2
  import { TDevice } from "./device";
3
- import { NamiLanguageCode } from "./languages";
3
+ import { NamiLanguageCodes } from "./externals/languages";
4
4
  import { NamiLogLevel } from "./loglevel";
5
5
  import { IPaywall } from "./paywall";
6
6
  import { PaywallSKU } from "./sku";
@@ -10,9 +10,9 @@ export interface IConfig {
10
10
  marketplace_app_id?: string | null;
11
11
  }
12
12
  export type NamiConfiguration = {
13
- appPlatformId: string;
13
+ appPlatformID: string;
14
14
  logLevel?: NamiLogLevel;
15
- languageCode?: NamiLanguageCode;
15
+ namiLanguageCode?: NamiLanguageCodes;
16
16
  namiCommands?: string[];
17
17
  initialConfig?: string | InitialConfig;
18
18
  formFactor?: TDevice;
@@ -22,7 +22,7 @@ export type InitialConfig = {
22
22
  platform_config?: IConfig;
23
23
  products?: PaywallSKU[];
24
24
  paywalls?: IPaywall[];
25
- campaign_rules?: CampaignRule[];
25
+ campaign_rules?: NamiCampaign[];
26
26
  };
27
27
  export type NamiConfigurationState = {
28
28
  sdkInitialized: boolean;
@@ -39,5 +39,6 @@ export declare enum Capabilities {
39
39
  THIRD_PARTY_TRANSACTIONS = "third_party_transactions",
40
40
  PAYWALL_PERSONALIZATION = "paywall_personalization",
41
41
  ANONYMOUS_MODE_CAPABILITY = "anonymous_allowed",
42
- LANGUAGE_MANAGEMENT = "language_management"
42
+ LANGUAGE_MANAGEMENT = "language_management",
43
+ ENTITLEMENT_MANAGEMENT = "entitlement_management"
43
44
  }
@@ -0,0 +1,19 @@
1
+ import { NamiPurchase } from "./externals/purchase";
2
+ import { NamiSKU } from "./externals/sku";
3
+ export type IEntitlements = {
4
+ id: string;
5
+ entitlement_ref_id: string;
6
+ name: string;
7
+ description: string | null;
8
+ type: string;
9
+ };
10
+ export type NamiEntitlement = {
11
+ activePurchases: NamiPurchase[];
12
+ desc: string;
13
+ name: string;
14
+ namiId: string;
15
+ purchasedSkus: NamiSKU[];
16
+ referenceId: string;
17
+ relatedSkus: NamiSKU[];
18
+ };
19
+ export type NamiActiveEntitlementsHandler = (entitlement: NamiEntitlement[]) => void;
@@ -0,0 +1,19 @@
1
+ import { CampaignRuleConversionEventType, FormFactor } from "../campaign";
2
+ export interface NamiCampaign {
3
+ rule: string;
4
+ name: string;
5
+ segment: string;
6
+ paywall: string;
7
+ type: string | NamiCampaignRuleType;
8
+ value?: string | null;
9
+ form_factors: FormFactor[];
10
+ external_segment_id: string | null;
11
+ conversion_event_type?: CampaignRuleConversionEventType;
12
+ conversion_event_url?: string;
13
+ }
14
+ export declare enum NamiCampaignRuleType {
15
+ DEFAULT = "default",
16
+ LABEL = "label",
17
+ UNKNOWN = "unknown",
18
+ URL = "url"
19
+ }
@@ -0,0 +1,22 @@
1
+ import { IConfig } from "../config";
2
+ import { TDevice } from "../device";
3
+ import { NamiLanguageCodes } from "./languages";
4
+ import { NamiLogLevel } from "../loglevel";
5
+ import { IPaywall } from "../paywall";
6
+ import { PaywallSKU } from "../sku";
7
+ import { NamiCampaign } from "./campaign";
8
+ export type NamiInitialConfig = {
9
+ appConfig?: IConfig;
10
+ platform_config?: IConfig;
11
+ products?: PaywallSKU[];
12
+ paywalls?: IPaywall[];
13
+ campaign_rules?: NamiCampaign[];
14
+ };
15
+ export type NamiConfiguration = {
16
+ appPlatformID: string;
17
+ logLevel: NamiLogLevel;
18
+ namiCommands?: string[];
19
+ namiLanguageCode?: NamiLanguageCodes;
20
+ initialConfig?: string | NamiInitialConfig;
21
+ formFactor?: TDevice;
22
+ };
@@ -0,0 +1,11 @@
1
+ import { NamiPurchase } from "./purchase";
2
+ import { NamiSKU } from "./sku";
3
+ export type NamiEntitlement = {
4
+ activePurchases: NamiPurchase[];
5
+ desc: string;
6
+ name: string;
7
+ namiId: string;
8
+ purchasedSkus: NamiSKU[];
9
+ referenceId: string;
10
+ relatedSkus: NamiSKU[];
11
+ };
@@ -0,0 +1,8 @@
1
+ export * from "./config";
2
+ export * from "./campaign";
3
+ export * from "./sku";
4
+ export * from "./paywall";
5
+ export * from "./product";
6
+ export * from "./purchase";
7
+ export * from "./languages";
8
+ export * from "./entitlement";
@@ -0,0 +1 @@
1
+ export type NamiLanguageCodes = "af" | "ar" | "ar-dz" | "ast" | "az" | "bg" | "be" | "bn" | "br" | "bs" | "ca" | "cs" | "cy" | "da" | "de" | "dsb" | "el" | "en" | "en-au" | "en-gb" | "eo" | "es" | "es-ar" | "es-co" | "es-mx" | "es-ni" | "es-ve" | "et" | "eu" | "fa" | "fi" | "fr" | "fy" | "ga" | "gd" | "gl" | "he" | "hi" | "hr" | "hsb" | "hu" | "hy" | "ia" | "id" | "ig" | "io" | "is" | "it" | "ja" | "ka" | "kab" | "kk" | "km" | "kn" | "ko" | "ky" | "lb" | "lt" | "lv" | "mk" | "ml" | "mn" | "mr" | "my" | "nb" | "ne" | "nl" | "nn" | "os" | "pa" | "pl" | "pt" | "pt-br" | "ro" | "ru" | "sk" | "sl" | "sq" | "sr" | "sr-latn" | "sv" | "sw" | "ta" | "te" | "tg" | "th" | "tk" | "tr" | "tt" | "udm" | "uk" | "ur" | "uz" | "vi" | "zh-hans" | "zh-hant";
@@ -0,0 +1,73 @@
1
+ import { NamiPurchase } from "./purchase";
2
+ import { NamiSKU } from "./sku";
3
+ export declare enum NamiPaywallAction {
4
+ BUY_SKU = "BUY_SKU",
5
+ SELECT_SKU = "SELECT_SKU",
6
+ RESTORE_PURCHASES = "RESTORE_PURCHASES",
7
+ SIGN_IN = "SIGN_IN",
8
+ CLOSE_PAYWALL = "CLOSE_PAYWALL",
9
+ SHOW_PAYWALL = "SHOW_PAYWALL",
10
+ PURCHASE_SELECTED_SKU = "PURCHASE_SELECTED_SKU",
11
+ PURCHASE_SUCCESS = "PURCHASE_SUCCESS",
12
+ PURCHASE_FAILED = "PURCHASE_FAILED",
13
+ PURCHASE_CANCELLED = "PURCHASE_CANCELLED",
14
+ PURCHASE_PENDING = "PURCHASE_PENDING",
15
+ PURCHASE_UNKNOWN = "PURCHASE_UNKNOWN",
16
+ PURCHASE_DEFERRED = "PURCHASE_DEFERRED",
17
+ DEEPLINK = "DEEPLINK",
18
+ TOGGLE_CHANGE = "TOGGLE_CHANGE",
19
+ PAGE_CHANGE = "PAGE_CHANGE",
20
+ SLIDE_CHANGE = "SLIDE_CHANGE",
21
+ COLLAPSIBLE_DRAWER_OPEN = "COLLAPSIBLE_DRAWER_OPEN",
22
+ COLLAPSIBLE_DRAWER_CLOSE = "COLLAPSIBLE_DRAWER_CLOSE",
23
+ VIDEO_STARTED = "VIDEO_STARTED",
24
+ VIDEO_PAUSED = "VIDEO_PAUSED",
25
+ VIDEO_RESUMED = "VIDEO_RESUMED",
26
+ VIDEO_ENDED = "VIDEO_ENDED",
27
+ VIDEO_CHANGED = "VIDEO_CHANGED",
28
+ VIDEO_MUTED = "VIDEO_MUTED",
29
+ VIDEO_UNMUTED = "VIDEO_UNMUTED",
30
+ UNKNOWN = "UNKNOWN"
31
+ }
32
+ export type NamiPaywallEvent = {
33
+ action: NamiPaywallAction;
34
+ sku?: NamiSKU;
35
+ campaignId?: string;
36
+ campaignName?: string;
37
+ campaignType?: string;
38
+ campaignLabel?: string;
39
+ campaignUrl?: string;
40
+ paywallId?: string;
41
+ paywallName?: string;
42
+ componentChange?: NamiPaywallComponentChange;
43
+ segmentId?: string;
44
+ externalSegmentId: string | null;
45
+ deeplinkUrl?: string;
46
+ purchaseError?: string;
47
+ purchases?: NamiPurchase[];
48
+ timeSpentOnPaywall?: number;
49
+ };
50
+ export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;
51
+ export type NamiPaywallLaunchContext = {
52
+ productGroups?: string[];
53
+ customAttributes: {
54
+ [key: string]: string;
55
+ };
56
+ customObject?: {
57
+ [key: string]: any;
58
+ };
59
+ };
60
+ export type NamiPaywallComponentChange = {
61
+ id?: string;
62
+ name?: string;
63
+ };
64
+ export type NamiPaywallEventVideoMetadata = {
65
+ id?: string;
66
+ name?: string;
67
+ url?: string;
68
+ loopVideo: boolean;
69
+ muteByDefault: boolean;
70
+ autoplayVideo: boolean;
71
+ contentTimecode?: number;
72
+ contentDuration?: number;
73
+ };
@@ -0,0 +1,28 @@
1
+ import { NamiSKUType } from "../externals/sku";
2
+ export interface NamiProductDetails {
3
+ name?: string;
4
+ description?: string;
5
+ product_ref_id: string;
6
+ product_type: NamiSKUType;
7
+ subscription_period?: NamiSubscriptionPeriod;
8
+ offers: NamiProductOffer[];
9
+ }
10
+ export type NamiProductOffer = NamiOfferPrice & {
11
+ offer_ref_id?: string;
12
+ offer_type: 'promo' | 'default';
13
+ promo_period?: NamiOfferPeriod;
14
+ promo_price?: NamiOfferPrice;
15
+ };
16
+ type NamiOfferPrice = {
17
+ price: number;
18
+ currency: string;
19
+ };
20
+ type NamiOfferPeriod = NamiSubscriptionPeriod;
21
+ export type NamiSubscriptionInterval = 'day' | 'week' | 'month' | 'year' | 'unknown';
22
+ export type NamiSubscriptionPeriod = {
23
+ type: NamiSubscriptionInterval;
24
+ count: number;
25
+ period_start?: number;
26
+ period_end?: number;
27
+ };
28
+ export {};
@@ -0,0 +1,18 @@
1
+ import { NamiPurchaseSource } from "../purchase";
2
+ import { NamiSKU } from "./sku";
3
+ export type NamiPurchase = {
4
+ sku?: NamiSKU;
5
+ skuId: string;
6
+ transactionIdentifier?: string;
7
+ expires?: Date;
8
+ purchaseToken?: string;
9
+ purchaseInitiatedTimestamp?: Date;
10
+ purchaseSource?: NamiPurchaseSource;
11
+ };
12
+ export type NamiPurchasesState = 'pending' | 'purchased' | 'consumed' | 'resubscribed' | 'unsubscribed' | 'deferred' | 'failed' | 'cancelled' | 'unknown';
13
+ export type NamiPurchaseDetails = {
14
+ skuId: string;
15
+ transactionId: string;
16
+ amount?: number;
17
+ currency?: string;
18
+ };
@@ -0,0 +1,17 @@
1
+ import { IEntitlements } from "../paywall";
2
+ import { AmazonProduct, AppleProduct, GoogleProduct } from "../sku";
3
+ import { NamiProductDetails } from "./product";
4
+ export type NamiSKU = {
5
+ id: string;
6
+ name?: string;
7
+ skuId: string;
8
+ appleProduct?: AppleProduct;
9
+ googleProduct?: GoogleProduct;
10
+ amazonProduct?: AmazonProduct;
11
+ type: NamiSKUType;
12
+ promoId?: string | null;
13
+ promoToken?: string | null;
14
+ productDetails?: NamiProductDetails | null;
15
+ entitlements: IEntitlements[];
16
+ };
17
+ export type NamiSKUType = 'unknown' | 'one_time_purchase' | 'subscription';
@@ -1,17 +1,20 @@
1
- import { CampaignRule } from "./campaign";
1
+ import { NamiCampaign } from "src/types/externals/campaign";
2
2
  import { TComponent, TContainer } from "./components";
3
3
  import { TButtonContainer, TCarouselSlidesState } from "./components/containers";
4
4
  import { TSpacerComponent, TTextComponent } from "./components/elements";
5
5
  import { TDeviceOrientation } from "./device";
6
- import { NamiSKU, PaywallSKU } from "./sku";
7
- import { NamiPurchase } from "./purchase";
6
+ import { PaywallSKU } from "./sku";
7
+ import { NamiPurchase } from "./externals/purchase";
8
8
  import { Optional } from "./utils";
9
9
  import { LaunchCampaignError } from "./errors";
10
+ import { NamiPaywallAction, NamiPaywallComponentChange, NamiPaywallLaunchContext } from "./externals/paywall";
11
+ import { NamiSKU } from "./externals/sku";
10
12
  export type TPaywallContext = TInitialState & {
11
13
  paywallId: string;
12
14
  livePaywalls: IPaywall[];
13
- selectedPaywall: IPaywall | undefined;
14
- campaignRules: CampaignRule[];
15
+ selectedPaywall?: IPaywall;
16
+ selectedCampaign?: NamiCampaign;
17
+ campaignRules: NamiCampaign[];
15
18
  anySkuHasTrialOffer: boolean;
16
19
  anySkuHasIntroOffer: boolean;
17
20
  anySkuHasPromoOffer: boolean;
@@ -49,15 +52,7 @@ export type TPaywallContext = TInitialState & {
49
52
  productBeingPurchased?: NamiSKU;
50
53
  timeSpentOnPaywall?: number;
51
54
  };
52
- export type TPaywallLaunchContext = {
53
- productGroups: string[];
54
- customAttributes: {
55
- [key: string]: any;
56
- };
57
- customObject?: {
58
- [key: string]: any;
59
- };
60
- };
55
+ export type TPaywallLaunchContext = NamiPaywallLaunchContext;
61
56
  export type ProductGroup = {
62
57
  id: string;
63
58
  products: PaywallSKU[];
@@ -100,7 +95,7 @@ export type FontDetails = {
100
95
  export type TPaywallTemplate = {
101
96
  id: string;
102
97
  orgs?: string | null;
103
- org_id?: string;
98
+ org_id: string | null;
104
99
  changelog?: string;
105
100
  userHasAccess?: boolean;
106
101
  media?: {
@@ -119,6 +114,8 @@ export type TPaywallTemplate = {
119
114
  };
120
115
  initialState: TInitialState;
121
116
  min_sdk_version: string;
117
+ capabilities?: string[];
118
+ displaySingleGroup?: boolean;
122
119
  };
123
120
  export type TPages = {
124
121
  name: string;
@@ -172,44 +169,6 @@ export declare enum PaywallManagerEvents {
172
169
  PAYWALL_RESTORE_REQUESTED = "PaywallRestoreRequested",
173
170
  PAYWALL_DEEPLINK_ACTION = "PaywallDeeplinkAction"
174
171
  }
175
- export declare enum NamiPaywallAction {
176
- BUY_SKU = "BUY_SKU",
177
- SELECT_SKU = "SELECT_SKU",
178
- RESTORE_PURCHASES = "RESTORE_PURCHASES",
179
- SIGN_IN = "SIGN_IN",
180
- CLOSE_PAYWALL = "CLOSE_PAYWALL",
181
- SHOW_PAYWALL = "SHOW_PAYWALL",
182
- PURCHASE_SELECTED_SKU = "PURCHASE_SELECTED_SKU",
183
- PURCHASE_SUCCESS = "PURCHASE_SUCCESS",
184
- PURCHASE_FAILED = "PURCHASE_FAILED",
185
- PURCHASE_CANCELLED = "PURCHASE_CANCELLED",
186
- PURCHASE_PENDING = "PURCHASE_PENDING",
187
- PURCHASE_UNKNOWN = "PURCHASE_UNKNOWN",
188
- PURCHASE_DEFERRED = "PURCHASE_DEFERRED",
189
- EMPTY = ""
190
- }
191
- export type NamiPaywallEvent = {
192
- action: NamiPaywallAction;
193
- sku?: NamiSKU;
194
- campaignId?: string;
195
- campaignName?: string;
196
- campaignType?: string;
197
- campaignLabel?: string;
198
- campaignUrl?: string;
199
- paywallId?: string;
200
- paywallName?: string;
201
- componentChange?: NamiPaywallComponentChange;
202
- segmentId?: string;
203
- externalSegmentId?: string;
204
- deeplinkUrl?: string;
205
- purchaseError?: string;
206
- purchases?: NamiPurchase[];
207
- timeSpentOnPaywall?: number;
208
- };
209
- export type NamiPaywallComponentChange = {
210
- id?: string;
211
- name?: string;
212
- };
213
172
  export type PaywallActionEvent = {
214
173
  action: NamiPaywallAction;
215
174
  sku?: NamiSKU;
@@ -218,5 +177,8 @@ export type PaywallActionEvent = {
218
177
  purchaseError?: string;
219
178
  purchases?: NamiPurchase[];
220
179
  };
221
- export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;
222
180
  export type PaywallResultHandler = (success: boolean, error?: LaunchCampaignError) => void;
181
+ export type NamiAppSuppliedVideoDetails = {
182
+ url: string;
183
+ name?: string;
184
+ };
@@ -1,34 +1,6 @@
1
- export interface NamiProductDetails {
2
- name?: string;
3
- description?: string;
4
- product_ref_id: string;
5
- product_type: ProductType;
6
- subscription_period?: NamiSubscriptionPeriod;
7
- offers: NamiProductOffer[];
8
- }
9
- export type NamiProductOffer = NamiOfferPrice & {
10
- offer_ref_id?: string;
11
- offer_type: 'promo' | 'default';
12
- promo_period?: NamiOfferPeriod;
13
- promo_price?: NamiOfferPrice;
14
- };
15
- type NamiOfferPrice = {
16
- price: number;
17
- currency: string;
18
- };
19
- export type NamiSubscriptionPeriod = {
20
- type: SubscriptionInterval;
21
- count: number;
22
- period_start?: number;
23
- period_end?: number;
24
- };
25
- type NamiOfferPeriod = NamiSubscriptionPeriod;
26
- export type SubscriptionInterval = 'day' | 'week' | 'month' | 'year' | 'unknown';
27
- export type ProductType = 'subscription' | 'one_time_purchase' | 'unknown';
28
1
  export type PricingPhase = {
29
2
  priceAmountMicros: number;
30
3
  priceCurrencyCode: string;
31
4
  billingPeriod: string;
32
5
  formattedPrice: string;
33
6
  };
34
- export {};
@@ -1,45 +1,32 @@
1
- import { NamiSKU } from "./sku";
2
- export type NamiPurchaseSource = "campaign" | "marketplace" | "unknown";
1
+ import { NamiPurchase } from "./externals";
2
+ export type NamiPurchaseSource = 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN';
3
3
  export type NamiPurchaseState = "purchased" | "failed" | "cancelled" | "pending" | "unknown";
4
- export interface Purchase {
5
- orderId: string;
6
- productId: string;
7
- purchaseTime: number;
8
- purchaseState: NamiPurchaseState;
9
- purchaseToken: string;
10
- autoRenewing: boolean;
11
- acknowledged: boolean;
12
- sku: NamiSKU;
13
- type: "inapp" | "subs" | "unknown";
14
- }
15
- export type NamiPurchase = {
16
- purchase_initiated_timestamp: number;
17
- purchase_source: NamiPurchaseSource;
18
- sku_id: string;
19
- sku_UUID: string;
20
- transaction_identifier?: string;
21
- purchase_token?: string;
22
- };
23
4
  export type TransactionRequest = {
24
5
  quantity?: string;
25
6
  currency?: string;
26
7
  purchase_env: string;
27
- amount: string;
28
- impression?: string;
29
- session: string;
8
+ amount?: number;
9
+ impression: string;
10
+ session?: string;
30
11
  original_transaction_id?: string;
31
- transaction_id?: string;
12
+ transaction_id: string;
32
13
  source?: string;
33
- sku?: string;
14
+ sku: string;
34
15
  localized_description?: string;
35
16
  subscription_interval?: string;
36
- subscription_interval_count: number;
17
+ subscription_interval_count?: number;
37
18
  purchase_date?: string;
38
19
  original_purchase_date?: string;
39
- app_env?: string;
20
+ app_env: string;
40
21
  };
41
22
  export type PurchaseValidationRequest = {
42
23
  app_env: string;
43
24
  payload: string;
44
25
  sku: string;
45
26
  };
27
+ export type NamiPurchaseCompleteResult = {
28
+ success: boolean;
29
+ billingResponseCode?: number;
30
+ message?: string;
31
+ purchase?: NamiPurchase;
32
+ };