@notifi-network/notifi-frontend-client
Advanced tools
Comparing version 0.90.9-alpha.10 to 0.90.9-alpha.11
@@ -5,3 +5,3 @@ import { Types, Operations, NotifiService } from '@notifi-network/notifi-graphql'; | ||
declare type NotifiEnvironmentConfiguration = Readonly<{ | ||
env: NotifiEnvironment; | ||
env?: NotifiEnvironment; | ||
tenantId: string; | ||
@@ -12,5 +12,5 @@ storageOption?: Readonly<{ | ||
}>; | ||
declare type WalletBlockchainWithPublicKey = Extract<Types.WalletBlockchain, 'ETHEREUM' | 'POLYGON' | 'ARBITRUM' | 'AVALANCHE' | 'BINANCE' | 'OPTIMISM' | 'SOLANA' | 'ZKSYNC' | 'BASE' | 'BLAST' | 'CELO' | 'MANTLE' | 'LINEA' | 'SCROLL' | 'MANTA' | 'MONAD' | 'BERACHAIN' | 'XION'>; | ||
declare type WalletBlockchainWithPublicKey = Extract<Types.WalletBlockchain, 'ETHEREUM' | 'POLYGON' | 'ARBITRUM' | 'AVALANCHE' | 'BINANCE' | 'OPTIMISM' | 'SOLANA' | 'ZKSYNC' | 'BASE' | 'BLAST' | 'CELO' | 'MANTLE' | 'LINEA' | 'SCROLL' | 'MANTA' | 'MONAD'>; | ||
declare type WalletBlockchainWithDelegate = 'XION'; | ||
declare type WalletBlockchainWithPublicKeyAndAddress = Exclude<Types.WalletBlockchain, WalletBlockchainWithPublicKey | 'OFF_CHAIN' | 'EVMOS' | WalletBlockchainWithDelegate>; | ||
declare type WalletBlockchainWithPublicKeyAndAddress = Exclude<Types.WalletBlockchain, WalletBlockchainWithPublicKey | 'OFF_CHAIN' | 'EVMOS'>; | ||
declare type NotifiConfigWithPublicKey = Readonly<{ | ||
@@ -42,3 +42,3 @@ walletBlockchain: WalletBlockchainWithPublicKey; | ||
tenantId: string; | ||
env: NotifiEnvironment; | ||
env?: NotifiEnvironment; | ||
walletBlockchain: NotifiConfigWithPublicKeyAndAddress['walletBlockchain']; | ||
@@ -53,3 +53,3 @@ storageOption?: NotifiEnvironmentConfiguration['storageOption']; | ||
tenantId: string; | ||
env: NotifiEnvironment; | ||
env?: NotifiEnvironment; | ||
walletBlockchain: NotifiConfigWithPublicKeyAndAddress['walletBlockchain']; | ||
@@ -63,3 +63,3 @@ storageOption?: NotifiEnvironmentConfiguration['storageOption']; | ||
tenantId: string; | ||
env: NotifiEnvironment; | ||
env?: NotifiEnvironment; | ||
walletBlockchain: NotifiConfigWithPublicKey['walletBlockchain']; | ||
@@ -70,3 +70,3 @@ storageOption?: NotifiEnvironmentConfiguration['storageOption']; | ||
declare const newFrontendConfig: (config: ConfigFactoryInput) => NotifiFrontendConfiguration; | ||
declare const envUrl: (env: NotifiEnvironment) => string; | ||
declare const envUrl: (env?: NotifiEnvironment, endpointType?: 'websocket' | 'http') => string; | ||
@@ -82,2 +82,3 @@ declare const notNullOrEmpty: <T>(item: T | null | undefined) => item is T; | ||
declare type ThresholdDirection = 'above' | 'below'; | ||
/**@deprecated this is for AP v1 infra, use fusionFilterOptions instead for new infra */ | ||
declare type FilterOptions = Partial<{ | ||
@@ -97,218 +98,55 @@ alertFrequency: AlertFrequency; | ||
declare type ValueOrRef<ValueType> = Readonly<{ | ||
type: 'ref'; | ||
ref: string | null; | ||
}> | Readonly<{ | ||
type: 'value'; | ||
value: ValueType; | ||
}>; | ||
declare type DirectPushEventTypeItem = Readonly<{ | ||
type: 'directPush'; | ||
declare type FusionEventMetadata = { | ||
uiConfigOverride?: { | ||
topicDisplayName?: string; | ||
historyDisplayName?: string; | ||
icon?: Types.GenericEventIconHint; | ||
customIconUrl?: string; | ||
}; | ||
filters: Array<Filter>; | ||
}; | ||
/** | ||
* @param name - `string` unique name | ||
*/ | ||
declare type Filter = AlertFilter | FrequencyFilter; | ||
declare type FilterBase = { | ||
name: string; | ||
directPushId: ValueOrRef<string>; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type FusionTypeBase = { | ||
name: string; | ||
type: 'fusion' | 'fusionToggle'; | ||
fusionEventId: ValueOrRef<string>; | ||
sourceAddress: ValueOrRef<string>; | ||
tooltipContent?: string; | ||
maintainSourceGroup?: boolean; | ||
alertFrequency?: AlertFrequency; | ||
optOutAtSignup?: boolean; | ||
displayNameOverride?: string; | ||
executionPriority: number; | ||
}; | ||
declare type FusionToggleEventTypeItem = FusionTypeBase & Readonly<{ | ||
selectedUIType: 'TOGGLE'; | ||
}>; | ||
declare type FusionHealthCheckEventTypeItem = FusionTypeBase & Readonly<{ | ||
selectedUIType: 'HEALTH_CHECK'; | ||
healthCheckSubtitle: string; | ||
numberType: NumberTypeSelect; | ||
checkRatios: CheckRatio[]; | ||
validInputRange?: ValidInputRange; | ||
}>; | ||
declare type ValidInputRange = { | ||
max: number; | ||
min: number; | ||
declare type FrequencyFilter = FilterBase & { | ||
minimumDurationBetweenTriggersInMinutes: number; | ||
}; | ||
declare type FusionMultiThreshholdEventTypeItem = FusionTypeBase & Readonly<{ | ||
selectedUIType: 'MULTI_THRESHOLD'; | ||
numberType: NumberTypeSelect; | ||
subtitle?: string; | ||
addThreshholdTitle?: string; | ||
}>; | ||
declare type FusionEventTypeItem = FusionToggleEventTypeItem | FusionHealthCheckEventTypeItem | FusionMultiThreshholdEventTypeItem; | ||
declare type BroadcastEventTypeItem = Readonly<{ | ||
type: 'broadcast'; | ||
name: string; | ||
broadcastId: ValueOrRef<string>; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
displayNameOverride?: string; | ||
}>; | ||
declare type HealthCheckEventTypeItem = Readonly<{ | ||
type: 'healthCheck'; | ||
name: string; | ||
checkRatios: ValueOrRef<CheckRatio[]>; | ||
alertFrequency: AlertFrequency; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type LabelEventTypeItem = Readonly<{ | ||
type: 'label'; | ||
name: string; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type TradingPairEventTypeItem = Readonly<{ | ||
type: 'tradingPair'; | ||
name: string; | ||
tooltipContent?: string; | ||
tradingPairs: ValueOrRef<ReadonlyArray<string>>; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type PriceChangeDataSource = 'coingecko'; | ||
declare type PriceChangeEventTypeItem = Readonly<{ | ||
type: 'priceChange'; | ||
name: string; | ||
tokenIds: ReadonlyArray<string>; | ||
dataSource: PriceChangeDataSource; | ||
tooltipContent: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type WalletBalanceEventTypeItem = Readonly<{ | ||
type: 'walletBalance'; | ||
name: string; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type CustomTypeBase = { | ||
type: 'custom'; | ||
name: string; | ||
tooltipContent: string; | ||
sourceType: Types.SourceType; | ||
filterType: string; | ||
sourceAddress: ValueOrRef<string>; | ||
optOutAtSignup?: boolean; | ||
declare type AlertFilter = FilterBase & { | ||
userInputParams: UserInputParam<UiType>[]; | ||
type: FilterType; | ||
staticFilterParams?: Record<string, object | string | number>; | ||
requiredParserVariables: Array<RequiredParserVariable>; | ||
description: string; | ||
}; | ||
declare type CustomToggleTypeItem = Readonly<{ | ||
filterOptions: FilterOptions; | ||
selectedUIType: 'TOGGLE'; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type NumberTypeSelect = 'percentage' | 'integer' | 'price'; | ||
declare type CustomHealthCheckItem = Readonly<{ | ||
selectedUIType: 'HEALTH_CHECK'; | ||
healthCheckSubtitle: string; | ||
numberType: NumberTypeSelect; | ||
alertFrequency: AlertFrequency; | ||
checkRatios: CheckRatio[]; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type RatiosBelow = Readonly<{ | ||
type: 'below'; | ||
ratio: number; | ||
}>; | ||
declare type RatiosAbove = Readonly<{ | ||
type: 'above'; | ||
ratio: number; | ||
}>; | ||
declare type CheckRatio = RatiosBelow | RatiosAbove; | ||
declare type CustomTopicTypeItem = CustomTypeBase & (CustomToggleTypeItem | CustomHealthCheckItem); | ||
declare type XMTPTopicTypeItem = { | ||
type: 'XMTP'; | ||
name: string; | ||
tooltipContent: string; | ||
sourceType?: Types.SourceType; | ||
filterType: string; | ||
XMTPTopics: ValueOrRef<ReadonlyArray<string>>; | ||
optOutAtSignup?: boolean; | ||
declare type RequiredParserVariable = { | ||
variableName: string; | ||
variableType: ValueType; | ||
variableDescription: string; | ||
}; | ||
declare type CreateSupportConversationEventTypeItem = { | ||
type: 'createSupportConversation'; | ||
declare type ValueType = 'integer' | 'price' | 'percentage' | 'string'; | ||
/** | ||
* @param UiType - `radio` or `button` (scalable). Define what component should be rendered in Card topic subscription view. | ||
* @param defaultValue - The value for default alert subscription | ||
*/ | ||
declare type UserInputParam<T extends UiType> = { | ||
name: string; | ||
sourceType: Types.SourceType; | ||
filterType: string; | ||
alertFrequency: AlertFrequency; | ||
optOutAtSignup?: boolean; | ||
kind: ValueType; | ||
uiType: T; | ||
description: string; | ||
options: (string | number)[]; | ||
defaultValue: string | number; | ||
allowCustomInput?: boolean; | ||
}; | ||
declare type EventTypeItem = DirectPushEventTypeItem | BroadcastEventTypeItem | HealthCheckEventTypeItem | TradingPairEventTypeItem | LabelEventTypeItem | PriceChangeEventTypeItem | CustomTopicTypeItem | FusionEventTypeItem | WalletBalanceEventTypeItem | XMTPTopicTypeItem | CreateSupportConversationEventTypeItem; | ||
declare type EventTypeConfig = ReadonlyArray<EventTypeItem>; | ||
declare type InputType = 'WebhookUrlInput' | 'WebhookHeadersInput' | 'DirectPushIdInput' | 'BroadcastIdInput'; | ||
declare type InputItem = Readonly<{ | ||
name: string; | ||
type: InputType; | ||
}>; | ||
declare type InputsConfig = ReadonlyArray<InputItem>; | ||
declare type ContactInfo = Readonly<{ | ||
active: boolean; | ||
}>; | ||
declare type EmailContactInfo = ContactInfo; | ||
declare type DiscordContactInfo = ContactInfo; | ||
declare type CountryCode = string; | ||
declare type SmsContactInfo = ContactInfo & Readonly<{ | ||
supportedCountryCodes: ReadonlyArray<CountryCode>; | ||
}>; | ||
declare type TelegramContactInfo = ContactInfo; | ||
declare type WebhookHeaders = Readonly<Record<string, string>>; | ||
declare type WebhookContactInfo = ContactInfo & Readonly<{ | ||
url: ValueOrRef<string>; | ||
headers: ValueOrRef<WebhookHeaders>; | ||
}>; | ||
declare type ContactInfoConfig = Readonly<{ | ||
email: EmailContactInfo; | ||
sms: SmsContactInfo; | ||
telegram: TelegramContactInfo; | ||
webhook: WebhookContactInfo; | ||
discord: DiscordContactInfo; | ||
}>; | ||
declare type CardConfigItemV1 = Readonly<{ | ||
version: 'v1'; | ||
id: string | null; | ||
name: string; | ||
eventTypes: EventTypeConfig; | ||
inputs: InputsConfig; | ||
contactInfo: ContactInfoConfig; | ||
isContactInfoRequired?: boolean; | ||
titles?: TitleSubtitleConfig; | ||
}>; | ||
declare type TitleSubtitleConfigInactive = Readonly<{ | ||
active: false; | ||
}>; | ||
declare type TitleSubtitleConfigActive = Readonly<{ | ||
active: true; | ||
editView: string; | ||
previewView: string; | ||
historyView: string; | ||
signupView: string; | ||
expiredView: string; | ||
alertDetailsView: string; | ||
verifyWalletsView: string; | ||
}>; | ||
declare type TitleSubtitleConfig = TitleSubtitleConfigActive | TitleSubtitleConfigInactive; | ||
declare type LabelItemConfigs<Config> = Readonly<{ | ||
[K in LabelType]: Config; | ||
}>; | ||
declare const LABEL_TYPE_MENU_LABELS: LabelItemConfigs<string>; | ||
declare type LabelType = 'ChatCompanyName' | 'ChatFTUTitle' | 'ChatFTUDescription' | 'ChatFTUSubTitle' | 'ChatBannerTitle' | 'ChatIntroQuestion'; | ||
declare type LabelItem = { | ||
name: string | null; | ||
type: LabelType; | ||
label: keyof typeof LABEL_TYPE_MENU_LABELS; | ||
declare type UiType = 'radio' | 'button'; | ||
declare type FilterType = 'AlertFilter'; | ||
declare type FusionFilterOptions = { | ||
input: Record<Filter['name'], UserInputOptions>; | ||
}; | ||
declare type LabelsConfig = Array<LabelItem>; | ||
declare type IntercomCardConfigItemV1 = Readonly<{ | ||
version: 'IntercomV1'; | ||
id: string | null; | ||
name: string; | ||
labels: LabelsConfig; | ||
contactInfo: ContactInfoConfig; | ||
}>; | ||
declare type UserInputOptions = Record<UserInputParam<UiType>['name'], UserInputParam<UiType>['options'][number]>; | ||
declare const packFilterOptions: (clientOptions: Readonly<FilterOptions> | null) => string; | ||
declare const normalizeHexString: (input: string) => string; | ||
@@ -383,2 +221,14 @@ declare type TradingPairInputs = { | ||
}>, value: string | undefined) => Promise<string | undefined>; | ||
declare const ensureSlack: (service: Readonly<{ | ||
createSlackChannelTarget: (variables: Types.Exact<{ | ||
name: string; | ||
value: string; | ||
}>) => Promise<Types.CreateSlackChannelTargetMutation>; | ||
}> & Readonly<{ | ||
getSlackChannelTargets: (variables: Types.Exact<{ | ||
after?: Types.InputMaybe<string>; | ||
first?: Types.InputMaybe<number>; | ||
ids?: Types.InputMaybe<string | string[]>; | ||
}>) => Promise<Types.GetSlackChannelTargetsQuery>; | ||
}>, value: string | undefined) => Promise<string | undefined>; | ||
declare type EnsureWebhookParams$1 = Omit<Types.CreateWebhookTargetMutationVariables, 'name'>; | ||
@@ -429,3 +279,3 @@ declare const ensureWebhook: (service: Operations.CreateWebhookTargetService & Operations.GetWebhookTargetsService, params: EnsureWebhookParams$1 | undefined) => Promise<string | undefined>; | ||
}> | Readonly<{ | ||
walletBlockchain: 'ETHEREUM' | 'POLYGON' | 'ARBITRUM' | 'AVALANCHE' | 'BINANCE' | 'OSMOSIS' | 'ELYS' | 'NEUTRON' | 'ARCHWAY' | 'AXELAR' | 'BERACHAIN' | 'NIBIRU' | 'OPTIMISM' | 'ZKSYNC' | 'INJECTIVE' | 'BASE' | 'BLAST' | 'CELO' | 'MANTLE' | 'LINEA' | 'SCROLL' | 'MANTA' | 'MONAD'; | ||
walletBlockchain: 'ETHEREUM' | 'POLYGON' | 'ARBITRUM' | 'AVALANCHE' | 'BINANCE' | 'OSMOSIS' | 'NIBIRU' | 'OPTIMISM' | 'ZKSYNC' | 'INJECTIVE' | 'BASE' | 'BLAST' | 'CELO' | 'MANTLE' | 'LINEA' | 'SCROLL' | 'MANTA' | 'MONAD'; | ||
signMessage: Uint8SignMessageFunction; | ||
@@ -457,3 +307,3 @@ }> | Readonly<{ | ||
}> | Readonly<{ | ||
walletBlockchain: 'ETHEREUM' | 'POLYGON' | 'ARBITRUM' | 'AVALANCHE' | 'BINANCE' | 'OPTIMISM' | 'ZKSYNC' | 'BASE' | 'BLAST' | 'CELO' | 'MANTLE' | 'LINEA' | 'SCROLL' | 'MANTA' | 'MONAD' | 'BERACHAIN'; | ||
walletBlockchain: 'ETHEREUM' | 'POLYGON' | 'ARBITRUM' | 'AVALANCHE' | 'BINANCE' | 'OPTIMISM' | 'ZKSYNC' | 'BASE' | 'BLAST' | 'CELO' | 'MANTLE' | 'LINEA' | 'SCROLL' | 'MANTA' | 'MONAD'; | ||
walletPublicKey: string; | ||
@@ -493,22 +343,2 @@ signMessage: Uint8SignMessageFunction; | ||
signMessage: Uint8SignMessageFunction; | ||
}> | Readonly<{ | ||
walletBlockchain: 'ELYS'; | ||
accountAddress: string; | ||
walletPublicKey: string; | ||
signMessage: Uint8SignMessageFunction; | ||
}> | Readonly<{ | ||
walletBlockchain: 'NEUTRON'; | ||
accountAddress: string; | ||
walletPublicKey: string; | ||
signMessage: Uint8SignMessageFunction; | ||
}> | Readonly<{ | ||
walletBlockchain: 'ARCHWAY'; | ||
accountAddress: string; | ||
walletPublicKey: string; | ||
signMessage: Uint8SignMessageFunction; | ||
}> | Readonly<{ | ||
walletBlockchain: 'AXELAR'; | ||
accountAddress: string; | ||
walletPublicKey: string; | ||
signMessage: Uint8SignMessageFunction; | ||
}>; | ||
@@ -524,3 +354,3 @@ declare type ConnectWalletParams = Readonly<{ | ||
declare type AcalaSignMessageFunction = (acalaAddress: string, message: string) => Promise<hexString>; | ||
declare type CardConfigType = CardConfigItemV1 | IntercomCardConfigItemV1; | ||
declare type CardConfigType = CardConfigItemV1; | ||
declare type BeginLoginProps = Omit<Types.BeginLogInByTransactionInput, 'dappAddress'>; | ||
@@ -564,3 +394,3 @@ declare type BeginLoginWithWeb3Props = Omit<Types.BeginLogInWithWeb3Input, 'dappAddress' | 'blockchainType'>; | ||
getTargetGroups(): Promise<ReadonlyArray<Types.TargetGroupFragmentFragment>>; | ||
ensureTargetGroup({ name, emailAddress, phoneNumber, telegramId, webhook, discordId, }: Readonly<{ | ||
ensureTargetGroup({ name, emailAddress, phoneNumber, telegramId, webhook, discordId, slackId, }: Readonly<{ | ||
name: string; | ||
@@ -572,2 +402,3 @@ emailAddress?: string; | ||
discordId?: string; | ||
slackId?: string; | ||
}>): Promise<Types.TargetGroupFragmentFragment>; | ||
@@ -582,2 +413,3 @@ private _updateTargetGroup; | ||
}>): Promise<Types.AlertFragmentFragment>; | ||
ensureFusionAlerts(input: Types.CreateFusionAlertsInput): Promise<Types.CreateFusionAlertsMutation['createFusionAlerts']>; | ||
deleteAlert({ id, }: Readonly<{ | ||
@@ -620,5 +452,9 @@ id: string; | ||
getUnreadNotificationHistoryCount(): Promise<Types.GetUnreadNotificationHistoryCountQuery['unreadNotificationHistoryCount']>; | ||
subscribeNotificationHistoryStateChanged(onMessageReceived: (data: any) => void | undefined, onError?: (data: any) => void | undefined, onComplete?: () => void | undefined): Promise<void>; | ||
wsDispose(): Promise<void>; | ||
getUserSettings(): Promise<Types.GetUserSettingsQuery['userSettings']>; | ||
getFusionNotificationHistory(variables: Types.GetFusionNotificationHistoryQueryVariables): Promise<Readonly<Types.GetFusionNotificationHistoryQuery['fusionNotificationHistory']>>; | ||
/**@deprecated for legacy infra, use fetchTenantConfig instead for new infra (fusionEvent) */ | ||
fetchSubscriptionCard(variables: FindSubscriptionCardParams): Promise<CardConfigType>; | ||
fetchTenantConfig(variables: FindSubscriptionCardParams): Promise<TenantConfig>; | ||
copyAuthorization(config: NotifiFrontendConfiguration): Promise<void>; | ||
@@ -629,5 +465,2 @@ sendEmailTargetVerification({ targetId, }: Readonly<{ | ||
subscribeWallet(params: ConnectWalletParams): Promise<Types.ConnectWalletMutation>; | ||
getConversationMessages(input: Types.GetConversationMessagesQueryVariables): Promise<Types.GetConversationMessagesQuery>; | ||
sendConversationMessages(input: Types.SendConversationMessageMutationVariables): Promise<Types.SendConversationMessageMutation>; | ||
createSupportConversation(input: Types.CreateSupportConversationMutationVariables): Promise<Types.CreateSupportConversationMutation>; | ||
createDiscordTarget(input: string): Promise<{ | ||
@@ -653,2 +486,205 @@ __typename?: "DiscordTarget" | undefined; | ||
export { AcalaSignMessageFunction, AlertFrequency, AptosSignMessageFunction, Authorization, AuthorizationStorage, BroadcastEventTypeItem, CardConfigItemV1, CardConfigType, CheckRatio, ConfigFactoryInput, ConfigFactoryInputDelegated, ConfigFactoryInputPublicKey, ConfigFactoryInputPublicKeyAndAddress, ConnectWalletParams, ContactInfo, ContactInfoConfig, CountryCode, CreateFunc, CreateSupportConversationEventTypeItem, CustomHealthCheckItem, CustomToggleTypeItem, CustomTopicTypeItem, CustomTypeBase, DirectPushEventTypeItem, DiscordContactInfo, EmailContactInfo, EnsureWebhookParams$1 as EnsureWebhookParams, EventTypeConfig, EventTypeItem, FetchFunc, FilterOptions, FrontendClientConfigFactory, FusionEventTypeItem, FusionHealthCheckEventTypeItem, FusionMultiThreshholdEventTypeItem, FusionToggleEventTypeItem, FusionTypeBase, GetStorageType, HasStorageType, HealthCheckEventInputsWithCustomPercentage, HealthCheckEventInputsWithIndex, HealthCheckEventTypeItem, HealthCheckInputs, IdentifyFunc, InputItem, InputType, InputsConfig, IntercomCardConfigItemV1, LABEL_TYPE_MENU_LABELS, LabelEventTypeItem, LabelItem, LabelType, LabelsConfig, NotifiConfigWithDelegate, NotifiConfigWithPublicKey, NotifiConfigWithPublicKeyAndAddress, NotifiEnvironment, NotifiEnvironmentConfiguration, NotifiFrontendClient, NotifiFrontendConfiguration, NotifiFrontendStorage, NotifiStorage, NumberTypeSelect, PriceChangeDataSource, PriceChangeEventTypeItem, Roles, RolesStorage, SIGNING_MESSAGE, SetStorageType, SignMessageParams, SmsContactInfo, StorageDriver, StorageType, SupportedCardConfigType, TelegramContactInfo, ThresholdDirection, TitleSubtitleConfig, TitleSubtitleConfigActive, TitleSubtitleConfigInactive, TradingPairEventTypeItem, TradingPairInputs, Uint8SignMessageFunction, UserState, ValidInputRange, ValueItemConfig, ValueOrRef, ValueTransformFunc, WalletBalanceEventTypeItem, WalletWithSignMessage, WalletWithSignParams, WebhookContactInfo, WebhookHeaders, XMTPTopicTypeItem, XionSignMessageFunction, checkIsConfigWithDelegate, checkIsConfigWithPublicKeyAndAddress, createInMemoryStorageDriver, createLocalForageStorageDriver, ensureDiscord, ensureEmail, ensureSms, ensureSourceAndFilters, ensureTarget, ensureTelegram, ensureWebhook, envUrl, newFrontendClient, newFrontendConfig, newNotifiService, newNotifiStorage, normalizeHexString, notNullOrEmpty, packFilterOptions }; | ||
declare type ValueOrRef<ValueType> = Readonly<{ | ||
type: 'ref'; | ||
ref: string | null; | ||
}> | Readonly<{ | ||
type: 'value'; | ||
value: ValueType; | ||
}>; | ||
declare type DirectPushEventTypeItem = Readonly<{ | ||
type: 'directPush'; | ||
name: string; | ||
directPushId: ValueOrRef<string>; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type FusionTypeBase = { | ||
name: string; | ||
type: 'fusion' | 'fusionToggle'; | ||
fusionEventId: ValueOrRef<string>; | ||
sourceAddress: ValueOrRef<string>; | ||
tooltipContent?: string; | ||
maintainSourceGroup?: boolean; | ||
alertFrequency?: AlertFrequency; | ||
optOutAtSignup?: boolean; | ||
displayNameOverride?: string; | ||
}; | ||
declare type FusionToggleEventTypeItem = FusionTypeBase & Readonly<{ | ||
selectedUIType: 'TOGGLE'; | ||
}>; | ||
declare type FusionHealthCheckEventTypeItem = FusionTypeBase & Readonly<{ | ||
selectedUIType: 'HEALTH_CHECK'; | ||
healthCheckSubtitle: string; | ||
numberType: NumberTypeSelect; | ||
checkRatios: CheckRatio[]; | ||
validInputRange?: ValidInputRange; | ||
}>; | ||
declare type ValidInputRange = { | ||
max: number; | ||
min: number; | ||
}; | ||
declare type FusionMultiThreshholdEventTypeItem = FusionTypeBase & Readonly<{ | ||
selectedUIType: 'MULTI_THRESHOLD'; | ||
numberType: NumberTypeSelect; | ||
subtitle?: string; | ||
addThreshholdTitle?: string; | ||
}>; | ||
declare type FusionEventTypeItem = FusionToggleEventTypeItem | FusionHealthCheckEventTypeItem | FusionMultiThreshholdEventTypeItem; | ||
declare type BroadcastEventTypeItem = Readonly<{ | ||
type: 'broadcast'; | ||
name: string; | ||
broadcastId: ValueOrRef<string>; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
displayNameOverride?: string; | ||
}>; | ||
declare type HealthCheckEventTypeItem = Readonly<{ | ||
type: 'healthCheck'; | ||
name: string; | ||
checkRatios: ValueOrRef<CheckRatio[]>; | ||
alertFrequency: AlertFrequency; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type LabelEventTypeItem = Readonly<{ | ||
type: 'label'; | ||
name: string; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type TradingPairEventTypeItem = Readonly<{ | ||
type: 'tradingPair'; | ||
name: string; | ||
tooltipContent?: string; | ||
tradingPairs: ValueOrRef<ReadonlyArray<string>>; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type PriceChangeDataSource = 'coingecko'; | ||
declare type PriceChangeEventTypeItem = Readonly<{ | ||
type: 'priceChange'; | ||
name: string; | ||
tokenIds: ReadonlyArray<string>; | ||
dataSource: PriceChangeDataSource; | ||
tooltipContent: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type WalletBalanceEventTypeItem = Readonly<{ | ||
type: 'walletBalance'; | ||
name: string; | ||
tooltipContent?: string; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type CustomTypeBase = { | ||
type: 'custom'; | ||
name: string; | ||
tooltipContent: string; | ||
sourceType: Types.SourceType; | ||
filterType: string; | ||
sourceAddress: ValueOrRef<string>; | ||
optOutAtSignup?: boolean; | ||
}; | ||
declare type CustomToggleTypeItem = Readonly<{ | ||
filterOptions: FilterOptions; | ||
selectedUIType: 'TOGGLE'; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type NumberTypeSelect = 'percentage' | 'integer' | 'price'; | ||
declare type CustomHealthCheckItem = Readonly<{ | ||
selectedUIType: 'HEALTH_CHECK'; | ||
healthCheckSubtitle: string; | ||
numberType: NumberTypeSelect; | ||
alertFrequency: AlertFrequency; | ||
checkRatios: CheckRatio[]; | ||
optOutAtSignup?: boolean; | ||
}>; | ||
declare type RatiosBelow = Readonly<{ | ||
type: 'below'; | ||
ratio: number; | ||
}>; | ||
declare type RatiosAbove = Readonly<{ | ||
type: 'above'; | ||
ratio: number; | ||
}>; | ||
declare type CheckRatio = RatiosBelow | RatiosAbove; | ||
declare type CustomTopicTypeItem = CustomTypeBase & (CustomToggleTypeItem | CustomHealthCheckItem); | ||
declare type XMTPTopicTypeItem = { | ||
type: 'XMTP'; | ||
name: string; | ||
tooltipContent: string; | ||
sourceType?: Types.SourceType; | ||
filterType: string; | ||
XMTPTopics: ValueOrRef<ReadonlyArray<string>>; | ||
optOutAtSignup?: boolean; | ||
}; | ||
declare type EventTypeItem = DirectPushEventTypeItem | BroadcastEventTypeItem | HealthCheckEventTypeItem | TradingPairEventTypeItem | LabelEventTypeItem | PriceChangeEventTypeItem | CustomTopicTypeItem | FusionEventTypeItem | WalletBalanceEventTypeItem | XMTPTopicTypeItem; | ||
declare type EventTypeConfig = ReadonlyArray<EventTypeItem>; | ||
declare type InputType = 'WebhookUrlInput' | 'WebhookHeadersInput' | 'DirectPushIdInput' | 'BroadcastIdInput'; | ||
declare type InputItem = Readonly<{ | ||
name: string; | ||
type: InputType; | ||
}>; | ||
declare type InputsConfig = ReadonlyArray<InputItem>; | ||
declare type ContactInfo = Readonly<{ | ||
active: boolean; | ||
}>; | ||
declare type EmailContactInfo = ContactInfo; | ||
declare type DiscordContactInfo = ContactInfo; | ||
declare type CountryCode = string; | ||
declare type SmsContactInfo = ContactInfo & Readonly<{ | ||
supportedCountryCodes: ReadonlyArray<CountryCode>; | ||
}>; | ||
declare type TelegramContactInfo = ContactInfo; | ||
declare type WebhookHeaders = Readonly<Record<string, string>>; | ||
declare type WebhookContactInfo = ContactInfo & Readonly<{ | ||
url: ValueOrRef<string>; | ||
headers: ValueOrRef<WebhookHeaders>; | ||
}>; | ||
declare type ContactInfoConfig = Readonly<{ | ||
email: EmailContactInfo; | ||
sms: SmsContactInfo; | ||
telegram: TelegramContactInfo; | ||
webhook: WebhookContactInfo; | ||
discord: DiscordContactInfo; | ||
}>; | ||
declare type CardConfigItemV1 = Readonly<{ | ||
version: 'v1'; | ||
id: string | null; | ||
name: string; | ||
eventTypes: EventTypeConfig; | ||
inputs: InputsConfig; | ||
contactInfo: ContactInfoConfig; | ||
isContactInfoRequired?: boolean; | ||
titles?: TitleSubtitleConfig; | ||
}>; | ||
declare type TitleSubtitleConfigInactive = Readonly<{ | ||
active: false; | ||
}>; | ||
declare type TitleSubtitleConfigActive = Readonly<{ | ||
active: true; | ||
editView: string; | ||
previewView: string; | ||
historyView: string; | ||
signupView: string; | ||
expiredView: string; | ||
alertDetailsView: string; | ||
verifyWalletsView: string; | ||
}>; | ||
declare type TitleSubtitleConfig = TitleSubtitleConfigActive | TitleSubtitleConfigInactive; | ||
declare type FusionEventTopic = { | ||
uiConfig: FusionEventTypeItem; | ||
fusionEventDescriptor: Types.FusionEventDescriptor; | ||
}; | ||
declare type TenantConfig = { | ||
cardConfig: CardConfigType; | ||
fusionEventTopics: ReadonlyArray<FusionEventTopic>; | ||
}; | ||
declare const packFilterOptions: (clientOptions: Readonly<FilterOptions> | null) => string; | ||
declare type ResolveFunc<T> = (name: string, valueOrRef: ValueOrRef<T>, inputs: Record<string, unknown>) => T; | ||
declare const resolveStringRef: ResolveFunc<string>; | ||
declare const resolveNumberRef: ResolveFunc<number>; | ||
declare const resolveStringArrayRef: ResolveFunc<readonly string[]>; | ||
declare const resolveCheckRatioArrayRef: ResolveFunc<readonly CheckRatio[]>; | ||
export { AcalaSignMessageFunction, AlertFilter, AlertFrequency, AptosSignMessageFunction, Authorization, AuthorizationStorage, BroadcastEventTypeItem, CardConfigItemV1, CardConfigType, CheckRatio, ConfigFactoryInput, ConfigFactoryInputDelegated, ConfigFactoryInputPublicKey, ConfigFactoryInputPublicKeyAndAddress, ConnectWalletParams, ContactInfo, ContactInfoConfig, CountryCode, CreateFunc, CustomHealthCheckItem, CustomToggleTypeItem, CustomTopicTypeItem, CustomTypeBase, DirectPushEventTypeItem, DiscordContactInfo, EmailContactInfo, EnsureWebhookParams$1 as EnsureWebhookParams, EventTypeConfig, EventTypeItem, FetchFunc, Filter, FilterBase, FilterOptions, FilterType, FrequencyFilter, FrontendClientConfigFactory, FusionEventMetadata, FusionEventTopic, FusionEventTypeItem, FusionFilterOptions, FusionHealthCheckEventTypeItem, FusionMultiThreshholdEventTypeItem, FusionToggleEventTypeItem, FusionTypeBase, GetStorageType, HasStorageType, HealthCheckEventInputsWithCustomPercentage, HealthCheckEventInputsWithIndex, HealthCheckEventTypeItem, HealthCheckInputs, IdentifyFunc, InputItem, InputType, InputsConfig, LabelEventTypeItem, NotifiConfigWithDelegate, NotifiConfigWithPublicKey, NotifiConfigWithPublicKeyAndAddress, NotifiEnvironment, NotifiEnvironmentConfiguration, NotifiFrontendClient, NotifiFrontendConfiguration, NotifiFrontendStorage, NotifiStorage, NumberTypeSelect, PriceChangeDataSource, PriceChangeEventTypeItem, RequiredParserVariable, Roles, RolesStorage, SIGNING_MESSAGE, SetStorageType, SignMessageParams, SmsContactInfo, StorageDriver, StorageType, SupportedCardConfigType, TelegramContactInfo, TenantConfig, ThresholdDirection, TitleSubtitleConfig, TitleSubtitleConfigActive, TitleSubtitleConfigInactive, TradingPairEventTypeItem, TradingPairInputs, UiType, Uint8SignMessageFunction, UserInputOptions, UserInputParam, UserState, ValidInputRange, ValueItemConfig, ValueOrRef, ValueTransformFunc, ValueType, WalletBalanceEventTypeItem, WalletWithSignMessage, WalletWithSignParams, WebhookContactInfo, WebhookHeaders, XMTPTopicTypeItem, XionSignMessageFunction, checkIsConfigWithDelegate, checkIsConfigWithPublicKeyAndAddress, createInMemoryStorageDriver, createLocalForageStorageDriver, ensureDiscord, ensureEmail, ensureSlack, ensureSms, ensureSourceAndFilters, ensureTarget, ensureTelegram, ensureWebhook, envUrl, newFrontendClient, newFrontendConfig, newNotifiService, newNotifiStorage, normalizeHexString, notNullOrEmpty, packFilterOptions, resolveCheckRatioArrayRef, resolveNumberRef, resolveStringArrayRef, resolveStringRef }; |
@@ -16,2 +16,3 @@ import { NotifiService } from '@notifi-network/notifi-graphql'; | ||
import { NotifiFrontendClient } from './NotifiFrontendClient'; | ||
import { NotifiSubscriptionService } from 'notifi-graphql/lib/NotifiSubscriptionService'; | ||
@@ -27,5 +28,7 @@ export const newNotifiStorage = (config: NotifiFrontendConfiguration) => { | ||
export const newNotifiService = (config: NotifiFrontendConfiguration) => { | ||
const url = envUrl(config.env); | ||
const url = envUrl(config.env, 'http'); | ||
const wsurl = envUrl(config.env, 'websocket'); | ||
const client = new GraphQLClient(url); | ||
return new NotifiService(client); | ||
const subService = new NotifiSubscriptionService(wsurl); | ||
return new NotifiService(client, subService); | ||
}; | ||
@@ -32,0 +35,0 @@ |
@@ -5,3 +5,2 @@ import type { Operations, Types } from '@notifi-network/notifi-graphql'; | ||
BroadcastEventTypeItem, | ||
CreateSupportConversationEventTypeItem, | ||
CustomTopicTypeItem, | ||
@@ -238,14 +237,2 @@ DirectPushEventTypeItem, | ||
return 'ZKSYNC_WALLET'; | ||
case 'ARCHWAY': | ||
return 'ARCHWAY_WALLET'; | ||
case 'ELYS': | ||
return 'ELYS_WALLET'; | ||
case 'AXELAR': | ||
return 'AXELAR_WALLET'; | ||
case 'NEUTRON': | ||
return 'NEUTRON_WALLET'; | ||
case 'BERACHAIN': | ||
return 'BERACHAIN_WALLET'; | ||
case 'XION': | ||
return 'XION_WALLET'; | ||
default: | ||
@@ -419,26 +406,2 @@ throw new Error('Unsupported walletType'); | ||
const ensureCreateSupportConversationSources = async ( | ||
service: Operations.GetSourcesService & Operations.CreateSourceService, | ||
eventType: CreateSupportConversationEventTypeItem, | ||
_inputs: Record<string, unknown>, | ||
): Promise<Types.SourceFragmentFragment> => { | ||
const sourcesQuery = await service.getSources({}); | ||
const sources = sourcesQuery.source; | ||
const source = sources?.find((it) => it?.type === 'NOTIFI_CHAT'); | ||
if (source) { | ||
return source; | ||
} | ||
const createMutation = await service.createSource({ | ||
type: eventType.sourceType, | ||
blockchainAddress: '*', | ||
}); | ||
const newSource = createMutation.createSource; | ||
if (newSource === undefined) { | ||
throw new Error('Failed to create source'); | ||
} | ||
return newSource; | ||
}; | ||
const ensureSources = async ( | ||
@@ -497,13 +460,8 @@ service: Operations.GetSourcesService & | ||
} | ||
case 'createSupportConversation': { | ||
const source = await ensureCreateSupportConversationSources( | ||
service, | ||
eventType, | ||
inputs, | ||
); | ||
return [source]; | ||
} | ||
case 'label': { | ||
throw new Error('Unsupported event type'); | ||
} | ||
default: | ||
throw new Error('Unsupported event type'); | ||
} | ||
@@ -840,21 +798,2 @@ }; | ||
const getCreateSupportConversationFilter = ( | ||
source: Types.SourceFragmentFragment, | ||
eventType: CreateSupportConversationEventTypeItem, | ||
_inputs: Record<string, unknown>, | ||
): GetFilterResults => { | ||
const filter = source.applicableFilters?.find( | ||
(it) => it?.filterType === 'NOTIFI_CHAT_MESSAGES', | ||
); | ||
if (filter === undefined) { | ||
throw new Error('Failed to retrieve filter: CreateSupportConversation'); | ||
} | ||
return { | ||
filter, | ||
filterOptions: { | ||
alertFrequency: eventType.alertFrequency, | ||
}, | ||
}; | ||
}; | ||
export type HealthCheckEventInputsWithIndex = { | ||
@@ -1073,15 +1012,5 @@ index: number; // The index of CheckRatio list | ||
} | ||
case 'createSupportConversation': { | ||
const { filter, filterOptions } = getCreateSupportConversationFilter( | ||
sources[0], | ||
eventType, | ||
inputs, | ||
); | ||
return { | ||
sourceGroup, | ||
filter, | ||
filterOptions, | ||
}; | ||
} | ||
default: | ||
throw new Error('Unsupported event type'); | ||
} | ||
}; |
@@ -137,2 +137,28 @@ import type { Operations, Types } from '@notifi-network/notifi-graphql'; | ||
export const ensureSlack = ensureTarget( | ||
async ( | ||
service: Operations.CreateSlackChannelTargetService, | ||
value: string, | ||
) => { | ||
const mutation = await service.createSlackChannelTarget({ | ||
name: value, | ||
value, | ||
}); | ||
const result = mutation.createSlackChannelTarget.slackChannelTarget; | ||
if (result === undefined) { | ||
throw new Error('Failed to create slackTarget'); | ||
} | ||
return result; | ||
}, | ||
async (service: Operations.GetSlackChannelTargetsService) => { | ||
const query = await service.getSlackChannelTargets({}); | ||
return query.slackChannelTargets?.nodes; | ||
}, | ||
(arg: Types.SlackChannelTargetFragmentFragment | undefined) => arg?.name, | ||
() => 'Default', | ||
); | ||
export type EnsureWebhookParams = Omit< | ||
@@ -139,0 +165,0 @@ Types.CreateWebhookTargetMutationVariables, |
@@ -14,5 +14,6 @@ import { Types } from '@notifi-network/notifi-graphql'; | ||
EventTypeItem, | ||
FusionEventTopic, | ||
TenantConfig, | ||
WalletBalanceEventTypeItem, | ||
} from '../models'; | ||
import { IntercomCardConfigItemV1 } from '../models/IntercomCardConfig'; | ||
import type { Authorization, NotifiStorage, Roles } from '../storage'; | ||
@@ -30,2 +31,3 @@ import { | ||
ensureEmail, | ||
ensureSlack, | ||
ensureSms, | ||
@@ -49,7 +51,2 @@ ensureTelegram, | ||
| 'OSMOSIS' | ||
| 'ELYS' | ||
| 'NEUTRON' | ||
| 'ARCHWAY' | ||
| 'AXELAR' | ||
| 'BERACHAIN' | ||
| 'NIBIRU' | ||
@@ -118,4 +115,3 @@ | 'OPTIMISM' | ||
| 'MANTA' | ||
| 'MONAD' | ||
| 'BERACHAIN'; | ||
| 'MONAD'; | ||
walletPublicKey: string; | ||
@@ -161,26 +157,2 @@ signMessage: Uint8SignMessageFunction; | ||
signMessage: Uint8SignMessageFunction; | ||
}> | ||
| Readonly<{ | ||
walletBlockchain: 'ELYS'; | ||
accountAddress: string; | ||
walletPublicKey: string; | ||
signMessage: Uint8SignMessageFunction; | ||
}> | ||
| Readonly<{ | ||
walletBlockchain: 'NEUTRON'; | ||
accountAddress: string; | ||
walletPublicKey: string; | ||
signMessage: Uint8SignMessageFunction; | ||
}> | ||
| Readonly<{ | ||
walletBlockchain: 'ARCHWAY'; | ||
accountAddress: string; | ||
walletPublicKey: string; | ||
signMessage: Uint8SignMessageFunction; | ||
}> | ||
| Readonly<{ | ||
walletBlockchain: 'AXELAR'; | ||
accountAddress: string; | ||
walletPublicKey: string; | ||
signMessage: Uint8SignMessageFunction; | ||
}>; | ||
@@ -209,3 +181,3 @@ | ||
export type CardConfigType = CardConfigItemV1 | IntercomCardConfigItemV1; | ||
export type CardConfigType = CardConfigItemV1; | ||
@@ -429,3 +401,2 @@ type BeginLoginProps = Omit<Types.BeginLogInByTransactionInput, 'dappAddress'>; | ||
case 'BLAST': | ||
case 'BERACHAIN': | ||
case 'CELO': | ||
@@ -461,6 +432,2 @@ case 'MANTLE': | ||
case 'OSMOSIS': | ||
case 'ELYS': | ||
case 'ARCHWAY': | ||
case 'AXELAR': | ||
case 'NEUTRON': | ||
case 'NIBIRU': | ||
@@ -506,3 +473,2 @@ case 'APTOS': { | ||
case 'ETHEREUM': | ||
case 'BERACHAIN': | ||
case 'POLYGON': | ||
@@ -536,7 +502,2 @@ case 'ARBITRUM': | ||
case 'ZKSYNC': | ||
case 'ELYS': | ||
case 'NEUTRON': | ||
case 'NIBIRU': | ||
case 'ARCHWAY': | ||
case 'AXELAR': | ||
case 'INJECTIVE': { | ||
@@ -763,2 +724,3 @@ const { authenticationKey, tenantId } = this | ||
discordId, | ||
slackId, | ||
}: Readonly<{ | ||
@@ -771,2 +733,3 @@ name: string; | ||
discordId?: string; | ||
slackId?: string; | ||
}>): Promise<Types.TargetGroupFragmentFragment> { | ||
@@ -780,2 +743,3 @@ const [ | ||
discordTargetId, | ||
slackTargetId, | ||
] = await Promise.all([ | ||
@@ -788,2 +752,3 @@ this._service.getTargetGroups({}), | ||
ensureDiscord(this._service, discordId), | ||
ensureSlack(this._service, slackId), | ||
]); | ||
@@ -799,2 +764,4 @@ | ||
discordTargetId === undefined ? [] : [discordTargetId]; | ||
const slackChannelTargetIds = | ||
slackTargetId === undefined ? [] : [slackTargetId]; | ||
@@ -812,2 +779,3 @@ const existing = targetGroupsQuery.targetGroup?.find( | ||
discordTargetIds, | ||
slackChannelTargetIds, | ||
}); | ||
@@ -823,2 +791,3 @@ } | ||
discordTargetIds, | ||
slackChannelTargetIds, | ||
}); | ||
@@ -840,2 +809,3 @@ | ||
discordTargetIds, | ||
slackChannelTargetIds, | ||
}: Readonly<{ | ||
@@ -848,2 +818,3 @@ existing: Types.TargetGroupFragmentFragment; | ||
discordTargetIds: Array<string>; | ||
slackChannelTargetIds: Array<string>; | ||
}>): Promise<Types.TargetGroupFragmentFragment> { | ||
@@ -855,3 +826,4 @@ if ( | ||
areIdsEqual(webhookTargetIds, existing.webhookTargets ?? []) && | ||
areIdsEqual(discordTargetIds, existing.discordTargets ?? []) | ||
areIdsEqual(discordTargetIds, existing.discordTargets ?? []) && | ||
areIdsEqual(slackChannelTargetIds, existing.slackChannelTargets ?? []) | ||
) { | ||
@@ -869,2 +841,3 @@ return existing; | ||
discordTargetIds, | ||
slackChannelTargetIds, | ||
}); | ||
@@ -956,2 +929,26 @@ | ||
async ensureFusionAlerts( | ||
input: Types.CreateFusionAlertsInput, | ||
): Promise<Types.CreateFusionAlertsMutation['createFusionAlerts']> { | ||
const inputAlertsNames = new Set(input.alerts.map((alert) => alert.name)); | ||
const query = await this._service.getAlerts({}); | ||
const existingAlerts = new Set(query.alert); | ||
const duplicateAlerts = [...existingAlerts].filter((alert) => | ||
inputAlertsNames.has(alert?.name), | ||
); | ||
const duplicateAlertsIds = duplicateAlerts | ||
.map((alert) => alert?.id) | ||
.filter((id): id is string => !!id); // TODO: n(^2) --> consider to move to BE when this grows huge | ||
// Alerts are immutable, delete the existing instead | ||
for (const id of duplicateAlertsIds) { | ||
await this.deleteAlert({ id }); | ||
} | ||
const mutation = await this._service.createFusionAlerts({ input }); | ||
return mutation.createFusionAlerts; | ||
} | ||
async deleteAlert({ | ||
@@ -1015,2 +1012,10 @@ id, | ||
async subscribeNotificationHistoryStateChanged(onMessageReceived: (data: any) => void | undefined, onError?: (data: any) => void | undefined, onComplete?: () => void | undefined): Promise<void> { | ||
this._service.subscribeNotificationHistoryStateChanged(onMessageReceived, onError, onComplete); | ||
} | ||
async wsDispose() { | ||
this._service.wsDispose(); | ||
} | ||
async getUserSettings(): Promise<Types.GetUserSettingsQuery['userSettings']> { | ||
@@ -1042,2 +1047,3 @@ const query = await this._service.getUserSettings({}); | ||
/**@deprecated for legacy infra, use fetchTenantConfig instead for new infra (fusionEvent) */ | ||
async fetchSubscriptionCard( | ||
@@ -1069,4 +1075,4 @@ variables: FindSubscriptionCardParams, | ||
} | ||
case 'IntercomV1': { | ||
card = obj as IntercomCardConfigItemV1; | ||
default: { | ||
throw new Error('Unsupported config version'); | ||
} | ||
@@ -1082,2 +1088,51 @@ } | ||
async fetchTenantConfig( | ||
variables: FindSubscriptionCardParams, | ||
): Promise<TenantConfig> { | ||
const query = await this._service.findTenantConfig({ | ||
input: { | ||
...variables, | ||
tenant: this._configuration.tenantId, | ||
}, | ||
}); | ||
const result = query.findTenantConfig; | ||
if (result === undefined || !result.dataJson || !result.fusionEvents) { | ||
throw new Error('Failed to find tenant config'); | ||
} | ||
const tenantConfigJsonString = result.dataJson; | ||
if (tenantConfigJsonString === undefined) { | ||
throw new Error('Invalid config data'); | ||
} | ||
const cardConfig = JSON.parse(tenantConfigJsonString) as CardConfigItemV1; | ||
const fusionEventDescriptors = result.fusionEvents; | ||
if (!cardConfig || cardConfig.version !== 'v1' || !fusionEventDescriptors) | ||
throw new Error('Unsupported config format'); | ||
const fusionEventDescriptorMap = new Map< | ||
string, | ||
Types.FusionEventDescriptor | ||
>(fusionEventDescriptors.map((item) => [item?.name ?? '', item ?? {}])); | ||
fusionEventDescriptorMap.delete(''); | ||
const fusionEventTopics: FusionEventTopic[] = cardConfig.eventTypes | ||
.map((eventType) => { | ||
if (eventType.type === 'fusion') { | ||
const fusionEventDescriptor = fusionEventDescriptorMap.get( | ||
eventType.name, | ||
); | ||
return { | ||
uiConfig: eventType, | ||
fusionEventDescriptor, | ||
}; | ||
} | ||
}) | ||
.filter((item): item is FusionEventTopic => !!item); | ||
return { cardConfig, fusionEventTopics }; | ||
} | ||
async copyAuthorization(config: NotifiFrontendConfiguration) { | ||
@@ -1148,23 +1203,2 @@ const auth = await this._storage.getAuthorization(); | ||
async getConversationMessages( | ||
input: Types.GetConversationMessagesQueryVariables, | ||
): Promise<Types.GetConversationMessagesQuery> { | ||
const query = await this._service.getConversationMessages(input); | ||
return query; | ||
} | ||
async sendConversationMessages( | ||
input: Types.SendConversationMessageMutationVariables, | ||
): Promise<Types.SendConversationMessageMutation> { | ||
const mutation = await this._service.sendConversationMessages(input); | ||
return mutation; | ||
} | ||
async createSupportConversation( | ||
input: Types.CreateSupportConversationMutationVariables, | ||
): Promise<Types.CreateSupportConversationMutation> { | ||
const mutation = await this._service.createSupportConversation(input); | ||
return mutation; | ||
} | ||
async createDiscordTarget(input: string) { | ||
@@ -1171,0 +1205,0 @@ const mutation = await this._service.createDiscordTarget({ |
@@ -10,3 +10,3 @@ import { Types } from '@notifi-network/notifi-graphql'; | ||
export type NotifiEnvironmentConfiguration = Readonly<{ | ||
env: NotifiEnvironment; | ||
env?: NotifiEnvironment; | ||
tenantId: string; | ||
@@ -36,4 +36,2 @@ storageOption?: Readonly<{ | ||
| 'MONAD' | ||
| 'BERACHAIN' | ||
| 'XION' // Temporarily added this - Xion can be one or the other, or new config needs to be supported | ||
>; | ||
@@ -45,6 +43,3 @@ | ||
Types.WalletBlockchain, | ||
| WalletBlockchainWithPublicKey | ||
| 'OFF_CHAIN' | ||
| 'EVMOS' | ||
| WalletBlockchainWithDelegate | ||
WalletBlockchainWithPublicKey | 'OFF_CHAIN' | 'EVMOS' | ||
>; | ||
@@ -93,3 +88,3 @@ | ||
return 'delegatedAddress' in config; | ||
}; | ||
} | ||
@@ -103,3 +98,3 @@ export type ConfigFactoryInputDelegated = { | ||
tenantId: string; | ||
env: NotifiEnvironment; | ||
env?: NotifiEnvironment; | ||
walletBlockchain: NotifiConfigWithPublicKeyAndAddress['walletBlockchain']; | ||
@@ -115,3 +110,3 @@ storageOption?: NotifiEnvironmentConfiguration['storageOption']; | ||
tenantId: string; | ||
env: NotifiEnvironment; | ||
env?: NotifiEnvironment; | ||
walletBlockchain: NotifiConfigWithPublicKeyAndAddress['walletBlockchain']; | ||
@@ -126,3 +121,3 @@ storageOption?: NotifiEnvironmentConfiguration['storageOption']; | ||
tenantId: string; | ||
env: NotifiEnvironment; | ||
env?: NotifiEnvironment; | ||
walletBlockchain: NotifiConfigWithPublicKey['walletBlockchain']; | ||
@@ -155,3 +150,2 @@ storageOption?: NotifiEnvironmentConfiguration['storageOption']; | ||
'ZKSYNC', | ||
'BERACHAIN', | ||
] as const; | ||
@@ -208,13 +202,21 @@ | ||
export const envUrl = (env: NotifiEnvironment): string => { | ||
export const envUrl = (env?: NotifiEnvironment, endpointType?: 'websocket' | 'http'): string => { | ||
if (!env) env = 'Production'; | ||
let url = ''; | ||
switch (env) { | ||
case 'Development': | ||
return 'https://api.dev.notifi.network/gql'; | ||
url = '://api.dev.notifi.network/gql'; | ||
break; | ||
case 'Local': | ||
return 'https://localhost:5001/gql'; | ||
url = '://localhost:5001/gql'; | ||
break; | ||
case 'Production': | ||
return 'https://api.notifi.network/gql'; | ||
url = '://api.notifi.network/gql'; | ||
break; | ||
case 'Staging': | ||
return 'https://api.stg.notifi.network/gql'; | ||
url = '://api.stg.notifi.network/gql'; | ||
} | ||
return `${endpointType === 'websocket' ? 'wss' : 'https'}${url}`; | ||
}; |
@@ -17,2 +17,3 @@ export type AlertFrequency = | ||
/**@deprecated this is for AP v1 infra, use fusionFilterOptions instead for new infra */ | ||
export type FilterOptions = Partial<{ | ||
@@ -19,0 +20,0 @@ alertFrequency: AlertFrequency; |
export * from './FilterOptions'; | ||
export * from './FusionEvent'; | ||
export * from './SubscriptionCardConfig'; | ||
export * from './IntercomCardConfig'; |
// TODO: Import from library rather than copy / paste | ||
import { Types as Gql } from '@notifi-network/notifi-graphql'; | ||
import { Types as Gql, Types } from '@notifi-network/notifi-graphql'; | ||
import { CardConfigType } from '../client'; | ||
import { AlertFrequency, FilterOptions } from './FilterOptions'; | ||
@@ -171,11 +172,2 @@ | ||
export type CreateSupportConversationEventTypeItem = { | ||
type: 'createSupportConversation'; | ||
name: string; | ||
sourceType: Gql.SourceType; | ||
filterType: string; | ||
alertFrequency: AlertFrequency; | ||
optOutAtSignup?: boolean; | ||
}; | ||
export type EventTypeItem = | ||
@@ -191,4 +183,3 @@ | DirectPushEventTypeItem | ||
| WalletBalanceEventTypeItem | ||
| XMTPTopicTypeItem | ||
| CreateSupportConversationEventTypeItem; | ||
| XMTPTopicTypeItem; | ||
@@ -267,1 +258,13 @@ export type EventTypeConfig = ReadonlyArray<EventTypeItem>; | ||
| TitleSubtitleConfigInactive; | ||
export type FusionEventTopic = { | ||
// The following from original fusionEventTypeItem (Legacy) | ||
uiConfig: FusionEventTypeItem; | ||
// The following is the respective fusionEventDescripter | ||
fusionEventDescriptor: Types.FusionEventDescriptor; | ||
}; | ||
export type TenantConfig = { | ||
cardConfig: CardConfigType; // Legacy | ||
fusionEventTopics: ReadonlyArray<FusionEventTopic>; | ||
}; |
@@ -9,3 +9,4 @@ import { | ||
const getEnvPrefix = (env: NotifiEnvironment): string => { | ||
const getEnvPrefix = (env?: NotifiEnvironment): string => { | ||
if (!env) env = 'Production'; | ||
switch (env) { | ||
@@ -26,4 +27,5 @@ case 'Production': | ||
): StorageDriver => { | ||
let keyPrefix = `${getEnvPrefix(config.env)}:${config.tenantId}:${config.walletBlockchain | ||
}`; | ||
let keyPrefix = `${getEnvPrefix(config.env || 'Production')}:${ | ||
config.tenantId | ||
}:${config.walletBlockchain}`; | ||
@@ -30,0 +32,0 @@ if (checkIsConfigWithPublicKeyAndAddress(config)) { |
@@ -15,3 +15,4 @@ import localforage from 'localforage'; | ||
const getEnvPrefix = (env: NotifiEnvironment): string => { | ||
const getEnvPrefix = (env?: NotifiEnvironment): string => { | ||
if (!env) env = 'Production'; | ||
switch (env) { | ||
@@ -32,4 +33,5 @@ case 'Production': | ||
): StorageDriver => { | ||
let keyPrefix = `${getEnvPrefix(config.env)}:${config.tenantId}:${config.walletBlockchain | ||
}`; | ||
let keyPrefix = `${getEnvPrefix(config.env)}:${config.tenantId}:${ | ||
config.walletBlockchain | ||
}`; | ||
@@ -36,0 +38,0 @@ if (checkIsConfigWithPublicKeyAndAddress(config)) { |
export * from './notNullOrEmpty'; | ||
export * from './packFilterOptions'; | ||
export * from './resolveRef'; |
{ | ||
"name": "@notifi-network/notifi-frontend-client", | ||
"version": "0.90.9-alpha.10+4dfba16", | ||
"version": "0.90.9-alpha.11+df764049", | ||
"description": "The frontend client for Notifi", | ||
@@ -35,7 +35,7 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@notifi-network/notifi-graphql": "^0.90.9-alpha.10+4dfba16", | ||
"@notifi-network/notifi-graphql": "^0.90.9-alpha.11+df764049", | ||
"graphql-request": "^6.0.0", | ||
"localforage": "^1.10.0" | ||
}, | ||
"gitHead": "4dfba16d4cc47a3f83c64c01403b54d5c8082176" | ||
"gitHead": "df764049df3e1c82fd9fa0ad3eef2e32ef98573e" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
307069
8972