@metamask-previews/notification-services-controller 19.0.0-preview-12e7e334 → 19.0.0-preview-952b49c0

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 (181) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +17 -38
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts +2 -2
  5. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  6. package/dist/NotificationServicesController/NotificationServicesController.d.mts +2 -2
  7. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  8. package/dist/NotificationServicesController/NotificationServicesController.mjs +17 -15
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  10. package/dist/NotificationServicesController/constants/notification-schema.cjs +4 -14
  11. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
  12. package/dist/NotificationServicesController/constants/notification-schema.d.cts +3 -13
  13. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
  14. package/dist/NotificationServicesController/constants/notification-schema.d.mts +3 -13
  15. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
  16. package/dist/NotificationServicesController/constants/notification-schema.mjs +3 -13
  17. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  18. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs +428 -530
  19. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -1
  20. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts +20 -50
  21. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts +20 -50
  23. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs +425 -522
  25. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -1
  26. package/dist/NotificationServicesController/mocks/mockResponses.cjs +5 -5
  27. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  28. package/dist/NotificationServicesController/mocks/mockResponses.d.cts +2 -2
  29. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  30. package/dist/NotificationServicesController/mocks/mockResponses.d.mts +2 -2
  31. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  32. package/dist/NotificationServicesController/mocks/mockResponses.mjs +1 -1
  33. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  34. package/dist/NotificationServicesController/processors/index.cjs +1 -1
  35. package/dist/NotificationServicesController/processors/index.cjs.map +1 -1
  36. package/dist/NotificationServicesController/processors/index.d.cts +1 -1
  37. package/dist/NotificationServicesController/processors/index.d.cts.map +1 -1
  38. package/dist/NotificationServicesController/processors/index.d.mts +1 -1
  39. package/dist/NotificationServicesController/processors/index.d.mts.map +1 -1
  40. package/dist/NotificationServicesController/processors/index.mjs +1 -1
  41. package/dist/NotificationServicesController/processors/index.mjs.map +1 -1
  42. package/dist/NotificationServicesController/processors/process-api-notifications.cjs +22 -0
  43. package/dist/NotificationServicesController/processors/process-api-notifications.cjs.map +1 -0
  44. package/dist/NotificationServicesController/processors/process-api-notifications.d.cts +10 -0
  45. package/dist/NotificationServicesController/processors/process-api-notifications.d.cts.map +1 -0
  46. package/dist/NotificationServicesController/processors/process-api-notifications.d.mts +10 -0
  47. package/dist/NotificationServicesController/processors/process-api-notifications.d.mts.map +1 -0
  48. package/dist/NotificationServicesController/processors/process-api-notifications.mjs +18 -0
  49. package/dist/NotificationServicesController/processors/process-api-notifications.mjs.map +1 -0
  50. package/dist/NotificationServicesController/processors/process-feature-announcement.cjs +2 -7
  51. package/dist/NotificationServicesController/processors/process-feature-announcement.cjs.map +1 -1
  52. package/dist/NotificationServicesController/processors/process-feature-announcement.d.cts.map +1 -1
  53. package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts.map +1 -1
  54. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs +1 -6
  55. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs.map +1 -1
  56. package/dist/NotificationServicesController/processors/process-notifications.cjs +3 -3
  57. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  58. package/dist/NotificationServicesController/processors/process-notifications.d.cts +398 -458
  59. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  60. package/dist/NotificationServicesController/processors/process-notifications.d.mts +398 -458
  61. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  62. package/dist/NotificationServicesController/processors/process-notifications.mjs +4 -4
  63. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  64. package/dist/NotificationServicesController/services/{onchain-notifications.cjs → api-notifications.cjs} +26 -15
  65. package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -0
  66. package/dist/NotificationServicesController/services/{onchain-notifications.d.cts → api-notifications.d.cts} +8 -7
  67. package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -0
  68. package/dist/NotificationServicesController/services/{onchain-notifications.d.mts → api-notifications.d.mts} +8 -7
  69. package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -0
  70. package/dist/NotificationServicesController/services/{onchain-notifications.mjs → api-notifications.mjs} +24 -13
  71. package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -0
  72. package/dist/NotificationServicesController/services/perp-notifications.cjs +0 -1
  73. package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
  74. package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
  75. package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
  76. package/dist/NotificationServicesController/services/perp-notifications.mjs +0 -1
  77. package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
  78. package/dist/NotificationServicesController/types/index.cjs.map +1 -1
  79. package/dist/NotificationServicesController/types/index.d.cts +1 -1
  80. package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
  81. package/dist/NotificationServicesController/types/index.d.mts +1 -1
  82. package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
  83. package/dist/NotificationServicesController/types/index.mjs.map +1 -1
  84. package/dist/NotificationServicesController/types/notification/notification.cjs.map +1 -1
  85. package/dist/NotificationServicesController/types/notification/notification.d.cts +3 -11
  86. package/dist/NotificationServicesController/types/notification/notification.d.cts.map +1 -1
  87. package/dist/NotificationServicesController/types/notification/notification.d.mts +3 -11
  88. package/dist/NotificationServicesController/types/notification/notification.d.mts.map +1 -1
  89. package/dist/NotificationServicesController/types/notification/notification.mjs.map +1 -1
  90. package/dist/NotificationServicesController/types/notification-api/index.cjs.map +1 -0
  91. package/dist/NotificationServicesController/types/notification-api/index.d.cts +3 -0
  92. package/dist/NotificationServicesController/types/notification-api/index.d.cts.map +1 -0
  93. package/dist/NotificationServicesController/types/notification-api/index.d.mts +3 -0
  94. package/dist/NotificationServicesController/types/notification-api/index.d.mts.map +1 -0
  95. package/dist/NotificationServicesController/types/notification-api/index.mjs.map +1 -0
  96. package/dist/NotificationServicesController/types/{on-chain-notification/on-chain-notification.cjs → notification-api/notification-api.cjs} +1 -1
  97. package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -0
  98. package/dist/NotificationServicesController/types/{on-chain-notification/on-chain-notification.d.cts → notification-api/notification-api.d.cts} +30 -17
  99. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -0
  100. package/dist/NotificationServicesController/types/{on-chain-notification/on-chain-notification.d.mts → notification-api/notification-api.d.mts} +30 -17
  101. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -0
  102. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs +2 -0
  103. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -0
  104. package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -0
  105. package/dist/NotificationServicesController/types/notification-api/schema.d.cts +364 -0
  106. package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -0
  107. package/dist/NotificationServicesController/types/notification-api/schema.d.mts +364 -0
  108. package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -0
  109. package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -0
  110. package/dist/NotificationServicesController/utils/should-auto-expire.cjs +12 -0
  111. package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -0
  112. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts +2 -0
  113. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -0
  114. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts +2 -0
  115. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -0
  116. package/dist/NotificationServicesController/utils/should-auto-expire.mjs +8 -0
  117. package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -0
  118. package/dist/NotificationServicesPushController/services/push/push-web.cjs +5 -2
  119. package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +1 -1
  120. package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +1 -1
  121. package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +1 -1
  122. package/dist/NotificationServicesPushController/services/push/push-web.mjs +6 -3
  123. package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +1 -1
  124. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +10 -10
  125. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  126. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +10 -10
  127. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  128. package/dist/NotificationServicesPushController/web/push-utils.cjs +5 -2
  129. package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -1
  130. package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -1
  131. package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -1
  132. package/dist/NotificationServicesPushController/web/push-utils.mjs +6 -3
  133. package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
  134. package/dist/shared/is-onchain-notification.cjs +1 -2
  135. package/dist/shared/is-onchain-notification.cjs.map +1 -1
  136. package/dist/shared/is-onchain-notification.d.cts.map +1 -1
  137. package/dist/shared/is-onchain-notification.d.mts.map +1 -1
  138. package/dist/shared/is-onchain-notification.mjs +1 -2
  139. package/dist/shared/is-onchain-notification.mjs.map +1 -1
  140. package/dist/shared/to-raw-notification.cjs +19 -6
  141. package/dist/shared/to-raw-notification.cjs.map +1 -1
  142. package/dist/shared/to-raw-notification.d.cts +2 -2
  143. package/dist/shared/to-raw-notification.d.cts.map +1 -1
  144. package/dist/shared/to-raw-notification.d.mts +2 -2
  145. package/dist/shared/to-raw-notification.d.mts.map +1 -1
  146. package/dist/shared/to-raw-notification.mjs +17 -4
  147. package/dist/shared/to-raw-notification.mjs.map +1 -1
  148. package/package.json +1 -1
  149. package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs +0 -19
  150. package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs.map +0 -1
  151. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.cts +0 -10
  152. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.cts.map +0 -1
  153. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts +0 -10
  154. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts.map +0 -1
  155. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs +0 -15
  156. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs.map +0 -1
  157. package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +0 -1
  158. package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +0 -1
  159. package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +0 -1
  160. package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +0 -1
  161. package/dist/NotificationServicesController/types/on-chain-notification/index.cjs.map +0 -1
  162. package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts +0 -2
  163. package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts.map +0 -1
  164. package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts +0 -2
  165. package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts.map +0 -1
  166. package/dist/NotificationServicesController/types/on-chain-notification/index.mjs.map +0 -1
  167. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.cjs.map +0 -1
  168. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts.map +0 -1
  169. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts.map +0 -1
  170. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs +0 -2
  171. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs.map +0 -1
  172. package/dist/NotificationServicesController/types/on-chain-notification/schema.cjs.map +0 -1
  173. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.cts +0 -681
  174. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.cts.map +0 -1
  175. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts +0 -681
  176. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts.map +0 -1
  177. package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs.map +0 -1
  178. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/index.cjs +0 -0
  179. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/index.mjs +0 -0
  180. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/schema.cjs +0 -0
  181. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/schema.mjs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"process-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":";;;AAAA,qFAGwC;AACxC,uFAA6E;AAC7E,iFAAuE;AACvE,8EAAiE;AASjE,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACM,EAA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YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAbD,0DAaC;AAED,MAAM,cAAc,GAAG,CAAO,CAAQ,EAAa,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1D,MAAM,6BAA6B,GAAG,CAC3C,EAA0B,EAC1B,OAAiB,EACjB,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAHlE,QAAA,6BAA6B,iCAGqC","sourcesContent":["import {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processOnChainNotification } from './process-onchain-notifications';\nimport { processSnapNotification } from './process-snap-notifications';\nimport { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type {\n INotification,\n RawNotificationUnion,\n} from '../types/notification/notification';\nimport type { OnChainRawNotification } from '../types/on-chain-notification/on-chain-notification';\nimport type { RawSnapNotification } from '../types/snaps';\n\nconst isOnChainNotification = (\n n: RawNotificationUnion,\n): n is OnChainRawNotification => Object.values(TRIGGER_TYPES).includes(n.type);\n\nconst isFeatureAnnouncement = (\n n: RawNotificationUnion,\n): n is FeatureAnnouncementRawNotification =>\n n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\nconst isSnapNotification = (\n n: RawNotificationUnion,\n): n is RawSnapNotification => n.type === TRIGGER_TYPES.SNAP;\n\n/**\n * Process feature announcement and wallet notifications into a shared/normalised notification shape.\n * We can still differentiate notifications by the `type` property\n *\n * @param notification - a feature announcement or on chain notification\n * @param readNotifications - all read notifications currently\n * @returns a processed notification\n */\nexport function processNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = notification?.type;\n throw new Error(`No processor found for notification kind ${type}`);\n };\n\n if (isFeatureAnnouncement(notification)) {\n const n = processFeatureAnnouncement(\n notification as FeatureAnnouncementRawNotification,\n );\n n.isRead = isFeatureAnnouncementRead(n, readNotifications);\n return n;\n }\n\n if (isSnapNotification(notification)) {\n return processSnapNotification(notification);\n }\n\n if (isOnChainNotification(notification)) {\n return processOnChainNotification(notification);\n }\n\n return exhaustedAllCases(notification as never);\n}\n\n/**\n * Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined\n *\n * @param notification - notification to processes\n * @param readNotifications - all read notifications currently\n * @returns a process notification or undefined if failed to process\n */\nexport function safeProcessNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification | undefined {\n try {\n const processedNotification = processNotification(\n notification,\n readNotifications,\n );\n return processedNotification;\n } catch {\n return undefined;\n }\n}\n\nconst isNotUndefined = <Item>(t?: Item): t is Item => Boolean(t);\nexport const processAndFilterNotifications = (\n ns: RawNotificationUnion[],\n readIds: string[],\n) => ns.map((n) => safeProcessNotification(n, readIds)).filter(isNotUndefined);\n"]}
1
+ {"version":3,"file":"process-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":";;;AAAA,+EAAsE;AACtE,qFAGwC;AACxC,iFAAuE;AACvE,8EAG0C;AAS1C,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACS,EAAE,CAClC,wDAAkC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEjD,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACkB,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,mCAAa,CAAC,qBAAqB,CAAC;AAEjD,MAAM,kBAAkB,GAAG,CACzB,CAAuB,EACG,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,mCAAa,CAAC,IAAI,CAA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,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAHlE,QAAA,6BAA6B,iCAGqC","sourcesContent":["import { processAPINotifications } from './process-api-notifications';\nimport {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processSnapNotification } from './process-snap-notifications';\nimport {\n TRIGGER_TYPES,\n NOTIFICATION_API_TRIGGER_TYPES_SET,\n} from '../constants/notification-schema';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type {\n INotification,\n RawNotificationUnion,\n} from '../types/notification/notification';\nimport type { NormalisedAPINotification } from '../types/notification-api/notification-api';\nimport type { RawSnapNotification } from '../types/snaps';\n\nconst isOnChainNotification = (\n n: RawNotificationUnion,\n): n is NormalisedAPINotification =>\n NOTIFICATION_API_TRIGGER_TYPES_SET.has(n.type);\n\nconst isFeatureAnnouncement = (\n n: RawNotificationUnion,\n): n is FeatureAnnouncementRawNotification =>\n n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\nconst isSnapNotification = (\n n: RawNotificationUnion,\n): n is RawSnapNotification => n.type === TRIGGER_TYPES.SNAP;\n\n/**\n * Process feature announcement and wallet notifications into a shared/normalised notification shape.\n * We can still differentiate notifications by the `type` property\n *\n * @param notification - a feature announcement or on chain notification\n * @param readNotifications - all read notifications currently\n * @returns a processed notification\n */\nexport function processNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = notification?.type;\n throw new Error(`No processor found for notification kind ${type}`);\n };\n\n if (isFeatureAnnouncement(notification)) {\n const n = processFeatureAnnouncement(\n notification as FeatureAnnouncementRawNotification,\n );\n n.isRead = isFeatureAnnouncementRead(n, readNotifications);\n return n;\n }\n\n if (isSnapNotification(notification)) {\n return processSnapNotification(notification);\n }\n\n if (isOnChainNotification(notification)) {\n return processAPINotifications(notification);\n }\n\n return exhaustedAllCases(notification as never);\n}\n\n/**\n * Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined\n *\n * @param notification - notification to processes\n * @param readNotifications - all read notifications currently\n * @returns a process notification or undefined if failed to process\n */\nexport function safeProcessNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification | undefined {\n try {\n const processedNotification = processNotification(\n notification,\n readNotifications,\n );\n return processedNotification;\n } catch {\n return undefined;\n }\n}\n\nconst isNotUndefined = <Item>(t?: Item): t is Item => Boolean(t);\nexport const processAndFilterNotifications = (\n ns: RawNotificationUnion[],\n readIds: string[],\n) => ns.map((n) => safeProcessNotification(n, readIds)).filter(isNotUndefined);\n"]}