@metamask-previews/notification-services-controller 21.0.0-preview-565dfca2 → 21.0.0-preview-3fa1672
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.
- package/dist/NotificationServicesController/NotificationServicesController.cjs +41 -37
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +41 -37
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.cjs +3 -0
- package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs +3 -0
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.cjs +6 -0
- package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.mjs +6 -0
- package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.cjs +11 -9
- package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.cts +1 -563
- package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.mts +1 -563
- package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.mjs +11 -9
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.cjs +21 -21
- package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.mjs +21 -21
- package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.cjs +10 -10
- package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.mjs +10 -10
- package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.cjs +4 -4
- package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.mjs +4 -4
- package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -1
- package/dist/NotificationServicesController/services/perp-notifications.cjs +2 -2
- package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/perp-notifications.mjs +2 -2
- package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.cjs +2 -0
- package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/notification-api/schema.mjs +2 -0
- package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -1
- package/dist/NotificationServicesController/types/perps/schema.cjs +2 -0
- package/dist/NotificationServicesController/types/perps/schema.cjs.map +1 -1
- package/dist/NotificationServicesController/types/perps/schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/perps/schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/perps/schema.mjs +2 -0
- package/dist/NotificationServicesController/types/perps/schema.mjs.map +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.cjs.map +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.d.cts.map +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.d.mts.map +1 -1
- package/dist/NotificationServicesController/utils/isVersionInBounds.mjs.map +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -1
- package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +9 -24
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +9 -24
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +4 -4
- package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +4 -4
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +62 -61
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +9 -9
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +9 -9
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +62 -61
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
- package/dist/NotificationServicesPushController/web/push-utils.cjs +3 -0
- package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/web/push-utils.mjs +3 -0
- package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
- package/dist/shared/is-onchain-notification.cjs +3 -3
- package/dist/shared/is-onchain-notification.cjs.map +1 -1
- package/dist/shared/is-onchain-notification.d.cts +2 -2
- package/dist/shared/is-onchain-notification.d.cts.map +1 -1
- package/dist/shared/is-onchain-notification.d.mts +2 -2
- package/dist/shared/is-onchain-notification.d.mts.map +1 -1
- package/dist/shared/is-onchain-notification.mjs +3 -3
- package/dist/shared/is-onchain-notification.mjs.map +1 -1
- package/dist/shared/to-raw-notification.cjs.map +1 -1
- package/dist/shared/to-raw-notification.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAmBX;AAnBD,WAAY,aAAa;IACvB,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IACnD,0CAAyB,CAAA;IACzB,kDAAiC,CAAA;IACjC,sCAAqB,CAAA;IACrB,8CAA6B,CAAA;IAC7B,0EAAyD,CAAA;IACzD,8EAA6D,CAAA;IAC7D,8DAA6C,CAAA;IAC7C,wEAAuD,CAAA;IACvD,wEAAuD,CAAA;IACvD,sFAAqE,CAAA;IACrE,4CAA2B,CAAA;IAC3B,oDAAmC,CAAA;IACnC,8CAA6B,CAAA;IAC7B,sDAAqC,CAAA;IACrC,8BAAa,CAAA;IACb,sCAAqB,CAAA;AACvB,CAAC,EAnBW,aAAa,KAAb,aAAa,QAmBxB;
|
|
1
|
+
{"version":3,"file":"notification-schema.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,yDAAyD;AACzD,MAAM,CAAN,IAAY,aAmBX;AAnBD,WAAY,aAAa;IACvB,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IACnD,0CAAyB,CAAA;IACzB,kDAAiC,CAAA;IACjC,sCAAqB,CAAA;IACrB,8CAA6B,CAAA;IAC7B,0EAAyD,CAAA;IACzD,8EAA6D,CAAA;IAC7D,8DAA6C,CAAA;IAC7C,wEAAuD,CAAA;IACvD,wEAAuD,CAAA;IACvD,sFAAqE,CAAA;IACrE,4CAA2B,CAAA;IAC3B,oDAAmC,CAAA;IACnC,8CAA6B,CAAA;IAC7B,sDAAqC,CAAA;IACrC,8BAAa,CAAA;IACb,sCAAqB,CAAA;AACvB,CAAC,EAnBW,aAAa,KAAb,aAAa,QAmBxB;AACD,wDAAwD;AAExD,MAAM,CAAC,MAAM,kCAAkC,GAAgB,IAAI,GAAG,CAAC;IACrE,aAAa,CAAC,uBAAuB;IACrC,aAAa,CAAC,UAAU;IACxB,aAAa,CAAC,cAAc;IAC5B,aAAa,CAAC,QAAQ;IACtB,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,0BAA0B;IACxC,aAAa,CAAC,4BAA4B;IAC1C,aAAa,CAAC,oBAAoB;IAClC,aAAa,CAAC,yBAAyB;IACvC,aAAa,CAAC,yBAAyB;IACvC,aAAa,CAAC,gCAAgC;IAC9C,aAAa,CAAC,WAAW;IACzB,aAAa,CAAC,eAAe;IAC7B,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,gBAAgB;IAC9B,aAAa,CAAC,QAAQ;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE,OAAO;IAClB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,MAAM;CACH,CAAC","sourcesContent":["// Using SCREAMING_SNAKE_CASE for enum name and members to mirror snake_case API string values for readability\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum TRIGGER_TYPES {\n FEATURES_ANNOUNCEMENT = 'features_announcement',\n METAMASK_SWAP_COMPLETED = 'metamask_swap_completed',\n ERC20_SENT = 'erc20_sent',\n ERC20_RECEIVED = 'erc20_received',\n ETH_SENT = 'eth_sent',\n ETH_RECEIVED = 'eth_received',\n ROCKETPOOL_STAKE_COMPLETED = 'rocketpool_stake_completed',\n ROCKETPOOL_UNSTAKE_COMPLETED = 'rocketpool_unstake_completed',\n LIDO_STAKE_COMPLETED = 'lido_stake_completed',\n LIDO_WITHDRAWAL_REQUESTED = 'lido_withdrawal_requested',\n LIDO_WITHDRAWAL_COMPLETED = 'lido_withdrawal_completed',\n LIDO_STAKE_READY_TO_BE_WITHDRAWN = 'lido_stake_ready_to_be_withdrawn',\n ERC721_SENT = 'erc721_sent',\n ERC721_RECEIVED = 'erc721_received',\n ERC1155_SENT = 'erc1155_sent',\n ERC1155_RECEIVED = 'erc1155_received',\n SNAP = 'snap',\n PLATFORM = 'platform',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport const NOTIFICATION_API_TRIGGER_TYPES_SET: Set<string> = new Set([\n TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,\n TRIGGER_TYPES.ERC20_SENT,\n TRIGGER_TYPES.ERC20_RECEIVED,\n TRIGGER_TYPES.ETH_SENT,\n TRIGGER_TYPES.ETH_RECEIVED,\n TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED,\n TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN,\n TRIGGER_TYPES.ERC721_SENT,\n TRIGGER_TYPES.ERC721_RECEIVED,\n TRIGGER_TYPES.ERC1155_SENT,\n TRIGGER_TYPES.ERC1155_RECEIVED,\n TRIGGER_TYPES.PLATFORM,\n]);\n\nexport const NOTIFICATION_CHAINS_ID = {\n ETHEREUM: '1',\n OPTIMISM: '10',\n BSC: '56',\n BASE: '8453',\n POLYGON: '137',\n ARBITRUM: '42161',\n AVALANCHE: '43114',\n LINEA: '59144',\n SEI: '1329',\n} as const;\n\n// Kept as SCREAMING_SNAKE_CASE for backwards compatibility\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport type NOTIFICATION_CHAINS_IDS =\n (typeof NOTIFICATION_CHAINS_ID)[keyof typeof NOTIFICATION_CHAINS_ID];\n"]}
|
|
@@ -7,6 +7,8 @@ const api_notifications_1 = require("../services/api-notifications.cjs");
|
|
|
7
7
|
const feature_announcements_1 = require("../services/feature-announcements.cjs");
|
|
8
8
|
const perp_notifications_1 = require("../services/perp-notifications.cjs");
|
|
9
9
|
exports.CONTENTFUL_RESPONSE = (0, mock_feature_announcements_1.createMockFeatureAnnouncementAPIResult)();
|
|
10
|
+
// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse
|
|
11
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
10
12
|
const getMockFeatureAnnouncementResponse = () => {
|
|
11
13
|
return {
|
|
12
14
|
url: feature_announcements_1.FEATURE_ANNOUNCEMENT_API,
|
|
@@ -31,7 +33,10 @@ const getMockOnChainNotificationsConfig = () => {
|
|
|
31
33
|
};
|
|
32
34
|
};
|
|
33
35
|
exports.getMockOnChainNotificationsConfig = getMockOnChainNotificationsConfig;
|
|
36
|
+
/* eslint-enable @typescript-eslint/explicit-function-return-type */
|
|
34
37
|
exports.MOCK_RAW_ON_CHAIN_NOTIFICATIONS = (0, mock_raw_notifications_1.createMockRawOnChainNotifications)();
|
|
38
|
+
// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse
|
|
39
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
35
40
|
const getMockListNotificationsResponse = () => {
|
|
36
41
|
return {
|
|
37
42
|
url: (0, api_notifications_1.NOTIFICATION_API_LIST_ENDPOINT)(),
|
|
@@ -56,4 +61,5 @@ const getMockCreatePerpOrderNotification = () => {
|
|
|
56
61
|
};
|
|
57
62
|
};
|
|
58
63
|
exports.getMockCreatePerpOrderNotification = getMockCreatePerpOrderNotification;
|
|
64
|
+
/* eslint-enable @typescript-eslint/explicit-function-return-type */
|
|
59
65
|
//# sourceMappingURL=mockResponses.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,iFAAsF;AACtF,yEAA6E;AAC7E,yEAKuC;AACvC,iFAA6E;AAC7E,2EAAyE;AAQ5D,QAAA,mBAAmB,GAAG,IAAA,mEAAsC,GAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,iFAAsF;AACtF,yEAA6E;AAC7E,yEAKuC;AACvC,iFAA6E;AAC7E,2EAAyE;AAQ5D,QAAA,mBAAmB,GAAG,IAAA,mEAAsC,GAAE,CAAC;AAE5E,kIAAkI;AAClI,qEAAqE;AAC9D,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,gDAAwB;QAC7B,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,2BAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,kCAAkC,sCAM7C;AAEK,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,OAAO;QACL,GAAG,EAAE,IAAA,sDAAkC,GAAE;QACzC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,iCAAiC,qCAM5C;AAEK,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,OAAO;QACL,GAAG,EAAE,IAAA,4DAAwC,GAAE;QAC/C,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KACjC,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,iCAAiC,qCAM5C;AACF,oEAAoE;AAEvD,QAAA,+BAA+B,GAC1C,IAAA,0DAAiC,GAAE,CAAC;AAEtC,kIAAkI;AAClI,qEAAqE;AAC9D,MAAM,gCAAgC,GAAG,GAAG,EAAE;IACnD,OAAO;QACL,GAAG,EAAE,IAAA,kDAA8B,GAAE;QACrC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,uCAA+B;KACnB,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,gCAAgC,oCAM3C;AAEK,MAAM,sCAAsC,GAAG,GAAG,EAAE;IACzD,OAAO;QACL,GAAG,EAAE,IAAA,8DAA0C,GAAE;QACjD,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,sCAAsC,0CAMjD;AAEK,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,4CAAuB;QAC5B,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,kCAAkC,sCAM7C;AACF,oEAAoE","sourcesContent":["import { createMockFeatureAnnouncementAPIResult } from './mock-feature-announcements';\nimport { createMockRawOnChainNotifications } from './mock-raw-notifications';\nimport {\n NOTIFICATION_API_LIST_ENDPOINT,\n NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,\n TRIGGER_API_NOTIFICATIONS_ENDPOINT,\n TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT,\n} from '../services/api-notifications';\nimport { FEATURE_ANNOUNCEMENT_API } from '../services/feature-announcements';\nimport { PERPS_API_CREATE_ORDERS } from '../services/perp-notifications';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';\n response: unknown;\n};\n\nexport const CONTENTFUL_RESPONSE = createMockFeatureAnnouncementAPIResult();\n\n// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nexport const getMockFeatureAnnouncementResponse = () => {\n return {\n url: FEATURE_ANNOUNCEMENT_API,\n requestMethod: 'GET',\n response: CONTENTFUL_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockUpdateOnChainNotifications = () => {\n return {\n url: TRIGGER_API_NOTIFICATIONS_ENDPOINT(),\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockOnChainNotificationsConfig = () => {\n return {\n url: TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT(),\n requestMethod: 'POST',\n response: [{ address: '0xTestAddress', enabled: true }],\n } satisfies MockResponse;\n};\n/* eslint-enable @typescript-eslint/explicit-function-return-type */\n\nexport const MOCK_RAW_ON_CHAIN_NOTIFICATIONS =\n createMockRawOnChainNotifications();\n\n// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nexport const getMockListNotificationsResponse = () => {\n return {\n url: NOTIFICATION_API_LIST_ENDPOINT(),\n requestMethod: 'POST',\n response: MOCK_RAW_ON_CHAIN_NOTIFICATIONS,\n } satisfies MockResponse;\n};\n\nexport const getMockMarkNotificationsAsReadResponse = () => {\n return {\n url: NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT(),\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockCreatePerpOrderNotification = () => {\n return {\n url: PERPS_API_CREATE_ORDERS,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n/* eslint-enable @typescript-eslint/explicit-function-return-type */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,mBAAmB,8DAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,mBAAmB,8DAA2C,CAAC;AAI5E,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;CAM7C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;CAM7C,CAAC;AAGF,eAAO,MAAM,+BAA+B,0CACP,CAAC;AAItC,eAAO,MAAM,gCAAgC;;;;CAM5C,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;CAMlD,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,mBAAmB,8DAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,mBAAmB,8DAA2C,CAAC;AAI5E,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;CAM7C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;CAM7C,CAAC;AAGF,eAAO,MAAM,+BAA+B,0CACP,CAAC;AAItC,eAAO,MAAM,gCAAgC;;;;CAM5C,CAAC;AAEF,eAAO,MAAM,sCAAsC;;;;CAMlD,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;CAM9C,CAAC"}
|
|
@@ -4,6 +4,8 @@ import { NOTIFICATION_API_LIST_ENDPOINT, NOTIFICATION_API_MARK_ALL_AS_READ_ENDPO
|
|
|
4
4
|
import { FEATURE_ANNOUNCEMENT_API } from "../services/feature-announcements.mjs";
|
|
5
5
|
import { PERPS_API_CREATE_ORDERS } from "../services/perp-notifications.mjs";
|
|
6
6
|
export const CONTENTFUL_RESPONSE = createMockFeatureAnnouncementAPIResult();
|
|
7
|
+
// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse
|
|
8
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
7
9
|
export const getMockFeatureAnnouncementResponse = () => {
|
|
8
10
|
return {
|
|
9
11
|
url: FEATURE_ANNOUNCEMENT_API,
|
|
@@ -25,7 +27,10 @@ export const getMockOnChainNotificationsConfig = () => {
|
|
|
25
27
|
response: [{ address: '0xTestAddress', enabled: true }],
|
|
26
28
|
};
|
|
27
29
|
};
|
|
30
|
+
/* eslint-enable @typescript-eslint/explicit-function-return-type */
|
|
28
31
|
export const MOCK_RAW_ON_CHAIN_NOTIFICATIONS = createMockRawOnChainNotifications();
|
|
32
|
+
// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse
|
|
33
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
29
34
|
export const getMockListNotificationsResponse = () => {
|
|
30
35
|
return {
|
|
31
36
|
url: NOTIFICATION_API_LIST_ENDPOINT(),
|
|
@@ -47,4 +52,5 @@ export const getMockCreatePerpOrderNotification = () => {
|
|
|
47
52
|
response: null,
|
|
48
53
|
};
|
|
49
54
|
};
|
|
55
|
+
/* eslint-enable @typescript-eslint/explicit-function-return-type */
|
|
50
56
|
//# sourceMappingURL=mockResponses.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,yCAAqC;AACtF,OAAO,EAAE,iCAAiC,EAAE,qCAAiC;AAC7E,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,EAC1C,kCAAkC,EAClC,wCAAwC,EACzC,0CAAsC;AACvC,OAAO,EAAE,wBAAwB,EAAE,8CAA0C;AAC7E,OAAO,EAAE,uBAAuB,EAAE,2CAAuC;AAQzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,sCAAsC,EAAE,CAAC;AAE5E,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,wBAAwB;QAC7B,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,mBAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,OAAO;QACL,GAAG,EAAE,kCAAkC,EAAE;QACzC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,OAAO;QACL,GAAG,EAAE,wCAAwC,EAAE;QAC/C,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KACjC,CAAC;AAC3B,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,yCAAqC;AACtF,OAAO,EAAE,iCAAiC,EAAE,qCAAiC;AAC7E,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,EAC1C,kCAAkC,EAClC,wCAAwC,EACzC,0CAAsC;AACvC,OAAO,EAAE,wBAAwB,EAAE,8CAA0C;AAC7E,OAAO,EAAE,uBAAuB,EAAE,2CAAuC;AAQzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,sCAAsC,EAAE,CAAC;AAE5E,kIAAkI;AAClI,qEAAqE;AACrE,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,wBAAwB;QAC7B,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,mBAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,OAAO;QACL,GAAG,EAAE,kCAAkC,EAAE;QACzC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,OAAO;QACL,GAAG,EAAE,wCAAwC,EAAE;QAC/C,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KACjC,CAAC;AAC3B,CAAC,CAAC;AACF,oEAAoE;AAEpE,MAAM,CAAC,MAAM,+BAA+B,GAC1C,iCAAiC,EAAE,CAAC;AAEtC,kIAAkI;AAClI,qEAAqE;AACrE,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,EAAE;IACnD,OAAO;QACL,GAAG,EAAE,8BAA8B,EAAE;QACrC,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,+BAA+B;KACnB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,EAAE;IACzD,OAAO;QACL,GAAG,EAAE,0CAA0C,EAAE;QACjD,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,EAAE;IACrD,OAAO;QACL,GAAG,EAAE,uBAAuB;QAC5B,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AACF,oEAAoE","sourcesContent":["import { createMockFeatureAnnouncementAPIResult } from './mock-feature-announcements';\nimport { createMockRawOnChainNotifications } from './mock-raw-notifications';\nimport {\n NOTIFICATION_API_LIST_ENDPOINT,\n NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,\n TRIGGER_API_NOTIFICATIONS_ENDPOINT,\n TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT,\n} from '../services/api-notifications';\nimport { FEATURE_ANNOUNCEMENT_API } from '../services/feature-announcements';\nimport { PERPS_API_CREATE_ORDERS } from '../services/perp-notifications';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';\n response: unknown;\n};\n\nexport const CONTENTFUL_RESPONSE = createMockFeatureAnnouncementAPIResult();\n\n// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nexport const getMockFeatureAnnouncementResponse = () => {\n return {\n url: FEATURE_ANNOUNCEMENT_API,\n requestMethod: 'GET',\n response: CONTENTFUL_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const getMockUpdateOnChainNotifications = () => {\n return {\n url: TRIGGER_API_NOTIFICATIONS_ENDPOINT(),\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockOnChainNotificationsConfig = () => {\n return {\n url: TRIGGER_API_NOTIFICATIONS_QUERY_ENDPOINT(),\n requestMethod: 'POST',\n response: [{ address: '0xTestAddress', enabled: true }],\n } satisfies MockResponse;\n};\n/* eslint-enable @typescript-eslint/explicit-function-return-type */\n\nexport const MOCK_RAW_ON_CHAIN_NOTIFICATIONS =\n createMockRawOnChainNotifications();\n\n// Using `satisfies` to preserve narrow return types while ensuring type safety; explicit return types would widen to MockResponse\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nexport const getMockListNotificationsResponse = () => {\n return {\n url: NOTIFICATION_API_LIST_ENDPOINT(),\n requestMethod: 'POST',\n response: MOCK_RAW_ON_CHAIN_NOTIFICATIONS,\n } satisfies MockResponse;\n};\n\nexport const getMockMarkNotificationsAsReadResponse = () => {\n return {\n url: NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT(),\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockCreatePerpOrderNotification = () => {\n return {\n url: PERPS_API_CREATE_ORDERS,\n requestMethod: 'POST',\n response: null,\n } satisfies MockResponse;\n};\n/* eslint-enable @typescript-eslint/explicit-function-return-type */\n"]}
|
|
@@ -5,9 +5,9 @@ const process_api_notifications_1 = require("./process-api-notifications.cjs");
|
|
|
5
5
|
const process_feature_announcement_1 = require("./process-feature-announcement.cjs");
|
|
6
6
|
const process_snap_notifications_1 = require("./process-snap-notifications.cjs");
|
|
7
7
|
const notification_schema_1 = require("../constants/notification-schema.cjs");
|
|
8
|
-
const isOnChainNotification = (
|
|
9
|
-
const isFeatureAnnouncement = (
|
|
10
|
-
const isSnapNotification = (
|
|
8
|
+
const isOnChainNotification = (notification) => notification_schema_1.NOTIFICATION_API_TRIGGER_TYPES_SET.has(notification.type);
|
|
9
|
+
const isFeatureAnnouncement = (notification) => notification.type === notification_schema_1.TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;
|
|
10
|
+
const isSnapNotification = (notification) => notification.type === notification_schema_1.TRIGGER_TYPES.SNAP;
|
|
11
11
|
/**
|
|
12
12
|
* Process feature announcement and wallet notifications into a shared/normalised notification shape.
|
|
13
13
|
* We can still differentiate notifications by the `type` property
|
|
@@ -17,14 +17,14 @@ const isSnapNotification = (n) => n.type === notification_schema_1.TRIGGER_TYPES
|
|
|
17
17
|
* @returns a processed notification
|
|
18
18
|
*/
|
|
19
19
|
function processNotification(notification, readNotifications = []) {
|
|
20
|
-
const exhaustedAllCases = (
|
|
20
|
+
const exhaustedAllCases = (_uncheckedCase) => {
|
|
21
21
|
const type = notification?.type;
|
|
22
22
|
throw new Error(`No processor found for notification kind ${type}`);
|
|
23
23
|
};
|
|
24
24
|
if (isFeatureAnnouncement(notification)) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
return
|
|
25
|
+
const processedNotification = (0, process_feature_announcement_1.processFeatureAnnouncement)(notification);
|
|
26
|
+
processedNotification.isRead = (0, process_feature_announcement_1.isFeatureAnnouncementRead)(processedNotification, readNotifications);
|
|
27
|
+
return processedNotification;
|
|
28
28
|
}
|
|
29
29
|
if (isSnapNotification(notification)) {
|
|
30
30
|
return (0, process_snap_notifications_1.processSnapNotification)(notification);
|
|
@@ -52,7 +52,9 @@ function safeProcessNotification(notification, readNotifications = []) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
exports.safeProcessNotification = safeProcessNotification;
|
|
55
|
-
const isNotUndefined = (
|
|
56
|
-
const processAndFilterNotifications = (
|
|
55
|
+
const isNotUndefined = (item) => Boolean(item);
|
|
56
|
+
const processAndFilterNotifications = (notifications, readIds) => notifications
|
|
57
|
+
.map((notification) => safeProcessNotification(notification, readIds))
|
|
58
|
+
.filter(isNotUndefined);
|
|
57
59
|
exports.processAndFilterNotifications = processAndFilterNotifications;
|
|
58
60
|
//# sourceMappingURL=process-notifications.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,YAAkC,EACS,EAAE,CAC7C,wDAAkC,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAE5D,MAAM,qBAAqB,GAAG,CAC5B,YAAkC,EACkB,EAAE,CACtD,YAAY,CAAC,IAAI,KAAK,mCAAa,CAAC,qBAAqB,CAAC;AAE5D,MAAM,kBAAkB,GAAG,CACzB,YAAkC,EACG,EAAE,CACvC,YAAY,CAAC,IAAI,KAAK,mCAAa,CAAC,IAAI,CAAC;AAE3C;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,MAAM,iBAAiB,GAAG,CAAC,cAAqB,EAAS,EAAE;QACzD,MAAM,IAAI,GAAW,YAAY,EAAE,IAAI,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,MAAM,qBAAqB,GAAG,IAAA,yDAA0B,EAAC,YAAY,CAAC,CAAC;QACvE,qBAAqB,CAAC,MAAM,GAAG,IAAA,wDAAyB,EACtD,qBAAqB,EACrB,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,OAAO,IAAA,oDAAuB,EAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,OAAO,IAAA,mDAAuB,EAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,iBAAiB,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC;AA3BD,kDA2BC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,IAAI,CAAC;QACH,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,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,IAAW,EAAgB,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACnE,MAAM,6BAA6B,GAAG,CAC3C,aAAqC,EACrC,OAAiB,EACA,EAAE,CACnB,aAAa;KACV,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,uBAAuB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;KACrE,MAAM,CAAC,cAAc,CAAC,CAAC;AANf,QAAA,6BAA6B,iCAMd","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 notification: RawNotificationUnion,\n): notification is NormalisedAPINotification =>\n NOTIFICATION_API_TRIGGER_TYPES_SET.has(notification.type);\n\nconst isFeatureAnnouncement = (\n notification: RawNotificationUnion,\n): notification is FeatureAnnouncementRawNotification =>\n notification.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\nconst isSnapNotification = (\n notification: RawNotificationUnion,\n): notification is RawSnapNotification =>\n notification.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 = (_uncheckedCase: never): 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 processedNotification = processFeatureAnnouncement(notification);\n processedNotification.isRead = isFeatureAnnouncementRead(\n processedNotification,\n readNotifications,\n );\n return processedNotification;\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);\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>(item?: Item): item is Item => Boolean(item);\nexport const processAndFilterNotifications = (\n notifications: RawNotificationUnion[],\n readIds: string[],\n): INotification[] =>\n notifications\n .map((notification) => safeProcessNotification(notification, readIds))\n .filter(isNotUndefined);\n"]}
|