@notifi-network/notifi-graphql
Advanced tools
Comparing version 2.2.1-alpha.15 to 3.0.0
@@ -15,3 +15,3 @@ import { Client as WebSocketClient } from 'graphql-ws'; | ||
type NotifiWebSocketStatusEvents = { | ||
export type NotifiWebSocketStatusEvents = { | ||
wsConnecting: []; | ||
@@ -23,3 +23,3 @@ wsConnected: [WebSocketClient]; | ||
type NotifiSubscriptionStatusEvents = { | ||
export type NotifiSubscriptionStatusEvents = { | ||
gqlSubscriptionError: [Error]; | ||
@@ -26,0 +26,0 @@ gqlComplete: []; |
@@ -480,3 +480,7 @@ import { GraphQLClient } from 'graphql-request'; | ||
} | ||
/** | ||
* @important To remove event listener, check the README.md of `notifi-node` or `notifi-frontend-client` package for more details. | ||
* - `notifi-node`: https://github.com/notifi-network/notifi-sdk-ts/tree/main/packages/notifi-node | ||
* - `notifi-frontend-client`: https://github.com/notifi-network/notifi-sdk-ts/tree/main/packages/notifi-frontend-client | ||
*/ | ||
removeEventListener<T extends keyof NotifiEmitterEvents>( | ||
@@ -690,2 +694,3 @@ event: T, | ||
'X-Notifi-Client-Version': version, | ||
'Accept-Encoding': 'gzip, br', | ||
}; | ||
@@ -692,0 +697,0 @@ |
@@ -109,3 +109,7 @@ import { | ||
}; | ||
/** | ||
* @important To remove event listener, check the README.md of `notifi-node` or `notifi-frontend-client` package for more details. | ||
* - `notifi-node`: https://github.com/notifi-network/notifi-sdk-ts/tree/main/packages/notifi-node | ||
* - `notifi-frontend-client`: https://github.com/notifi-network/notifi-sdk-ts/tree/main/packages/notifi-frontend-client | ||
*/ | ||
removeEventListener = <T extends keyof NotifiEmitterEvents>( | ||
@@ -205,3 +209,2 @@ event: T, | ||
this._wsClient.on('connecting', () => { | ||
console.log('WebSocket connecting'); // TODO: Remove before merge | ||
this.eventEmitter.emit('wsConnecting'); | ||
@@ -211,4 +214,2 @@ }); | ||
this._wsClient.on('connected', () => { | ||
console.log('WebSocket connected'); // TODO: Remove before merge | ||
this.eventEmitter.emit('wsConnected', this._wsClient!); | ||
@@ -218,4 +219,2 @@ }); | ||
this._wsClient.on('closed', (event) => { | ||
console.log(`WebSocket closed`); // TODO: Remove before merge | ||
this.eventEmitter.emit('wsClosed', event); | ||
@@ -225,6 +224,9 @@ }); | ||
this._wsClient.on('error', (error) => { | ||
console.error('WebSocket error:', error); // TODO: Remove before merge | ||
if (error instanceof Error) { | ||
this.eventEmitter.emit('wsError', error); | ||
if (error instanceof Error /*⬅ Client (browser) side error*/) { | ||
return this.eventEmitter.emit('wsError', error); | ||
} | ||
this.eventEmitter.emit('wsError', { | ||
...(error as Error), | ||
message: 'NotifiEventEmitter: Server side or unknown error', | ||
}); | ||
}); | ||
@@ -236,20 +238,30 @@ }; | ||
// NOTE: GraphQL Subscription Event Response Format: https://spec.graphql.org/October2021/#sec-Response-Format | ||
type GqlSubscriptionEventData<T extends keyof NotifiSubscriptionEvents> = { | ||
data: Record<T, NotifiSubscriptionEvents[T][0]>; | ||
}; | ||
const getSubscriptionData = <T extends keyof NotifiSubscriptionEvents>( | ||
subscriptionEvent: T, | ||
data: unknown, | ||
subscriptionEventData: unknown, | ||
) => { | ||
// NOTE: The raw data from the subscription is in the format { data: { subscriptionEvent: T } } | ||
if (typeof data !== 'object' || data === null) return null; | ||
if (!('data' in data)) return null; | ||
const subscriptionData = data.data; | ||
if ( | ||
typeof subscriptionData === 'object' && | ||
subscriptionData !== null && | ||
subscriptionEvent in subscriptionData | ||
typeof subscriptionEventData !== 'object' || | ||
subscriptionEventData === null | ||
) | ||
return null; | ||
if (!('data' in subscriptionEventData)) return null; | ||
const { data: eventPayload } = | ||
subscriptionEventData as GqlSubscriptionEventData<T>; | ||
if ( | ||
typeof eventPayload === 'object' && | ||
eventPayload !== null && | ||
subscriptionEvent in eventPayload | ||
) { | ||
return (subscriptionData as Record<keyof NotifiSubscriptionEvents, any>)[ | ||
subscriptionEvent | ||
] as NotifiSubscriptionEvents[T][0]; | ||
return eventPayload[subscriptionEvent]; | ||
} | ||
return null; | ||
}; |
import { | ||
BeginLogInWithWeb3Mutation, | ||
BeginLogInWithWeb3MutationVariables, | ||
} from '../gql/generated'; | ||
export type BeginLogInWithWeb3Service = Readonly<{ | ||
beginLogInWithWeb3: ( | ||
variables: BeginLogInWithWeb3MutationVariables, | ||
) => Promise<BeginLogInWithWeb3Mutation>; | ||
}>; | ||
BeginLogInWithWeb3Mutation, | ||
BeginLogInWithWeb3MutationVariables, | ||
} from '../gql/generated'; | ||
export type BeginLogInWithWeb3Service = Readonly<{ | ||
beginLogInWithWeb3: ( | ||
variables: BeginLogInWithWeb3MutationVariables, | ||
) => Promise<BeginLogInWithWeb3Mutation>; | ||
}>; |
{ | ||
"name": "@notifi-network/notifi-graphql", | ||
"version": "2.2.1-alpha.15+ef3fed3b", | ||
"version": "3.0.0", | ||
"description": "The GraphQL API for Notifi", | ||
@@ -49,3 +49,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "ef3fed3bf7163352c537cfcef1829b30e805e973" | ||
"gitHead": "06be91701874716f81401700aa326144ffb86afc" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1319576
187
17868
1
0