zixflow-reactnative 1.0.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 (284) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +451 -0
  3. package/android/build.gradle +155 -0
  4. package/android/cio-core.gradle +12 -0
  5. package/android/consumer-rules.pro +3 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +19 -0
  8. package/android/src/main/java/io/customer/reactnative/sdk/CustomerIOReactNativePackage.kt +85 -0
  9. package/android/src/main/java/io/customer/reactnative/sdk/NativeCustomerIOModule.kt +201 -0
  10. package/android/src/main/java/io/customer/reactnative/sdk/constant/Keys.kt +20 -0
  11. package/android/src/main/java/io/customer/reactnative/sdk/extension/MapExtensions.kt +92 -0
  12. package/android/src/main/java/io/customer/reactnative/sdk/extension/ReactExtensions.kt +11 -0
  13. package/android/src/main/java/io/customer/reactnative/sdk/extension/StringExtensions.kt +3 -0
  14. package/android/src/main/java/io/customer/reactnative/sdk/extension/ViewExtensions.kt +34 -0
  15. package/android/src/main/java/io/customer/reactnative/sdk/location/NativeLocationModule.kt +66 -0
  16. package/android/src/main/java/io/customer/reactnative/sdk/logging/NativeCustomerIOLoggingModule.kt +90 -0
  17. package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/InlineInAppMessageViewManager.kt +56 -0
  18. package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/NativeMessagingInAppModule.kt +215 -0
  19. package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/NotificationInboxExtensions.kt +23 -0
  20. package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/ReactInAppEventListener.kt +77 -0
  21. package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/ReactInAppPlatformDelegate.kt +37 -0
  22. package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/ReactInlineInAppMessageView.kt +44 -0
  23. package/android/src/main/java/io/customer/reactnative/sdk/messaginginapp/ReactNotificationInboxChangeListener.kt +47 -0
  24. package/android/src/main/java/io/customer/reactnative/sdk/messagingpush/NativeMessagingPushModule.kt +283 -0
  25. package/android/src/main/java/io/customer/reactnative/sdk/messagingpush/PermissionStatus.kt +9 -0
  26. package/android/src/main/java/io/customer/reactnative/sdk/messagingpush/PushMessagingExtensions.kt +58 -0
  27. package/android/src/main/java/io/customer/reactnative/sdk/util/Preconditions.kt +35 -0
  28. package/android/src/main/res/values/customer_io_config.xml +13 -0
  29. package/customerio-reactnative.podspec +60 -0
  30. package/ios/CustomerioReactnative.xcodeproj/project.pbxproj +285 -0
  31. package/ios/CustomerioReactnative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  32. package/ios/CustomerioReactnative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  33. package/ios/wrappers/CustomerioReactnative-Bridging-Header.h +2 -0
  34. package/ios/wrappers/NativeCustomerIO.mm +100 -0
  35. package/ios/wrappers/NativeCustomerIO.swift +162 -0
  36. package/ios/wrappers/inapp/InboxMessage+Conversion.swift +22 -0
  37. package/ios/wrappers/inapp/NativeMessagingInApp.mm +122 -0
  38. package/ios/wrappers/inapp/NativeMessagingInApp.swift +214 -0
  39. package/ios/wrappers/inapp/ReactInAppEventListener.swift +74 -0
  40. package/ios/wrappers/inapp/inline/InlineInAppMessageStateEvent.swift +23 -0
  41. package/ios/wrappers/inapp/inline/RCTInlineMessageNative.h +18 -0
  42. package/ios/wrappers/inapp/inline/RCTInlineMessageNative.mm +168 -0
  43. package/ios/wrappers/inapp/inline/ReactInlineMessageView.h +42 -0
  44. package/ios/wrappers/inapp/inline/ReactInlineMessageView.swift +124 -0
  45. package/ios/wrappers/location/NativeLocation.mm +52 -0
  46. package/ios/wrappers/location/NativeLocation.swift +37 -0
  47. package/ios/wrappers/logging/NativeCustomerIOLogging.mm +81 -0
  48. package/ios/wrappers/logging/NativeCustomerIOLogging.swift +62 -0
  49. package/ios/wrappers/push/NativeMessagingPush.mm +87 -0
  50. package/ios/wrappers/push/NativeMessagingPush.swift +119 -0
  51. package/ios/wrappers/utils/CioConfigUtils.swift +63 -0
  52. package/ios/wrappers/utils/CioConstants.swift +25 -0
  53. package/ios/wrappers/utils/Preconditions.swift +20 -0
  54. package/ios/wrappers/utils/RCTCustomerIOUtils.h +19 -0
  55. package/lib/commonjs/cio-params.js +2 -0
  56. package/lib/commonjs/cio-params.js.map +1 -0
  57. package/lib/commonjs/components/InlineInAppMessageView.js +146 -0
  58. package/lib/commonjs/components/InlineInAppMessageView.js.map +1 -0
  59. package/lib/commonjs/components/index.js +14 -0
  60. package/lib/commonjs/components/index.js.map +1 -0
  61. package/lib/commonjs/customerio-cdp.js +163 -0
  62. package/lib/commonjs/customerio-cdp.js.map +1 -0
  63. package/lib/commonjs/customerio-inapp.js +107 -0
  64. package/lib/commonjs/customerio-inapp.js.map +1 -0
  65. package/lib/commonjs/customerio-location.js +53 -0
  66. package/lib/commonjs/customerio-location.js.map +1 -0
  67. package/lib/commonjs/customerio-push.js +115 -0
  68. package/lib/commonjs/customerio-push.js.map +1 -0
  69. package/lib/commonjs/index.js +17 -0
  70. package/lib/commonjs/index.js.map +1 -0
  71. package/lib/commonjs/native-logger-listener.js +84 -0
  72. package/lib/commonjs/native-logger-listener.js.map +1 -0
  73. package/lib/commonjs/notification-inbox.js +132 -0
  74. package/lib/commonjs/notification-inbox.js.map +1 -0
  75. package/lib/commonjs/package.json +1 -0
  76. package/lib/commonjs/postInstall.js +13 -0
  77. package/lib/commonjs/postInstall.js.map +1 -0
  78. package/lib/commonjs/specs/components/InlineMessageNativeComponent.ts +59 -0
  79. package/lib/commonjs/specs/modules/NativeCustomerIO.js +40 -0
  80. package/lib/commonjs/specs/modules/NativeCustomerIO.js.map +1 -0
  81. package/lib/commonjs/specs/modules/NativeCustomerIOLocation.js +15 -0
  82. package/lib/commonjs/specs/modules/NativeCustomerIOLocation.js.map +1 -0
  83. package/lib/commonjs/specs/modules/NativeCustomerIOLogging.js +19 -0
  84. package/lib/commonjs/specs/modules/NativeCustomerIOLogging.js.map +1 -0
  85. package/lib/commonjs/specs/modules/NativeCustomerIOMessagingInApp.js +16 -0
  86. package/lib/commonjs/specs/modules/NativeCustomerIOMessagingInApp.js.map +1 -0
  87. package/lib/commonjs/specs/modules/NativeCustomerIOMessagingPush.js +15 -0
  88. package/lib/commonjs/specs/modules/NativeCustomerIOMessagingPush.js.map +1 -0
  89. package/lib/commonjs/types/data-pipelines.js +123 -0
  90. package/lib/commonjs/types/data-pipelines.js.map +1 -0
  91. package/lib/commonjs/types/in-app.js +43 -0
  92. package/lib/commonjs/types/in-app.js.map +1 -0
  93. package/lib/commonjs/types/index.js +39 -0
  94. package/lib/commonjs/types/index.js.map +1 -0
  95. package/lib/commonjs/types/internal.js +2 -0
  96. package/lib/commonjs/types/internal.js.map +1 -0
  97. package/lib/commonjs/types/push.js +49 -0
  98. package/lib/commonjs/types/push.js.map +1 -0
  99. package/lib/commonjs/utils/native-bridge.js +31 -0
  100. package/lib/commonjs/utils/native-bridge.js.map +1 -0
  101. package/lib/commonjs/utils/param-validation.js +136 -0
  102. package/lib/commonjs/utils/param-validation.js.map +1 -0
  103. package/lib/commonjs/zixflow.js +71 -0
  104. package/lib/commonjs/zixflow.js.map +1 -0
  105. package/lib/module/cio-params.js +2 -0
  106. package/lib/module/cio-params.js.map +1 -0
  107. package/lib/module/components/InlineInAppMessageView.js +141 -0
  108. package/lib/module/components/InlineInAppMessageView.js.map +1 -0
  109. package/lib/module/components/index.js +6 -0
  110. package/lib/module/components/index.js.map +1 -0
  111. package/lib/module/customerio-cdp.js +157 -0
  112. package/lib/module/customerio-cdp.js.map +1 -0
  113. package/lib/module/customerio-inapp.js +92 -0
  114. package/lib/module/customerio-inapp.js.map +1 -0
  115. package/lib/module/customerio-location.js +48 -0
  116. package/lib/module/customerio-location.js.map +1 -0
  117. package/lib/module/customerio-push.js +111 -0
  118. package/lib/module/customerio-push.js.map +1 -0
  119. package/lib/module/index.js +12 -0
  120. package/lib/module/index.js.map +1 -0
  121. package/lib/module/native-logger-listener.js +79 -0
  122. package/lib/module/native-logger-listener.js.map +1 -0
  123. package/lib/module/notification-inbox.js +127 -0
  124. package/lib/module/notification-inbox.js.map +1 -0
  125. package/lib/module/package.json +1 -0
  126. package/lib/module/postInstall.js +13 -0
  127. package/lib/module/postInstall.js.map +1 -0
  128. package/lib/module/specs/components/InlineMessageNativeComponent.ts +59 -0
  129. package/lib/module/specs/modules/NativeCustomerIO.js +41 -0
  130. package/lib/module/specs/modules/NativeCustomerIO.js.map +1 -0
  131. package/lib/module/specs/modules/NativeCustomerIOLocation.js +13 -0
  132. package/lib/module/specs/modules/NativeCustomerIOLocation.js.map +1 -0
  133. package/lib/module/specs/modules/NativeCustomerIOLogging.js +18 -0
  134. package/lib/module/specs/modules/NativeCustomerIOLogging.js.map +1 -0
  135. package/lib/module/specs/modules/NativeCustomerIOMessagingInApp.js +15 -0
  136. package/lib/module/specs/modules/NativeCustomerIOMessagingInApp.js.map +1 -0
  137. package/lib/module/specs/modules/NativeCustomerIOMessagingPush.js +13 -0
  138. package/lib/module/specs/modules/NativeCustomerIOMessagingPush.js.map +1 -0
  139. package/lib/module/types/data-pipelines.js +126 -0
  140. package/lib/module/types/data-pipelines.js.map +1 -0
  141. package/lib/module/types/in-app.js +42 -0
  142. package/lib/module/types/in-app.js.map +1 -0
  143. package/lib/module/types/index.js +6 -0
  144. package/lib/module/types/index.js.map +1 -0
  145. package/lib/module/types/internal.js +2 -0
  146. package/lib/module/types/internal.js.map +1 -0
  147. package/lib/module/types/push.js +47 -0
  148. package/lib/module/types/push.js.map +1 -0
  149. package/lib/module/utils/native-bridge.js +25 -0
  150. package/lib/module/utils/native-bridge.js.map +1 -0
  151. package/lib/module/utils/param-validation.js +132 -0
  152. package/lib/module/utils/param-validation.js.map +1 -0
  153. package/lib/module/zixflow.js +23 -0
  154. package/lib/module/zixflow.js.map +1 -0
  155. package/lib/typescript/commonjs/cio-params.d.ts +5 -0
  156. package/lib/typescript/commonjs/cio-params.d.ts.map +1 -0
  157. package/lib/typescript/commonjs/components/InlineInAppMessageView.d.ts +41 -0
  158. package/lib/typescript/commonjs/components/InlineInAppMessageView.d.ts.map +1 -0
  159. package/lib/typescript/commonjs/components/index.d.ts +3 -0
  160. package/lib/typescript/commonjs/components/index.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/customerio-cdp.d.ts +40 -0
  162. package/lib/typescript/commonjs/customerio-cdp.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/customerio-inapp.d.ts +48 -0
  164. package/lib/typescript/commonjs/customerio-inapp.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/customerio-location.d.ts +31 -0
  166. package/lib/typescript/commonjs/customerio-location.d.ts.map +1 -0
  167. package/lib/typescript/commonjs/customerio-push.d.ts +56 -0
  168. package/lib/typescript/commonjs/customerio-push.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/index.d.ts +8 -0
  170. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/native-logger-listener.d.ts +8 -0
  172. package/lib/typescript/commonjs/native-logger-listener.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/notification-inbox.d.ts +57 -0
  174. package/lib/typescript/commonjs/notification-inbox.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/package.json +1 -0
  176. package/lib/typescript/commonjs/postInstall.d.ts +2 -0
  177. package/lib/typescript/commonjs/postInstall.d.ts.map +1 -0
  178. package/lib/typescript/commonjs/specs/components/InlineMessageNativeComponent.d.ts +40 -0
  179. package/lib/typescript/commonjs/specs/components/InlineMessageNativeComponent.d.ts.map +1 -0
  180. package/lib/typescript/commonjs/specs/modules/NativeCustomerIO.d.ts +46 -0
  181. package/lib/typescript/commonjs/specs/modules/NativeCustomerIO.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/specs/modules/NativeCustomerIOLocation.d.ts +14 -0
  183. package/lib/typescript/commonjs/specs/modules/NativeCustomerIOLocation.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/specs/modules/NativeCustomerIOLogging.d.ts +18 -0
  185. package/lib/typescript/commonjs/specs/modules/NativeCustomerIOLogging.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/specs/modules/NativeCustomerIOMessagingInApp.d.ts +23 -0
  187. package/lib/typescript/commonjs/specs/modules/NativeCustomerIOMessagingInApp.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/specs/modules/NativeCustomerIOMessagingPush.d.ts +20 -0
  189. package/lib/typescript/commonjs/specs/modules/NativeCustomerIOMessagingPush.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/types/data-pipelines.d.ts +143 -0
  191. package/lib/typescript/commonjs/types/data-pipelines.d.ts.map +1 -0
  192. package/lib/typescript/commonjs/types/in-app.d.ts +67 -0
  193. package/lib/typescript/commonjs/types/in-app.d.ts.map +1 -0
  194. package/lib/typescript/commonjs/types/index.d.ts +4 -0
  195. package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
  196. package/lib/typescript/commonjs/types/internal.d.ts +20 -0
  197. package/lib/typescript/commonjs/types/internal.d.ts.map +1 -0
  198. package/lib/typescript/commonjs/types/push.d.ts +49 -0
  199. package/lib/typescript/commonjs/types/push.d.ts.map +1 -0
  200. package/lib/typescript/commonjs/utils/native-bridge.d.ts +9 -0
  201. package/lib/typescript/commonjs/utils/native-bridge.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/utils/param-validation.d.ts +44 -0
  203. package/lib/typescript/commonjs/utils/param-validation.d.ts.map +1 -0
  204. package/lib/typescript/commonjs/zixflow.d.ts +14 -0
  205. package/lib/typescript/commonjs/zixflow.d.ts.map +1 -0
  206. package/lib/typescript/module/cio-params.d.ts +5 -0
  207. package/lib/typescript/module/cio-params.d.ts.map +1 -0
  208. package/lib/typescript/module/components/InlineInAppMessageView.d.ts +41 -0
  209. package/lib/typescript/module/components/InlineInAppMessageView.d.ts.map +1 -0
  210. package/lib/typescript/module/components/index.d.ts +3 -0
  211. package/lib/typescript/module/components/index.d.ts.map +1 -0
  212. package/lib/typescript/module/customerio-cdp.d.ts +40 -0
  213. package/lib/typescript/module/customerio-cdp.d.ts.map +1 -0
  214. package/lib/typescript/module/customerio-inapp.d.ts +48 -0
  215. package/lib/typescript/module/customerio-inapp.d.ts.map +1 -0
  216. package/lib/typescript/module/customerio-location.d.ts +31 -0
  217. package/lib/typescript/module/customerio-location.d.ts.map +1 -0
  218. package/lib/typescript/module/customerio-push.d.ts +56 -0
  219. package/lib/typescript/module/customerio-push.d.ts.map +1 -0
  220. package/lib/typescript/module/index.d.ts +8 -0
  221. package/lib/typescript/module/index.d.ts.map +1 -0
  222. package/lib/typescript/module/native-logger-listener.d.ts +8 -0
  223. package/lib/typescript/module/native-logger-listener.d.ts.map +1 -0
  224. package/lib/typescript/module/notification-inbox.d.ts +57 -0
  225. package/lib/typescript/module/notification-inbox.d.ts.map +1 -0
  226. package/lib/typescript/module/package.json +1 -0
  227. package/lib/typescript/module/postInstall.d.ts +2 -0
  228. package/lib/typescript/module/postInstall.d.ts.map +1 -0
  229. package/lib/typescript/module/specs/components/InlineMessageNativeComponent.d.ts +40 -0
  230. package/lib/typescript/module/specs/components/InlineMessageNativeComponent.d.ts.map +1 -0
  231. package/lib/typescript/module/specs/modules/NativeCustomerIO.d.ts +46 -0
  232. package/lib/typescript/module/specs/modules/NativeCustomerIO.d.ts.map +1 -0
  233. package/lib/typescript/module/specs/modules/NativeCustomerIOLocation.d.ts +14 -0
  234. package/lib/typescript/module/specs/modules/NativeCustomerIOLocation.d.ts.map +1 -0
  235. package/lib/typescript/module/specs/modules/NativeCustomerIOLogging.d.ts +18 -0
  236. package/lib/typescript/module/specs/modules/NativeCustomerIOLogging.d.ts.map +1 -0
  237. package/lib/typescript/module/specs/modules/NativeCustomerIOMessagingInApp.d.ts +23 -0
  238. package/lib/typescript/module/specs/modules/NativeCustomerIOMessagingInApp.d.ts.map +1 -0
  239. package/lib/typescript/module/specs/modules/NativeCustomerIOMessagingPush.d.ts +20 -0
  240. package/lib/typescript/module/specs/modules/NativeCustomerIOMessagingPush.d.ts.map +1 -0
  241. package/lib/typescript/module/types/data-pipelines.d.ts +143 -0
  242. package/lib/typescript/module/types/data-pipelines.d.ts.map +1 -0
  243. package/lib/typescript/module/types/in-app.d.ts +67 -0
  244. package/lib/typescript/module/types/in-app.d.ts.map +1 -0
  245. package/lib/typescript/module/types/index.d.ts +4 -0
  246. package/lib/typescript/module/types/index.d.ts.map +1 -0
  247. package/lib/typescript/module/types/internal.d.ts +20 -0
  248. package/lib/typescript/module/types/internal.d.ts.map +1 -0
  249. package/lib/typescript/module/types/push.d.ts +49 -0
  250. package/lib/typescript/module/types/push.d.ts.map +1 -0
  251. package/lib/typescript/module/utils/native-bridge.d.ts +9 -0
  252. package/lib/typescript/module/utils/native-bridge.d.ts.map +1 -0
  253. package/lib/typescript/module/utils/param-validation.d.ts +44 -0
  254. package/lib/typescript/module/utils/param-validation.d.ts.map +1 -0
  255. package/lib/typescript/module/zixflow.d.ts +14 -0
  256. package/lib/typescript/module/zixflow.d.ts.map +1 -0
  257. package/package.json +165 -0
  258. package/src/cio-params.ts +4 -0
  259. package/src/components/InlineInAppMessageView.tsx +187 -0
  260. package/src/components/index.ts +3 -0
  261. package/src/customerio-cdp.ts +190 -0
  262. package/src/customerio-inapp.ts +127 -0
  263. package/src/customerio-location.ts +56 -0
  264. package/src/customerio-push.ts +127 -0
  265. package/src/index.ts +9 -0
  266. package/src/native-logger-listener.ts +84 -0
  267. package/src/notification-inbox.ts +154 -0
  268. package/src/postInstall.js +10 -0
  269. package/src/specs/components/InlineMessageNativeComponent.ts +59 -0
  270. package/src/specs/modules/NativeCustomerIO.ts +55 -0
  271. package/src/specs/modules/NativeCustomerIOLocation.ts +15 -0
  272. package/src/specs/modules/NativeCustomerIOLogging.ts +24 -0
  273. package/src/specs/modules/NativeCustomerIOMessagingInApp.ts +30 -0
  274. package/src/specs/modules/NativeCustomerIOMessagingPush.ts +27 -0
  275. package/src/types/data-pipelines.ts +150 -0
  276. package/src/types/in-app.ts +69 -0
  277. package/src/types/index.ts +3 -0
  278. package/src/types/internal.ts +20 -0
  279. package/src/types/push.ts +50 -0
  280. package/src/utils/native-bridge.ts +30 -0
  281. package/src/utils/param-validation.ts +178 -0
  282. package/src/zixflow.ts +24 -0
  283. package/zixflow-reactnative-richpush.podspec +42 -0
  284. package/zixflow-reactnative.podspec +66 -0
@@ -0,0 +1,30 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `The package 'customerio-reactnative' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo managed workflow\n';
8
+
9
+ /**
10
+ * Ensures the native module is available, otherwise throws a helpful linking error.
11
+ */
12
+ export function ensureNativeModule<NativeModule>(
13
+ nativeModule: NativeModule | null
14
+ ): NativeModule {
15
+ if (!nativeModule) {
16
+ throw new Error(LINKING_ERROR);
17
+ }
18
+
19
+ return nativeModule;
20
+ }
21
+
22
+ /**
23
+ * Calls a method on a native module with type-safe access.
24
+ */
25
+ export const callNativeModule = <Spec, Result>(
26
+ nativeModule: Spec,
27
+ fn: (native: Spec) => Result
28
+ ): Result => {
29
+ return fn(nativeModule);
30
+ };
@@ -0,0 +1,178 @@
1
+ // Argument validation utilities for SDK internal use
2
+ // Ensures input safety and throws clear errors when validation fails
3
+
4
+ import type { CioConfig, CustomAttributes } from '../types';
5
+
6
+ /**
7
+ * Builds a standardized error message for validation failures.
8
+ */
9
+ function buildErrorMessage(
10
+ usage: string | undefined,
11
+ fieldName: string,
12
+ error: string
13
+ ): string {
14
+ const prefix = usage ? `${usage} ` : '';
15
+ return `${prefix}"${fieldName}" ${error}.`;
16
+ }
17
+
18
+ /**
19
+ * Returns true if the value is undefined or null.
20
+ */
21
+ function isUndefined(value: unknown): boolean {
22
+ return value === undefined || value === null;
23
+ }
24
+
25
+ /**
26
+ * Throws an error if the condition is true.
27
+ * Use this to fail validation checks with cleaner syntax.
28
+ */
29
+ function failIf(condition: boolean, message: () => string): void {
30
+ if (__DEV__ && condition) {
31
+ throw new Error(`[CustomerIO] ${message()}`);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Validates that a value is defined (not undefined or null).
37
+ * Useful for checking required fields.
38
+ */
39
+ function failIfUndefined(
40
+ value: unknown,
41
+ fieldName: string,
42
+ usage?: string
43
+ ): void {
44
+ failIf(isUndefined(value), () =>
45
+ buildErrorMessage(usage, fieldName, 'is required')
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Validates that a value is a string.
51
+ * Throws if the value is not a string, or if it's empty (unless allowEmpty is true).
52
+ */
53
+ function validateString(
54
+ value: unknown,
55
+ fieldName: string,
56
+ options: {
57
+ allowEmpty?: boolean;
58
+ usage?: string;
59
+ optional?: boolean;
60
+ } = { allowEmpty: true }
61
+ ) {
62
+ const { allowEmpty, usage, optional } = options;
63
+ if (optional && isUndefined(value)) {
64
+ return; // Skip validation for optional fields
65
+ }
66
+
67
+ const prefix = usage ? `${usage} ` : '';
68
+
69
+ failIfUndefined(value, fieldName, usage);
70
+ failIf(
71
+ typeof value !== 'string',
72
+ () => `${prefix}"${fieldName}" must be a string.`
73
+ );
74
+ // Since typeof value is already checked to be a string,
75
+ // we can safely cast it here without additional checks.
76
+ const typedValue = value as string;
77
+ failIf(
78
+ !allowEmpty && typedValue.trim() === '',
79
+ () => `${prefix}"${fieldName}" must be a non-empty string.`
80
+ );
81
+ }
82
+
83
+ /**
84
+ * Validates that a value is a plain object (not null or an array).
85
+ */
86
+ function validateRecord(
87
+ value: unknown,
88
+ fieldName: string,
89
+ options: {
90
+ usage?: string;
91
+ expectedType?: string;
92
+ optional?: boolean;
93
+ } = {}
94
+ ) {
95
+ const { usage, expectedType, optional } = options;
96
+ if (optional && isUndefined(value)) {
97
+ return; // Skip validation for optional fields
98
+ }
99
+
100
+ const prefix = usage ? `${usage} ` : '';
101
+ const typeName = expectedType ?? 'plain';
102
+
103
+ failIfUndefined(value, fieldName, usage);
104
+ failIf(
105
+ typeof value !== 'object' || Array.isArray(value),
106
+ () => `${prefix}"${fieldName}" must be a valid ${typeName} object.`
107
+ );
108
+ }
109
+
110
+ /**
111
+ * Validates that a value is a valid CustomAttributes object.
112
+ * Automatically converts Map objects to plain objects for compatibility.
113
+ * This is a specialized version of validateRecord optimized for attribute validation.
114
+ */
115
+ function validateAttributes(
116
+ value: unknown,
117
+ fieldName: string,
118
+ options: {
119
+ usage?: string;
120
+ expectedType?: string;
121
+ optional?: boolean;
122
+ } = {}
123
+ ): CustomAttributes | undefined {
124
+ const exists = !isUndefined(value);
125
+ if (options.optional && !exists) {
126
+ return; // Skip validation for optional fields
127
+ }
128
+
129
+ let attributes: unknown;
130
+ if (exists && value instanceof Map) {
131
+ // Convert Map to plain object for native serialization
132
+ attributes = Object.fromEntries(value);
133
+ } else {
134
+ attributes = value;
135
+ }
136
+ validateRecord(attributes, fieldName, options);
137
+ return attributes as CustomAttributes;
138
+ }
139
+
140
+ /**
141
+ * Validates that the given value is a valid CioConfig object.
142
+ * Throws if required fields are missing or incorrectly typed.
143
+ */
144
+ function validateConfig(value: unknown): asserts value is CioConfig {
145
+ const fieldName = 'config';
146
+ const usage = 'SDK';
147
+
148
+ validateRecord(value, fieldName, {
149
+ expectedType: 'CioConfig',
150
+ usage: usage,
151
+ });
152
+
153
+ const obj = value as CioConfig;
154
+ validateString(obj.cdpApiKey, `${fieldName}.cdpApiKey`, {
155
+ allowEmpty: false,
156
+ usage: usage,
157
+ });
158
+ }
159
+
160
+ // For type safety, we define a ConfigValidator type that asserts the value is a CioConfig
161
+ // This allows us to use it in the assert object without needing to redefine the function signature
162
+ type ConfigValidator = (value: unknown) => asserts value is CioConfig;
163
+
164
+ export const assert: {
165
+ string: typeof validateString;
166
+ record: typeof validateRecord;
167
+ attributes: typeof validateAttributes;
168
+ config: ConfigValidator;
169
+ } = {
170
+ string: validateString,
171
+ record: validateRecord,
172
+ attributes: validateAttributes,
173
+ config: validateConfig,
174
+ };
175
+
176
+ export const validate = {
177
+ isUndefined: isUndefined,
178
+ };
package/src/zixflow.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Zixflow SDK - Main entry point
3
+ *
4
+ * This provides the Zixflow-branded API that wraps the underlying Customer.io implementation.
5
+ */
6
+
7
+ import { CustomerIO } from './customerio-cdp';
8
+ import { CustomerIOInAppMessaging } from './customerio-inapp';
9
+ import { CustomerIOLocation } from './customerio-location';
10
+ import { CustomerIOPushMessaging } from './customerio-push';
11
+
12
+ // Re-export the CustomerIO class as Zixflow for branding
13
+ export const Zixflow = CustomerIO;
14
+
15
+ // Re-export all types and utilities
16
+ export * from './types';
17
+ export * from './notification-inbox';
18
+
19
+ // Export sub-modules with their original names (they work with the main Zixflow class)
20
+ export {
21
+ CustomerIOInAppMessaging,
22
+ CustomerIOLocation,
23
+ CustomerIOPushMessaging,
24
+ };
@@ -0,0 +1,42 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ # Used by customers to install native iOS dependencies inside their Notification Service Extension (NSE) target to setup rich push.
6
+ # Note: We need a unique podspec for rich push because the other podspecs in this project install too many dependencies that should not be installed inside of a NSE target. We need this podspec which installs minimal dependencies that are only included in the NSE target.
7
+ Pod::Spec.new do |s|
8
+ s.name = "zixflow-reactnative-richpush"
9
+ s.version = package["version"]
10
+ s.summary = package["description"]
11
+ s.homepage = package["homepage"]
12
+ s.license = package["license"]
13
+ s.authors = package["author"]
14
+ s.platforms = { :ios => min_ios_version_supported }
15
+
16
+ s.source = { :git => "https://github.com/zixflow/zixflow-reactnative.git", :tag => "#{s.version}" }
17
+
18
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
19
+
20
+ # Note: Zixflow iOS SDK dependencies need to be added to NSE target via CocoaPods
21
+ # Add these pods to your NotificationServiceExtension target in your Podfile:
22
+ # pod "ZixflowMessagingPushAPN", "= 1.0.0" (or ZixflowMessagingPushFCM for FCM)
23
+ # pod "ZixflowMessagingPush", "= 1.0.0"
24
+ # pod "ZixflowDataPipelines", "= 1.0.0"
25
+ # pod "ZixflowCommon", "= 1.0.0"
26
+
27
+ # Subspecs allow customers to choose between multiple options of what type of version of this rich push package they would like to install.
28
+ # Set default subspec to 'apn' to prevent both APN and FCM dependencies from being installed by default.
29
+ #
30
+ # To override the default subspec, specify the desired subspec in your Podfile. For example:
31
+ # pod 'zixflow-reactnative-richpush/fcm'
32
+
33
+ s.default_subspec = 'apn'
34
+
35
+ s.subspec 'apn' do |ss|
36
+ # ZixflowMessagingPushAPN linked via SPM
37
+ end
38
+
39
+ s.subspec 'fcm' do |ss|
40
+ # ZixflowMessagingPushFCM linked via SPM
41
+ end
42
+ end
@@ -0,0 +1,66 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ # Zixflow React Native wrapper podspec
6
+ # Uses Zixflow iOS SDK via CocoaPods
7
+ Pod::Spec.new do |s|
8
+ s.name = "zixflow-reactnative"
9
+ s.version = package["version"]
10
+ s.summary = package["description"]
11
+ s.homepage = package["homepage"]
12
+ s.license = package["license"]
13
+ s.authors = package["author"]
14
+
15
+ s.platforms = { :ios => min_ios_version_supported }
16
+ s.source = { :git => "https://github.com/zixflow/zixflow-reactnative.git", :tag => "#{s.version}" }
17
+
18
+ s.source_files = "ios/wrappers/**/*.{h,m,mm,swift}"
19
+
20
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+ end
26
+
27
+ # Zixflow iOS SDK dependencies via CocoaPods
28
+ # Using `= X.X.X` for exact version matching
29
+ s.dependency "ZixflowDataPipelines", package["zixflowNativeiOSSdkVersion"]
30
+ s.dependency "ZixflowMessagingInApp", package["zixflowNativeiOSSdkVersion"]
31
+ s.dependency "ZixflowCommon", package["zixflowNativeiOSSdkVersion"]
32
+ s.dependency "ZixflowTrackingMigration", package["zixflowNativeiOSSdkVersion"]
33
+
34
+ # Transitive dependencies (required for explicit module builds)
35
+ s.dependency "AnalyticsSwiftZixflow", "1.7.3+zixflow.1"
36
+ s.dependency "JSONSafeEncoding", "~> 2.0"
37
+ s.dependency "Sovran", "~> 1.1"
38
+ s.dependency "LDSwiftEventSource", "~> 3.3"
39
+
40
+ # If we do not specify a default_subspec, then *all* dependencies inside of *all* the subspecs will be downloaded by cocoapods.
41
+ # We want customers to opt into push dependencies especially because the FCM subspec downloads Firebase dependencies. APN customers should not install Firebase dependencies at all.
42
+ s.default_subspec = "nopush"
43
+
44
+ s.subspec "nopush" do |ss|
45
+ # This is the default subspec designed to not install any push dependencies. Customer should choose APN or FCM.
46
+ # The SDK at runtime currently requires the MessagingPush module so we do include it here.
47
+ ss.dependency "ZixflowMessagingPush", package["zixflowNativeiOSSdkVersion"]
48
+ end
49
+
50
+ # Note: Subspecs inherit all dependencies specified the parent spec (this file).
51
+ s.subspec "apn" do |ss|
52
+ ss.dependency "ZixflowMessagingPushAPN", package["zixflowNativeiOSSdkVersion"]
53
+ end
54
+
55
+ s.subspec "fcm" do |ss|
56
+ ss.dependency "ZixflowMessagingPushFCM", package["zixflowNativeiOSSdkVersion"]
57
+ end
58
+
59
+ # Location module is optional - customers must opt in by adding this subspec.
60
+ s.subspec "location" do |ss|
61
+ ss.dependency "ZixflowLocation", package["zixflowNativeiOSSdkVersion"]
62
+ ss.pod_target_xcconfig = {
63
+ 'OTHER_SWIFT_FLAGS' => '$(inherited) -DCIO_LOCATION_ENABLED'
64
+ }
65
+ end
66
+ end