airdcpp-apisocket 2.5.0-beta.2 → 3.0.0-beta.10
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/babel.config.cjs +1 -1
- package/dist-es/Promise.js.map +1 -1
- package/dist-es/PublicHelpers.js +21 -4
- package/dist-es/PublicHelpers.js.map +1 -1
- package/dist-es/SocketBase.js +13 -11
- package/dist-es/SocketBase.js.map +1 -1
- package/dist-es/SocketLogger.js.map +1 -1
- package/dist-es/SocketRequestHandler.js +3 -5
- package/dist-es/SocketRequestHandler.js.map +1 -1
- package/dist-es/SocketSubscriptionHandler.js.map +1 -1
- package/dist-es/tests/mocks/index.d.ts +3 -0
- package/dist-es/tests/mocks/index.js +4 -0
- package/dist-es/tests/mocks/index.js.map +1 -0
- package/dist-es/tests/mocks/mock-data.d.ts +54 -0
- package/dist-es/tests/mocks/mock-data.js +34 -0
- package/dist-es/tests/mocks/mock-data.js.map +1 -0
- package/dist-es/tests/mocks/mock-server.d.ts +43 -0
- package/dist-es/tests/mocks/mock-server.js +154 -0
- package/dist-es/tests/mocks/mock-server.js.map +1 -0
- package/dist-es/tests/mocks/mock-socket.d.ts +23 -0
- package/dist-es/tests/mocks/mock-socket.js +31 -0
- package/dist-es/tests/mocks/mock-socket.js.map +1 -0
- package/dist-es/tests/test-utils.d.ts +8 -0
- package/dist-es/tests/test-utils.js +28 -0
- package/dist-es/tests/test-utils.js.map +1 -0
- package/dist-es/types/public_helpers.d.ts +12 -3
- package/dist-es/types/public_helpers_internal.d.ts +4 -4
- package/dist-es/types/socket.d.ts +1 -0
- package/dist-es/utils.js.map +1 -1
- package/jest.config.js +0 -5
- package/package.json +13 -11
- package/src/PublicHelpers.ts +22 -4
- package/src/SocketBase.ts +15 -12
- package/src/SocketRequestHandler.ts +3 -5
- package/src/tests/Socket.test.ts +107 -109
- package/src/tests/mocks/index.ts +3 -0
- package/src/tests/mocks/mock-data.ts +36 -0
- package/src/tests/mocks/mock-server.ts +269 -0
- package/src/tests/mocks/mock-socket.ts +68 -0
- package/src/tests/public_helpers.test.ts +63 -62
- package/src/tests/test-utils.ts +31 -0
- package/src/types/api_internal.ts +0 -1
- package/src/types/public_helpers.ts +11 -11
- package/src/types/public_helpers_internal.ts +4 -4
- package/src/types/socket.ts +1 -0
- package/tsconfig.json +5 -5
- package/tslint.json +0 -2
- package/dist/ApiConstants.d.ts +0 -6
- package/dist/ApiConstants.js +0 -8
- package/dist/ApiConstants.js.map +0 -1
- package/dist/NodeSocket.d.ts +0 -4
- package/dist/NodeSocket.js +0 -25
- package/dist/NodeSocket.js.map +0 -1
- package/dist/Promise.d.ts +0 -8
- package/dist/Promise.js +0 -27
- package/dist/Promise.js.map +0 -1
- package/dist/PublicHelpers.d.ts +0 -2
- package/dist/PublicHelpers.js +0 -95
- package/dist/PublicHelpers.js.map +0 -1
- package/dist/SocketBase.d.ts +0 -4
- package/dist/SocketBase.js +0 -352
- package/dist/SocketBase.js.map +0 -1
- package/dist/SocketLogger.d.ts +0 -9
- package/dist/SocketLogger.js +0 -75
- package/dist/SocketLogger.js.map +0 -1
- package/dist/SocketRequestHandler.d.ts +0 -14
- package/dist/SocketRequestHandler.js +0 -169
- package/dist/SocketRequestHandler.js.map +0 -1
- package/dist/SocketSubscriptionHandler.d.ts +0 -11
- package/dist/SocketSubscriptionHandler.js +0 -162
- package/dist/SocketSubscriptionHandler.js.map +0 -1
- package/dist/types/api.d.ts +0 -30
- package/dist/types/api.js +0 -4
- package/dist/types/api.js.map +0 -1
- package/dist/types/api_internal.d.ts +0 -24
- package/dist/types/api_internal.js +0 -3
- package/dist/types/api_internal.js.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -24
- package/dist/types/index.js.map +0 -1
- package/dist/types/logger.d.ts +0 -6
- package/dist/types/logger.js +0 -3
- package/dist/types/logger.js.map +0 -1
- package/dist/types/options.d.ts +0 -31
- package/dist/types/options.js +0 -4
- package/dist/types/options.js.map +0 -1
- package/dist/types/public_helpers.d.ts +0 -19
- package/dist/types/public_helpers.js +0 -3
- package/dist/types/public_helpers.js.map +0 -1
- package/dist/types/public_helpers_internal.d.ts +0 -27
- package/dist/types/public_helpers_internal.js +0 -3
- package/dist/types/public_helpers_internal.js.map +0 -1
- package/dist/types/requests.d.ts +0 -14
- package/dist/types/requests.js +0 -3
- package/dist/types/requests.js.map +0 -1
- package/dist/types/socket.d.ts +0 -23
- package/dist/types/socket.js +0 -3
- package/dist/types/socket.js.map +0 -1
- package/dist/types/subscriptions.d.ts +0 -20
- package/dist/types/subscriptions.js +0 -3
- package/dist/types/subscriptions.js.map +0 -1
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -16
- package/dist/utils.js.map +0 -1
- package/src/tests/helpers.ts +0 -195
@@ -1,19 +0,0 @@
|
|
1
|
-
import { HookSubscriberInfo } from './subscriptions.js';
|
2
|
-
type AsyncCallbackProperty<IdT, EntityIdT, ReturnT> = (selectedIds: IdT[], entityId: EntityIdT | null, permissions: string[], supports: string[]) => ReturnT | Promise<ReturnT>;
|
3
|
-
export type ContextMenuIcon = {
|
4
|
-
[key in string]: string;
|
5
|
-
};
|
6
|
-
export interface ContextMenu extends HookSubscriberInfo {
|
7
|
-
icon?: ContextMenuIcon;
|
8
|
-
}
|
9
|
-
export interface ContextMenuItem<IdT, EntityIdT> {
|
10
|
-
id: string;
|
11
|
-
title: string;
|
12
|
-
icon?: ContextMenuIcon;
|
13
|
-
urls?: string[] | AsyncCallbackProperty<IdT, EntityIdT, string[] | undefined>;
|
14
|
-
onClick?: (selectedIds: IdT[], entityId: EntityIdT | null, permissions: string[], supports: string[], formValues: object) => void;
|
15
|
-
filter?: AsyncCallbackProperty<IdT, EntityIdT, boolean>;
|
16
|
-
access?: string;
|
17
|
-
formDefinitions?: object[] | AsyncCallbackProperty<IdT, EntityIdT, object[]>;
|
18
|
-
}
|
19
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"public_helpers.js","sourceRoot":"","sources":["../../src/types/public_helpers.ts"],"names":[],"mappings":""}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { ContextMenuIcon, ContextMenuItem } from './public_helpers.js';
|
2
|
-
export interface SelectedMenuItemListenerData<IdT, EntityIdT> {
|
3
|
-
hook_id: string;
|
4
|
-
menu_id: string;
|
5
|
-
menuitem_id: string;
|
6
|
-
selected_ids: IdT[];
|
7
|
-
entity_id: EntityIdT | null;
|
8
|
-
permissions: string[];
|
9
|
-
supports: string[];
|
10
|
-
form_values: object;
|
11
|
-
}
|
12
|
-
export interface MenuItemListHookData<IdT, EntityIdT> {
|
13
|
-
selected_ids: IdT[];
|
14
|
-
entity_id: EntityIdT | null;
|
15
|
-
permissions: string[];
|
16
|
-
supports: string[];
|
17
|
-
}
|
18
|
-
export interface ResponseMenuItemCallbackFields {
|
19
|
-
urls?: string[] | undefined;
|
20
|
-
form_definitions?: object[] | undefined;
|
21
|
-
}
|
22
|
-
export type ResponseMenuItem<IdT, EntityIdT> = Omit<ContextMenuItem<IdT, EntityIdT>, 'onClick' | 'filter' | 'urls' | 'form_definitions'> & ResponseMenuItemCallbackFields;
|
23
|
-
export interface MenuItemListHookAcceptData<IdT, EntityIdT> {
|
24
|
-
menuitems: ResponseMenuItem<IdT, EntityIdT>[];
|
25
|
-
icon?: ContextMenuIcon;
|
26
|
-
title?: string;
|
27
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"public_helpers_internal.js","sourceRoot":"","sources":["../../src/types/public_helpers_internal.ts"],"names":[],"mappings":""}
|
package/dist/types/requests.d.ts
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import * as API from './api.js';
|
2
|
-
export interface SocketRequestMethods {
|
3
|
-
put: <ResponseT extends object | void>(path: string, data?: object) => Promise<ResponseT>;
|
4
|
-
patch: <ResponseT extends object | void>(path: string, data?: object) => Promise<ResponseT>;
|
5
|
-
post: <ResponseT extends object | void>(path: string, data?: object) => Promise<ResponseT>;
|
6
|
-
delete: <ResponseT extends object | void>(path: string) => Promise<ResponseT>;
|
7
|
-
get: <ResponseT extends object | void>(path: string) => Promise<ResponseT>;
|
8
|
-
getPendingRequestCount: () => number;
|
9
|
-
}
|
10
|
-
export interface ErrorResponse {
|
11
|
-
message: string;
|
12
|
-
code: number;
|
13
|
-
json: API.FieldError | API.ErrorBase;
|
14
|
-
}
|
package/dist/types/requests.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"requests.js","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":""}
|
package/dist/types/socket.d.ts
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
import { AuthTokenType, LogoutResponse, AuthenticationResponse } from './api.js';
|
2
|
-
import { Logger } from './logger.js';
|
3
|
-
import { SocketRequestMethods } from './requests.js';
|
4
|
-
import { SocketSubscriptions } from './subscriptions.js';
|
5
|
-
export type ConnectedCallback = (data: AuthenticationResponse) => void;
|
6
|
-
export type SessionResetCallback = () => void;
|
7
|
-
export type DisconnectedCallback = (reason: string, code: number, wasClean: boolean) => void;
|
8
|
-
export interface APISocket extends SocketRequestMethods, SocketSubscriptions {
|
9
|
-
connect: (username?: string, password?: string, reconnectOnFailure?: boolean) => Promise<AuthenticationResponse>;
|
10
|
-
connectRefreshToken: (refreshToken: string, reconnectOnFailure?: boolean) => Promise<AuthenticationResponse>;
|
11
|
-
disconnect: (autoConnect?: boolean, reason?: string) => void;
|
12
|
-
waitDisconnected: (timeoutMs?: number) => Promise<void>;
|
13
|
-
reconnect: (token?: AuthTokenType, reconnectOnFailure?: boolean) => Promise<AuthenticationResponse>;
|
14
|
-
logout: () => Promise<LogoutResponse>;
|
15
|
-
isConnecting: () => boolean;
|
16
|
-
isConnected: () => boolean;
|
17
|
-
isActive: () => boolean;
|
18
|
-
logger: Logger;
|
19
|
-
onConnected: ConnectedCallback | null;
|
20
|
-
onSessionReset: SessionResetCallback | null;
|
21
|
-
onDisconnected: DisconnectedCallback | null;
|
22
|
-
readonly nativeSocket: WebSocket | null;
|
23
|
-
}
|
package/dist/types/socket.js
DELETED
package/dist/types/socket.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/types/socket.ts"],"names":[],"mappings":""}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import * as API from './api.js';
|
2
|
-
export type SubscriptionRemoveHandler = (sendApi?: boolean) => void;
|
3
|
-
export type SubscriptionCallback<DataT extends object | void = object, EntityIdT = API.EntityId | undefined> = (data: DataT, entityId: EntityIdT) => void;
|
4
|
-
export interface HookSubscriberInfo {
|
5
|
-
id: string;
|
6
|
-
name: string;
|
7
|
-
}
|
8
|
-
export type HookRejectHandler = (rejectId: string, rejectMessage: string) => void;
|
9
|
-
export type HookAcceptHandler<DataT extends object | undefined> = (data: DataT) => void;
|
10
|
-
export type HookCallback<DataT extends object = object, CompletionDataT extends object | undefined = object | undefined> = (data: DataT, accept: HookAcceptHandler<CompletionDataT>, reject: HookRejectHandler) => void;
|
11
|
-
export interface SocketSubscriptions {
|
12
|
-
addHook: <DataT extends object, CompletionDataT extends object | undefined>(apiModule: string, event: string, callback: HookCallback<DataT, CompletionDataT>, subscriberInfo: HookSubscriberInfo) => Promise<SubscriptionRemoveHandler>;
|
13
|
-
addListener: <DataT extends object | void, EntityIdT extends API.EntityId | undefined = undefined>(apiModule: string, event: string, callback: SubscriptionCallback<DataT, EntityIdT>, entityId?: API.EntityId) => Promise<SubscriptionRemoveHandler>;
|
14
|
-
addViewUpdateListener: <DataT extends object | void, EntityIdT extends API.EntityId | undefined = undefined>(viewName: string, callback: SubscriptionCallback<DataT, EntityIdT>, entityId?: API.EntityId) => () => void;
|
15
|
-
hasListeners: () => boolean;
|
16
|
-
getPendingSubscriptionCount: () => number;
|
17
|
-
}
|
18
|
-
export type AddHook = SocketSubscriptions['addHook'];
|
19
|
-
export type AddListener = SocketSubscriptions['addListener'];
|
20
|
-
export type AddViewUpdateListener = SocketSubscriptions['addViewUpdateListener'];
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/types/subscriptions.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
DELETED
package/dist/utils.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.eventIgnored = void 0;
|
4
|
-
const eventIgnored = (path, ignoredEvents) => {
|
5
|
-
if (!ignoredEvents) {
|
6
|
-
return false;
|
7
|
-
}
|
8
|
-
// Array?
|
9
|
-
if (Array.isArray(ignoredEvents)) {
|
10
|
-
return ignoredEvents.indexOf(path) !== -1;
|
11
|
-
}
|
12
|
-
// Regexp
|
13
|
-
return ignoredEvents.test(path);
|
14
|
-
};
|
15
|
-
exports.eventIgnored = eventIgnored;
|
16
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAGO,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,aAAqC,EAAE,EAAE;IAClF,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,KAAK,CAAC;KACd;IAED,SAAS;IACT,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QAChC,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KAC3C;IAED,SAAS;IACT,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC;AAZW,QAAA,YAAY,gBAYvB"}
|
package/src/tests/helpers.ts
DELETED
@@ -1,195 +0,0 @@
|
|
1
|
-
import { Socket } from '../NodeSocket.js';
|
2
|
-
import { Client, Server, WebSocket } from 'mock-socket';
|
3
|
-
import { jest } from '@jest/globals';
|
4
|
-
|
5
|
-
import { OutgoingRequest, RequestSuccessResponse, RequestErrorResponse } from '../types/api_internal.js';
|
6
|
-
import * as Options from '../types/options.js';
|
7
|
-
import ApiConstants from '../ApiConstants.js';
|
8
|
-
import { EventEmitter } from 'events';
|
9
|
-
|
10
|
-
import waitForExpectOriginal from 'wait-for-expect';
|
11
|
-
|
12
|
-
const EXCEPT_TIMEOUT = 1000;
|
13
|
-
//@ts-ignore
|
14
|
-
export const waitForExpect = (func: () => void | Promise<void>) => waitForExpectOriginal.default(func, EXCEPT_TIMEOUT);
|
15
|
-
|
16
|
-
const VERBOSE = false;
|
17
|
-
|
18
|
-
const getMockConsole = () => ({
|
19
|
-
log: jest.fn((a1: any, a2: any, a3: any, a4: any) => {
|
20
|
-
if (VERBOSE) {
|
21
|
-
console.log(a1, a2, a3, a4);
|
22
|
-
}
|
23
|
-
}),
|
24
|
-
info: jest.fn((a1: any, a2: any, a3: any, a4: any) => {
|
25
|
-
if (VERBOSE) {
|
26
|
-
console.info(a1, a2, a3, a4);
|
27
|
-
}
|
28
|
-
}),
|
29
|
-
warn: jest.fn((a1: any, a2: any, a3: any, a4: any) => {
|
30
|
-
console.warn(a1, a2, a3, a4);
|
31
|
-
}),
|
32
|
-
error: jest.fn((a1: any, a2: any, a3: any, a4: any) => {
|
33
|
-
console.error(a1, a2, a3, a4);
|
34
|
-
}),
|
35
|
-
});
|
36
|
-
|
37
|
-
const CONNECT_PARAMS = {
|
38
|
-
username: 'test',
|
39
|
-
password: 'test',
|
40
|
-
url: 'ws://localhost:7171/api/v1/',
|
41
|
-
};
|
42
|
-
|
43
|
-
const getDefaultSocketOptions = (mockConsole: Options.LogOutput): Options.APISocketOptions => ({
|
44
|
-
...CONNECT_PARAMS,
|
45
|
-
logOutput: mockConsole,
|
46
|
-
logLevel: VERBOSE ? 'verbose' : 'warn',
|
47
|
-
});
|
48
|
-
|
49
|
-
const AUTH_RESPONSE = {
|
50
|
-
auth_token: 'b823187f-4aab-4b71-9764-e63e88401a26',
|
51
|
-
refresh_token: '5124faasf-4aab-4b71-9764-e63e88401a26',
|
52
|
-
user: {
|
53
|
-
permissions: [ 'admin' ],
|
54
|
-
username: 'test',
|
55
|
-
active_sessions: 1,
|
56
|
-
last_login: 0,
|
57
|
-
},
|
58
|
-
system: {
|
59
|
-
cid: 'AHLUODI2YZ2U7FDWMHFNJU65ERGKUN4MH7GW5LY',
|
60
|
-
hostname: 'ubuntu-htpc',
|
61
|
-
network_type: 'private',
|
62
|
-
path_separator: '/',
|
63
|
-
platform: 'other',
|
64
|
-
language: 'fi',
|
65
|
-
},
|
66
|
-
wizard_pending: false,
|
67
|
-
};
|
68
|
-
|
69
|
-
export type MockSocketOptions = Omit<Options.APISocketOptions, 'username' | 'password' | 'url'> & {
|
70
|
-
username?: string;
|
71
|
-
password?: string;
|
72
|
-
url?: string;
|
73
|
-
};
|
74
|
-
|
75
|
-
const getSocket = (options: MockSocketOptions = {}) => {
|
76
|
-
const mockConsole = getMockConsole();
|
77
|
-
const socket = Socket(
|
78
|
-
{
|
79
|
-
...getDefaultSocketOptions(mockConsole),
|
80
|
-
...options,
|
81
|
-
},
|
82
|
-
WebSocket as any
|
83
|
-
);
|
84
|
-
|
85
|
-
return { socket, mockConsole };
|
86
|
-
};
|
87
|
-
|
88
|
-
|
89
|
-
type Callback = (requestData: object) => void;
|
90
|
-
|
91
|
-
const getConnectedSocket = async (
|
92
|
-
server: ReturnType<typeof getMockServer>,
|
93
|
-
options?: MockSocketOptions,
|
94
|
-
authCallback?: Callback
|
95
|
-
) => {
|
96
|
-
server.addDataHandler('POST', ApiConstants.LOGIN_URL, AUTH_RESPONSE, authCallback);
|
97
|
-
|
98
|
-
const { socket, mockConsole } = getSocket(options);
|
99
|
-
await socket.connect();
|
100
|
-
|
101
|
-
return { socket, mockConsole };
|
102
|
-
};
|
103
|
-
|
104
|
-
const toEmitId = (path: string, method: string) => {
|
105
|
-
return `${path}_${method}`;
|
106
|
-
};
|
107
|
-
|
108
|
-
const getMockServer = () => {
|
109
|
-
const mockServer = new Server(CONNECT_PARAMS.url);
|
110
|
-
let socket: Client;
|
111
|
-
const emitter = new EventEmitter();
|
112
|
-
|
113
|
-
const addServerHandler = <DataT extends object | undefined>(
|
114
|
-
method: string,
|
115
|
-
path: string,
|
116
|
-
responseData: Omit<RequestSuccessResponse<DataT>, 'callback_id'> | Omit<RequestErrorResponse, 'callback_id'>,
|
117
|
-
subscriptionCallback?: Callback
|
118
|
-
) => {
|
119
|
-
emitter.addListener(
|
120
|
-
toEmitId(path, method),
|
121
|
-
(request: OutgoingRequest, s: WebSocket) => {
|
122
|
-
if (subscriptionCallback) {
|
123
|
-
subscriptionCallback(request);
|
124
|
-
}
|
125
|
-
|
126
|
-
const response: RequestSuccessResponse | RequestErrorResponse = {
|
127
|
-
callback_id: request.callback_id,
|
128
|
-
...responseData,
|
129
|
-
};
|
130
|
-
|
131
|
-
s.send(JSON.stringify(response));
|
132
|
-
}
|
133
|
-
);
|
134
|
-
};
|
135
|
-
|
136
|
-
mockServer.on('connection', s => {
|
137
|
-
socket = s;
|
138
|
-
|
139
|
-
socket.on('message', (messageObj) => {
|
140
|
-
const request: OutgoingRequest = JSON.parse(messageObj as string);
|
141
|
-
emitter.emit(toEmitId(request.path, request.method), request, s);
|
142
|
-
});
|
143
|
-
});
|
144
|
-
|
145
|
-
mockServer.on('close', () => {
|
146
|
-
emitter.removeAllListeners();
|
147
|
-
});
|
148
|
-
|
149
|
-
return {
|
150
|
-
addDataHandler: <DataT extends object | undefined>(
|
151
|
-
method: string,
|
152
|
-
path: string,
|
153
|
-
data?: DataT,
|
154
|
-
subscriptionCallback?: Callback
|
155
|
-
) => {
|
156
|
-
addServerHandler<DataT>(
|
157
|
-
method,
|
158
|
-
path, {
|
159
|
-
data,
|
160
|
-
code: 200,
|
161
|
-
},
|
162
|
-
subscriptionCallback
|
163
|
-
);
|
164
|
-
},
|
165
|
-
addErrorHandler: (
|
166
|
-
method: string,
|
167
|
-
path: string,
|
168
|
-
errorStr: string | null,
|
169
|
-
errorCode: number,
|
170
|
-
subscriptionCallback?: Callback
|
171
|
-
) => {
|
172
|
-
addServerHandler(
|
173
|
-
method,
|
174
|
-
path,
|
175
|
-
{
|
176
|
-
error: !errorStr ? null as any : {
|
177
|
-
message: errorStr,
|
178
|
-
},
|
179
|
-
code: errorCode,
|
180
|
-
},
|
181
|
-
subscriptionCallback
|
182
|
-
);
|
183
|
-
},
|
184
|
-
stop: () => {
|
185
|
-
mockServer.stop(() => {
|
186
|
-
// ...
|
187
|
-
});
|
188
|
-
},
|
189
|
-
send: (data: object) => {
|
190
|
-
socket.send(JSON.stringify(data));
|
191
|
-
},
|
192
|
-
};
|
193
|
-
};
|
194
|
-
|
195
|
-
export { getMockServer, getSocket, getConnectedSocket, CONNECT_PARAMS, AUTH_RESPONSE };
|