@ammarahmed/notifee-react-native 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/.gitattributes +3 -0
  2. package/LICENSE +44 -0
  3. package/README.md +131 -0
  4. package/RNNotifee.podspec +39 -0
  5. package/RNNotifeeCore.podspec +33 -0
  6. package/android/build.gradle +116 -0
  7. package/android/gradle.properties +1 -0
  8. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar +0 -0
  9. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.md5 +1 -0
  10. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha1 +1 -0
  11. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha256 +1 -0
  12. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha512 +1 -0
  13. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom +9 -0
  14. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.md5 +1 -0
  15. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha1 +1 -0
  16. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha256 +1 -0
  17. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha512 +1 -0
  18. package/android/libs/app/notifee/core/maven-metadata.xml +13 -0
  19. package/android/libs/app/notifee/core/maven-metadata.xml.md5 +1 -0
  20. package/android/libs/app/notifee/core/maven-metadata.xml.sha1 +1 -0
  21. package/android/libs/app/notifee/core/maven-metadata.xml.sha256 +1 -0
  22. package/android/libs/app/notifee/core/maven-metadata.xml.sha512 +1 -0
  23. package/android/lint.xml +5 -0
  24. package/android/proguard-rules.pro +74 -0
  25. package/android/settings.gradle +1 -0
  26. package/android/src/main/AndroidManifest.xml +12 -0
  27. package/android/src/main/java/io/invertase/notifee/NotifeeApiModule.java +349 -0
  28. package/android/src/main/java/io/invertase/notifee/NotifeeEventSubscriber.java +118 -0
  29. package/android/src/main/java/io/invertase/notifee/NotifeeInitProvider.java +55 -0
  30. package/android/src/main/java/io/invertase/notifee/NotifeePackage.java +30 -0
  31. package/android/src/main/java/io/invertase/notifee/NotifeeReactUtils.java +244 -0
  32. package/app.plugin.js +1 -0
  33. package/dist/NotifeeApiModule.d.ts +53 -0
  34. package/dist/NotifeeApiModule.js +607 -0
  35. package/dist/NotifeeApiModule.js.map +1 -0
  36. package/dist/NotifeeJSEventEmitter.d.ts +3 -0
  37. package/dist/NotifeeJSEventEmitter.js +14 -0
  38. package/dist/NotifeeJSEventEmitter.js.map +1 -0
  39. package/dist/NotifeeNativeError.d.ts +15 -0
  40. package/dist/NotifeeNativeError.js +61 -0
  41. package/dist/NotifeeNativeError.js.map +1 -0
  42. package/dist/NotifeeNativeModule.d.ts +14 -0
  43. package/dist/NotifeeNativeModule.js +43 -0
  44. package/dist/NotifeeNativeModule.js.map +1 -0
  45. package/dist/NotifeeNativeModule.web.d.ts +12 -0
  46. package/dist/NotifeeNativeModule.web.js +19 -0
  47. package/dist/NotifeeNativeModule.web.js.map +1 -0
  48. package/dist/index.d.ts +8 -0
  49. package/dist/index.js +43 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/types/Library.d.ts +21 -0
  52. package/dist/types/Library.js +6 -0
  53. package/dist/types/Library.js.map +1 -0
  54. package/dist/types/Module.d.ts +572 -0
  55. package/dist/types/Module.js +6 -0
  56. package/dist/types/Module.js.map +1 -0
  57. package/dist/types/Notification.d.ts +450 -0
  58. package/dist/types/Notification.js +105 -0
  59. package/dist/types/Notification.js.map +1 -0
  60. package/dist/types/NotificationAndroid.d.ts +1276 -0
  61. package/dist/types/NotificationAndroid.js +380 -0
  62. package/dist/types/NotificationAndroid.js.map +1 -0
  63. package/dist/types/NotificationIOS.d.ts +537 -0
  64. package/dist/types/NotificationIOS.js +92 -0
  65. package/dist/types/NotificationIOS.js.map +1 -0
  66. package/dist/types/NotificationWeb.d.ts +5 -0
  67. package/dist/types/NotificationWeb.js +3 -0
  68. package/dist/types/NotificationWeb.js.map +1 -0
  69. package/dist/types/PowerManagerInfo.d.ts +36 -0
  70. package/dist/types/PowerManagerInfo.js +6 -0
  71. package/dist/types/PowerManagerInfo.js.map +1 -0
  72. package/dist/types/Trigger.d.ts +108 -0
  73. package/dist/types/Trigger.js +39 -0
  74. package/dist/types/Trigger.js.map +1 -0
  75. package/dist/utils/id.d.ts +1 -0
  76. package/dist/utils/id.js +16 -0
  77. package/dist/utils/id.js.map +1 -0
  78. package/dist/utils/index.d.ts +16 -0
  79. package/dist/utils/index.js +52 -0
  80. package/dist/utils/index.js.map +1 -0
  81. package/dist/utils/validate.d.ts +15 -0
  82. package/dist/utils/validate.js +93 -0
  83. package/dist/utils/validate.js.map +1 -0
  84. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.d.ts +2 -0
  85. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js +39 -0
  86. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js.map +1 -0
  87. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.d.ts +2 -0
  88. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js +27 -0
  89. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js.map +1 -0
  90. package/dist/validators/validate.d.ts +25 -0
  91. package/dist/validators/validate.js +75 -0
  92. package/dist/validators/validate.js.map +1 -0
  93. package/dist/validators/validateAndroidAction.d.ts +2 -0
  94. package/dist/validators/validateAndroidAction.js +52 -0
  95. package/dist/validators/validateAndroidAction.js.map +1 -0
  96. package/dist/validators/validateAndroidChannel.d.ts +2 -0
  97. package/dist/validators/validateAndroidChannel.js +155 -0
  98. package/dist/validators/validateAndroidChannel.js.map +1 -0
  99. package/dist/validators/validateAndroidChannelGroup.d.ts +2 -0
  100. package/dist/validators/validateAndroidChannelGroup.js +42 -0
  101. package/dist/validators/validateAndroidChannelGroup.js.map +1 -0
  102. package/dist/validators/validateAndroidFullScreenAction.d.ts +2 -0
  103. package/dist/validators/validateAndroidFullScreenAction.js +50 -0
  104. package/dist/validators/validateAndroidFullScreenAction.js.map +1 -0
  105. package/dist/validators/validateAndroidInput.d.ts +2 -0
  106. package/dist/validators/validateAndroidInput.js +54 -0
  107. package/dist/validators/validateAndroidInput.js.map +1 -0
  108. package/dist/validators/validateAndroidNotification.d.ts +2 -0
  109. package/dist/validators/validateAndroidNotification.js +529 -0
  110. package/dist/validators/validateAndroidNotification.js.map +1 -0
  111. package/dist/validators/validateAndroidPressAction.d.ts +2 -0
  112. package/dist/validators/validateAndroidPressAction.js +50 -0
  113. package/dist/validators/validateAndroidPressAction.js.map +1 -0
  114. package/dist/validators/validateAndroidStyle.d.ts +22 -0
  115. package/dist/validators/validateAndroidStyle.js +231 -0
  116. package/dist/validators/validateAndroidStyle.js.map +1 -0
  117. package/dist/validators/validateIOSAttachment.d.ts +6 -0
  118. package/dist/validators/validateIOSAttachment.js +102 -0
  119. package/dist/validators/validateIOSAttachment.js.map +1 -0
  120. package/dist/validators/validateIOSCategory.d.ts +2 -0
  121. package/dist/validators/validateIOSCategory.js +124 -0
  122. package/dist/validators/validateIOSCategory.js.map +1 -0
  123. package/dist/validators/validateIOSCategoryAction.d.ts +2 -0
  124. package/dist/validators/validateIOSCategoryAction.js +59 -0
  125. package/dist/validators/validateIOSCategoryAction.js.map +1 -0
  126. package/dist/validators/validateIOSInput.d.ts +2 -0
  127. package/dist/validators/validateIOSInput.js +32 -0
  128. package/dist/validators/validateIOSInput.js.map +1 -0
  129. package/dist/validators/validateIOSNotification.d.ts +2 -0
  130. package/dist/validators/validateIOSNotification.js +211 -0
  131. package/dist/validators/validateIOSNotification.js.map +1 -0
  132. package/dist/validators/validateIOSPermissions.d.ts +2 -0
  133. package/dist/validators/validateIOSPermissions.js +62 -0
  134. package/dist/validators/validateIOSPermissions.js.map +1 -0
  135. package/dist/validators/validateNotification.d.ts +11 -0
  136. package/dist/validators/validateNotification.js +129 -0
  137. package/dist/validators/validateNotification.js.map +1 -0
  138. package/dist/validators/validateTrigger.d.ts +2 -0
  139. package/dist/validators/validateTrigger.js +104 -0
  140. package/dist/validators/validateTrigger.js.map +1 -0
  141. package/dist/version.d.ts +1 -0
  142. package/dist/version.js.map +1 -0
  143. package/ios/NotifeeCore/Info.plist +22 -0
  144. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.h +28 -0
  145. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +72 -0
  146. package/ios/NotifeeCore/NotifeeCore+NSURLSession.h +25 -0
  147. package/ios/NotifeeCore/NotifeeCore+NSURLSession.m +55 -0
  148. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.h +37 -0
  149. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +242 -0
  150. package/ios/NotifeeCore/NotifeeCore.h +118 -0
  151. package/ios/NotifeeCore/NotifeeCore.m +784 -0
  152. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.h +34 -0
  153. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.m +70 -0
  154. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.h +39 -0
  155. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.m +68 -0
  156. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.h +38 -0
  157. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.m +224 -0
  158. package/ios/NotifeeCore/NotifeeCoreUtil.h +82 -0
  159. package/ios/NotifeeCore/NotifeeCoreUtil.m +793 -0
  160. package/ios/RNNotifee/NotifeeApiModule.h +25 -0
  161. package/ios/RNNotifee/NotifeeApiModule.m +371 -0
  162. package/ios/RNNotifee/NotifeeExtensionHelper.h +37 -0
  163. package/ios/RNNotifee/NotifeeExtensionHelper.m +37 -0
  164. package/ios/RNNotifee.xcodeproj/project.pbxproj +318 -0
  165. package/jest-mock.js +158 -0
  166. package/package.json +59 -0
  167. package/plugin/build/index.d.ts +3 -0
  168. package/plugin/build/index.js +12 -0
  169. package/plugin/build/index.js.map +1 -0
  170. package/plugin/build/withNotifeeProjectGradlePlugin.d.ts +5 -0
  171. package/plugin/build/withNotifeeProjectGradlePlugin.js +24 -0
  172. package/plugin/build/withNotifeeProjectGradlePlugin.js.map +1 -0
  173. package/plugin/src/index.ts +9 -0
  174. package/plugin/src/withNotifeeProjectGradlePlugin.ts +27 -0
  175. package/plugin/tsconfig.json +9 -0
  176. package/react-native.config.js +11 -0
  177. package/refresh-example.sh +71 -0
  178. package/src/NotifeeApiModule.ts +825 -0
  179. package/src/NotifeeJSEventEmitter.ts +11 -0
  180. package/src/NotifeeNativeError.ts +70 -0
  181. package/src/NotifeeNativeModule.ts +55 -0
  182. package/src/NotifeeNativeModule.web.ts +25 -0
  183. package/src/index.ts +33 -0
  184. package/src/types/Library.ts +28 -0
  185. package/src/types/Module.ts +625 -0
  186. package/src/types/Notification.ts +505 -0
  187. package/src/types/NotificationAndroid.ts +1443 -0
  188. package/src/types/NotificationIOS.ts +681 -0
  189. package/src/types/NotificationWeb.ts +5 -0
  190. package/src/types/PowerManagerInfo.ts +43 -0
  191. package/src/types/Trigger.ts +118 -0
  192. package/src/utils/id.ts +13 -0
  193. package/src/utils/index.ts +47 -0
  194. package/src/utils/validate.ts +92 -0
  195. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts +45 -0
  196. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.ts +33 -0
  197. package/src/validators/validate.ts +85 -0
  198. package/src/validators/validateAndroidAction.ts +54 -0
  199. package/src/validators/validateAndroidChannel.ts +188 -0
  200. package/src/validators/validateAndroidChannelGroup.ts +49 -0
  201. package/src/validators/validateAndroidFullScreenAction.ts +65 -0
  202. package/src/validators/validateAndroidInput.ts +67 -0
  203. package/src/validators/validateAndroidNotification.ts +704 -0
  204. package/src/validators/validateAndroidPressAction.ts +65 -0
  205. package/src/validators/validateAndroidStyle.ts +315 -0
  206. package/src/validators/validateIOSAttachment.ts +136 -0
  207. package/src/validators/validateIOSCategory.ts +150 -0
  208. package/src/validators/validateIOSCategoryAction.ts +65 -0
  209. package/src/validators/validateIOSInput.ts +38 -0
  210. package/src/validators/validateIOSNotification.ts +296 -0
  211. package/src/validators/validateIOSPermissions.ts +78 -0
  212. package/src/validators/validateNotification.ts +156 -0
  213. package/src/validators/validateTrigger.ts +134 -0
  214. package/src/version.ts +2 -0
  215. package/tsconfig.json +23 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Interface for building a trigger with a timestamp.
3
+ *
4
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more.
5
+ */
6
+ export interface TimestampTrigger {
7
+ /**
8
+ * Constant enum value used to identify the trigger type.
9
+ */
10
+ type: TriggerType.TIMESTAMP;
11
+ /**
12
+ * The timestamp when the notification should first be shown, in milliseconds since 1970.
13
+ */
14
+ timestamp: number;
15
+ /**
16
+ * The frequency at which the trigger repeats.
17
+ * If unset, the notification will only be displayed once.
18
+ *
19
+ * For example:
20
+ * if set to `RepeatFrequency.HOURLY`, the notification will repeat every hour from the timestamp specified.
21
+ * if set to `RepeatFrequency.DAILY`, the notification will repeat every day from the timestamp specified.
22
+ * if set to `RepeatFrequency.WEEKLY`, the notification will repeat every week from the timestamp specified.
23
+ */
24
+ repeatFrequency?: RepeatFrequency;
25
+ /**
26
+ * Choose to schedule your trigger notification with Android's AlarmManager API.
27
+ *
28
+ * By default, trigger notifications are created with Android's WorkManager API.
29
+ *
30
+ * @platform android
31
+ */
32
+ alarmManager?: boolean | TimestampTriggerAlarmManager | undefined;
33
+ }
34
+ /**
35
+ * Interface to specify additional options for the AlarmManager which can be used with `TimestampTrigger.alarmManager`.
36
+ *
37
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more.
38
+ *
39
+ * @platform android
40
+ */
41
+ export interface TimestampTriggerAlarmManager {
42
+ /**
43
+ * Sets whether your trigger notification should be displayed even when the system is in low-power idle modes.
44
+ *
45
+ * Defaults to `false`.
46
+ */
47
+ allowWhileIdle?: boolean;
48
+ }
49
+ /**
50
+ * An interface representing the different frequencies which can be used with `TimestampTrigger.repeatFrequency`.
51
+ *
52
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more.
53
+ */
54
+ export declare enum RepeatFrequency {
55
+ NONE = -1,
56
+ HOURLY = 0,
57
+ DAILY = 1,
58
+ WEEKLY = 2,
59
+ MONTHLY = 3
60
+ }
61
+ /**
62
+ * Interface for building a trigger that repeats at a specified interval.
63
+ *
64
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more.
65
+ */
66
+ export interface IntervalTrigger {
67
+ /**
68
+ * Constant enum value used to identify the trigger type.
69
+ */
70
+ type: TriggerType.INTERVAL;
71
+ /**
72
+ * How frequently the notification should be repeated.
73
+ *
74
+ * For example, if set to 30, the notification will be displayed every 30 minutes.
75
+ *
76
+ * Must be set to a minimum of 15 minutes.
77
+ */
78
+ interval: number;
79
+ /**
80
+ * The unit of time that the `interval` is measured in.
81
+ *
82
+ * For example, if set to `TimeUnit.DAYS` and repeat interval is set to 3, the notification will repeat every 3 days.
83
+ *
84
+ * Defaults to `TimeUnit.SECONDS`
85
+ */
86
+ timeUnit?: TimeUnit | TimeUnit.SECONDS;
87
+ }
88
+ /**
89
+ * An interface representing the different units of time which can be used with `IntervalTrigger.timeUnit`.
90
+ *
91
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more.
92
+ */
93
+ export declare enum TimeUnit {
94
+ SECONDS = "SECONDS",
95
+ MINUTES = "MINUTES",
96
+ HOURS = "HOURS",
97
+ DAYS = "DAYS"
98
+ }
99
+ /**
100
+ * Available Trigger Types.
101
+ *
102
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more with example usage.
103
+ */
104
+ export declare enum TriggerType {
105
+ TIMESTAMP = 0,
106
+ INTERVAL = 1
107
+ }
108
+ export declare type Trigger = TimestampTrigger | IntervalTrigger;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TriggerType = exports.TimeUnit = exports.RepeatFrequency = void 0;
4
+ /**
5
+ * An interface representing the different frequencies which can be used with `TimestampTrigger.repeatFrequency`.
6
+ *
7
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more.
8
+ */
9
+ var RepeatFrequency;
10
+ (function (RepeatFrequency) {
11
+ RepeatFrequency[RepeatFrequency["NONE"] = -1] = "NONE";
12
+ RepeatFrequency[RepeatFrequency["HOURLY"] = 0] = "HOURLY";
13
+ RepeatFrequency[RepeatFrequency["DAILY"] = 1] = "DAILY";
14
+ RepeatFrequency[RepeatFrequency["WEEKLY"] = 2] = "WEEKLY";
15
+ RepeatFrequency[RepeatFrequency["MONTHLY"] = 3] = "MONTHLY";
16
+ })(RepeatFrequency = exports.RepeatFrequency || (exports.RepeatFrequency = {}));
17
+ /**
18
+ * An interface representing the different units of time which can be used with `IntervalTrigger.timeUnit`.
19
+ *
20
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more.
21
+ */
22
+ var TimeUnit;
23
+ (function (TimeUnit) {
24
+ TimeUnit["SECONDS"] = "SECONDS";
25
+ TimeUnit["MINUTES"] = "MINUTES";
26
+ TimeUnit["HOURS"] = "HOURS";
27
+ TimeUnit["DAYS"] = "DAYS";
28
+ })(TimeUnit = exports.TimeUnit || (exports.TimeUnit = {}));
29
+ /**
30
+ * Available Trigger Types.
31
+ *
32
+ * View the [Triggers](/react-native/docs/triggers) documentation to learn more with example usage.
33
+ */
34
+ var TriggerType;
35
+ (function (TriggerType) {
36
+ TriggerType[TriggerType["TIMESTAMP"] = 0] = "TIMESTAMP";
37
+ TriggerType[TriggerType["INTERVAL"] = 1] = "INTERVAL";
38
+ })(TriggerType = exports.TriggerType || (exports.TriggerType = {}));
39
+ //# sourceMappingURL=Trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Trigger.js","sourceRoot":"","sources":["../../src/types/Trigger.ts"],"names":[],"mappings":";;;AAoDA;;;;GAIG;AACH,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,sDAAS,CAAA;IACT,yDAAU,CAAA;IACV,uDAAS,CAAA;IACT,yDAAU,CAAA;IACV,2DAAW,CAAA;AACb,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B;AAgCD;;;;GAIG;AACH,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,2BAAe,CAAA;IACf,yBAAa,CAAA;AACf,CAAC,EALW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAKnB;AAED;;;;GAIG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,uDAAa,CAAA;IACb,qDAAY,CAAA;AACd,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB"}
@@ -0,0 +1 @@
1
+ export declare function generateId(): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2016-present Invertase Limited
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateId = void 0;
7
+ const CHARACTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
8
+ function generateId() {
9
+ let newId = '';
10
+ for (let i = 0; i < 20; i++) {
11
+ newId += CHARACTERS.charAt(Math.floor(Math.random() * CHARACTERS.length));
12
+ }
13
+ return newId;
14
+ }
15
+ exports.generateId = generateId;
16
+ //# sourceMappingURL=id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/utils/id.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAM,UAAU,GAAG,gEAAgE,CAAC;AAEpF,SAAgB,UAAU;IACxB,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;QAC3B,KAAK,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;KAC3E;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAND,gCAMC"}
@@ -0,0 +1,16 @@
1
+ export * from './id';
2
+ export * from './validate';
3
+ export declare function isError(value: object): boolean;
4
+ export declare function objectHasProperty<T>(target: T, property: string | number | symbol): property is keyof T;
5
+ export declare const isIOS: boolean;
6
+ export declare const isAndroid: boolean;
7
+ export declare const isWeb: boolean;
8
+ export declare function noop(): void;
9
+ export declare const kReactNativeNotifeeForegroundServiceHeadlessTask = "app.notifee.foreground-service-headless-task";
10
+ export declare const kReactNativeNotifeeNotificationEvent = "app.notifee.notification-event";
11
+ export declare const kReactNativeNotifeeNotificationBackgroundEvent = "app.notifee.notification-event-background";
12
+ export declare enum NotificationType {
13
+ ALL = 0,
14
+ DISPLAYED = 1,
15
+ TRIGGER = 2
16
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2016-present Invertase Limited
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.NotificationType = exports.kReactNativeNotifeeNotificationBackgroundEvent = exports.kReactNativeNotifeeNotificationEvent = exports.kReactNativeNotifeeForegroundServiceHeadlessTask = exports.noop = exports.isWeb = exports.isAndroid = exports.isIOS = exports.objectHasProperty = exports.isError = void 0;
21
+ const react_native_1 = require("react-native");
22
+ __exportStar(require("./id"), exports);
23
+ __exportStar(require("./validate"), exports);
24
+ /* eslint-disable-next-line @typescript-eslint/ban-types */
25
+ function isError(value) {
26
+ if (Object.prototype.toString.call(value) === '[object Error]') {
27
+ return true;
28
+ }
29
+ return value instanceof Error;
30
+ }
31
+ exports.isError = isError;
32
+ function objectHasProperty(target, property) {
33
+ return Object.hasOwnProperty.call(target, property);
34
+ }
35
+ exports.objectHasProperty = objectHasProperty;
36
+ exports.isIOS = react_native_1.Platform.OS === 'ios';
37
+ exports.isAndroid = react_native_1.Platform.OS === 'android';
38
+ exports.isWeb = react_native_1.Platform.OS === 'web';
39
+ function noop() {
40
+ // noop-🐈
41
+ }
42
+ exports.noop = noop;
43
+ exports.kReactNativeNotifeeForegroundServiceHeadlessTask = 'app.notifee.foreground-service-headless-task';
44
+ exports.kReactNativeNotifeeNotificationEvent = 'app.notifee.notification-event';
45
+ exports.kReactNativeNotifeeNotificationBackgroundEvent = 'app.notifee.notification-event-background';
46
+ var NotificationType;
47
+ (function (NotificationType) {
48
+ NotificationType[NotificationType["ALL"] = 0] = "ALL";
49
+ NotificationType[NotificationType["DISPLAYED"] = 1] = "DISPLAYED";
50
+ NotificationType[NotificationType["TRIGGER"] = 2] = "TRIGGER";
51
+ })(NotificationType = exports.NotificationType || (exports.NotificationType = {}));
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,+CAAwC;AAExC,uCAAqB;AACrB,6CAA2B;AAE3B,2DAA2D;AAC3D,SAAgB,OAAO,CAAC,KAAa;IACnC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,gBAAgB,EAAE;QAC9D,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,YAAY,KAAK,CAAC;AAChC,CAAC;AAND,0BAMC;AAED,SAAgB,iBAAiB,CAC/B,MAAS,EACT,QAAkC;IAElC,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC;AALD,8CAKC;AAEY,QAAA,KAAK,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAE9B,QAAA,SAAS,GAAG,uBAAQ,CAAC,EAAE,KAAK,SAAS,CAAC;AAEtC,QAAA,KAAK,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAE3C,SAAgB,IAAI;IAClB,UAAU;AACZ,CAAC;AAFD,oBAEC;AACY,QAAA,gDAAgD,GAC3D,8CAA8C,CAAC;AAEpC,QAAA,oCAAoC,GAAG,gCAAgC,CAAC;AAExE,QAAA,8CAA8C,GACzD,2CAA2C,CAAC;AAE9C,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,qDAAO,CAAA;IACP,iEAAa,CAAA;IACb,6DAAW,CAAA;AACb,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B"}
@@ -0,0 +1,15 @@
1
+ export declare function isNull(value: any): value is null;
2
+ export declare function isObject(value: any): value is object;
3
+ export declare function isFunction(value: any): value is Function;
4
+ export declare function isString(value: any): value is string;
5
+ export declare function isNumber(value: any): value is number;
6
+ export declare function isBoolean(value: any): value is boolean;
7
+ export declare function isArray(value: any): value is Array<any>;
8
+ export declare function isArrayOfStrings(value: any): value is Array<string>;
9
+ export declare function isUndefined(value: any): value is undefined;
10
+ export declare function objectKeyValuesAreStrings(value: object): value is {
11
+ [key: string]: string;
12
+ };
13
+ export declare function isAlphaNumericUnderscore(value: string): boolean;
14
+ export declare function isValidUrl(url: string): boolean;
15
+ export declare function isValidEnum(value: any, enumType: Record<string, any>): boolean;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidEnum = exports.isValidUrl = exports.isAlphaNumericUnderscore = exports.objectKeyValuesAreStrings = exports.isUndefined = exports.isArrayOfStrings = exports.isArray = exports.isBoolean = exports.isNumber = exports.isString = exports.isFunction = exports.isObject = exports.isNull = void 0;
4
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
5
+ /* eslint-disable @typescript-eslint/ban-types */
6
+ /*
7
+ * Copyright (c) 2016-present Invertase Limited
8
+ */
9
+ function isNull(value) {
10
+ return value === null;
11
+ }
12
+ exports.isNull = isNull;
13
+ function isObject(value) {
14
+ return value ? typeof value === 'object' && !Array.isArray(value) && !isNull(value) : false;
15
+ }
16
+ exports.isObject = isObject;
17
+ function isFunction(value) {
18
+ return value ? typeof value === 'function' : false;
19
+ }
20
+ exports.isFunction = isFunction;
21
+ function isString(value) {
22
+ return typeof value === 'string';
23
+ }
24
+ exports.isString = isString;
25
+ function isNumber(value) {
26
+ return typeof value === 'number';
27
+ }
28
+ exports.isNumber = isNumber;
29
+ function isBoolean(value) {
30
+ return typeof value === 'boolean';
31
+ }
32
+ exports.isBoolean = isBoolean;
33
+ function isArray(value) {
34
+ return Array.isArray(value);
35
+ }
36
+ exports.isArray = isArray;
37
+ function isArrayOfStrings(value) {
38
+ if (!isArray(value))
39
+ return false;
40
+ for (let i = 0; i < value.length; i++) {
41
+ if (!isString(value[i]))
42
+ return false;
43
+ }
44
+ return true;
45
+ }
46
+ exports.isArrayOfStrings = isArrayOfStrings;
47
+ function isUndefined(value) {
48
+ return value === undefined;
49
+ }
50
+ exports.isUndefined = isUndefined;
51
+ function objectKeyValuesAreStrings(value) {
52
+ if (!isObject(value)) {
53
+ return false;
54
+ }
55
+ const entries = Object.entries(value);
56
+ for (let i = 0; i < entries.length; i++) {
57
+ const [key, entryValue] = entries[i];
58
+ if (!isString(key) || !isString(entryValue)) {
59
+ return false;
60
+ }
61
+ }
62
+ return true;
63
+ }
64
+ exports.objectKeyValuesAreStrings = objectKeyValuesAreStrings;
65
+ /**
66
+ * /^[a-zA-Z0-9_]+$/
67
+ *
68
+ * @param value
69
+ * @returns {boolean}
70
+ */
71
+ const AlphaNumericUnderscore = /^[a-zA-Z0-9_]+$/;
72
+ function isAlphaNumericUnderscore(value) {
73
+ return AlphaNumericUnderscore.test(value);
74
+ }
75
+ exports.isAlphaNumericUnderscore = isAlphaNumericUnderscore;
76
+ /**
77
+ * URL test
78
+ * @param url
79
+ * @returns {boolean}
80
+ */
81
+ const IS_VALID_URL_REGEX = /^(http|https):\/\/[^ "]+$/;
82
+ function isValidUrl(url) {
83
+ return IS_VALID_URL_REGEX.test(url);
84
+ }
85
+ exports.isValidUrl = isValidUrl;
86
+ function isValidEnum(value, enumType) {
87
+ if (!Object.values(enumType).includes(value)) {
88
+ return false;
89
+ }
90
+ return true;
91
+ }
92
+ exports.isValidEnum = isValidEnum;
93
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,iDAAiD;AACjD;;GAEG;AACH,SAAgB,MAAM,CAAC,KAAU;IAC/B,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB,CAAC;AAFD,wBAEC;AAED,SAAgB,QAAQ,CAAC,KAAU;IACjC,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9F,CAAC;AAFD,4BAEC;AAED,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;AACrD,CAAC;AAFD,gCAEC;AAED,SAAgB,QAAQ,CAAC,KAAU;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED,SAAgB,QAAQ,CAAC,KAAU;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,4BAEC;AAED,SAAgB,SAAS,CAAC,KAAU;IAClC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC;AAFD,8BAEC;AAED,SAAgB,OAAO,CAAC,KAAU;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAFD,0BAEC;AAED,SAAgB,gBAAgB,CAAC,KAAU;IACzC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;KACvC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAND,4CAMC;AAED,SAAgB,WAAW,CAAC,KAAU;IACpC,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B,CAAC;AAFD,kCAEC;AAED,SAAgB,yBAAyB,CAAC,KAAa;IACrD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACpB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC3C,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAfD,8DAeC;AAED;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEjD,SAAgB,wBAAwB,CAAC,KAAa;IACpD,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAFD,4DAEC;AAED;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAEvD,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAFD,gCAEC;AAED,SAAgB,WAAW,CAAC,KAAU,EAAE,QAA6B;IACnE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5C,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAND,kCAMC"}
@@ -0,0 +1,2 @@
1
+ import { IOSCommunicationInfo } from '../../types/NotificationIOS';
2
+ export default function validateIOSCommunicationInfo(communicationInfo: IOSCommunicationInfo): IOSCommunicationInfo;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const validateIOSCommunicationInfoPerson_1 = __importDefault(require("./validateIOSCommunicationInfoPerson"));
8
+ function validateIOSCommunicationInfo(communicationInfo) {
9
+ if (!(0, utils_1.isObject)(communicationInfo)) {
10
+ throw new Error('expected an object.');
11
+ }
12
+ if (!(0, utils_1.isString)(communicationInfo.conversationId) ||
13
+ communicationInfo.conversationId.length === 0) {
14
+ throw new Error("'conversationId' expected a valid string value.");
15
+ }
16
+ if (!communicationInfo.sender || !(0, utils_1.isObject)(communicationInfo.sender)) {
17
+ throw new Error("'sender' expected a valid object value.");
18
+ }
19
+ let sender;
20
+ try {
21
+ sender = (0, validateIOSCommunicationInfoPerson_1.default)(communicationInfo.sender);
22
+ }
23
+ catch (e) {
24
+ throw new Error(`'sender' ${e.message}.`);
25
+ }
26
+ const out = {
27
+ conversationId: communicationInfo.conversationId,
28
+ sender,
29
+ };
30
+ if (communicationInfo.body) {
31
+ if (!(0, utils_1.isString)(communicationInfo.body)) {
32
+ throw new Error("'body' expected a valid string value.");
33
+ }
34
+ out.body = communicationInfo.body;
35
+ }
36
+ return out;
37
+ }
38
+ exports.default = validateIOSCommunicationInfo;
39
+ //# sourceMappingURL=validateIOSCommunicationInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateIOSCommunicationInfo.js","sourceRoot":"","sources":["../../../src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts"],"names":[],"mappings":";;;;;AACA,uCAAiD;AACjD,8GAAsF;AAEtF,SAAwB,4BAA4B,CAClD,iBAAuC;IAEvC,IAAI,CAAC,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;KACxC;IAED,IACE,CAAC,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,cAAc,CAAC;QAC3C,iBAAiB,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAC7C;QACA,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;KACpE;IAED,IAAI,CAAC,iBAAiB,CAAC,MAAM,IAAI,CAAC,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE;QACpE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IAED,IAAI,MAAM,CAAC;IAEX,IAAI;QACF,MAAM,GAAG,IAAA,4CAAkC,EAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;KACvE;IAAC,OAAO,CAAM,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;KAC3C;IAED,MAAM,GAAG,GAAyB;QAChC,cAAc,EAAE,iBAAiB,CAAC,cAAc;QAChD,MAAM;KACP,CAAC;IAEF,IAAI,iBAAiB,CAAC,IAAI,EAAE;QAC1B,IAAI,CAAC,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;SAC1D;QAED,GAAG,CAAC,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC;KACnC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAxCD,+CAwCC"}
@@ -0,0 +1,2 @@
1
+ import { IOSCommunicationInfoPerson } from '../../types/NotificationIOS';
2
+ export default function validateIOSCommunicationInfoPerson(person: IOSCommunicationInfoPerson): IOSCommunicationInfoPerson;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../utils");
4
+ function validateIOSCommunicationInfoPerson(person) {
5
+ if (!(0, utils_1.isObject)(person)) {
6
+ throw new Error("'person' expected an object.");
7
+ }
8
+ if (!(0, utils_1.isString)(person.id) || person.id.length === 0) {
9
+ throw new Error('"person.id" expected a valid string value.');
10
+ }
11
+ if (!(0, utils_1.isString)(person.displayName) || person.displayName.length === 0) {
12
+ throw new Error('"person.displayName" expected a valid string value.');
13
+ }
14
+ const out = {
15
+ id: person.id,
16
+ displayName: person.displayName,
17
+ };
18
+ if ((0, utils_1.objectHasProperty)(person, 'avatar') && !(0, utils_1.isUndefined)(person.avatar)) {
19
+ if (!(0, utils_1.isString)(person.avatar)) {
20
+ throw new Error('"person.avatar" expected a valid object value.');
21
+ }
22
+ out.avatar = person.avatar;
23
+ }
24
+ return out;
25
+ }
26
+ exports.default = validateIOSCommunicationInfoPerson;
27
+ //# sourceMappingURL=validateIOSCommunicationInfoPerson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateIOSCommunicationInfoPerson.js","sourceRoot":"","sources":["../../../src/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.ts"],"names":[],"mappings":";;AACA,uCAAiF;AAEjF,SAAwB,kCAAkC,CACxD,MAAkC;IAElC,IAAI,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IAED,IAAI,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;QAClD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;IAED,IAAI,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QACpE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KACxE;IAED,MAAM,GAAG,GAA+B;QACtC,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC;IAEF,IAAI,IAAA,yBAAiB,EAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAA,mBAAW,EAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QACtE,IAAI,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACnE;QAED,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;KAC5B;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AA7BD,qDA6BC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Validates any hexadecimal (optional transparency)
3
+ * @param color
4
+ * @returns {boolean}
5
+ */
6
+ export declare function isValidColor(color: string): boolean;
7
+ /**
8
+ * Checks the timestamp is at some point in the future.
9
+ * @param timestamp
10
+ * @returns {boolean}
11
+ */
12
+ export declare function isValidTimestamp(timestamp: number): boolean;
13
+ /**
14
+ * Ensures all values in the pattern are valid
15
+ * @param pattern {array}
16
+ */
17
+ export declare function isValidVibratePattern(pattern: number[]): boolean;
18
+ /**
19
+ * Ensures a given light pattern is valid
20
+ * @param pattern {array}
21
+ */
22
+ declare type LightPattern = [string, number, number];
23
+ declare type ValidLightPattern = [boolean] | [boolean, 'color' | 'onMs' | 'offMs'];
24
+ export declare function isValidLightPattern(pattern: LightPattern): ValidLightPattern;
25
+ export {};
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2016-present Invertase Limited
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isValidLightPattern = exports.isValidVibratePattern = exports.isValidTimestamp = exports.isValidColor = void 0;
7
+ const NotificationAndroid_1 = require("../types/NotificationAndroid");
8
+ const utils_1 = require("../utils");
9
+ /**
10
+ * Validates any hexadecimal (optional transparency)
11
+ * @param color
12
+ * @returns {boolean}
13
+ */
14
+ function isValidColor(color) {
15
+ if (Object.values(NotificationAndroid_1.AndroidColor).includes(color)) {
16
+ return true;
17
+ }
18
+ if (!color.startsWith('#')) {
19
+ return false;
20
+ }
21
+ // exclude #
22
+ const length = color.length - 1;
23
+ return length === 6 || length === 8;
24
+ }
25
+ exports.isValidColor = isValidColor;
26
+ /**
27
+ * Checks the timestamp is at some point in the future.
28
+ * @param timestamp
29
+ * @returns {boolean}
30
+ */
31
+ function isValidTimestamp(timestamp) {
32
+ return timestamp > 0;
33
+ }
34
+ exports.isValidTimestamp = isValidTimestamp;
35
+ /**
36
+ * Ensures all values in the pattern are valid
37
+ * @param pattern {array}
38
+ */
39
+ function isValidVibratePattern(pattern) {
40
+ if (pattern.length % 2 !== 0) {
41
+ return false;
42
+ }
43
+ for (let i = 0; i < pattern.length; i++) {
44
+ const ms = pattern[i];
45
+ if (!(0, utils_1.isNumber)(ms)) {
46
+ return false;
47
+ }
48
+ if (ms <= 0) {
49
+ return false;
50
+ }
51
+ }
52
+ return true;
53
+ }
54
+ exports.isValidVibratePattern = isValidVibratePattern;
55
+ function isValidLightPattern(pattern) {
56
+ const [color, onMs, offMs] = pattern;
57
+ if (!isValidColor(color)) {
58
+ return [false, 'color'];
59
+ }
60
+ if (!(0, utils_1.isNumber)(onMs)) {
61
+ return [false, 'onMs'];
62
+ }
63
+ if (!(0, utils_1.isNumber)(offMs)) {
64
+ return [false, 'offMs'];
65
+ }
66
+ if (onMs < 1) {
67
+ return [false, 'onMs'];
68
+ }
69
+ if (offMs < 1) {
70
+ return [false, 'offMs'];
71
+ }
72
+ return [true];
73
+ }
74
+ exports.isValidLightPattern = isValidLightPattern;
75
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validators/validate.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sEAA4D;AAC5D,oCAAoC;AAEpC;;;;GAIG;AACH,SAAgB,YAAY,CAAC,KAAa;IACxC,IAAI,MAAM,CAAC,MAAM,CAAC,kCAAY,CAAC,CAAC,QAAQ,CAAC,KAAqB,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAC;KACb;IAED,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC1B,OAAO,KAAK,CAAC;KACd;IAED,YAAY;IACZ,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAChC,OAAO,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC;AACtC,CAAC;AAZD,oCAYC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,SAAiB;IAChD,OAAO,SAAS,GAAG,CAAC,CAAC;AACvB,CAAC;AAFD,4CAEC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,OAAiB;IACrD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;QAC5B,OAAO,KAAK,CAAC;KACd;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,IAAA,gBAAQ,EAAC,EAAE,CAAC,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;QACD,IAAI,EAAE,IAAI,CAAC,EAAE;YACX,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAdD,sDAcC;AASD,SAAgB,mBAAmB,CAAC,OAAqB;IACvD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC;IAErC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACzB;IAED,IAAI,CAAC,IAAA,gBAAQ,EAAC,IAAI,CAAC,EAAE;QACnB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KACxB;IAED,IAAI,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAE;QACpB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACzB;IACD,IAAI,IAAI,GAAG,CAAC,EAAE;QACZ,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KACxB;IACD,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KACzB;IAED,OAAO,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAtBD,kDAsBC"}
@@ -0,0 +1,2 @@
1
+ import { AndroidAction } from '../types/NotificationAndroid';
2
+ export default function validateAndroidAction(action: AndroidAction): AndroidAction;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2016-present Invertase Limited
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const utils_1 = require("../utils");
10
+ const validateAndroidPressAction_1 = __importDefault(require("./validateAndroidPressAction"));
11
+ const validateAndroidInput_1 = __importDefault(require("./validateAndroidInput"));
12
+ function validateAndroidAction(action) {
13
+ if (!(0, utils_1.isObject)(action)) {
14
+ throw new Error("'action' expected an object value.");
15
+ }
16
+ if (!(0, utils_1.isString)(action.title) || !action.title) {
17
+ throw new Error("'action.title' expected a string value.");
18
+ }
19
+ let pressAction;
20
+ try {
21
+ pressAction = (0, validateAndroidPressAction_1.default)(action.pressAction);
22
+ }
23
+ catch (e) {
24
+ throw new Error(`'action' ${e.message}.`);
25
+ }
26
+ const out = {
27
+ title: action.title,
28
+ pressAction,
29
+ };
30
+ if ((0, utils_1.objectHasProperty)(action, 'icon') && !(0, utils_1.isUndefined)(action.icon)) {
31
+ if (!(0, utils_1.isString)(action.icon) || !action.icon) {
32
+ throw new Error("'action.icon' expected a string value.");
33
+ }
34
+ out.icon = action.icon;
35
+ }
36
+ if ((0, utils_1.objectHasProperty)(action, 'input') && !(0, utils_1.isUndefined)(action.input)) {
37
+ if (action.input === true) {
38
+ out.input = (0, validateAndroidInput_1.default)();
39
+ }
40
+ else {
41
+ try {
42
+ out.input = (0, validateAndroidInput_1.default)(action.input);
43
+ }
44
+ catch (e) {
45
+ throw new Error(`'action.input' ${e.message}.`);
46
+ }
47
+ }
48
+ }
49
+ return out;
50
+ }
51
+ exports.default = validateAndroidAction;
52
+ //# sourceMappingURL=validateAndroidAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAndroidAction.js","sourceRoot":"","sources":["../../src/validators/validateAndroidAction.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AAEH,oCAA8E;AAG9E,8FAAsE;AACtE,kFAA0D;AAE1D,SAAwB,qBAAqB,CAAC,MAAqB;IACjE,IAAI,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IAED,IAAI,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IAED,IAAI,WAAW,CAAC;IAEhB,IAAI;QACF,WAAW,GAAG,IAAA,oCAA0B,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC;KAC9D;IAAC,OAAO,CAAM,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;KAC3C;IAED,MAAM,GAAG,GAAkB;QACzB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,WAAW;KACZ,CAAC;IAEF,IAAI,IAAA,yBAAiB,EAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAA,mBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QAClE,IAAI,CAAC,IAAA,gBAAQ,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;SAC3D;QAED,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;KACxB;IAED,IAAI,IAAA,yBAAiB,EAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,IAAA,mBAAW,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE;QACpE,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE;YACzB,GAAG,CAAC,KAAK,GAAG,IAAA,8BAAoB,GAAE,CAAC;SACpC;aAAM;YACL,IAAI;gBACF,GAAG,CAAC,KAAK,GAAG,IAAA,8BAAoB,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aAChD;YAAC,OAAO,CAAM,EAAE;gBACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;aACjD;SACF;KACF;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AA3CD,wCA2CC"}
@@ -0,0 +1,2 @@
1
+ import { AndroidChannel } from '../types/NotificationAndroid';
2
+ export default function validateAndroidChannel(channel: AndroidChannel): AndroidChannel;