react-native-nami-sdk 3.1.37-beta.1 → 3.2.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.
package/.eslintignore CHANGED
@@ -1,2 +1,3 @@
1
1
  node_modules/
2
2
  .eslintrc
3
+ *.d.ts
@@ -10,6 +10,58 @@ jobs:
10
10
  contents: write
11
11
  id-token: write
12
12
  runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/setup-node@v3
15
+ with:
16
+ node-version: "16"
17
+
18
+ - name: 'Checkout ${{ inputs.ref }}'
19
+ uses: actions/checkout@v3
20
+ with:
21
+ path: source
22
+ ref: '${{ inputs.ref }}'
23
+
24
+ - name: Install dependencies
25
+ run: yarn --frozen-lockfile --prefer-offline
26
+ working-directory: source/
27
+
28
+ - name: Linter
29
+ run: |
30
+ npx eslint . --ext .js,.jsx,.ts,.tsx
31
+ working-directory: source/
32
+ tsc:
33
+ name: Generate Declaration Files
34
+ permissions:
35
+ actions: write
36
+ contents: write
37
+ id-token: write
38
+ runs-on: ubuntu-latest
39
+ steps:
40
+ - uses: actions/setup-node@v3
41
+ with:
42
+ node-version: "16"
43
+
44
+ - name: 'Checkout ${{ inputs.ref }}'
45
+ uses: actions/checkout@v3
46
+ with:
47
+ path: source
48
+ ref: '${{ inputs.ref }}'
49
+
50
+ - name: Install dependencies
51
+ run: yarn --frozen-lockfile --prefer-offline
52
+ working-directory: source/
53
+
54
+ - name: Generate .d files
55
+ run: |
56
+ npx tsc
57
+ working-directory: source/
58
+ eslintapps:
59
+ name: ESLint Sample Apps
60
+ permissions:
61
+ actions: write
62
+ contents: write
63
+ id-token: write
64
+ runs-on: ubuntu-latest
13
65
  steps:
14
66
  - uses: actions/setup-node@v3
15
67
  with:
@@ -1,4 +1,6 @@
1
1
  name: Generate Test React PROD
2
+ env:
3
+ DEVELOPER_DIR: /Applications/Xcode_15.0.1.app/Contents/Developer
2
4
  on:
3
5
  workflow_dispatch:
4
6
  inputs:
@@ -107,7 +109,7 @@ jobs:
107
109
  actions: write
108
110
  contents: write
109
111
  id-token: write
110
- runs-on: macos-12
112
+ runs-on: macos-13
111
113
  timeout-minutes: 40
112
114
  steps:
113
115
  - uses: actions/setup-node@v3
@@ -156,7 +158,7 @@ jobs:
156
158
  - name: Install the provisioning profile
157
159
  run: |
158
160
  PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
159
- echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode --output $PP_PATH
161
+ echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode -o $PP_PATH
160
162
  mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
161
163
  cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
162
164
  env:
@@ -199,6 +201,11 @@ jobs:
199
201
  pod install --repo-update
200
202
  working-directory: source/examples/Basic/ios
201
203
 
204
+ - name: Apply Patches
205
+ run: |
206
+ patch -p0 < *.patch
207
+ working-directory: source/examples/Basic/patches
208
+
202
209
  - name: Build resolve Swift dependencies
203
210
  run: |
204
211
  xcodebuild -resolvePackageDependencies -workspace ios/Basic.xcworkspace -scheme BasicProduction -configuration Release
@@ -227,7 +234,7 @@ jobs:
227
234
  actions: write
228
235
  contents: write
229
236
  id-token: write
230
- runs-on: macos-12
237
+ runs-on: macos-13
231
238
  timeout-minutes: 40
232
239
  steps:
233
240
  - uses: actions/setup-node@v3
@@ -276,7 +283,7 @@ jobs:
276
283
  - name: Install the provisioning profile
277
284
  run: |
278
285
  PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
279
- echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode --output $PP_PATH
286
+ echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode -o $PP_PATH
280
287
  mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
281
288
  cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
282
289
  env:
@@ -319,6 +326,11 @@ jobs:
319
326
  RCT_NEW_ARCH_ENABLED=0 SWIFT_VERSION=5 pod install --repo-update
320
327
  working-directory: source/examples/TestNamiTV/ios
321
328
 
329
+ - name: Apply Patches
330
+ run: |
331
+ patch -p0 < *.patch
332
+ working-directory: source/examples/TestNamiTV/patches
333
+
322
334
  - name: Build resolve Swift dependencies
323
335
  run: |
324
336
  xcodebuild -resolvePackageDependencies -workspace ios/Basic.xcworkspace -scheme Basic-tvOS-PROD -configuration Release
@@ -1,4 +1,6 @@
1
1
  name: Generate Test React STG
2
+ env:
3
+ DEVELOPER_DIR: /Applications/Xcode_15.0.1.app/Contents/Developer
2
4
  on:
3
5
  workflow_dispatch:
4
6
  inputs:
@@ -107,7 +109,7 @@ jobs:
107
109
  actions: write
108
110
  contents: write
109
111
  id-token: write
110
- runs-on: macos-12
112
+ runs-on: macos-13
111
113
  timeout-minutes: 40
112
114
  steps:
113
115
  - uses: actions/setup-node@v3
@@ -156,7 +158,7 @@ jobs:
156
158
  - name: Install the provisioning profile
157
159
  run: |
158
160
  PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
159
- echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode --output $PP_PATH
161
+ echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode -o $PP_PATH
160
162
  mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
161
163
  cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
162
164
  env:
@@ -199,6 +201,11 @@ jobs:
199
201
  pod install --repo-update
200
202
  working-directory: source/examples/Basic/ios
201
203
 
204
+ - name: Apply Patches
205
+ run: |
206
+ patch -p0 < *.patch
207
+ working-directory: source/examples/Basic/patches
208
+
202
209
  - name: Build resolve Swift dependencies
203
210
  run: |
204
211
  xcodebuild -resolvePackageDependencies -workspace ios/Basic.xcworkspace -scheme Basic -configuration Release
@@ -227,7 +234,7 @@ jobs:
227
234
  actions: write
228
235
  contents: write
229
236
  id-token: write
230
- runs-on: macos-12
237
+ runs-on: macos-13
231
238
  timeout-minutes: 40
232
239
  steps:
233
240
  - uses: actions/setup-node@v3
@@ -276,7 +283,7 @@ jobs:
276
283
  - name: Install the provisioning profile
277
284
  run: |
278
285
  PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
279
- echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode --output $PP_PATH
286
+ echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode -o $PP_PATH
280
287
  mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
281
288
  cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
282
289
  env:
@@ -319,6 +326,11 @@ jobs:
319
326
  RCT_NEW_ARCH_ENABLED=0 SWIFT_VERSION=5 pod install --repo-update
320
327
  working-directory: source/examples/TestNamiTV/ios
321
328
 
329
+ - name: Apply Patches
330
+ run: |
331
+ patch -p0 < *.patch
332
+ working-directory: source/examples/TestNamiTV/patches
333
+
322
334
  - name: Build resolve Swift dependencies
323
335
  run: |
324
336
  xcodebuild -resolvePackageDependencies -workspace ios/Basic.xcworkspace -scheme Basic-tvOS -configuration Release
@@ -84,7 +84,7 @@ dependencies {
84
84
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
85
85
 
86
86
  implementation 'com.github.jeziellago:compose-markdown:0.3.0'
87
- compileOnly "com.namiml:sdk-amazon:3.1.34"
87
+ compileOnly "com.namiml:sdk-amazon:3.2.0-beta.01"
88
88
 
89
89
  implementation 'com.facebook.react:react-native:+' // From node_modules
90
90
  coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
@@ -106,7 +106,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
106
106
  } else {
107
107
  Arguments.createArray()
108
108
  }
109
- val settingsList = mutableListOf("extendedClientInfo:react-native:3.1.36")
109
+ val settingsList = mutableListOf("extendedClientInfo:react-native:3.2.0")
110
110
  namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
111
111
  settingsList.addAll(commandsFromReact)
112
112
  }
@@ -221,10 +221,13 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
221
221
  }
222
222
 
223
223
  @ReactMethod
224
- fun setProductDetails(productDetails: String, allowOffers: Boolean) {
225
- Log.i(LOG_TAG, "$productDetails")
224
+ fun setProductDetails(productDetails: String, allowOffers: Boolean) {
225
+ NamiPaywallManager.setProductDetails(productDetails, allowOffers = false)
226
+ }
226
227
 
227
- NamiPaywallManager.setProductDetails(productDetails, allowOffers = allowOffers)
228
+ @ReactMethod
229
+ fun setAppSuppliedVideoDetails(url: String, name: String?) {
230
+ // To be implemented
228
231
  }
229
232
 
230
233
  @ReactMethod
package/ios/Nami.m CHANGED
@@ -50,7 +50,7 @@ RCT_EXPORT_METHOD(configure: (NSDictionary *)configDict completion: (RCTResponse
50
50
  }
51
51
 
52
52
  // Start commands with header iformation for Nami to let them know this is a React client.
53
- NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.1.36"]];
53
+ NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.2.0"]];
54
54
 
55
55
  // Add additional namiCommands app may have sent in.
56
56
  NSObject *appCommandStrings = configDict[@"namiCommands"];
@@ -39,8 +39,9 @@ RCT_EXTERN_METHOD(isPaywallOpen:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
39
39
 
40
40
  RCT_EXTERN_METHOD(buySkuCancel)
41
41
 
42
- RCT_EXTERN_METHOD(setProductDetails:(NSString *)productDetails allowOffers:(BOOL *))
42
+ RCT_EXTERN_METHOD(setProductDetails:(NSString *)productDetails allowOffers:(nullable BOOL *))
43
43
 
44
+ RCT_EXTERN_METHOD(setAppSuppliedVideoDetails:(NSString *)url name:(nullable NSString *))
44
45
 
45
46
  + (BOOL)requiresMainQueueSetup {
46
47
  return YES;
@@ -154,7 +154,12 @@ class RNNamiPaywallManager: RCTEventEmitter {
154
154
  }
155
155
 
156
156
  @objc(setProductDetails:allowOffers:)
157
- func setProductDetails(productDetails: String, allowOffers: Bool) {
157
+ func setProductDetails(productDetails _: String, allowOffers _: Bool) {
158
158
  // Do nothing on Apple
159
159
  }
160
+
161
+ @objc(setAppSuppliedVideoDetails:name:)
162
+ func setAppSuppliedVideoDetails(url _: String, name _: String?) {
163
+ // To be implemented
164
+ }
160
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nami-sdk",
3
- "version": "3.1.37-beta.1",
3
+ "version": "3.2.0",
4
4
  "description": "React Native Module for Nami - Easy subscriptions & in-app purchases, with powerful built-in paywalls and A/B testing.",
5
5
  "main": "index.ts",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,7 @@ Pod::Spec.new do |s|
20
20
  s.source_files = "ios/**/*.{h,m,swift}"
21
21
  s.requires_arc = true
22
22
 
23
- s.dependency 'Nami', '3.1.34'
23
+ s.dependency 'Nami', '3.2.0'
24
24
  s.dependency 'React'
25
25
 
26
26
  end
package/src/Nami.d.ts CHANGED
@@ -1,113 +1,8 @@
1
- export const Nami: {
2
- configure: (
3
- config: NamiConfiguration,
4
- resultCallback?: (resultObject: { success: boolean }) => void,
5
- ) => void;
6
- };
7
-
8
- export type NamiConfiguration = {
9
- 'appPlatformID-apple': string;
10
- 'appPlatformID-android': string;
11
- logLevel: string;
12
- namiCommands?: string[];
13
- namiLanguageCode?: NamiLanguageCodes;
14
- initialConfig?: string;
15
- };
16
-
17
- export type NamiLanguageCodes =
18
- | 'af'
19
- | 'ar'
20
- | 'ar-dz'
21
- | 'ast'
22
- | 'az'
23
- | 'bg'
24
- | 'be'
25
- | 'bn'
26
- | 'br'
27
- | 'bs'
28
- | 'ca'
29
- | 'cs'
30
- | 'cy'
31
- | 'da'
32
- | 'de'
33
- | 'dsb'
34
- | 'el'
35
- | 'en'
36
- | 'en-au'
37
- | 'en-gb'
38
- | 'eo'
39
- | 'es'
40
- | 'es-ar'
41
- | 'es-co'
42
- | 'es-mx'
43
- | 'es-ni'
44
- | 'es-ve'
45
- | 'et'
46
- | 'eu'
47
- | 'fa'
48
- | 'fi'
49
- | 'fr'
50
- | 'fy'
51
- | 'ga'
52
- | 'gd'
53
- | 'gl'
54
- | 'he'
55
- | 'hi'
56
- | 'hr'
57
- | 'hsb'
58
- | 'hu'
59
- | 'hy'
60
- | 'ia'
61
- | 'id'
62
- | 'ig'
63
- | 'io'
64
- | 'is'
65
- | 'it'
66
- | 'ja'
67
- | 'ka'
68
- | 'kab'
69
- | 'kk'
70
- | 'km'
71
- | 'kn'
72
- | 'ko'
73
- | 'ky'
74
- | 'lb'
75
- | 'lt'
76
- | 'lv'
77
- | 'mk'
78
- | 'ml'
79
- | 'mn'
80
- | 'mr'
81
- | 'my'
82
- | 'nb'
83
- | 'ne'
84
- | 'nl'
85
- | 'nn'
86
- | 'os'
87
- | 'pa'
88
- | 'pl'
89
- | 'pt'
90
- | 'pt-br'
91
- | 'ro'
92
- | 'ru'
93
- | 'sk'
94
- | 'sl'
95
- | 'sq'
96
- | 'sr'
97
- | 'sr-latn'
98
- | 'sv'
99
- | 'sw'
100
- | 'ta'
101
- | 'te'
102
- | 'tg'
103
- | 'th'
104
- | 'tk'
105
- | 'tr'
106
- | 'tt'
107
- | 'udm'
108
- | 'uk'
109
- | 'ur'
110
- | 'uz'
111
- | 'vi'
112
- | 'zh-hans'
113
- | 'zh-hant';
1
+ import { NamiConfiguration } from './types';
2
+ export declare const NamiBridge: any, NamiManager: any;
3
+ export interface INami {
4
+ configure: (config: NamiConfiguration) => Promise<{
5
+ success: boolean;
6
+ }>;
7
+ }
8
+ export declare const Nami: INami;
package/src/Nami.ts CHANGED
@@ -4,18 +4,21 @@ import { NamiConfiguration } from './types';
4
4
  export const { NamiBridge, NamiManager } = NativeModules;
5
5
 
6
6
  export interface INami {
7
- configure: (
8
- config: NamiConfiguration,
9
- resultCallback?: (resultObject: { success: boolean }) => void,
10
- ) => void;
7
+ configure: (config: NamiConfiguration) => Promise<{ success: boolean }>;
11
8
  }
12
9
 
13
10
  export const Nami: INami = {
14
11
  ...NamiBridge,
15
12
  configure: (
16
13
  configureObj: NamiConfiguration,
17
- resultCallback?: (resultObject: { success: boolean }) => void,
18
- ) => {
19
- NamiBridge.configure(configureObj, resultCallback ?? (() => {}));
14
+ ): Promise<{ success: boolean }> => {
15
+ return new Promise(resolve => {
16
+ NamiBridge.configure(
17
+ configureObj,
18
+ (resultObject: { success: boolean }) => {
19
+ resolve(resultObject);
20
+ },
21
+ );
22
+ });
20
23
  },
21
24
  };
@@ -1,98 +1,18 @@
1
- import { EmitterSubscription } from 'react-native';
2
- import { NamiPaywallAction, NamiPurchase, NamiSKU } from './types';
3
-
4
- export const NamiCampaignManager: {
5
- allCampaigns: () => Promise<Array<NamiCampaign>>;
6
- isCampaignAvailable(campaignSource: string | null): Promise<boolean>;
7
- launch: (
8
- label?: string,
9
- withUrl?: string,
10
- context?: PaywallLaunchContext,
11
- resultCallback?: (success: boolean, error?: LaunchCampaignError) => void,
12
- actionCallback?: (
13
- action: NamiPaywallAction,
14
- campaignId: string,
15
- paywallId: string,
16
- campaignName?: string,
17
- campaignType?: string,
18
- campaignLabel?: string,
19
- campaignUrl?: string,
20
- paywallName?: string,
21
- segmentId?: string,
22
- externalSegmentId?: string,
23
- deeplinkUrl?: string,
24
- skuId?: string,
25
- componentChangeId?: string,
26
- componentChangeName?: string,
27
- purchaseError?: string,
28
- purchases?: NamiPurchase[],
29
- ) => void,
30
- ) => void;
31
- refresh: () => void;
32
- registerAvailableCampaignsHandler: (
33
- callback: (availableCampaigns: NamiCampaign[]) => void,
34
- ) => EmitterSubscription['remove'];
35
- };
36
-
37
- export type NamiCampaign = {
38
- id: string;
39
- rule: string;
40
- segment: string;
41
- paywall: string;
42
- type: NamiCampaignRule;
43
- value?: string | null;
44
- };
45
-
46
- export enum NamiCampaignRule {
47
- DEFAULT = 'default',
48
- LABEL = 'label',
49
- UNKNOWN = 'unknown',
50
- URL = 'url',
1
+ import { NativeEventEmitter, EmitterSubscription } from 'react-native';
2
+ import { LaunchCampaignError, NamiCampaign, NamiPaywallActionHandler, PaywallLaunchContext } from './types';
3
+ export declare const RNNamiCampaignManager: any;
4
+ export declare enum NamiCampaignManagerEvents {
5
+ ResultCampaign = "ResultCampaign",
6
+ AvailableCampaignsChanged = "AvailableCampaignsChanged"
51
7
  }
52
-
53
- export enum LaunchCampaignError {
54
- DEFAULT_CAMPAIGN_NOT_FOUND = 0,
55
- LABELED_CAMPAIGN_NOT_FOUND = 1,
56
- CAMPAIGN_DATA_NOT_FOUND = 2,
57
- PAYWALL_ALREADY_DISPLAYED = 3,
58
- SDK_NOT_INITIALIZED = 4,
8
+ interface ICampaignManager {
9
+ launchSubscription: EmitterSubscription | undefined;
10
+ emitter: NativeEventEmitter;
11
+ allCampaigns: () => Promise<Array<NamiCampaign>>;
12
+ isCampaignAvailable(campaignSource: string | null): Promise<boolean>;
13
+ launch: (label?: string, withUrl?: string, context?: PaywallLaunchContext, resultCallback?: (success: boolean, error?: LaunchCampaignError) => void, actionCallback?: NamiPaywallActionHandler) => void;
14
+ refresh: () => void;
15
+ registerAvailableCampaignsHandler: (callback: (availableCampaigns: NamiCampaign[]) => void) => EmitterSubscription['remove'];
59
16
  }
60
-
61
- export enum LaunchCampaignResultAction {
62
- FAILURE = 'FAILURE',
63
- SUCCESS = 'SUCCESS',
64
- }
65
-
66
- export type FailureResultObject = {
67
- error: string;
68
- };
69
-
70
- export type PaywallLaunchContext = {
71
- productGroups?: string[];
72
- customAttributes?: {
73
- [key: string]: string;
74
- };
75
- };
76
-
77
- export type NamiPaywallEvent = {
78
- action: NamiPaywallAction;
79
- campaignId?: string;
80
- campaignName?: string;
81
- campaignType?: string;
82
- campaignLabel?: string;
83
- campaignUrl?: string;
84
- paywallId?: string;
85
- paywallName?: string;
86
- componentChange?: NamiPaywallComponentChange;
87
- segmentId?: string;
88
- externalSegmentId?: string;
89
- deeplinkUrl?: string;
90
- sku?: NamiSKU;
91
- purchaseError?: string;
92
- purchases?: NamiPurchase[];
93
- };
94
-
95
- export type NamiPaywallComponentChange = {
96
- id?: string;
97
- name?: string;
98
- };
17
+ export declare const NamiCampaignManager: ICampaignManager;
18
+ export {};
@@ -6,8 +6,8 @@ import {
6
6
  import {
7
7
  LaunchCampaignError,
8
8
  NamiCampaign,
9
- NamiPaywallAction,
10
- NamiPurchase,
9
+ NamiPaywallActionHandler,
10
+ NamiPaywallEvent,
11
11
  PaywallLaunchContext,
12
12
  } from './types';
13
13
 
@@ -30,24 +30,7 @@ interface ICampaignManager {
30
30
  withUrl?: string,
31
31
  context?: PaywallLaunchContext,
32
32
  resultCallback?: (success: boolean, error?: LaunchCampaignError) => void,
33
- actionCallback?: (
34
- action: NamiPaywallAction,
35
- campaignId: string,
36
- paywallId: string,
37
- campaignName?: string,
38
- campaignType?: string,
39
- campaignLabel?: string,
40
- campaignUrl?: string,
41
- paywallName?: string,
42
- segmentId?: string,
43
- externalSegmentId?: string,
44
- deeplinkUrl?: string,
45
- skuId?: string,
46
- componentChangeId?: string,
47
- componentChangeName?: string,
48
- purchaseError?: string,
49
- purchases?: NamiPurchase[],
50
- ) => void,
33
+ actionCallback?: NamiPaywallActionHandler,
51
34
  ) => void;
52
35
  refresh: () => void;
53
36
  registerAvailableCampaignsHandler: (
@@ -71,43 +54,25 @@ export const NamiCampaignManager: ICampaignManager = {
71
54
  ? body.action.substring(5, body.action.length)
72
55
  : body.action;
73
56
 
74
- const {
75
- action,
76
- campaignId,
77
- paywallId,
78
- campaignName,
79
- campaignType,
80
- campaignLabel,
81
- campaignUrl,
82
- paywallName,
83
- segmentId,
84
- externalSegmentId,
85
- deeplinkUrl,
86
- skuId,
87
- componentChangeId,
88
- componentChangeName,
89
- purchaseError,
90
- purchases,
91
- } = body;
92
57
  if (actionCallback) {
93
- actionCallback(
94
- action,
95
- campaignId,
96
- paywallId,
97
- campaignName,
98
- campaignType,
99
- campaignLabel,
100
- campaignUrl,
101
- paywallName,
102
- segmentId,
103
- externalSegmentId,
104
- deeplinkUrl,
105
- skuId,
106
- componentChangeId,
107
- componentChangeName,
108
- purchaseError,
109
- purchases,
110
- );
58
+ const paywallEvent: NamiPaywallEvent = {
59
+ action: body.action,
60
+ campaignId: body.campaignId,
61
+ campaignName: body.campaignName,
62
+ campaignType: body.campaignType,
63
+ campaignLabel: body.campaignLabel,
64
+ campaignUrl: body.campaignUrl,
65
+ paywallId: body.paywallId,
66
+ paywallName: body.paywallName,
67
+ componentChange: body.componentChange,
68
+ segmentId: body.segmentId,
69
+ externalSegmentId: body.externalSegmentId,
70
+ deeplinkUrl: body.deeplinkUrl,
71
+ sku: body.sku,
72
+ purchaseError: body.purchaseError,
73
+ purchases: body.purchases,
74
+ };
75
+ actionCallback(paywallEvent);
111
76
  }
112
77
  },
113
78
  );
@@ -1,39 +1,27 @@
1
- import { EmitterSubscription } from 'react-native';
2
- import { AccountStateAction } from './types';
3
-
4
- export const NamiCustomerManager: {
5
- setCustomerAttribute: (key: string, value: string) => void;
6
- getCustomerAttribute: (key: string) => Promise<string | undefined>;
7
- clearCustomerAttribute: (key: string) => void;
8
- clearAllCustomerAttributes: () => void;
9
- journeyState: () => Promise<CustomerJourneyState | undefined>;
10
- isLoggedIn: () => Promise<boolean>;
11
- loggedInId: () => Promise<string | undefined>;
12
- deviceId: () => Promise<string>;
13
- login: (customerId: string) => void;
14
- logout: () => void;
15
- registerJourneyStateHandler: (
16
- callback: (journeyState: CustomerJourneyState) => void,
17
- ) => EmitterSubscription['remove'];
18
- registerAccountStateHandler: (
19
- callback: (
20
- action: AccountStateAction,
21
- success: boolean,
22
- error?: number,
23
- ) => void,
24
- ) => EmitterSubscription['remove'];
25
- clearCustomerDataPlatformId: () => void;
26
- setCustomerDataPlatformId: (platformId: string) => void;
27
- setAnonymousMode: (anonymousMode: boolean) => void;
28
- inAnonymousMode: () => Promise<boolean>;
29
- };
30
-
31
- export type CustomerJourneyState = {
32
- formerSubscriber: boolean;
33
- inGracePeriod: boolean;
34
- inTrialPeriod: boolean;
35
- inIntroOfferPeriod: boolean;
36
- isCancelled: boolean;
37
- inPause: boolean;
38
- inAccountHold: boolean;
39
- };
1
+ import { NativeEventEmitter, EmitterSubscription } from 'react-native';
2
+ import { AccountStateAction, CustomerJourneyState } from './types';
3
+ export declare const RNNamiCustomerManager: any;
4
+ export declare enum NamiCustomerManagerEvents {
5
+ JourneyStateChanged = "JourneyStateChanged",
6
+ AccountStateChanged = "AccountStateChanged"
7
+ }
8
+ export interface INamiCustomerManager {
9
+ emitter: NativeEventEmitter;
10
+ setCustomerAttribute: (key: string, value: string) => void;
11
+ getCustomerAttribute: (key: string) => Promise<string | undefined>;
12
+ clearCustomerAttribute: (key: string) => void;
13
+ clearAllCustomerAttributes: () => void;
14
+ journeyState: () => Promise<CustomerJourneyState | undefined>;
15
+ isLoggedIn: () => Promise<boolean>;
16
+ loggedInId: () => Promise<string | undefined>;
17
+ deviceId: () => Promise<string>;
18
+ login: (customerId: string) => void;
19
+ logout: () => void;
20
+ registerJourneyStateHandler: (callback: (journeyState: CustomerJourneyState) => void) => EmitterSubscription['remove'];
21
+ registerAccountStateHandler: (callback: (action: AccountStateAction, success: boolean, error?: number) => void) => EmitterSubscription['remove'];
22
+ clearCustomerDataPlatformId: () => void;
23
+ setCustomerDataPlatformId: (platformId: string) => void;
24
+ setAnonymousMode: (anonymousMode: boolean) => void;
25
+ inAnonymousMode: () => Promise<boolean>;
26
+ }
27
+ export declare const NamiCustomerManager: INamiCustomerManager;
@@ -1,23 +1,15 @@
1
- import { EmitterSubscription } from 'react-native';
2
- import { NamiPurchase, NamiSKU } from './types';
3
-
4
- export const NamiEntitlementManager: {
5
- active: () => Promise<Array<NamiEntitlement>>;
6
- isEntitlementActive: (label?: string) => boolean;
7
- refresh: (
8
- resultCallback?: (entitlements?: NamiEntitlement[]) => void,
9
- ) => void;
10
- registerActiveEntitlementsHandler: (
11
- callback: (activeEntitlements: NamiEntitlement[]) => void,
12
- ) => EmitterSubscription['remove'];
13
- clearProvisionalEntitlementGrants: () => void;
14
- };
15
-
16
- export type NamiEntitlement = {
17
- activePurchases: NamiPurchase[];
18
- desc: string;
19
- name: string;
20
- purchasedSkus: NamiSKU[];
21
- referenceId: string;
22
- relatedSkus: NamiSKU[];
23
- };
1
+ import { NativeEventEmitter, EmitterSubscription } from 'react-native';
2
+ import { NamiEntitlement } from './types';
3
+ export declare const RNNamiEntitlementManager: any;
4
+ export declare enum NamiEntitlementManagerEvents {
5
+ EntitlementsChanged = "EntitlementsChanged"
6
+ }
7
+ export interface INamiEntitlementManager {
8
+ emitter: NativeEventEmitter;
9
+ active: () => Promise<Array<NamiEntitlement>>;
10
+ isEntitlementActive: (label?: string) => boolean;
11
+ refresh: (resultCallback?: (entitlements?: NamiEntitlement[]) => void) => void;
12
+ registerActiveEntitlementsHandler: (callback: (activeEntitlements: NamiEntitlement[]) => void) => EmitterSubscription['remove'];
13
+ clearProvisionalEntitlementGrants: () => void;
14
+ }
15
+ export declare const NamiEntitlementManager: INamiEntitlementManager;
@@ -1,5 +1,7 @@
1
- export const NamiMLManager: {
2
- coreAction: (label: string) => void;
3
- enterCoreContent: (label: string | string[]) => void;
4
- exitCoreContent: (label: string | string[]) => void;
5
- };
1
+ export declare const NamiMLManagerBridge: any;
2
+ export interface INamiMLManager {
3
+ coreAction: (label: string) => void;
4
+ enterCoreContent: (label: string | string[]) => void;
5
+ exitCoreContent: (label: string | string[]) => void;
6
+ }
7
+ export declare const NamiMLManager: INamiMLManager;
@@ -1,3 +1,5 @@
1
- export const NamiManager: {
2
- sdkConfigured: () => Promise<boolean>;
3
- };
1
+ export declare const RNNamiManager: any;
2
+ export interface INamiManager {
3
+ sdkConfigured: () => Promise<boolean>;
4
+ }
5
+ export declare const NamiManager: INamiManager;
@@ -1,73 +1,33 @@
1
- import { EmitterSubscription } from 'react-native';
2
- import { NamiSKU } from './types';
3
-
4
- export const NamiPaywallManager: {
5
- buySkuCompleteApple: (purchaseSuccess: NamiPurchaseSuccessApple) => void;
6
- buySkuCompleteAmazon: (purchaseSuccess: NamiPurchaseSuccessAmazon) => void;
7
- buySkuCompleteGooglePlay: (
8
- purchaseSuccess: NamiPurchaseSuccessGooglePlay,
9
- ) => void;
10
- dismiss: () => Promise<boolean>;
11
- registerBuySkuHandler: (
12
- callback: (sku: NamiSKU) => void,
13
- ) => EmitterSubscription['remove'];
14
- registerCloseHandler: (callback: () => void) => EmitterSubscription['remove'];
15
- registerSignInHandler: (
16
- callback: () => void,
17
- ) => EmitterSubscription['remove'];
18
- registerRestoreHandler: (
19
- callback: () => void,
20
- ) => EmitterSubscription['remove'];
21
- registerDeeplinkActionHandler: (
22
- callback: (url: string) => void,
23
- ) => EmitterSubscription['remove'];
24
- show: () => void;
25
- hide: () => void;
26
- buySkuCancel: () => void;
27
- isHidden: () => Promise<boolean>;
28
- isPaywallOpen: () => Promise<boolean>;
29
- setProductDetails: (productDetails: string, allowOffers: boolean) => void;
30
- };
31
-
32
- export type NamiPurchaseSuccessApple = {
33
- product: NamiSKU;
34
- transactionID: string;
35
- originalTransactionID: string;
36
- price: string;
37
- currencyCode: string;
38
- };
39
-
40
- export type NamiPurchaseSuccessGooglePlay = {
41
- product: NamiSKU;
42
- orderId: string;
43
- purchaseToken: string;
44
- };
45
-
46
- export type NamiPurchaseSuccessAmazon = {
47
- product: NamiSKU;
48
- receiptId: string;
49
- localizedPrice: string;
50
- userId: string;
51
- marketplace: string;
52
- };
53
-
54
- export enum NamiPaywallAction {
55
- BUY_SKU = 'BUY_SKU',
56
- SELECT_SKU = 'SELECT_SKU',
57
- RESTORE_PURCHASES = 'RESTORE_PURCHASES',
58
- SIGN_IN = 'SIGN_IN',
59
- CLOSE_PAYWALL = 'CLOSE_PAYWALL',
60
- SHOW_PAYWALL = 'SHOW_PAYWALL',
61
- PURCHASE_SELECTED_SKU = 'PURCHASE_SELECTED_SKU',
62
- PURCHASE_SUCCESS = 'PURCHASE_SUCCESS',
63
- PURCHASE_FAILED = 'PURCHASE_FAILED',
64
- PURCHASE_CANCELLED = 'PURCHASE_CANCELLED',
65
- PURCHASE_PENDING = 'PURCHASE_PENDING',
66
- PURCHASE_UNKNOWN = 'PURCHASE_UNKNOWN',
67
- PURCHASE_DEFERRED = 'PURCHASE_DEFERRED',
68
- DEEPLINK = 'DEEPLINK',
69
- TOGGLE_CHANGE = 'TOGGLE_CHANGE',
70
- PAGE_CHANGE = 'PAGE_CHANGE',
71
- SLIDE_CHANGE = 'SLIDE_CHANGE',
72
- UNKNOWN = 'UNKNOWN',
1
+ import { NativeEventEmitter, EmitterSubscription } from 'react-native';
2
+ import { NamiPurchaseSuccessAmazon, NamiPurchaseSuccessApple, NamiPurchaseSuccessGooglePlay, NamiSKU } from './types';
3
+ export declare enum NamiPaywallManagerEvents {
4
+ RegisterBuySKU = "RegisterBuySKU",
5
+ PaywallCloseRequested = "PaywallCloseRequested",
6
+ PaywallSignInRequested = "PaywallSignInRequested",
7
+ PaywallRestoreRequested = "PaywallRestoreRequested",
8
+ PaywallDeeplinkAction = "PaywallDeeplinkAction"
73
9
  }
10
+ export declare enum ServicesEnum {
11
+ Amazon = "Amazon",
12
+ GooglePlay = "GooglePlay"
13
+ }
14
+ export interface INamiPaywallManager {
15
+ paywallEmitter: NativeEventEmitter;
16
+ buySkuCompleteApple: (purchaseSuccess: NamiPurchaseSuccessApple) => void;
17
+ buySkuCompleteAmazon: (purchaseSuccess: NamiPurchaseSuccessAmazon) => void;
18
+ buySkuCompleteGooglePlay: (purchaseSuccess: NamiPurchaseSuccessGooglePlay) => void;
19
+ buySkuCancel: () => void;
20
+ registerBuySkuHandler: (callback: (sku: NamiSKU) => void) => EmitterSubscription['remove'];
21
+ registerCloseHandler: (callback: () => void) => EmitterSubscription['remove'];
22
+ registerSignInHandler: (callback: () => void) => EmitterSubscription['remove'];
23
+ registerRestoreHandler: (callback: () => void) => EmitterSubscription['remove'];
24
+ registerDeeplinkActionHandler: (callback: (url: string) => void) => EmitterSubscription['remove'];
25
+ dismiss: () => Promise<boolean>;
26
+ show: () => void;
27
+ hide: () => void;
28
+ isHidden: () => Promise<boolean>;
29
+ isPaywallOpen: () => Promise<boolean>;
30
+ setProductDetails: (productDetails: string, allowOffers: boolean) => void;
31
+ setAppSuppliedVideoDetails: (url: string, name?: string) => void;
32
+ }
33
+ export declare const NamiPaywallManager: INamiPaywallManager;
@@ -50,6 +50,7 @@ export interface INamiPaywallManager {
50
50
  isHidden: () => Promise<boolean>;
51
51
  isPaywallOpen: () => Promise<boolean>;
52
52
  setProductDetails: (productDetails: string, allowOffers: boolean) => void;
53
+ setAppSuppliedVideoDetails: (url: string, name?: string) => void;
53
54
  }
54
55
 
55
56
  const { NamiPaywallManagerBridge, RNNamiPaywallManager } = NativeModules;
@@ -161,13 +162,10 @@ export const NamiPaywallManager: INamiPaywallManager = {
161
162
  isPaywallOpen: () => {
162
163
  return RNNamiPaywallManager.isPaywallOpen();
163
164
  },
164
- setProductDetails: (
165
- productDetails: string,
166
- allowOffers: boolean
167
- ) => {
168
- RNNamiPaywallManager.setProductDetails(
169
- productDetails,
170
- allowOffers,
171
- );
165
+ setProductDetails: (productDetails: string, allowOffers: boolean) => {
166
+ RNNamiPaywallManager.setProductDetails(productDetails, allowOffers);
167
+ },
168
+ setAppSuppliedVideoDetails: (url: string, name?: string) => {
169
+ RNNamiPaywallManager.setAppSuppliedVideoDetails(url, name);
172
170
  },
173
171
  };
@@ -1,61 +1,20 @@
1
+ import { NativeEventEmitter } from 'react-native';
1
2
  import { EmitterSubscription } from 'react-native';
2
- import { NamiSKU } from './types';
3
-
4
- export const NamiPurchaseManager: {
5
- allPurchases: () => NamiPurchase[];
6
- anySkuPurchased: (skuIds: string[]) => boolean;
7
- consumePurchasedSku: (skuId: string) => void;
8
- presentCodeRedemptionSheet: () => void;
9
- restorePurchases: (
10
- callback: (
11
- purchaseState: NamiPurchasesState,
12
- purchases: NamiPurchase[],
13
- error: string,
14
- ) => void,
15
- ) => EmitterSubscription['remove'];
16
- skuPurchased: (skuId: string) => boolean;
17
- registerPurchasesChangedHandler: (
18
- callback: (
19
- purchaseState: NamiPurchasesState,
20
- purchases: NamiPurchase[],
21
- error: string,
22
- ) => void,
23
- ) => EmitterSubscription['remove'];
24
- registerRestorePurchasesHandler: (
25
- callback: (
26
- state: NamiRestorePurchasesState,
27
- newPurchases: NamiPurchase[],
28
- oldPurchases: NamiPurchase[],
29
- ) => void,
30
- ) => EmitterSubscription['remove'];
31
- };
32
-
33
- export type NamiPurchase = {
34
- sku?: NamiSKU;
35
- skuId: string;
36
- transactionIdentifier?: string;
37
- expires?: Date;
38
- purchaseInitiatedTimestamp: Date;
39
- purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN';
40
- };
41
-
42
- export enum NamiPurchaseState {
43
- PURCHASED = 'PURCHASED',
44
- FAILED = 'FAILED',
45
- CANCELLED = 'CANCELLEDd',
46
- PENDING = 'PENDING',
47
- UNKNOWN = 'UNKNOWN',
3
+ import { NamiPurchase, NamiPurchasesState, NamiRestorePurchasesState } from './types';
4
+ export declare const NamiPurchaseManagerBridge: any, RNNamiPurchaseManager: any;
5
+ export declare enum NamiPurchaseManagerEvents {
6
+ PurchasesChanged = "PurchasesChanged",
7
+ RestorePurchasesStateChanged = "RestorePurchasesStateChanged"
48
8
  }
49
-
50
- export type NamiRestorePurchasesState = 'started' | 'finished' | 'error';
51
-
52
- export type NamiPurchasesState =
53
- | 'pending'
54
- | 'purchased'
55
- | 'consumed'
56
- | 'resubscribed'
57
- | 'unsubscribed'
58
- | 'deferred'
59
- | 'failed'
60
- | 'cancelled'
61
- | 'unknown';
9
+ export interface INamiPurchaseManager {
10
+ emitter: NativeEventEmitter;
11
+ allPurchases: () => NamiPurchase[];
12
+ anySkuPurchased: (skuIds: string[]) => boolean;
13
+ consumePurchasedSku: (skuId: string) => void;
14
+ presentCodeRedemptionSheet: () => void;
15
+ restorePurchases: (callback: (purchaseState: NamiPurchasesState, purchases: NamiPurchase[], error: string) => void) => EmitterSubscription['remove'];
16
+ skuPurchased: (skuId: string) => boolean;
17
+ registerPurchasesChangedHandler: (callback: (purchaseState: NamiPurchasesState, purchases: NamiPurchase[], error: string) => void) => EmitterSubscription['remove'];
18
+ registerRestorePurchasesHandler: (callback: (state: NamiRestorePurchasesState, newPurchases: NamiPurchase[], oldPurchases: NamiPurchase[]) => void) => EmitterSubscription['remove'];
19
+ }
20
+ export declare const NamiPurchaseManager: INamiPurchaseManager;
package/src/types.d.ts ADDED
@@ -0,0 +1,178 @@
1
+ export type NamiConfiguration = {
2
+ 'appPlatformID-apple': string;
3
+ 'appPlatformID-android': string;
4
+ logLevel: string;
5
+ namiCommands?: string[];
6
+ namiLanguageCode?: NamiLanguageCodes;
7
+ initialConfig?: string;
8
+ };
9
+ 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';
10
+ export type NamiSKU = {
11
+ id: string;
12
+ name?: string;
13
+ skuId: string;
14
+ appleProduct?: AppleProduct;
15
+ googleProduct?: GoogleProduct;
16
+ amazonProduct?: AmazonProduct;
17
+ type: NamiSKUType;
18
+ promoId?: string | null;
19
+ promoToken?: string | null;
20
+ };
21
+ export declare enum NamiPurchaseState {
22
+ PENDING = "pending",
23
+ PURCHASED = "purchased",
24
+ CONSUMED = "consumed",
25
+ RESUBSCRIBED = "resubscribed",
26
+ UNSUBSCRIBED = "unsubscribed",
27
+ DEFERRED = "deferred",
28
+ FAILED = "failed",
29
+ CANCELLED = "cancelled",
30
+ UNKNOWN = "unknown"
31
+ }
32
+ export declare enum NamiRestorePurchasesState {
33
+ STARTED = "started",
34
+ FINISHED = "finished",
35
+ ERROR = "error"
36
+ }
37
+ export type NamiSKUType = 'unknown' | 'one_time_purchase' | 'subscription';
38
+ export type AppleProduct = {
39
+ localizedDescription: string;
40
+ localizedMultipliedPrice: string;
41
+ localizedPrice: string;
42
+ localizedTitle: string;
43
+ price: string;
44
+ priceCurrency: string;
45
+ priceLanguage: string;
46
+ };
47
+ export type GoogleProduct = {};
48
+ export type AmazonProduct = {};
49
+ export type NamiCampaign = {
50
+ id: string;
51
+ rule: string;
52
+ segment: string;
53
+ paywall: string;
54
+ type: NamiCampaignRuleType;
55
+ value?: string | null;
56
+ };
57
+ export declare enum NamiCampaignRuleType {
58
+ DEFAULT = "default",
59
+ LABEL = "label",
60
+ UNKNOWN = "unknown",
61
+ URL = "url"
62
+ }
63
+ export declare enum LaunchCampaignError {
64
+ DEFAULT_CAMPAIGN_NOT_FOUND = 0,
65
+ LABELED_CAMPAIGN_NOT_FOUND = 1,
66
+ CAMPAIGN_DATA_NOT_FOUND = 2,
67
+ PAYWALL_ALREADY_DISPLAYED = 3,
68
+ SDK_NOT_INITIALIZED = 4,
69
+ PAYWALL_COULD_NOT_DISPLAY = 5,
70
+ URL_CAMPAIGN_NOT_FOUND = 6,
71
+ PRODUCT_DATA_NOT_FOUND = 7,
72
+ PRODUCT_GROUPS_NOT_FOUND = 8
73
+ }
74
+ export declare enum LaunchCampaignResultAction {
75
+ FAILURE = "FAILURE",
76
+ SUCCESS = "SUCCESS"
77
+ }
78
+ export type FailureResultObject = {
79
+ error: string;
80
+ };
81
+ export type PaywallLaunchContext = {
82
+ productGroups?: string[];
83
+ customAttributes: {
84
+ [key: string]: string;
85
+ };
86
+ customObject?: {
87
+ [key: string]: any;
88
+ };
89
+ };
90
+ export type CustomerJourneyState = {
91
+ formerSubscriber: boolean;
92
+ inGracePeriod: boolean;
93
+ inTrialPeriod: boolean;
94
+ inIntroOfferPeriod: boolean;
95
+ isCancelled: boolean;
96
+ inPause: boolean;
97
+ inAccountHold: boolean;
98
+ };
99
+ export type AccountStateAction = 'login' | 'logout' | 'advertising_id_set' | 'vendor_id_set' | 'customer_data_platform_id_set' | 'nami_device_id_set' | 'advertising_id_cleared' | 'vendor_id_cleared' | 'customer_data_platform_id_cleared' | 'nami_device_id_cleared' | 'anonymous_mode_on' | 'anonymous_mode_off';
100
+ export type NamiEntitlement = {
101
+ activePurchases: NamiPurchase[];
102
+ desc: string;
103
+ name: string;
104
+ namiId: string;
105
+ purchasedSkus: NamiSKU[];
106
+ referenceId: string;
107
+ relatedSkus: NamiSKU[];
108
+ };
109
+ export type NamiPurchaseSuccessApple = {
110
+ product: NamiSKU;
111
+ transactionID: string;
112
+ originalTransactionID: string;
113
+ price: string;
114
+ currencyCode: string;
115
+ };
116
+ export type NamiPurchaseSuccessGooglePlay = {
117
+ product: NamiSKU;
118
+ orderId: string;
119
+ purchaseToken: string;
120
+ };
121
+ export type NamiPurchaseSuccessAmazon = {
122
+ product: NamiSKU;
123
+ receiptId: string;
124
+ localizedPrice: string;
125
+ userId: string;
126
+ marketplace: string;
127
+ };
128
+ export declare enum NamiPaywallAction {
129
+ BUY_SKU = "BUY_SKU",
130
+ SELECT_SKU = "SELECT_SKU",
131
+ RESTORE_PURCHASES = "RESTORE_PURCHASES",
132
+ SIGN_IN = "SIGN_IN",
133
+ CLOSE_PAYWALL = "CLOSE_PAYWALL",
134
+ SHOW_PAYWALL = "SHOW_PAYWALL",
135
+ PURCHASE_SELECTED_SKU = "PURCHASE_SELECTED_SKU",
136
+ PURCHASE_SUCCESS = "PURCHASE_SUCCESS",
137
+ PURCHASE_FAILED = "PURCHASE_FAILED",
138
+ PURCHASE_CANCELLED = "PURCHASE_CANCELLED",
139
+ PURCHASE_PENDING = "PURCHASE_PENDING",
140
+ PURCHASE_UNKNOWN = "PURCHASE_UNKNOWN",
141
+ PURCHASE_DEFERRED = "PURCHASE_DEFERRED",
142
+ DEEPLINK = "DEEPLINK",
143
+ TOGGLE_CHANGE = "TOGGLE_CHANGE",
144
+ PAGE_CHANGE = "PAGE_CHANGE",
145
+ SLIDE_CHANGE = "SLIDE_CHANGE",
146
+ UNKNOWN = "UNKNOWN"
147
+ }
148
+ export type NamiPurchase = {
149
+ sku?: NamiSKU;
150
+ skuId: string;
151
+ transactionIdentifier?: string;
152
+ expires?: Date;
153
+ purchaseInitiatedTimestamp: Date;
154
+ purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN';
155
+ };
156
+ export type NamiPurchasesState = 'pending' | 'purchased' | 'consumed' | 'resubscribed' | 'unsubscribed' | 'deferred' | 'failed' | 'cancelled' | 'unknown';
157
+ export type NamiPaywallEvent = {
158
+ action: NamiPaywallAction;
159
+ campaignId?: string;
160
+ campaignName?: string;
161
+ campaignType?: string;
162
+ campaignLabel?: string;
163
+ campaignUrl?: string;
164
+ paywallId?: string;
165
+ paywallName?: string;
166
+ componentChange?: NamiPaywallComponentChange;
167
+ segmentId?: string;
168
+ externalSegmentId?: string;
169
+ deeplinkUrl?: string;
170
+ sku?: NamiSKU;
171
+ purchaseError?: string;
172
+ purchases?: NamiPurchase[];
173
+ };
174
+ export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;
175
+ export type NamiPaywallComponentChange = {
176
+ id?: string;
177
+ name?: string;
178
+ };
package/src/types.ts CHANGED
@@ -151,7 +151,7 @@ export type GoogleProduct = {};
151
151
 
152
152
  export type AmazonProduct = {};
153
153
 
154
- // NameCampaignManager
154
+ // NamiCampaignManager
155
155
  export type NamiCampaign = {
156
156
  id: string;
157
157
  rule: string;
@@ -177,7 +177,7 @@ export enum LaunchCampaignError {
177
177
  PAYWALL_COULD_NOT_DISPLAY = 5,
178
178
  URL_CAMPAIGN_NOT_FOUND = 6,
179
179
  PRODUCT_DATA_NOT_FOUND = 7,
180
- PRODUCT_GROUPS_NOT_FOUND = 8
180
+ PRODUCT_GROUPS_NOT_FOUND = 8,
181
181
  }
182
182
 
183
183
  export enum LaunchCampaignResultAction {
@@ -196,6 +196,10 @@ export type PaywallLaunchContext = {
196
196
  customAttributes: {
197
197
  [key: string]: string;
198
198
  };
199
+ // Custom object used as data source for advanced paywall components
200
+ customObject?: {
201
+ [key: string]: any;
202
+ };
199
203
  };
200
204
 
201
205
  export type CustomerJourneyState = {
@@ -297,3 +301,28 @@ export type NamiPurchasesState =
297
301
  | 'failed'
298
302
  | 'cancelled'
299
303
  | 'unknown';
304
+
305
+ export type NamiPaywallEvent = {
306
+ action: NamiPaywallAction;
307
+ campaignId?: string;
308
+ campaignName?: string;
309
+ campaignType?: string;
310
+ campaignLabel?: string;
311
+ campaignUrl?: string;
312
+ paywallId?: string;
313
+ paywallName?: string;
314
+ componentChange?: NamiPaywallComponentChange;
315
+ segmentId?: string;
316
+ externalSegmentId?: string;
317
+ deeplinkUrl?: string;
318
+ sku?: NamiSKU;
319
+ purchaseError?: string;
320
+ purchases?: NamiPurchase[];
321
+ };
322
+
323
+ export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;
324
+
325
+ export type NamiPaywallComponentChange = {
326
+ id?: string;
327
+ name?: string;
328
+ };
package/tsconfig.json CHANGED
@@ -9,10 +9,12 @@
9
9
  "declaration": true, /* Generates corresponding '.d.ts' file. */
10
10
  // "sourceMap": true, /* Generates corresponding '.map' file. */
11
11
  // "outFile": "./", /* Concatenate and emit output to single file. */
12
+ "declarationDir": "src", /* Output directory for generated declaration files. */
12
13
  "outDir": "dist", /* Redirect output structure to the directory. */
13
14
  "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
14
15
  // "removeComments": true, /* Do not emit comments to output. */
15
- "noEmit": true, /* Do not emit outputs. */
16
+ "emitDeclarationOnly": true, /* Only output d.ts files and not js files */
17
+ // "noEmit": true, /* Do not emit outputs. */
16
18
  // "incremental": true, /* Enable incremental compilation */
17
19
  // "importHelpers": true, /* Import emit helpers from 'tslib'. */
18
20
  // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
@@ -57,8 +59,7 @@
57
59
  // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
58
60
  },
59
61
  "include": [
60
- "./src",
61
- ".eslintrc.js"
62
+ "./src"
62
63
  ],
63
64
  "exclude": [
64
65
  "node_modules",