-
Notifications
You must be signed in to change notification settings - Fork 38
[MOB-11826] make-frontend-api-and-codegen #685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ export const Login = ({ navigation }: RootStackScreenProps<Route.Login>) => { | |
<TextInput | ||
style={styles.input} | ||
onChangeText={setUserId} | ||
value={userId} | ||
value={userId ?? ''} | ||
placeholder="eg: [email protected] or 1234567890" | ||
autoCapitalize="none" | ||
autoCorrect={false} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import type { TurboModule } from 'react-native'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
import { TurboModuleRegistry } from 'react-native'; | ||
|
||
export interface Spec extends TurboModule { | ||
// Initialization | ||
initializeWithApiKey( | ||
apiKey: string, | ||
config: { [key: string]: string | number | boolean | undefined | string[] }, | ||
version: string | ||
): Promise<boolean>; | ||
|
||
initialize2WithApiKey( | ||
apiKey: string, | ||
config: { [key: string]: string | number | boolean | undefined | string[] }, | ||
apiEndPointOverride: string, | ||
version: string | ||
): Promise<boolean>; | ||
|
||
// User management | ||
setEmail(email: string | null, authToken?: string | null): void; | ||
getEmail(): Promise<string | null>; | ||
setUserId(userId?: string | null, authToken?: string | null): void; | ||
getUserId(): Promise<string | null | undefined>; | ||
|
||
// In-app messaging | ||
setInAppShowResponse(number: number): void; | ||
getInAppMessages(): Promise<{ [key: string]: string | number | boolean }[]>; | ||
getInboxMessages(): Promise<{ [key: string]: string | number | boolean }[]>; | ||
getUnreadInboxMessagesCount(): Promise<number>; | ||
showMessage(messageId: string, consume: boolean): Promise<string | null>; | ||
removeMessage(messageId: string, location: number, source: number): void; | ||
setReadForMessage(messageId: string, read: boolean): void; | ||
setAutoDisplayPaused(autoDisplayPaused: boolean): void; | ||
|
||
// Tracking | ||
trackEvent( | ||
name: string, | ||
dataFields?: { [key: string]: string | number | boolean } | ||
): void; | ||
trackPushOpenWithCampaignId( | ||
campaignId: number, | ||
templateId: number | null, | ||
messageId: string, | ||
appAlreadyRunning: boolean, | ||
dataFields?: { [key: string]: string | number | boolean } | ||
): void; | ||
trackInAppOpen(messageId: string, location: number): void; | ||
trackInAppClick( | ||
messageId: string, | ||
location: number, | ||
clickedUrl: string | ||
): void; | ||
trackInAppClose( | ||
messageId: string, | ||
location: number, | ||
source: number, | ||
clickedUrl?: string | ||
): void; | ||
inAppConsume(messageId: string, location: number, source: number): void; | ||
|
||
// Commerce | ||
updateCart(items: { [key: string]: string | number | boolean }[]): void; | ||
trackPurchase( | ||
total: number, | ||
items: { [key: string]: string | number | boolean }[], | ||
dataFields?: { [key: string]: string | number | boolean } | ||
): void; | ||
|
||
// User data | ||
updateUser( | ||
dataFields: { [key: string]: string | number | boolean }, | ||
mergeNestedObjects: boolean | ||
): void; | ||
updateEmail(email: string, authToken?: string): void; | ||
|
||
// Attribution | ||
getAttributionInfo(): Promise<{ | ||
[key: string]: string | number | boolean; | ||
} | null>; | ||
setAttributionInfo( | ||
dict: { [key: string]: string | number | boolean } | null | ||
): void; | ||
|
||
// Device management | ||
disableDeviceForCurrentUser(): void; | ||
getLastPushPayload(): Promise<{ | ||
[key: string]: string | number | boolean; | ||
} | null>; | ||
|
||
// Content | ||
getHtmlInAppContentForMessage( | ||
messageId: string | ||
): Promise<{ [key: string]: string | number | boolean }>; | ||
|
||
// App links | ||
handleAppLink(appLink: string): Promise<boolean>; | ||
|
||
// Subscriptions | ||
updateSubscriptions( | ||
emailListIds: number[] | null, | ||
unsubscribedChannelIds: number[] | null, | ||
unsubscribedMessageTypeIds: number[] | null, | ||
subscribedMessageTypeIds: number[] | null, | ||
campaignId: number, | ||
templateId: number | ||
): void; | ||
|
||
// Session tracking | ||
startSession( | ||
visibleRows: { [key: string]: string | number | boolean }[] | ||
): void; | ||
endSession(): void; | ||
updateVisibleRows( | ||
visibleRows: { [key: string]: string | number | boolean }[] | ||
): void; | ||
|
||
// Auth | ||
passAlongAuthToken(authToken?: string | null): void; | ||
|
||
// Wake app -- android only | ||
wakeApp(): void; | ||
|
||
|
||
// REQUIRED for RCTEventEmitter | ||
addListener(eventName: string): void; | ||
removeListeners(count: number): void; | ||
} | ||
|
||
// Check if we're in a test environment | ||
const isTestEnvironment = () => { | ||
return ( | ||
typeof jest !== 'undefined' || | ||
process.env.NODE_ENV === 'test' || | ||
process.env.JEST_WORKER_ID !== undefined | ||
); | ||
}; | ||
|
||
export default isTestEnvironment() | ||
? undefined | ||
: TurboModuleRegistry.getEnforcing<Spec>('RNIterableAPI'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { NativeModules } from 'react-native'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
import BridgelessModule from './NativeRNIterableAPI'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure where the BridgelessModule specifically comes from. |
||
|
||
export const RNIterableAPI = BridgelessModule ?? NativeModules.RNIterableAPI; | ||
|
||
export default RNIterableAPI; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { | ||
Linking, | ||
NativeEventEmitter, | ||
NativeModules, | ||
Platform, | ||
} from 'react-native'; | ||
|
||
import { buildInfo } from '../../itblBuildInfo'; | ||
|
||
import { RNIterableAPI } from '../../api'; | ||
// TODO: Organize these so that there are no circular dependencies | ||
// See https://github.com/expo/expo/issues/35100 | ||
import { IterableInAppMessage } from '../../inApp/classes/IterableInAppMessage'; | ||
|
@@ -23,7 +23,6 @@ import type { IterableCommerceItem } from './IterableCommerceItem'; | |
import { IterableConfig } from './IterableConfig'; | ||
import { IterableLogger } from './IterableLogger'; | ||
|
||
const RNIterableAPI = NativeModules.RNIterableAPI; | ||
const RNEventEmitter = new NativeEventEmitter(RNIterableAPI); | ||
|
||
/* eslint-disable tsdoc/syntax */ | ||
|
@@ -181,7 +180,7 @@ export class Iterable { | |
* Iterable.setEmail('[email protected]'); | ||
* ``` | ||
*/ | ||
static setEmail(email?: string | null, authToken?: string | null) { | ||
static setEmail(email: string | null, authToken?: string | null) { | ||
Iterable?.logger?.log('setEmail: ' + email); | ||
|
||
RNIterableAPI.setEmail(email, authToken); | ||
|
@@ -197,7 +196,7 @@ export class Iterable { | |
* }); | ||
* ``` | ||
*/ | ||
static getEmail(): Promise<string | undefined> { | ||
static getEmail(): Promise<string | null> { | ||
Iterable?.logger?.log('getEmail'); | ||
|
||
return RNIterableAPI.getEmail(); | ||
|
@@ -262,7 +261,7 @@ export class Iterable { | |
* }); | ||
* ``` | ||
*/ | ||
static getUserId(): Promise<string | undefined> { | ||
static getUserId(): Promise<string | null | undefined> { | ||
Iterable?.logger?.log('getUserId'); | ||
|
||
return RNIterableAPI.getUserId(); | ||
|
@@ -325,12 +324,12 @@ export class Iterable { | |
Iterable?.logger?.log('getAttributionInfo'); | ||
|
||
return RNIterableAPI.getAttributionInfo().then( | ||
(dict?: IterableAttributionInfo) => { | ||
(dict: { campaignId: number; templateId: number; messageId: string } | null) => { | ||
if (dict) { | ||
return new IterableAttributionInfo( | ||
dict.campaignId, | ||
dict.templateId, | ||
dict.messageId | ||
dict.campaignId as number, | ||
dict.templateId as number, | ||
dict.messageId as string | ||
); | ||
} else { | ||
return undefined; | ||
|
@@ -366,7 +365,7 @@ export class Iterable { | |
static setAttributionInfo(attributionInfo?: IterableAttributionInfo) { | ||
Iterable?.logger?.log('setAttributionInfo'); | ||
|
||
RNIterableAPI.setAttributionInfo(attributionInfo); | ||
RNIterableAPI.setAttributionInfo(attributionInfo as unknown as { [key: string]: string | number | boolean; } | null); | ||
} | ||
|
||
/** | ||
|
@@ -410,9 +409,9 @@ export class Iterable { | |
RNIterableAPI.trackPushOpenWithCampaignId( | ||
campaignId, | ||
templateId, | ||
messageId, | ||
messageId as string, | ||
appAlreadyRunning, | ||
dataFields | ||
dataFields as { [key: string]: string | number | boolean } | undefined | ||
); | ||
} | ||
|
||
|
@@ -445,7 +444,7 @@ export class Iterable { | |
static updateCart(items: IterableCommerceItem[]) { | ||
Iterable?.logger?.log('updateCart'); | ||
|
||
RNIterableAPI.updateCart(items); | ||
RNIterableAPI.updateCart(items as unknown as { [key: string]: string | number | boolean }[]); | ||
} | ||
|
||
/** | ||
|
@@ -497,7 +496,7 @@ export class Iterable { | |
) { | ||
Iterable?.logger?.log('trackPurchase'); | ||
|
||
RNIterableAPI.trackPurchase(total, items, dataFields); | ||
RNIterableAPI.trackPurchase(total, items as unknown as { [key: string]: string | number | boolean }[], dataFields as { [key: string]: string | number | boolean } | undefined); | ||
} | ||
|
||
/** | ||
|
@@ -666,7 +665,7 @@ export class Iterable { | |
static trackEvent(name: string, dataFields?: unknown) { | ||
Iterable?.logger?.log('trackEvent'); | ||
|
||
RNIterableAPI.trackEvent(name, dataFields); | ||
RNIterableAPI.trackEvent(name, dataFields as { [key: string]: string | number | boolean } | undefined); | ||
} | ||
|
||
/** | ||
|
@@ -714,7 +713,7 @@ export class Iterable { | |
) { | ||
Iterable?.logger?.log('updateUser'); | ||
|
||
RNIterableAPI.updateUser(dataFields, mergeNestedObjects); | ||
RNIterableAPI.updateUser(dataFields as { [key: string]: string | number | boolean }, mergeNestedObjects); | ||
} | ||
|
||
/** | ||
|
@@ -859,10 +858,10 @@ export class Iterable { | |
* ``` | ||
*/ | ||
static updateSubscriptions( | ||
emailListIds: number[] | undefined, | ||
unsubscribedChannelIds: number[] | undefined, | ||
unsubscribedMessageTypeIds: number[] | undefined, | ||
subscribedMessageTypeIds: number[] | undefined, | ||
emailListIds: number[] | null, | ||
unsubscribedChannelIds: number[] | null, | ||
unsubscribedMessageTypeIds: number[] | null, | ||
subscribedMessageTypeIds: number[] | null, | ||
campaignId: number, | ||
templateId: number | ||
Comment on lines
860
to
866
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Comment on lines
860
to
866
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error loading TSDoc config file:
Error encountered for /home/runner/work/react-native-sdk/tsdoc.json:
Unable to resolve "extends" reference to "typedoc/tsdoc.json": Cannot find module 'typedoc/tsdoc.json' from '/home/runner/work/react-native-sdk'
[eslint:tsdoc/syntax]