From db826d98c2f95c20e5b869cb578fe2c4d72b3987 Mon Sep 17 00:00:00 2001 From: Josh Vermaire Date: Thu, 23 May 2024 12:43:57 -0700 Subject: [PATCH 1/2] feat: automatically generate declaration files --- src/Nami.d.ts | 121 ++----------------------- src/NamiCampaignManager.d.ts | 112 ++++------------------- src/NamiCustomerManager.d.ts | 66 ++++++-------- src/NamiEntitlementManager.d.ts | 38 ++++---- src/NamiMLManager.d.ts | 12 +-- src/NamiManager.d.ts | 8 +- src/NamiPaywallManager.d.ts | 103 +++++++-------------- src/NamiPurchaseManager.d.ts | 77 ++++------------ src/types.d.ts | 153 ++++++++++++++++++++++++++++++++ tsconfig.json | 7 +- 10 files changed, 284 insertions(+), 413 deletions(-) create mode 100644 src/types.d.ts diff --git a/src/Nami.d.ts b/src/Nami.d.ts index ccc4a335..3615c82a 100644 --- a/src/Nami.d.ts +++ b/src/Nami.d.ts @@ -1,113 +1,8 @@ -export const Nami: { - configure: ( - config: NamiConfiguration, - resultCallback?: (resultObject: { success: boolean }) => void, - ) => void; -}; - -export type NamiConfiguration = { - 'appPlatformID-apple': string; - 'appPlatformID-android': string; - logLevel: string; - namiCommands?: string[]; - namiLanguageCode?: NamiLanguageCodes; - initialConfig?: string; -}; - -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'; +import { NamiConfiguration } from './types'; +export declare const NamiBridge: any, NamiManager: any; +export interface INami { + configure: (config: NamiConfiguration, resultCallback?: (resultObject: { + success: boolean; + }) => void) => void; +} +export declare const Nami: INami; diff --git a/src/NamiCampaignManager.d.ts b/src/NamiCampaignManager.d.ts index a1594118..cc3d0e47 100644 --- a/src/NamiCampaignManager.d.ts +++ b/src/NamiCampaignManager.d.ts @@ -1,98 +1,18 @@ -import { EmitterSubscription } from 'react-native'; -import { NamiPaywallAction, NamiPurchase, NamiSKU } from './types'; - -export const NamiCampaignManager: { - allCampaigns: () => Promise>; - isCampaignAvailable(campaignSource: string | null): Promise; - launch: ( - label?: string, - withUrl?: string, - context?: PaywallLaunchContext, - resultCallback?: (success: boolean, error?: LaunchCampaignError) => void, - actionCallback?: ( - action: NamiPaywallAction, - campaignId: string, - paywallId: string, - campaignName?: string, - campaignType?: string, - campaignLabel?: string, - campaignUrl?: string, - paywallName?: string, - segmentId?: string, - externalSegmentId?: string, - deeplinkUrl?: string, - skuId?: string, - componentChangeId?: string, - componentChangeName?: string, - purchaseError?: string, - purchases?: NamiPurchase[], - ) => void, - ) => void; - refresh: () => void; - registerAvailableCampaignsHandler: ( - callback: (availableCampaigns: NamiCampaign[]) => void, - ) => EmitterSubscription['remove']; -}; - -export type NamiCampaign = { - id: string; - rule: string; - segment: string; - paywall: string; - type: NamiCampaignRule; - value?: string | null; -}; - -export enum NamiCampaignRule { - DEFAULT = 'default', - LABEL = 'label', - UNKNOWN = 'unknown', - URL = 'url', +import { NativeEventEmitter, EmitterSubscription } from 'react-native'; +import { LaunchCampaignError, NamiCampaign, NamiPaywallAction, NamiPurchase, PaywallLaunchContext } from './types'; +export declare const RNNamiCampaignManager: any; +export declare enum NamiCampaignManagerEvents { + ResultCampaign = "ResultCampaign", + AvailableCampaignsChanged = "AvailableCampaignsChanged" } - -export enum LaunchCampaignError { - DEFAULT_CAMPAIGN_NOT_FOUND = 0, - LABELED_CAMPAIGN_NOT_FOUND = 1, - CAMPAIGN_DATA_NOT_FOUND = 2, - PAYWALL_ALREADY_DISPLAYED = 3, - SDK_NOT_INITIALIZED = 4, +interface ICampaignManager { + launchSubscription: EmitterSubscription | undefined; + emitter: NativeEventEmitter; + allCampaigns: () => Promise>; + isCampaignAvailable(campaignSource: string | null): Promise; + launch: (label?: string, withUrl?: string, context?: PaywallLaunchContext, resultCallback?: (success: boolean, error?: LaunchCampaignError) => void, actionCallback?: (action: NamiPaywallAction, campaignId: string, paywallId: string, campaignName?: string, campaignType?: string, campaignLabel?: string, campaignUrl?: string, paywallName?: string, segmentId?: string, externalSegmentId?: string, deeplinkUrl?: string, skuId?: string, componentChangeId?: string, componentChangeName?: string, purchaseError?: string, purchases?: NamiPurchase[]) => void) => void; + refresh: () => void; + registerAvailableCampaignsHandler: (callback: (availableCampaigns: NamiCampaign[]) => void) => EmitterSubscription['remove']; } - -export enum LaunchCampaignResultAction { - FAILURE = 'FAILURE', - SUCCESS = 'SUCCESS', -} - -export type FailureResultObject = { - error: string; -}; - -export type PaywallLaunchContext = { - productGroups?: string[]; - customAttributes?: { - [key: string]: string; - }; -}; - -export type NamiPaywallEvent = { - action: NamiPaywallAction; - campaignId?: string; - campaignName?: string; - campaignType?: string; - campaignLabel?: string; - campaignUrl?: string; - paywallId?: string; - paywallName?: string; - componentChange?: NamiPaywallComponentChange; - segmentId?: string; - externalSegmentId?: string; - deeplinkUrl?: string; - sku?: NamiSKU; - purchaseError?: string; - purchases?: NamiPurchase[]; -}; - -export type NamiPaywallComponentChange = { - id?: string; - name?: string; -}; +export declare const NamiCampaignManager: ICampaignManager; +export {}; diff --git a/src/NamiCustomerManager.d.ts b/src/NamiCustomerManager.d.ts index 7d15c0d8..c0f7262b 100644 --- a/src/NamiCustomerManager.d.ts +++ b/src/NamiCustomerManager.d.ts @@ -1,39 +1,27 @@ -import { EmitterSubscription } from 'react-native'; -import { AccountStateAction } from './types'; - -export const NamiCustomerManager: { - setCustomerAttribute: (key: string, value: string) => void; - getCustomerAttribute: (key: string) => Promise; - clearCustomerAttribute: (key: string) => void; - clearAllCustomerAttributes: () => void; - journeyState: () => Promise; - isLoggedIn: () => Promise; - loggedInId: () => Promise; - deviceId: () => Promise; - login: (customerId: string) => void; - logout: () => void; - registerJourneyStateHandler: ( - callback: (journeyState: CustomerJourneyState) => void, - ) => EmitterSubscription['remove']; - registerAccountStateHandler: ( - callback: ( - action: AccountStateAction, - success: boolean, - error?: number, - ) => void, - ) => EmitterSubscription['remove']; - clearCustomerDataPlatformId: () => void; - setCustomerDataPlatformId: (platformId: string) => void; - setAnonymousMode: (anonymousMode: boolean) => void; - inAnonymousMode: () => Promise; -}; - -export type CustomerJourneyState = { - formerSubscriber: boolean; - inGracePeriod: boolean; - inTrialPeriod: boolean; - inIntroOfferPeriod: boolean; - isCancelled: boolean; - inPause: boolean; - inAccountHold: boolean; -}; +import { NativeEventEmitter, EmitterSubscription } from 'react-native'; +import { AccountStateAction, CustomerJourneyState } from './types'; +export declare const RNNamiCustomerManager: any; +export declare enum NamiCustomerManagerEvents { + JourneyStateChanged = "JourneyStateChanged", + AccountStateChanged = "AccountStateChanged" +} +export interface INamiCustomerManager { + emitter: NativeEventEmitter; + setCustomerAttribute: (key: string, value: string) => void; + getCustomerAttribute: (key: string) => Promise; + clearCustomerAttribute: (key: string) => void; + clearAllCustomerAttributes: () => void; + journeyState: () => Promise; + isLoggedIn: () => Promise; + loggedInId: () => Promise; + deviceId: () => Promise; + login: (customerId: string) => void; + logout: () => void; + registerJourneyStateHandler: (callback: (journeyState: CustomerJourneyState) => void) => EmitterSubscription['remove']; + registerAccountStateHandler: (callback: (action: AccountStateAction, success: boolean, error?: number) => void) => EmitterSubscription['remove']; + clearCustomerDataPlatformId: () => void; + setCustomerDataPlatformId: (platformId: string) => void; + setAnonymousMode: (anonymousMode: boolean) => void; + inAnonymousMode: () => Promise; +} +export declare const NamiCustomerManager: INamiCustomerManager; diff --git a/src/NamiEntitlementManager.d.ts b/src/NamiEntitlementManager.d.ts index f55c52cf..112b05ce 100644 --- a/src/NamiEntitlementManager.d.ts +++ b/src/NamiEntitlementManager.d.ts @@ -1,23 +1,15 @@ -import { EmitterSubscription } from 'react-native'; -import { NamiPurchase, NamiSKU } from './types'; - -export const NamiEntitlementManager: { - active: () => Promise>; - isEntitlementActive: (label?: string) => boolean; - refresh: ( - resultCallback?: (entitlements?: NamiEntitlement[]) => void, - ) => void; - registerActiveEntitlementsHandler: ( - callback: (activeEntitlements: NamiEntitlement[]) => void, - ) => EmitterSubscription['remove']; - clearProvisionalEntitlementGrants: () => void; -}; - -export type NamiEntitlement = { - activePurchases: NamiPurchase[]; - desc: string; - name: string; - purchasedSkus: NamiSKU[]; - referenceId: string; - relatedSkus: NamiSKU[]; -}; +import { NativeEventEmitter, EmitterSubscription } from 'react-native'; +import { NamiEntitlement } from './types'; +export declare const RNNamiEntitlementManager: any; +export declare enum NamiEntitlementManagerEvents { + EntitlementsChanged = "EntitlementsChanged" +} +export interface INamiEntitlementManager { + emitter: NativeEventEmitter; + active: () => Promise>; + isEntitlementActive: (label?: string) => boolean; + refresh: (resultCallback?: (entitlements?: NamiEntitlement[]) => void) => void; + registerActiveEntitlementsHandler: (callback: (activeEntitlements: NamiEntitlement[]) => void) => EmitterSubscription['remove']; + clearProvisionalEntitlementGrants: () => void; +} +export declare const NamiEntitlementManager: INamiEntitlementManager; diff --git a/src/NamiMLManager.d.ts b/src/NamiMLManager.d.ts index 1124fe20..d85a6959 100644 --- a/src/NamiMLManager.d.ts +++ b/src/NamiMLManager.d.ts @@ -1,5 +1,7 @@ -export const NamiMLManager: { - coreAction: (label: string) => void; - enterCoreContent: (label: string | string[]) => void; - exitCoreContent: (label: string | string[]) => void; -}; +export declare const NamiMLManagerBridge: any; +export interface INamiMLManager { + coreAction: (label: string) => void; + enterCoreContent: (label: string | string[]) => void; + exitCoreContent: (label: string | string[]) => void; +} +export declare const NamiMLManager: INamiMLManager; diff --git a/src/NamiManager.d.ts b/src/NamiManager.d.ts index c837c3c1..0e060fb1 100644 --- a/src/NamiManager.d.ts +++ b/src/NamiManager.d.ts @@ -1,3 +1,5 @@ -export const NamiManager: { - sdkConfigured: () => Promise; -}; +export declare const RNNamiManager: any; +export interface INamiManager { + sdkConfigured: () => Promise; +} +export declare const NamiManager: INamiManager; diff --git a/src/NamiPaywallManager.d.ts b/src/NamiPaywallManager.d.ts index 55cf89f8..fa01d800 100644 --- a/src/NamiPaywallManager.d.ts +++ b/src/NamiPaywallManager.d.ts @@ -1,73 +1,32 @@ -import { EmitterSubscription } from 'react-native'; -import { NamiSKU } from './types'; - -export const NamiPaywallManager: { - buySkuCompleteApple: (purchaseSuccess: NamiPurchaseSuccessApple) => void; - buySkuCompleteAmazon: (purchaseSuccess: NamiPurchaseSuccessAmazon) => void; - buySkuCompleteGooglePlay: ( - purchaseSuccess: NamiPurchaseSuccessGooglePlay, - ) => void; - dismiss: () => Promise; - registerBuySkuHandler: ( - callback: (sku: NamiSKU) => void, - ) => EmitterSubscription['remove']; - registerCloseHandler: (callback: () => void) => EmitterSubscription['remove']; - registerSignInHandler: ( - callback: () => void, - ) => EmitterSubscription['remove']; - registerRestoreHandler: ( - callback: () => void, - ) => EmitterSubscription['remove']; - registerDeeplinkActionHandler: ( - callback: (url: string) => void, - ) => EmitterSubscription['remove']; - show: () => void; - hide: () => void; - buySkuCancel: () => void; - isHidden: () => Promise; - isPaywallOpen: () => Promise; - setProductDetails: (productDetails: string, allowOffers: boolean) => void; -}; - -export type NamiPurchaseSuccessApple = { - product: NamiSKU; - transactionID: string; - originalTransactionID: string; - price: string; - currencyCode: string; -}; - -export type NamiPurchaseSuccessGooglePlay = { - product: NamiSKU; - orderId: string; - purchaseToken: string; -}; - -export type NamiPurchaseSuccessAmazon = { - product: NamiSKU; - receiptId: string; - localizedPrice: string; - userId: string; - marketplace: string; -}; - -export enum NamiPaywallAction { - BUY_SKU = 'BUY_SKU', - SELECT_SKU = 'SELECT_SKU', - RESTORE_PURCHASES = 'RESTORE_PURCHASES', - SIGN_IN = 'SIGN_IN', - CLOSE_PAYWALL = 'CLOSE_PAYWALL', - SHOW_PAYWALL = 'SHOW_PAYWALL', - PURCHASE_SELECTED_SKU = 'PURCHASE_SELECTED_SKU', - PURCHASE_SUCCESS = 'PURCHASE_SUCCESS', - PURCHASE_FAILED = 'PURCHASE_FAILED', - PURCHASE_CANCELLED = 'PURCHASE_CANCELLED', - PURCHASE_PENDING = 'PURCHASE_PENDING', - PURCHASE_UNKNOWN = 'PURCHASE_UNKNOWN', - PURCHASE_DEFERRED = 'PURCHASE_DEFERRED', - DEEPLINK = 'DEEPLINK', - TOGGLE_CHANGE = 'TOGGLE_CHANGE', - PAGE_CHANGE = 'PAGE_CHANGE', - SLIDE_CHANGE = 'SLIDE_CHANGE', - UNKNOWN = 'UNKNOWN', +import { NativeEventEmitter, EmitterSubscription } from 'react-native'; +import { NamiPurchaseSuccessAmazon, NamiPurchaseSuccessApple, NamiPurchaseSuccessGooglePlay, NamiSKU } from './types'; +export declare enum NamiPaywallManagerEvents { + RegisterBuySKU = "RegisterBuySKU", + PaywallCloseRequested = "PaywallCloseRequested", + PaywallSignInRequested = "PaywallSignInRequested", + PaywallRestoreRequested = "PaywallRestoreRequested", + PaywallDeeplinkAction = "PaywallDeeplinkAction" } +export declare enum ServicesEnum { + Amazon = "Amazon", + GooglePlay = "GooglePlay" +} +export interface INamiPaywallManager { + paywallEmitter: NativeEventEmitter; + buySkuCompleteApple: (purchaseSuccess: NamiPurchaseSuccessApple) => void; + buySkuCompleteAmazon: (purchaseSuccess: NamiPurchaseSuccessAmazon) => void; + buySkuCompleteGooglePlay: (purchaseSuccess: NamiPurchaseSuccessGooglePlay) => void; + buySkuCancel: () => void; + registerBuySkuHandler: (callback: (sku: NamiSKU) => void) => EmitterSubscription['remove']; + registerCloseHandler: (callback: () => void) => EmitterSubscription['remove']; + registerSignInHandler: (callback: () => void) => EmitterSubscription['remove']; + registerRestoreHandler: (callback: () => void) => EmitterSubscription['remove']; + registerDeeplinkActionHandler: (callback: (url: string) => void) => EmitterSubscription['remove']; + dismiss: () => Promise; + show: () => void; + hide: () => void; + isHidden: () => Promise; + isPaywallOpen: () => Promise; + setProductDetails: (productDetails: string, allowOffers: boolean) => void; +} +export declare const NamiPaywallManager: INamiPaywallManager; diff --git a/src/NamiPurchaseManager.d.ts b/src/NamiPurchaseManager.d.ts index 8bccd089..7ebee436 100644 --- a/src/NamiPurchaseManager.d.ts +++ b/src/NamiPurchaseManager.d.ts @@ -1,61 +1,20 @@ +import { NativeEventEmitter } from 'react-native'; import { EmitterSubscription } from 'react-native'; -import { NamiSKU } from './types'; - -export const NamiPurchaseManager: { - allPurchases: () => NamiPurchase[]; - anySkuPurchased: (skuIds: string[]) => boolean; - consumePurchasedSku: (skuId: string) => void; - presentCodeRedemptionSheet: () => void; - restorePurchases: ( - callback: ( - purchaseState: NamiPurchasesState, - purchases: NamiPurchase[], - error: string, - ) => void, - ) => EmitterSubscription['remove']; - skuPurchased: (skuId: string) => boolean; - registerPurchasesChangedHandler: ( - callback: ( - purchaseState: NamiPurchasesState, - purchases: NamiPurchase[], - error: string, - ) => void, - ) => EmitterSubscription['remove']; - registerRestorePurchasesHandler: ( - callback: ( - state: NamiRestorePurchasesState, - newPurchases: NamiPurchase[], - oldPurchases: NamiPurchase[], - ) => void, - ) => EmitterSubscription['remove']; -}; - -export type NamiPurchase = { - sku?: NamiSKU; - skuId: string; - transactionIdentifier?: string; - expires?: Date; - purchaseInitiatedTimestamp: Date; - purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN'; -}; - -export enum NamiPurchaseState { - PURCHASED = 'PURCHASED', - FAILED = 'FAILED', - CANCELLED = 'CANCELLEDd', - PENDING = 'PENDING', - UNKNOWN = 'UNKNOWN', +import { NamiPurchase, NamiPurchasesState, NamiRestorePurchasesState } from './types'; +export declare const NamiPurchaseManagerBridge: any, RNNamiPurchaseManager: any; +export declare enum NamiPurchaseManagerEvents { + PurchasesChanged = "PurchasesChanged", + RestorePurchasesStateChanged = "RestorePurchasesStateChanged" } - -export type NamiRestorePurchasesState = 'started' | 'finished' | 'error'; - -export type NamiPurchasesState = - | 'pending' - | 'purchased' - | 'consumed' - | 'resubscribed' - | 'unsubscribed' - | 'deferred' - | 'failed' - | 'cancelled' - | 'unknown'; +export interface INamiPurchaseManager { + emitter: NativeEventEmitter; + allPurchases: () => NamiPurchase[]; + anySkuPurchased: (skuIds: string[]) => boolean; + consumePurchasedSku: (skuId: string) => void; + presentCodeRedemptionSheet: () => void; + restorePurchases: (callback: (purchaseState: NamiPurchasesState, purchases: NamiPurchase[], error: string) => void) => EmitterSubscription['remove']; + skuPurchased: (skuId: string) => boolean; + registerPurchasesChangedHandler: (callback: (purchaseState: NamiPurchasesState, purchases: NamiPurchase[], error: string) => void) => EmitterSubscription['remove']; + registerRestorePurchasesHandler: (callback: (state: NamiRestorePurchasesState, newPurchases: NamiPurchase[], oldPurchases: NamiPurchase[]) => void) => EmitterSubscription['remove']; +} +export declare const NamiPurchaseManager: INamiPurchaseManager; diff --git a/src/types.d.ts b/src/types.d.ts new file mode 100644 index 00000000..8bc4c117 --- /dev/null +++ b/src/types.d.ts @@ -0,0 +1,153 @@ +export type NamiConfiguration = { + 'appPlatformID-apple': string; + 'appPlatformID-android': string; + logLevel: string; + namiCommands?: string[]; + namiLanguageCode?: NamiLanguageCodes; + initialConfig?: string; +}; +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'; +export type NamiSKU = { + id: string; + name?: string; + skuId: string; + appleProduct?: AppleProduct; + googleProduct?: GoogleProduct; + amazonProduct?: AmazonProduct; + type: NamiSKUType; + promoId?: string | null; + promoToken?: string | null; +}; +export declare enum NamiPurchaseState { + PENDING = "pending", + PURCHASED = "purchased", + CONSUMED = "consumed", + RESUBSCRIBED = "resubscribed", + UNSUBSCRIBED = "unsubscribed", + DEFERRED = "deferred", + FAILED = "failed", + CANCELLED = "cancelled", + UNKNOWN = "unknown" +} +export declare enum NamiRestorePurchasesState { + STARTED = "started", + FINISHED = "finished", + ERROR = "error" +} +export type NamiSKUType = 'unknown' | 'one_time_purchase' | 'subscription'; +export type AppleProduct = { + localizedDescription: string; + localizedMultipliedPrice: string; + localizedPrice: string; + localizedTitle: string; + price: string; + priceCurrency: string; + priceLanguage: string; +}; +export type GoogleProduct = {}; +export type AmazonProduct = {}; +export type NamiCampaign = { + id: string; + rule: string; + segment: string; + paywall: string; + type: NamiCampaignRuleType; + value?: string | null; +}; +export declare enum NamiCampaignRuleType { + DEFAULT = "default", + LABEL = "label", + UNKNOWN = "unknown", + URL = "url" +} +export declare enum LaunchCampaignError { + DEFAULT_CAMPAIGN_NOT_FOUND = 0, + LABELED_CAMPAIGN_NOT_FOUND = 1, + CAMPAIGN_DATA_NOT_FOUND = 2, + PAYWALL_ALREADY_DISPLAYED = 3, + SDK_NOT_INITIALIZED = 4, + PAYWALL_COULD_NOT_DISPLAY = 5, + URL_CAMPAIGN_NOT_FOUND = 6, + PRODUCT_DATA_NOT_FOUND = 7, + PRODUCT_GROUPS_NOT_FOUND = 8 +} +export declare enum LaunchCampaignResultAction { + FAILURE = "FAILURE", + SUCCESS = "SUCCESS" +} +export type FailureResultObject = { + error: string; +}; +export type PaywallLaunchContext = { + productGroups?: string[]; + customAttributes: { + [key: string]: string; + }; +}; +export type CustomerJourneyState = { + formerSubscriber: boolean; + inGracePeriod: boolean; + inTrialPeriod: boolean; + inIntroOfferPeriod: boolean; + isCancelled: boolean; + inPause: boolean; + inAccountHold: boolean; +}; +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'; +export type NamiEntitlement = { + activePurchases: NamiPurchase[]; + desc: string; + name: string; + namiId: string; + purchasedSkus: NamiSKU[]; + referenceId: string; + relatedSkus: NamiSKU[]; +}; +export type NamiPurchaseSuccessApple = { + product: NamiSKU; + transactionID: string; + originalTransactionID: string; + price: string; + currencyCode: string; +}; +export type NamiPurchaseSuccessGooglePlay = { + product: NamiSKU; + orderId: string; + purchaseToken: string; +}; +export type NamiPurchaseSuccessAmazon = { + product: NamiSKU; + receiptId: string; + localizedPrice: string; + userId: string; + marketplace: string; +}; +export declare enum NamiPaywallAction { + BUY_SKU = "BUY_SKU", + SELECT_SKU = "SELECT_SKU", + RESTORE_PURCHASES = "RESTORE_PURCHASES", + SIGN_IN = "SIGN_IN", + CLOSE_PAYWALL = "CLOSE_PAYWALL", + SHOW_PAYWALL = "SHOW_PAYWALL", + PURCHASE_SELECTED_SKU = "PURCHASE_SELECTED_SKU", + PURCHASE_SUCCESS = "PURCHASE_SUCCESS", + PURCHASE_FAILED = "PURCHASE_FAILED", + PURCHASE_CANCELLED = "PURCHASE_CANCELLED", + PURCHASE_PENDING = "PURCHASE_PENDING", + PURCHASE_UNKNOWN = "PURCHASE_UNKNOWN", + PURCHASE_DEFERRED = "PURCHASE_DEFERRED", + DEEPLINK = "DEEPLINK", + TOGGLE_CHANGE = "TOGGLE_CHANGE", + PAGE_CHANGE = "PAGE_CHANGE", + SLIDE_CHANGE = "SLIDE_CHANGE", + UNKNOWN = "UNKNOWN" +} +export type NamiPurchase = { + sku?: NamiSKU; + skuId: string; + transactionIdentifier?: string; + expires?: Date; + purchaseInitiatedTimestamp: Date; + purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN'; +}; +export type NamiPurchasesState = 'pending' | 'purchased' | 'consumed' | 'resubscribed' | 'unsubscribed' | 'deferred' | 'failed' | 'cancelled' | 'unknown'; diff --git a/tsconfig.json b/tsconfig.json index 6fa1d9f7..abac1c29 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,10 +9,12 @@ "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ + "declarationDir": "src", /* Output directory for generated declaration files. */ "outDir": "dist", /* Redirect output structure to the directory. */ "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "removeComments": true, /* Do not emit comments to output. */ - "noEmit": true, /* Do not emit outputs. */ + "emitDeclarationOnly": true, /* Only output d.ts files and not js files */ + // "noEmit": true, /* Do not emit outputs. */ // "incremental": true, /* Enable incremental compilation */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ @@ -57,8 +59,7 @@ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ }, "include": [ - "./src", - ".eslintrc.js" + "./src" ], "exclude": [ "node_modules", From 1af6c2f9bb7b59f23a268c7ec56236da969ae075 Mon Sep 17 00:00:00 2001 From: Josh Vermaire Date: Wed, 19 Jun 2024 12:19:32 -0700 Subject: [PATCH 2/2] chore: add NamiPaywallEvent type --- src/types.d.ts | 21 +++++++++++++++++++++ src/types.ts | 25 ++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/types.d.ts b/src/types.d.ts index 8bc4c117..d5d5c136 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -151,3 +151,24 @@ export type NamiPurchase = { purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN'; }; export type NamiPurchasesState = 'pending' | 'purchased' | 'consumed' | 'resubscribed' | 'unsubscribed' | 'deferred' | 'failed' | 'cancelled' | 'unknown'; +export type NamiPaywallEvent = { + action: NamiPaywallAction; + campaignId?: string; + campaignName?: string; + campaignType?: string; + campaignLabel?: string; + campaignUrl?: string; + paywallId?: string; + paywallName?: string; + componentChange?: NamiPaywallComponentChange; + segmentId?: string; + externalSegmentId?: string; + deeplinkUrl?: string; + sku?: NamiSKU; + purchaseError?: string; + purchases?: NamiPurchase[]; +}; +export type NamiPaywallComponentChange = { + id?: string; + name?: string; +}; diff --git a/src/types.ts b/src/types.ts index 725ac9cc..76d348e4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -151,7 +151,7 @@ export type GoogleProduct = {}; export type AmazonProduct = {}; -// NameCampaignManager +// NamiCampaignManager export type NamiCampaign = { id: string; rule: string; @@ -297,3 +297,26 @@ export type NamiPurchasesState = | 'failed' | 'cancelled' | 'unknown'; + +export type NamiPaywallEvent = { + action: NamiPaywallAction; + campaignId?: string; + campaignName?: string; + campaignType?: string; + campaignLabel?: string; + campaignUrl?: string; + paywallId?: string; + paywallName?: string; + componentChange?: NamiPaywallComponentChange; + segmentId?: string; + externalSegmentId?: string; + deeplinkUrl?: string; + sku?: NamiSKU; + purchaseError?: string; + purchases?: NamiPurchase[]; +}; + +export type NamiPaywallComponentChange = { + id?: string; + name?: string; +};