Skip to content

Commit

Permalink
NAS-131557: Rename IncomingWebsocketMessage to IncomingApiMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanY147 committed Nov 13, 2024
1 parent 4e942dd commit 0fa3a26
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app/interfaces/api-message.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type ApiEventTyped<
T extends ApiEventResponseType<M> = ApiEventResponseType<M>,
> = ApiEvent<T>;

export type IncomingWebSocketMessage =
export type IncomingApiMessage =
| PongMessage
| SubscriptionReadyMessage
| ResultMessage
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from 'app/interfaces/api/api-job-directory.interface';
import { ApiError } from 'app/interfaces/api-error.interface';
import {
ApiEvent, ApiEventMethod, ApiEventTyped, IncomingWebSocketMessage, ResultMessage,
ApiEvent, ApiEventMethod, ApiEventTyped, IncomingApiMessage, ResultMessage,
} from 'app/interfaces/api-message.interface';
import { Job } from 'app/interfaces/job.interface';
import { WebSocketConnectionService } from 'app/services/websocket-connection.service';
Expand Down Expand Up @@ -155,8 +155,8 @@ export class ApiService {
});
}),
switchMap(() => this.ws$),
filter((data: IncomingWebSocketMessage) => data.msg === IncomingApiMessageType.Result && data.id === uuid),
switchMap((data: IncomingWebSocketMessage) => {
filter((data: IncomingApiMessage) => data.msg === IncomingApiMessageType.Result && data.id === uuid),
switchMap((data: IncomingApiMessage) => {
if ('error' in data && data.error) {
this.printError(data.error, { method, params });
const error = this.enhanceError(data.error, { method });
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ApiCallParams,
ApiCallResponse,
} from 'app/interfaces/api/api-call-directory.interface';
import { IncomingWebSocketMessage, ResultMessage } from 'app/interfaces/api-message.interface';
import { IncomingApiMessage, ResultMessage } from 'app/interfaces/api-message.interface';
import { LoginExMechanism, LoginExResponse, LoginExResponseType } from 'app/interfaces/auth.interface';
import { LoggedInUser } from 'app/interfaces/ds-cache.interface';
import { GlobalTwoFactorConfig } from 'app/interfaces/two-factor-config.interface';
Expand Down Expand Up @@ -258,8 +258,8 @@ export class AuthService {

private getFilteredWebSocketResponse<T>(uuid: string): Observable<T> {
return this.wsManager.websocket$.pipe(
filter((data: IncomingWebSocketMessage) => data.msg === IncomingApiMessageType.Result && data.id === uuid),
switchMap((data: IncomingWebSocketMessage) => {
filter((data: IncomingApiMessage) => data.msg === IncomingApiMessageType.Result && data.id === uuid),
switchMap((data: IncomingApiMessage) => {
if ('error' in data && data.error) {
return throwError(() => data.error);
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/services/websocket-connection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { webSocket as rxjsWebSocket, WebSocketSubject } from 'rxjs/webSocket';
import { IncomingApiMessageType, OutgoingApiMessageType } from 'app/enums/api-message-type.enum';
import { WEBSOCKET } from 'app/helpers/websocket.helper';
import { WINDOW } from 'app/helpers/window.helper';
import { ApiEventMethod, ApiEventTyped, IncomingWebSocketMessage } from 'app/interfaces/api-message.interface';
import { ApiEventMethod, ApiEventTyped, IncomingApiMessage } from 'app/interfaces/api-message.interface';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -76,7 +76,7 @@ export class WebSocketConnectionService {
},
});
this.wsAsObservable$ = this.ws$.asObservable().pipe(
switchMap((data: IncomingWebSocketMessage) => {
switchMap((data: IncomingApiMessage) => {
if (this.hasAuthError(data)) {
console.error(data);
this.ws$.complete();
Expand All @@ -86,7 +86,7 @@ export class WebSocketConnectionService {
);
// At least one explicit subscription required to keep the connection open
this.ws$.pipe(
tap((response: IncomingWebSocketMessage) => {
tap((response: IncomingApiMessage) => {
if (response.msg === IncomingApiMessageType.Connected) {
performance.mark('WS Connected');
performance.measure('Establishing WS connection', 'WS Init', 'WS Connected');
Expand Down Expand Up @@ -129,7 +129,7 @@ export class WebSocketConnectionService {
});
}

private hasAuthError(data: IncomingWebSocketMessage): boolean {
private hasAuthError(data: IncomingApiMessage): boolean {
return 'error' in data && data.error.error === 207;
}

Expand Down

0 comments on commit 0fa3a26

Please sign in to comment.