react-native-notify-kit 9.1.8

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 (212) hide show
  1. package/LICENSE +44 -0
  2. package/README.md +212 -0
  3. package/RNNotifee.podspec +37 -0
  4. package/RNNotifeeCore.podspec +32 -0
  5. package/android/.editorconfig +10 -0
  6. package/android/build.gradle +117 -0
  7. package/android/gradle.properties +1 -0
  8. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar +0 -0
  9. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.md5 +1 -0
  10. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha1 +1 -0
  11. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha256 +1 -0
  12. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha512 +1 -0
  13. package/android/libs/app/notifee/core/202108261754/core-202108261754.pom +9 -0
  14. package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.md5 +1 -0
  15. package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.sha1 +1 -0
  16. package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.sha256 +1 -0
  17. package/android/libs/app/notifee/core/202108261754/core-202108261754.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 +82 -0
  25. package/android/settings.gradle +1 -0
  26. package/android/src/main/AndroidManifest.xml +12 -0
  27. package/android/src/main/kotlin/io/invertase/notifee/HeadlessTask.kt +257 -0
  28. package/android/src/main/kotlin/io/invertase/notifee/NotifeeApiModule.kt +392 -0
  29. package/android/src/main/kotlin/io/invertase/notifee/NotifeeEventSubscriber.kt +117 -0
  30. package/android/src/main/kotlin/io/invertase/notifee/NotifeeInitProvider.kt +43 -0
  31. package/android/src/main/kotlin/io/invertase/notifee/NotifeePackage.kt +37 -0
  32. package/android/src/main/kotlin/io/invertase/notifee/NotifeeReactUtils.kt +118 -0
  33. package/dist/NotifeeApiModule.d.ts +53 -0
  34. package/dist/NotifeeApiModule.js +593 -0
  35. package/dist/NotifeeApiModule.js.map +1 -0
  36. package/dist/NotifeeJSEventEmitter.d.ts +3 -0
  37. package/dist/NotifeeJSEventEmitter.js +9 -0
  38. package/dist/NotifeeJSEventEmitter.js.map +1 -0
  39. package/dist/NotifeeNativeError.d.ts +15 -0
  40. package/dist/NotifeeNativeError.js +56 -0
  41. package/dist/NotifeeNativeError.js.map +1 -0
  42. package/dist/NotifeeNativeModule.d.ts +13 -0
  43. package/dist/NotifeeNativeModule.js +27 -0
  44. package/dist/NotifeeNativeModule.js.map +1 -0
  45. package/dist/NotifeeNativeModule.web.d.ts +12 -0
  46. package/dist/NotifeeNativeModule.web.js +15 -0
  47. package/dist/NotifeeNativeModule.web.js.map +1 -0
  48. package/dist/index.d.ts +8 -0
  49. package/dist/index.js +24 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/specs/NativeNotifeeModule.d.ts +53 -0
  52. package/dist/specs/NativeNotifeeModule.js +6 -0
  53. package/dist/specs/NativeNotifeeModule.js.map +1 -0
  54. package/dist/types/Library.d.ts +21 -0
  55. package/dist/types/Library.js +5 -0
  56. package/dist/types/Library.js.map +1 -0
  57. package/dist/types/Module.d.ts +576 -0
  58. package/dist/types/Module.js +5 -0
  59. package/dist/types/Module.js.map +1 -0
  60. package/dist/types/Notification.d.ts +462 -0
  61. package/dist/types/Notification.js +108 -0
  62. package/dist/types/Notification.js.map +1 -0
  63. package/dist/types/NotificationAndroid.d.ts +1311 -0
  64. package/dist/types/NotificationAndroid.js +406 -0
  65. package/dist/types/NotificationAndroid.js.map +1 -0
  66. package/dist/types/NotificationIOS.d.ts +539 -0
  67. package/dist/types/NotificationIOS.js +89 -0
  68. package/dist/types/NotificationIOS.js.map +1 -0
  69. package/dist/types/NotificationWeb.d.ts +5 -0
  70. package/dist/types/NotificationWeb.js +5 -0
  71. package/dist/types/NotificationWeb.js.map +1 -0
  72. package/dist/types/PowerManagerInfo.d.ts +36 -0
  73. package/dist/types/PowerManagerInfo.js +5 -0
  74. package/dist/types/PowerManagerInfo.js.map +1 -0
  75. package/dist/types/Trigger.d.ts +124 -0
  76. package/dist/types/Trigger.js +48 -0
  77. package/dist/types/Trigger.js.map +1 -0
  78. package/dist/utils/id.d.ts +1 -0
  79. package/dist/utils/id.js +12 -0
  80. package/dist/utils/id.js.map +1 -0
  81. package/dist/utils/index.d.ts +16 -0
  82. package/dist/utils/index.js +31 -0
  83. package/dist/utils/index.js.map +1 -0
  84. package/dist/utils/validate.d.ts +15 -0
  85. package/dist/utils/validate.js +75 -0
  86. package/dist/utils/validate.js.map +1 -0
  87. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.d.ts +2 -0
  88. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js +45 -0
  89. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js.map +1 -0
  90. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.d.ts +2 -0
  91. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js +24 -0
  92. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js.map +1 -0
  93. package/dist/validators/validate.d.ts +25 -0
  94. package/dist/validators/validate.js +68 -0
  95. package/dist/validators/validate.js.map +1 -0
  96. package/dist/validators/validateAndroidAction.d.ts +2 -0
  97. package/dist/validators/validateAndroidAction.js +46 -0
  98. package/dist/validators/validateAndroidAction.js.map +1 -0
  99. package/dist/validators/validateAndroidChannel.d.ts +2 -0
  100. package/dist/validators/validateAndroidChannel.js +152 -0
  101. package/dist/validators/validateAndroidChannel.js.map +1 -0
  102. package/dist/validators/validateAndroidChannelGroup.d.ts +2 -0
  103. package/dist/validators/validateAndroidChannelGroup.js +39 -0
  104. package/dist/validators/validateAndroidChannelGroup.js.map +1 -0
  105. package/dist/validators/validateAndroidFullScreenAction.d.ts +2 -0
  106. package/dist/validators/validateAndroidFullScreenAction.js +47 -0
  107. package/dist/validators/validateAndroidFullScreenAction.js.map +1 -0
  108. package/dist/validators/validateAndroidInput.d.ts +2 -0
  109. package/dist/validators/validateAndroidInput.js +51 -0
  110. package/dist/validators/validateAndroidInput.js.map +1 -0
  111. package/dist/validators/validateAndroidNotification.d.ts +2 -0
  112. package/dist/validators/validateAndroidNotification.js +541 -0
  113. package/dist/validators/validateAndroidNotification.js.map +1 -0
  114. package/dist/validators/validateAndroidPressAction.d.ts +2 -0
  115. package/dist/validators/validateAndroidPressAction.js +47 -0
  116. package/dist/validators/validateAndroidPressAction.js.map +1 -0
  117. package/dist/validators/validateAndroidStyle.d.ts +22 -0
  118. package/dist/validators/validateAndroidStyle.js +222 -0
  119. package/dist/validators/validateAndroidStyle.js.map +1 -0
  120. package/dist/validators/validateIOSAttachment.d.ts +6 -0
  121. package/dist/validators/validateIOSAttachment.js +96 -0
  122. package/dist/validators/validateIOSAttachment.js.map +1 -0
  123. package/dist/validators/validateIOSCategory.d.ts +2 -0
  124. package/dist/validators/validateIOSCategory.js +118 -0
  125. package/dist/validators/validateIOSCategory.js.map +1 -0
  126. package/dist/validators/validateIOSCategoryAction.d.ts +2 -0
  127. package/dist/validators/validateIOSCategoryAction.js +53 -0
  128. package/dist/validators/validateIOSCategoryAction.js.map +1 -0
  129. package/dist/validators/validateIOSInput.d.ts +2 -0
  130. package/dist/validators/validateIOSInput.js +29 -0
  131. package/dist/validators/validateIOSInput.js.map +1 -0
  132. package/dist/validators/validateIOSNotification.d.ts +2 -0
  133. package/dist/validators/validateIOSNotification.js +205 -0
  134. package/dist/validators/validateIOSNotification.js.map +1 -0
  135. package/dist/validators/validateIOSPermissions.d.ts +2 -0
  136. package/dist/validators/validateIOSPermissions.js +59 -0
  137. package/dist/validators/validateIOSPermissions.js.map +1 -0
  138. package/dist/validators/validateNotification.d.ts +11 -0
  139. package/dist/validators/validateNotification.js +121 -0
  140. package/dist/validators/validateNotification.js.map +1 -0
  141. package/dist/validators/validateTrigger.d.ts +2 -0
  142. package/dist/validators/validateTrigger.js +107 -0
  143. package/dist/validators/validateTrigger.js.map +1 -0
  144. package/dist/version.d.ts +1 -0
  145. package/dist/version.js +3 -0
  146. package/dist/version.js.map +1 -0
  147. package/ios/NotifeeCore/Info.plist +22 -0
  148. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.h +28 -0
  149. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +76 -0
  150. package/ios/NotifeeCore/NotifeeCore+NSURLSession.h +25 -0
  151. package/ios/NotifeeCore/NotifeeCore+NSURLSession.m +55 -0
  152. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.h +44 -0
  153. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +270 -0
  154. package/ios/NotifeeCore/NotifeeCore.h +118 -0
  155. package/ios/NotifeeCore/NotifeeCore.m +843 -0
  156. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.h +34 -0
  157. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.m +70 -0
  158. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.h +39 -0
  159. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.m +68 -0
  160. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.h +38 -0
  161. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.m +224 -0
  162. package/ios/NotifeeCore/NotifeeCoreUtil.h +81 -0
  163. package/ios/NotifeeCore/NotifeeCoreUtil.m +834 -0
  164. package/ios/RNNotifee/NotifeeApiModule.h +25 -0
  165. package/ios/RNNotifee/NotifeeApiModule.mm +421 -0
  166. package/ios/RNNotifee/NotifeeExtensionHelper.h +37 -0
  167. package/ios/RNNotifee/NotifeeExtensionHelper.m +37 -0
  168. package/ios/RNNotifee.xcodeproj/project.pbxproj +318 -0
  169. package/ios/RNNotifee.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  170. package/ios/RNNotifee.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  171. package/jest-mock.js +162 -0
  172. package/package.json +85 -0
  173. package/react-native.config.js +11 -0
  174. package/src/NotifeeApiModule.ts +823 -0
  175. package/src/NotifeeJSEventEmitter.ts +10 -0
  176. package/src/NotifeeNativeError.ts +68 -0
  177. package/src/NotifeeNativeModule.ts +39 -0
  178. package/src/NotifeeNativeModule.web.ts +25 -0
  179. package/src/index.ts +33 -0
  180. package/src/specs/NativeNotifeeModule.ts +71 -0
  181. package/src/types/Library.ts +28 -0
  182. package/src/types/Module.ts +629 -0
  183. package/src/types/Notification.ts +518 -0
  184. package/src/types/NotificationAndroid.ts +1478 -0
  185. package/src/types/NotificationIOS.ts +683 -0
  186. package/src/types/NotificationWeb.ts +5 -0
  187. package/src/types/PowerManagerInfo.ts +43 -0
  188. package/src/types/Trigger.ts +136 -0
  189. package/src/utils/id.ts +13 -0
  190. package/src/utils/index.ts +46 -0
  191. package/src/utils/validate.ts +90 -0
  192. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts +61 -0
  193. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.ts +33 -0
  194. package/src/validators/validate.ts +85 -0
  195. package/src/validators/validateAndroidAction.ts +54 -0
  196. package/src/validators/validateAndroidChannel.ts +188 -0
  197. package/src/validators/validateAndroidChannelGroup.ts +49 -0
  198. package/src/validators/validateAndroidFullScreenAction.ts +65 -0
  199. package/src/validators/validateAndroidInput.ts +67 -0
  200. package/src/validators/validateAndroidNotification.ts +734 -0
  201. package/src/validators/validateAndroidPressAction.ts +65 -0
  202. package/src/validators/validateAndroidStyle.ts +315 -0
  203. package/src/validators/validateIOSAttachment.ts +135 -0
  204. package/src/validators/validateIOSCategory.ts +150 -0
  205. package/src/validators/validateIOSCategoryAction.ts +65 -0
  206. package/src/validators/validateIOSInput.ts +38 -0
  207. package/src/validators/validateIOSNotification.ts +296 -0
  208. package/src/validators/validateIOSPermissions.ts +78 -0
  209. package/src/validators/validateNotification.ts +156 -0
  210. package/src/validators/validateTrigger.ts +142 -0
  211. package/src/version.ts +2 -0
  212. package/tsconfig.json +27 -0
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Interface for building a trigger with a timestamp.
3
+ *
4
+ * View the [Triggers](/react-native/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
+ * An interface representing the different alarm types which can be used with `TimestampTrigger.alarmManager.type`.
36
+ *
37
+ * View the [Triggers](/react-native/triggers) documentation to learn more.
38
+ */
39
+ export declare enum AlarmType {
40
+ SET = 0,
41
+ SET_AND_ALLOW_WHILE_IDLE = 1,
42
+ SET_EXACT = 2,
43
+ SET_EXACT_AND_ALLOW_WHILE_IDLE = 3,
44
+ SET_ALARM_CLOCK = 4
45
+ }
46
+ /**
47
+ * Interface to specify additional options for the AlarmManager which can be used with `TimestampTrigger.alarmManager`.
48
+ *
49
+ * View the [Triggers](/react-native/triggers) documentation to learn more.
50
+ *
51
+ * @platform android
52
+ */
53
+ export interface TimestampTriggerAlarmManager {
54
+ /**
55
+ * @deprecated use `type` instead
56
+ * -----
57
+ *
58
+ * Sets whether your trigger notification should be displayed even when the system is in low-power idle modes.
59
+ *
60
+ * Defaults to `false`.
61
+ */
62
+ allowWhileIdle?: boolean;
63
+ /** The type of alarm set by alarm manager of android */
64
+ type?: AlarmType;
65
+ }
66
+ /**
67
+ * An interface representing the different frequencies which can be used with `TimestampTrigger.repeatFrequency`.
68
+ *
69
+ * View the [Triggers](/react-native/triggers) documentation to learn more.
70
+ */
71
+ export declare enum RepeatFrequency {
72
+ NONE = -1,
73
+ HOURLY = 0,
74
+ DAILY = 1,
75
+ WEEKLY = 2
76
+ }
77
+ /**
78
+ * Interface for building a trigger that repeats at a specified interval.
79
+ *
80
+ * View the [Triggers](/react-native/triggers) documentation to learn more.
81
+ */
82
+ export interface IntervalTrigger {
83
+ /**
84
+ * Constant enum value used to identify the trigger type.
85
+ */
86
+ type: TriggerType.INTERVAL;
87
+ /**
88
+ * How frequently the notification should be repeated.
89
+ *
90
+ * For example, if set to 30, the notification will be displayed every 30 minutes.
91
+ *
92
+ * Must be set to a minimum of 15 minutes.
93
+ */
94
+ interval: number;
95
+ /**
96
+ * The unit of time that the `interval` is measured in.
97
+ *
98
+ * For example, if set to `TimeUnit.DAYS` and repeat interval is set to 3, the notification will repeat every 3 days.
99
+ *
100
+ * Defaults to `TimeUnit.SECONDS`
101
+ */
102
+ timeUnit?: TimeUnit | TimeUnit.SECONDS;
103
+ }
104
+ /**
105
+ * An interface representing the different units of time which can be used with `IntervalTrigger.timeUnit`.
106
+ *
107
+ * View the [Triggers](/react-native/triggers) documentation to learn more.
108
+ */
109
+ export declare enum TimeUnit {
110
+ SECONDS = "SECONDS",
111
+ MINUTES = "MINUTES",
112
+ HOURS = "HOURS",
113
+ DAYS = "DAYS"
114
+ }
115
+ /**
116
+ * Available Trigger Types.
117
+ *
118
+ * View the [Triggers](/react-native/triggers) documentation to learn more with example usage.
119
+ */
120
+ export declare enum TriggerType {
121
+ TIMESTAMP = 0,
122
+ INTERVAL = 1
123
+ }
124
+ export declare type Trigger = TimestampTrigger | IntervalTrigger;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * An interface representing the different alarm types which can be used with `TimestampTrigger.alarmManager.type`.
3
+ *
4
+ * View the [Triggers](/react-native/triggers) documentation to learn more.
5
+ */
6
+ export var AlarmType;
7
+ (function (AlarmType) {
8
+ AlarmType[AlarmType["SET"] = 0] = "SET";
9
+ AlarmType[AlarmType["SET_AND_ALLOW_WHILE_IDLE"] = 1] = "SET_AND_ALLOW_WHILE_IDLE";
10
+ AlarmType[AlarmType["SET_EXACT"] = 2] = "SET_EXACT";
11
+ AlarmType[AlarmType["SET_EXACT_AND_ALLOW_WHILE_IDLE"] = 3] = "SET_EXACT_AND_ALLOW_WHILE_IDLE";
12
+ AlarmType[AlarmType["SET_ALARM_CLOCK"] = 4] = "SET_ALARM_CLOCK";
13
+ })(AlarmType || (AlarmType = {}));
14
+ /**
15
+ * An interface representing the different frequencies which can be used with `TimestampTrigger.repeatFrequency`.
16
+ *
17
+ * View the [Triggers](/react-native/triggers) documentation to learn more.
18
+ */
19
+ export var RepeatFrequency;
20
+ (function (RepeatFrequency) {
21
+ RepeatFrequency[RepeatFrequency["NONE"] = -1] = "NONE";
22
+ RepeatFrequency[RepeatFrequency["HOURLY"] = 0] = "HOURLY";
23
+ RepeatFrequency[RepeatFrequency["DAILY"] = 1] = "DAILY";
24
+ RepeatFrequency[RepeatFrequency["WEEKLY"] = 2] = "WEEKLY";
25
+ })(RepeatFrequency || (RepeatFrequency = {}));
26
+ /**
27
+ * An interface representing the different units of time which can be used with `IntervalTrigger.timeUnit`.
28
+ *
29
+ * View the [Triggers](/react-native/triggers) documentation to learn more.
30
+ */
31
+ export var TimeUnit;
32
+ (function (TimeUnit) {
33
+ TimeUnit["SECONDS"] = "SECONDS";
34
+ TimeUnit["MINUTES"] = "MINUTES";
35
+ TimeUnit["HOURS"] = "HOURS";
36
+ TimeUnit["DAYS"] = "DAYS";
37
+ })(TimeUnit || (TimeUnit = {}));
38
+ /**
39
+ * Available Trigger Types.
40
+ *
41
+ * View the [Triggers](/react-native/triggers) documentation to learn more with example usage.
42
+ */
43
+ export var TriggerType;
44
+ (function (TriggerType) {
45
+ TriggerType[TriggerType["TIMESTAMP"] = 0] = "TIMESTAMP";
46
+ TriggerType[TriggerType["INTERVAL"] = 1] = "INTERVAL";
47
+ })(TriggerType || (TriggerType = {}));
48
+ //# sourceMappingURL=Trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Trigger.js","sourceRoot":"","sources":["../../src/types/Trigger.ts"],"names":[],"mappings":"AAoCA;;;;GAIG;AACH,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,uCAAG,CAAA;IACH,iFAAwB,CAAA;IACxB,mDAAS,CAAA;IACT,6FAA8B,CAAA;IAC9B,+DAAe,CAAA;AACjB,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB;AAwBD;;;;GAIG;AACH,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,sDAAS,CAAA;IACT,yDAAU,CAAA;IACV,uDAAS,CAAA;IACT,yDAAU,CAAA;AACZ,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAgCD;;;;GAIG;AACH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,2BAAe,CAAA;IACf,yBAAa,CAAA;AACf,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,uDAAa,CAAA;IACb,qDAAY,CAAA;AACd,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
@@ -0,0 +1 @@
1
+ export declare function generateId(): string;
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited
3
+ */
4
+ const CHARACTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
5
+ export function generateId() {
6
+ let newId = '';
7
+ for (let i = 0; i < 20; i++) {
8
+ newId += CHARACTERS.charAt(Math.floor(Math.random() * CHARACTERS.length));
9
+ }
10
+ return newId;
11
+ }
12
+ //# 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,MAAM,UAAU,UAAU;IACxB,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,KAAK,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -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,31 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited
3
+ */
4
+ import { Platform } from 'react-native';
5
+ export * from './id';
6
+ export * from './validate';
7
+ export function isError(value) {
8
+ if (Object.prototype.toString.call(value) === '[object Error]') {
9
+ return true;
10
+ }
11
+ return value instanceof Error;
12
+ }
13
+ export function objectHasProperty(target, property) {
14
+ return Object.hasOwnProperty.call(target, property);
15
+ }
16
+ export const isIOS = Platform.OS === 'ios';
17
+ export const isAndroid = Platform.OS === 'android';
18
+ export const isWeb = Platform.OS === 'web';
19
+ export function noop() {
20
+ // noop-🐈
21
+ }
22
+ export const kReactNativeNotifeeForegroundServiceHeadlessTask = 'app.notifee.foreground-service-headless-task';
23
+ export const kReactNativeNotifeeNotificationEvent = 'app.notifee.notification-event';
24
+ export const kReactNativeNotifeeNotificationBackgroundEvent = 'app.notifee.notification-event-background';
25
+ export var NotificationType;
26
+ (function (NotificationType) {
27
+ NotificationType[NotificationType["ALL"] = 0] = "ALL";
28
+ NotificationType[NotificationType["DISPLAYED"] = 1] = "DISPLAYED";
29
+ NotificationType[NotificationType["TRIGGER"] = 2] = "TRIGGER";
30
+ })(NotificationType || (NotificationType = {}));
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAE3B,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,gBAAgB,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,YAAY,KAAK,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAS,EACT,QAAkC;IAElC,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAE3C,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC;AAEnD,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAE3C,MAAM,UAAU,IAAI;IAClB,UAAU;AACZ,CAAC;AACD,MAAM,CAAC,MAAM,gDAAgD,GAC3D,8CAA8C,CAAC;AAEjD,MAAM,CAAC,MAAM,oCAAoC,GAAG,gCAAgC,CAAC;AAErF,MAAM,CAAC,MAAM,8CAA8C,GACzD,2CAA2C,CAAC;AAE9C,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,qDAAO,CAAA;IACP,iEAAa,CAAA;IACb,6DAAW,CAAA;AACb,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,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,75 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited
3
+ */
4
+ export function isNull(value) {
5
+ return value === null;
6
+ }
7
+ export function isObject(value) {
8
+ return value ? typeof value === 'object' && !Array.isArray(value) && !isNull(value) : false;
9
+ }
10
+ export function isFunction(value) {
11
+ return value ? typeof value === 'function' : false;
12
+ }
13
+ export function isString(value) {
14
+ return typeof value === 'string';
15
+ }
16
+ export function isNumber(value) {
17
+ return typeof value === 'number';
18
+ }
19
+ export function isBoolean(value) {
20
+ return typeof value === 'boolean';
21
+ }
22
+ export function isArray(value) {
23
+ return Array.isArray(value);
24
+ }
25
+ export function isArrayOfStrings(value) {
26
+ if (!isArray(value))
27
+ return false;
28
+ for (let i = 0; i < value.length; i++) {
29
+ if (!isString(value[i]))
30
+ return false;
31
+ }
32
+ return true;
33
+ }
34
+ export function isUndefined(value) {
35
+ return value === undefined;
36
+ }
37
+ export function objectKeyValuesAreStrings(value) {
38
+ if (!isObject(value)) {
39
+ return false;
40
+ }
41
+ const entries = Object.entries(value);
42
+ for (let i = 0; i < entries.length; i++) {
43
+ const [key, entryValue] = entries[i];
44
+ if (!isString(key) || !isString(entryValue)) {
45
+ return false;
46
+ }
47
+ }
48
+ return true;
49
+ }
50
+ /**
51
+ * /^[a-zA-Z0-9_]+$/
52
+ *
53
+ * @param value
54
+ * @returns {boolean}
55
+ */
56
+ const AlphaNumericUnderscore = /^[a-zA-Z0-9_]+$/;
57
+ export function isAlphaNumericUnderscore(value) {
58
+ return AlphaNumericUnderscore.test(value);
59
+ }
60
+ /**
61
+ * URL test
62
+ * @param url
63
+ * @returns {boolean}
64
+ */
65
+ const IS_VALID_URL_REGEX = /^(http|https):\/\/[^ "]+$/;
66
+ export function isValidUrl(url) {
67
+ return IS_VALID_URL_REGEX.test(url);
68
+ }
69
+ export function isValidEnum(value, enumType) {
70
+ if (!Object.values(enumType).includes(value)) {
71
+ return false;
72
+ }
73
+ return true;
74
+ }
75
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAU;IAC/B,OAAO,KAAK,KAAK,IAAI,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,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;AAED,MAAM,UAAU,UAAU,CAAC,KAAU;IACnC,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAU;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAU;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAU;IAClC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAU;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,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,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IACxC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAU;IACpC,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACrD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;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,CAAC;QACxC,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,CAAC;YAC5C,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEjD,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAEvD,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAU,EAAE,QAA6B;IACnE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { IOSCommunicationInfo } from '../../types/NotificationIOS';
2
+ export default function validateIOSCommunicationInfo(communicationInfo: IOSCommunicationInfo): IOSCommunicationInfo;
@@ -0,0 +1,45 @@
1
+ import { isObject, isString } from '../../utils';
2
+ import validateIOSCommunicationInfoPerson from './validateIOSCommunicationInfoPerson';
3
+ export default function validateIOSCommunicationInfo(communicationInfo) {
4
+ if (!isObject(communicationInfo)) {
5
+ throw new Error('expected an object.');
6
+ }
7
+ if (!isString(communicationInfo.conversationId) ||
8
+ communicationInfo.conversationId.length === 0) {
9
+ throw new Error("'conversationId' expected a valid string value.");
10
+ }
11
+ if (!communicationInfo.sender || !isObject(communicationInfo.sender)) {
12
+ throw new Error("'sender' expected a valid object value.");
13
+ }
14
+ let sender;
15
+ try {
16
+ sender = validateIOSCommunicationInfoPerson(communicationInfo.sender);
17
+ }
18
+ catch (e) {
19
+ throw new Error(`'sender' ${e.message}.`);
20
+ }
21
+ const out = {
22
+ conversationId: communicationInfo.conversationId,
23
+ sender,
24
+ };
25
+ if (communicationInfo.body) {
26
+ if (!isString(communicationInfo.body)) {
27
+ throw new Error("'body' expected a valid string value.");
28
+ }
29
+ out.body = communicationInfo.body;
30
+ }
31
+ if (communicationInfo.groupName) {
32
+ if (!isString(communicationInfo.groupName)) {
33
+ throw new Error("'groupName' expected a valid string value.");
34
+ }
35
+ out.groupName = communicationInfo.groupName;
36
+ }
37
+ if (communicationInfo.groupAvatar) {
38
+ if (!isString(communicationInfo.groupAvatar)) {
39
+ throw new Error("'groupAvatar' expected a valid string value.");
40
+ }
41
+ out.groupAvatar = communicationInfo.groupAvatar;
42
+ }
43
+ return out;
44
+ }
45
+ //# sourceMappingURL=validateIOSCommunicationInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateIOSCommunicationInfo.js","sourceRoot":"","sources":["../../../src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,kCAAkC,MAAM,sCAAsC,CAAC;AAEtF,MAAM,CAAC,OAAO,UAAU,4BAA4B,CAClD,iBAAuC;IAEvC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED,IACE,CAAC,QAAQ,CAAC,iBAAiB,CAAC,cAAc,CAAC;QAC3C,iBAAiB,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAC7C,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,iBAAiB,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC;IAEX,IAAI,CAAC;QACH,MAAM,GAAG,kCAAkC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,GAAG,GAAyB;QAChC,cAAc,EAAE,iBAAiB,CAAC,cAAc;QAChD,MAAM;KACP,CAAC;IAEF,IAAI,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QAED,GAAG,CAAC,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC;IACpC,CAAC;IAED,IAAI,iBAAiB,CAAC,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QAED,GAAG,CAAC,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAC9C,CAAC;IAED,IAAI,iBAAiB,CAAC,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;QAED,GAAG,CAAC,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC;IAClD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { IOSCommunicationInfoPerson } from '../../types/NotificationIOS';
2
+ export default function validateIOSCommunicationInfoPerson(person: IOSCommunicationInfoPerson): IOSCommunicationInfoPerson;
@@ -0,0 +1,24 @@
1
+ import { objectHasProperty, isObject, isString, isUndefined } from '../../utils';
2
+ export default function validateIOSCommunicationInfoPerson(person) {
3
+ if (!isObject(person)) {
4
+ throw new Error("'person' expected an object.");
5
+ }
6
+ if (!isString(person.id) || person.id.length === 0) {
7
+ throw new Error('"person.id" expected a valid string value.');
8
+ }
9
+ if (!isString(person.displayName) || person.displayName.length === 0) {
10
+ throw new Error('"person.displayName" expected a valid string value.');
11
+ }
12
+ const out = {
13
+ id: person.id,
14
+ displayName: person.displayName,
15
+ };
16
+ if (objectHasProperty(person, 'avatar') && !isUndefined(person.avatar)) {
17
+ if (!isString(person.avatar)) {
18
+ throw new Error('"person.avatar" expected a valid object value.');
19
+ }
20
+ out.avatar = person.avatar;
21
+ }
22
+ return out;
23
+ }
24
+ //# sourceMappingURL=validateIOSCommunicationInfoPerson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateIOSCommunicationInfoPerson.js","sourceRoot":"","sources":["../../../src/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF,MAAM,CAAC,OAAO,UAAU,kCAAkC,CACxD,MAAkC;IAElC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,GAAG,GAA+B;QACtC,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC;IAEF,IAAI,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACvE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QAED,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -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
+ type LightPattern = [string, number, number];
23
+ type ValidLightPattern = [boolean] | [boolean, 'color' | 'onMs' | 'offMs'];
24
+ export declare function isValidLightPattern(pattern: LightPattern): ValidLightPattern;
25
+ export {};
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited
3
+ */
4
+ import { AndroidColor } from '../types/NotificationAndroid';
5
+ import { isNumber } from '../utils';
6
+ /**
7
+ * Validates any hexadecimal (optional transparency)
8
+ * @param color
9
+ * @returns {boolean}
10
+ */
11
+ export function isValidColor(color) {
12
+ if (Object.values(AndroidColor).includes(color)) {
13
+ return true;
14
+ }
15
+ if (!color.startsWith('#')) {
16
+ return false;
17
+ }
18
+ // exclude #
19
+ const length = color.length - 1;
20
+ return length === 6 || length === 8;
21
+ }
22
+ /**
23
+ * Checks the timestamp is at some point in the future.
24
+ * @param timestamp
25
+ * @returns {boolean}
26
+ */
27
+ export function isValidTimestamp(timestamp) {
28
+ return timestamp > 0;
29
+ }
30
+ /**
31
+ * Ensures all values in the pattern are valid
32
+ * @param pattern {array}
33
+ */
34
+ export function isValidVibratePattern(pattern) {
35
+ if (pattern.length % 2 !== 0) {
36
+ return false;
37
+ }
38
+ for (let i = 0; i < pattern.length; i++) {
39
+ const ms = pattern[i];
40
+ if (!isNumber(ms)) {
41
+ return false;
42
+ }
43
+ if (ms <= 0) {
44
+ return false;
45
+ }
46
+ }
47
+ return true;
48
+ }
49
+ export function isValidLightPattern(pattern) {
50
+ const [color, onMs, offMs] = pattern;
51
+ if (!isValidColor(color)) {
52
+ return [false, 'color'];
53
+ }
54
+ if (!isNumber(onMs)) {
55
+ return [false, 'onMs'];
56
+ }
57
+ if (!isNumber(offMs)) {
58
+ return [false, 'offMs'];
59
+ }
60
+ if (onMs < 1) {
61
+ return [false, 'onMs'];
62
+ }
63
+ if (offMs < 1) {
64
+ return [false, 'offMs'];
65
+ }
66
+ return [true];
67
+ }
68
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validators/validate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,KAAqB,CAAC,EAAE,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,YAAY;IACZ,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAChC,OAAO,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,SAAS,GAAG,CAAC,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAiB;IACrD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;YAClB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YACZ,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AASD,MAAM,UAAU,mBAAmB,CAAC,OAAqB;IACvD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC;IAErC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IACD,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { AndroidAction } from '../types/NotificationAndroid';
2
+ export default function validateAndroidAction(action: AndroidAction): AndroidAction;
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited
3
+ */
4
+ import { objectHasProperty, isObject, isString, isUndefined } from '../utils';
5
+ import validateAndroidPressAction from './validateAndroidPressAction';
6
+ import validateAndroidInput from './validateAndroidInput';
7
+ export default function validateAndroidAction(action) {
8
+ if (!isObject(action)) {
9
+ throw new Error("'action' expected an object value.");
10
+ }
11
+ if (!isString(action.title) || !action.title) {
12
+ throw new Error("'action.title' expected a string value.");
13
+ }
14
+ let pressAction;
15
+ try {
16
+ pressAction = validateAndroidPressAction(action.pressAction);
17
+ }
18
+ catch (e) {
19
+ throw new Error(`'action' ${e.message}.`);
20
+ }
21
+ const out = {
22
+ title: action.title,
23
+ pressAction,
24
+ };
25
+ if (objectHasProperty(action, 'icon') && !isUndefined(action.icon)) {
26
+ if (!isString(action.icon) || !action.icon) {
27
+ throw new Error("'action.icon' expected a string value.");
28
+ }
29
+ out.icon = action.icon;
30
+ }
31
+ if (objectHasProperty(action, 'input') && !isUndefined(action.input)) {
32
+ if (action.input === true) {
33
+ out.input = validateAndroidInput();
34
+ }
35
+ else {
36
+ try {
37
+ out.input = validateAndroidInput(action.input);
38
+ }
39
+ catch (e) {
40
+ throw new Error(`'action.input' ${e.message}.`);
41
+ }
42
+ }
43
+ }
44
+ return out;
45
+ }
46
+ //# sourceMappingURL=validateAndroidAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateAndroidAction.js","sourceRoot":"","sources":["../../src/validators/validateAndroidAction.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG9E,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AACtE,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,MAAqB;IACjE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,WAAW,CAAC;IAEhB,IAAI,CAAC;QACH,WAAW,GAAG,0BAA0B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,GAAG,GAAkB;QACzB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,WAAW;KACZ,CAAC;IAEF,IAAI,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACnE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QAED,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,IAAI,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACrE,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1B,GAAG,CAAC,KAAK,GAAG,oBAAoB,EAAE,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,GAAG,CAAC,KAAK,GAAG,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjD,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { AndroidChannel } from '../types/NotificationAndroid';
2
+ export default function validateAndroidChannel(channel: AndroidChannel): AndroidChannel;