{"version":3,"file":"notification-api.mjs","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification-api/notification-api.ts"],"names":[],"mappings":"","sourcesContent":["import type { TRIGGER_TYPES } from '../../constants/notification-schema';\nimport type { Compute } from '../type-utils';\n// Types derived from external Notification API schema - naming follows API conventions\n/* eslint-disable @typescript-eslint/naming-convention */\nimport type { components } from './schema';\n\nexport type Data_MetamaskSwapCompleted =\n  components['schemas']['Data_MetamaskSwapCompleted'];\nexport type Data_LidoStakeReadyToBeWithdrawn =\n  components['schemas']['Data_LidoStakeReadyToBeWithdrawn'];\nexport type Data_LidoStakeCompleted =\n  components['schemas']['Data_LidoStakeCompleted'];\nexport type Data_LidoWithdrawalRequested =\n  components['schemas']['Data_LidoWithdrawalRequested'];\nexport type Data_LidoWithdrawalCompleted =\n  components['schemas']['Data_LidoWithdrawalCompleted'];\nexport type Data_RocketPoolStakeCompleted =\n  components['schemas']['Data_RocketPoolStakeCompleted'];\nexport type Data_RocketPoolUnstakeCompleted =\n  components['schemas']['Data_RocketPoolUnstakeCompleted'];\nexport type Data_ETHSent = components['schemas']['Data_ETHSent'];\nexport type Data_ETHReceived = components['schemas']['Data_ETHReceived'];\nexport type Data_ERC20Sent = components['schemas']['Data_ERC20Sent'];\nexport type Data_ERC20Received = components['schemas']['Data_ERC20Received'];\nexport type Data_ERC721Sent = components['schemas']['Data_ERC721Sent'];\nexport type Data_ERC721Received = components['schemas']['Data_ERC721Received'];\nexport type NetworkMetadata = components['schemas']['NetworkMetadata'];\nexport type BlockExplorer = components['schemas']['BlockExplorer'];\n\ntype Notification = components['schemas']['NotificationOutputV3'][number];\ntype PlatformNotification = Extract<\n  Notification,\n  { notification_type: 'platform' }\n>;\ntype OnChainNotification = Extract<\n  Notification,\n  { notification_type: 'on-chain' }\n>;\n\ntype ConvertToEnum<Kind> = {\n  [K in TRIGGER_TYPES]: Kind extends `${K}` ? K : never;\n}[TRIGGER_TYPES];\n\n/**\n * Type-Computation.\n * Adds a `type` field to on-chain notifications for easier enum checking.\n * Preserves the original nested payload structure.\n */\ntype NormalizeOnChainNotification<\n  N extends OnChainNotification = OnChainNotification,\n  NotificationDataKinds extends string = NonNullable<\n    N['payload']['data']\n  >['kind'],\n> = {\n  [K in NotificationDataKinds]: Compute<\n    Omit<N, 'payload'> & {\n      type: ConvertToEnum<K>;\n      payload: Compute<\n        Omit<N['payload'], 'data'> & {\n          data: Extract<NonNullable<N['payload']['data']>, { kind: K }>;\n        }\n      >;\n    }\n  >;\n}[NotificationDataKinds];\n\n/**\n * Type-Computation.\n * Adds a `type` field to platform notifications for easier enum checking.\n * Preserves the original nested payload structure.\n */\ntype NormalizePlatformNotification<\n  N extends PlatformNotification = PlatformNotification,\n  NotificationKind extends string = N['notification_type'],\n> = {\n  [K in NotificationKind]: Compute<\n    N & {\n      type: ConvertToEnum<K>;\n    }\n  >;\n}[NotificationKind];\n\nexport type OnChainRawNotification = Compute<\n  NormalizeOnChainNotification<OnChainNotification>\n>;\n\nexport type PlatformRawNotification = Compute<\n  NormalizePlatformNotification<PlatformNotification>\n>;\n\nexport type UnprocessedRawNotification = Notification;\n\nexport type NormalisedAPINotification =\n  | OnChainRawNotification\n  | PlatformRawNotification;\n\nexport type OnChainRawNotificationsWithNetworkFields = Extract<\n  OnChainRawNotification,\n  { payload: { data: { network_fee: unknown } } }\n>;\n"]}