airdcpp-apisocket 2.4.4 → 2.5.0-beta.1
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/GUIDE.md +7 -7
- package/README.md +3 -2
- package/babel.config.cjs +6 -0
- package/dist/ApiConstants.d.ts +6 -6
- package/dist/ApiConstants.js +7 -7
- package/dist/NodeSocket.d.ts +4 -4
- package/dist/NodeSocket.js +24 -20
- package/dist/NodeSocket.js.map +1 -1
- package/dist/Promise.d.ts +8 -8
- package/dist/Promise.js +26 -26
- package/dist/Promise.js.map +1 -1
- package/dist/PublicHelpers.d.ts +2 -2
- package/dist/PublicHelpers.js +94 -192
- package/dist/PublicHelpers.js.map +1 -1
- package/dist/SocketBase.d.ts +4 -4
- package/dist/SocketBase.js +351 -359
- package/dist/SocketBase.js.map +1 -1
- package/dist/SocketLogger.d.ts +9 -9
- package/dist/SocketLogger.js +74 -84
- package/dist/SocketLogger.js.map +1 -1
- package/dist/SocketRequestHandler.d.ts +14 -14
- package/dist/SocketRequestHandler.js +168 -176
- package/dist/SocketRequestHandler.js.map +1 -1
- package/dist/SocketSubscriptionHandler.d.ts +11 -11
- package/dist/SocketSubscriptionHandler.js +161 -173
- package/dist/SocketSubscriptionHandler.js.map +1 -1
- package/dist/types/api.d.ts +30 -30
- package/dist/types/api.js +3 -3
- package/dist/types/api_internal.d.ts +24 -24
- package/dist/types/api_internal.js +2 -2
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.js +23 -19
- package/dist/types/index.js.map +1 -1
- package/dist/types/logger.d.ts +6 -6
- package/dist/types/logger.js +2 -2
- package/dist/types/options.d.ts +31 -31
- package/dist/types/options.js +3 -3
- package/dist/types/public_helpers.d.ts +19 -14
- package/dist/types/public_helpers.js +2 -2
- package/dist/types/public_helpers_internal.d.ts +27 -25
- package/dist/types/public_helpers_internal.js +2 -2
- package/dist/types/requests.d.ts +14 -14
- package/dist/types/requests.js +2 -2
- package/dist/types/socket.d.ts +23 -23
- package/dist/types/socket.js +2 -3
- package/dist/types/socket.js.map +1 -1
- package/dist/types/subscriptions.d.ts +20 -20
- package/dist/types/subscriptions.js +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +15 -15
- package/dist/utils.js.map +1 -1
- package/dist-es/ApiConstants.d.ts +6 -6
- package/dist-es/ApiConstants.js +5 -5
- package/dist-es/NodeSocket.d.ts +4 -4
- package/dist-es/NodeSocket.js +4 -4
- package/dist-es/NodeSocket.js.map +1 -1
- package/dist-es/Promise.d.ts +8 -8
- package/dist-es/Promise.js +24 -24
- package/dist-es/Promise.js.map +1 -1
- package/dist-es/PublicHelpers.d.ts +2 -2
- package/dist-es/PublicHelpers.js +90 -188
- package/dist-es/PublicHelpers.js.map +1 -1
- package/dist-es/SocketBase.d.ts +4 -4
- package/dist-es/SocketBase.js +346 -354
- package/dist-es/SocketBase.js.map +1 -1
- package/dist-es/SocketLogger.d.ts +9 -9
- package/dist-es/SocketLogger.js +68 -78
- package/dist-es/SocketLogger.js.map +1 -1
- package/dist-es/SocketRequestHandler.d.ts +14 -14
- package/dist-es/SocketRequestHandler.js +163 -171
- package/dist-es/SocketRequestHandler.js.map +1 -1
- package/dist-es/SocketSubscriptionHandler.d.ts +11 -11
- package/dist-es/SocketSubscriptionHandler.js +156 -168
- package/dist-es/SocketSubscriptionHandler.js.map +1 -1
- package/dist-es/types/api.d.ts +30 -30
- package/dist-es/types/api.js +2 -2
- package/dist-es/types/api_internal.d.ts +24 -24
- package/dist-es/types/api_internal.js +1 -1
- package/dist-es/types/index.d.ts +7 -7
- package/dist-es/types/index.js +7 -7
- package/dist-es/types/index.js.map +1 -1
- package/dist-es/types/logger.d.ts +6 -6
- package/dist-es/types/logger.js +1 -1
- package/dist-es/types/options.d.ts +31 -31
- package/dist-es/types/options.js +2 -2
- package/dist-es/types/public_helpers.d.ts +19 -14
- package/dist-es/types/public_helpers.js +1 -1
- package/dist-es/types/public_helpers_internal.d.ts +27 -25
- package/dist-es/types/public_helpers_internal.js +1 -1
- package/dist-es/types/requests.d.ts +14 -14
- package/dist-es/types/requests.js +1 -1
- package/dist-es/types/socket.d.ts +23 -23
- package/dist-es/types/socket.js +1 -2
- package/dist-es/types/socket.js.map +1 -1
- package/dist-es/types/subscriptions.d.ts +20 -20
- package/dist-es/types/subscriptions.js +1 -1
- package/dist-es/utils.d.ts +2 -2
- package/dist-es/utils.js +11 -11
- package/dist-es/utils.js.map +1 -1
- package/jest.config.js +15 -3
- package/package.json +15 -13
- package/src/NodeSocket.ts +3 -3
- package/src/PublicHelpers.ts +11 -10
- package/src/SocketBase.ts +9 -9
- package/src/SocketLogger.ts +6 -6
- package/src/SocketRequestHandler.ts +10 -10
- package/src/SocketSubscriptionHandler.ts +10 -10
- package/src/tests/Socket.test.ts +29 -26
- package/src/tests/helpers.ts +14 -8
- package/src/tests/public_helpers.test.ts +7 -6
- package/src/types/api_internal.ts +1 -1
- package/src/types/index.ts +7 -7
- package/src/types/public_helpers.ts +7 -1
- package/src/types/public_helpers_internal.ts +3 -1
- package/src/types/requests.ts +1 -1
- package/src/types/socket.ts +4 -20
- package/src/types/subscriptions.ts +1 -1
- package/src/utils.ts +1 -1
- package/tsconfig.json +5 -10
- package/dist/tests/Socket.test.d.ts +0 -1
- package/dist/tests/Socket.test.js +0 -758
- package/dist/tests/Socket.test.js.map +0 -1
- package/dist/tests/helpers.d.ts +0 -57
- package/dist/tests/helpers.js +0 -178
- package/dist/tests/helpers.js.map +0 -1
- package/dist/tests/public_helpers.test.d.ts +0 -1
- package/dist/tests/public_helpers.test.js +0 -241
- package/dist/tests/public_helpers.test.js.map +0 -1
- package/dist-es/tests/Socket.test.d.ts +0 -1
- package/dist-es/tests/Socket.test.js +0 -734
- package/dist-es/tests/Socket.test.js.map +0 -1
- package/dist-es/tests/helpers.d.ts +0 -57
- package/dist-es/tests/helpers.js +0 -168
- package/dist-es/tests/helpers.js.map +0 -1
- package/dist-es/tests/public_helpers.test.d.ts +0 -1
- package/dist-es/tests/public_helpers.test.js +0 -236
- package/dist-es/tests/public_helpers.test.js.map +0 -1
@@ -1,31 +1,31 @@
|
|
1
|
-
export
|
2
|
-
export interface LogOutput {
|
3
|
-
log: PrintHandler;
|
4
|
-
info: PrintHandler;
|
5
|
-
warn: PrintHandler;
|
6
|
-
error: PrintHandler;
|
7
|
-
}
|
8
|
-
export
|
9
|
-
export interface SocketRequestOptions {
|
10
|
-
ignoredRequestPaths?: IgnoreMatcher;
|
11
|
-
requestTimeout?: number;
|
12
|
-
}
|
13
|
-
export interface SocketSubscriptionOptions {
|
14
|
-
ignoredListenerEvents?: IgnoreMatcher;
|
15
|
-
}
|
16
|
-
export interface RequiredSocketOptions {
|
17
|
-
url: string;
|
18
|
-
username?: string;
|
19
|
-
password?: string;
|
20
|
-
}
|
21
|
-
export interface AdvancedSocketOptions {
|
22
|
-
autoReconnect: boolean;
|
23
|
-
reconnectInterval: number;
|
24
|
-
userSession: boolean;
|
25
|
-
}
|
26
|
-
export interface LoggerOptions {
|
27
|
-
logLevel?: string;
|
28
|
-
logOutput?: LogOutput;
|
29
|
-
}
|
30
|
-
|
31
|
-
export { UserOptions as APISocketOptions };
|
1
|
+
export type PrintHandler = (...optionalParams: any[]) => void;
|
2
|
+
export interface LogOutput {
|
3
|
+
log: PrintHandler;
|
4
|
+
info: PrintHandler;
|
5
|
+
warn: PrintHandler;
|
6
|
+
error: PrintHandler;
|
7
|
+
}
|
8
|
+
export type IgnoreMatcher = string[] | RegExp;
|
9
|
+
export interface SocketRequestOptions {
|
10
|
+
ignoredRequestPaths?: IgnoreMatcher;
|
11
|
+
requestTimeout?: number;
|
12
|
+
}
|
13
|
+
export interface SocketSubscriptionOptions {
|
14
|
+
ignoredListenerEvents?: IgnoreMatcher;
|
15
|
+
}
|
16
|
+
export interface RequiredSocketOptions {
|
17
|
+
url: string;
|
18
|
+
username?: string;
|
19
|
+
password?: string;
|
20
|
+
}
|
21
|
+
export interface AdvancedSocketOptions {
|
22
|
+
autoReconnect: boolean;
|
23
|
+
reconnectInterval: number;
|
24
|
+
userSession: boolean;
|
25
|
+
}
|
26
|
+
export interface LoggerOptions {
|
27
|
+
logLevel?: string;
|
28
|
+
logOutput?: LogOutput;
|
29
|
+
}
|
30
|
+
type UserOptions = RequiredSocketOptions & Partial<AdvancedSocketOptions> & LoggerOptions & SocketSubscriptionOptions & SocketRequestOptions;
|
31
|
+
export { UserOptions as APISocketOptions };
|
package/dist-es/types/options.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
// HELPERS
|
2
|
-
export {};
|
1
|
+
// HELPERS
|
2
|
+
export {};
|
3
3
|
//# sourceMappingURL=options.js.map
|
@@ -1,14 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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,2 +1,2 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
2
2
|
//# sourceMappingURL=public_helpers.js.map
|
@@ -1,25 +1,27 @@
|
|
1
|
-
import { ContextMenuItem } from './public_helpers';
|
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
|
23
|
-
export interface MenuItemListHookAcceptData<IdT, EntityIdT> {
|
24
|
-
menuitems: ResponseMenuItem<IdT, EntityIdT>[];
|
25
|
-
|
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,2 +1,2 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
2
2
|
//# sourceMappingURL=public_helpers_internal.js.map
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import * as API from './api';
|
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
|
-
}
|
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
|
+
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
2
2
|
//# sourceMappingURL=requests.js.map
|
@@ -1,23 +1,23 @@
|
|
1
|
-
import { AuthTokenType, LogoutResponse, AuthenticationResponse } from './api';
|
2
|
-
import { Logger } from './logger';
|
3
|
-
import { SocketRequestMethods } from './requests';
|
4
|
-
import { SocketSubscriptions } from './subscriptions';
|
5
|
-
export
|
6
|
-
export
|
7
|
-
export
|
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
|
-
}
|
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-es/types/socket.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/types/socket.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/types/socket.ts"],"names":[],"mappings":""}
|
@@ -1,20 +1,20 @@
|
|
1
|
-
import * as API from './api';
|
2
|
-
export
|
3
|
-
export
|
4
|
-
export interface HookSubscriberInfo {
|
5
|
-
id: string;
|
6
|
-
name: string;
|
7
|
-
}
|
8
|
-
export
|
9
|
-
export
|
10
|
-
export
|
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
|
19
|
-
export
|
20
|
-
export
|
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,2 +1,2 @@
|
|
1
|
-
export {};
|
1
|
+
export {};
|
2
2
|
//# sourceMappingURL=subscriptions.js.map
|
package/dist-es/utils.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import * as Options from './types/options';
|
2
|
-
export declare const eventIgnored: (path: string, ignoredEvents?: Options.IgnoreMatcher
|
1
|
+
import * as Options from './types/options.js';
|
2
|
+
export declare const eventIgnored: (path: string, ignoredEvents?: Options.IgnoreMatcher) => boolean;
|
package/dist-es/utils.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
export
|
2
|
-
if (!ignoredEvents) {
|
3
|
-
return false;
|
4
|
-
}
|
5
|
-
// Array?
|
6
|
-
if (Array.isArray(ignoredEvents)) {
|
7
|
-
return ignoredEvents.indexOf(path) !== -1;
|
8
|
-
}
|
9
|
-
// Regexp
|
10
|
-
return ignoredEvents.test(path);
|
11
|
-
};
|
1
|
+
export const eventIgnored = (path, ignoredEvents) => {
|
2
|
+
if (!ignoredEvents) {
|
3
|
+
return false;
|
4
|
+
}
|
5
|
+
// Array?
|
6
|
+
if (Array.isArray(ignoredEvents)) {
|
7
|
+
return ignoredEvents.indexOf(path) !== -1;
|
8
|
+
}
|
9
|
+
// Regexp
|
10
|
+
return ignoredEvents.test(path);
|
11
|
+
};
|
12
12
|
//# sourceMappingURL=utils.js.map
|
package/dist-es/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,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"}
|
package/jest.config.js
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
// import type { JestConfigWithTsJest } from 'ts-jest';
|
2
|
+
|
3
|
+
const jestConfig = {
|
2
4
|
preset: 'ts-jest',
|
3
5
|
testEnvironment: 'node',
|
4
6
|
coverageDirectory: './coverage/',
|
@@ -10,5 +12,15 @@ module.exports = {
|
|
10
12
|
collectCoverage: true,
|
11
13
|
roots: [
|
12
14
|
'<rootDir>/src/'
|
13
|
-
]
|
14
|
-
|
15
|
+
],
|
16
|
+
moduleNameMapper: {
|
17
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
18
|
+
'#(.*)': '<rootDir>/node_modules/$1',
|
19
|
+
},
|
20
|
+
transform: {
|
21
|
+
'^.+\\.jsx?$': 'babel-jest',
|
22
|
+
'^.+\\.tsx?$': 'ts-jest'
|
23
|
+
},
|
24
|
+
};
|
25
|
+
|
26
|
+
export default jestConfig;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "airdcpp-apisocket",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.5.0-beta.1",
|
4
4
|
"description": "Javascript connector for AirDC++ Web API",
|
5
5
|
"license": "MIT",
|
6
6
|
"authors": [
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"scripts": {
|
23
23
|
"build": "npm run build-commonjs && npm run build-es",
|
24
24
|
"build-commonjs": "rimraf dist && tsc -d --outDir dist --module CommonJS",
|
25
|
-
"build-es": "rimraf dist-es && tsc -d --outDir dist-es --module
|
25
|
+
"build-es": "rimraf dist-es && tsc -d --outDir dist-es --module es2020",
|
26
26
|
"clean": "rimraf dist/*",
|
27
27
|
"lint": "tslint --project tsconfig.json",
|
28
28
|
"lint-fix": "tslint --project tsconfig.json --fix",
|
@@ -37,25 +37,27 @@
|
|
37
37
|
"events": "^3.3.0",
|
38
38
|
"invariant": "^2.2.4",
|
39
39
|
"is-in-browser": "^2.0.0",
|
40
|
-
"promise": "^8.
|
40
|
+
"promise": "^8.3.0"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
|
+
"@babel/preset-env": "^7.20.2",
|
43
44
|
"@types/invariant": "^2.2.35",
|
44
|
-
"@types/jest": "^
|
45
|
-
"@types/node": "^
|
46
|
-
"jest": "^
|
47
|
-
"jest-cli": "^
|
45
|
+
"@types/jest": "^28.1.1",
|
46
|
+
"@types/node": "^18.11.5",
|
47
|
+
"jest": "^28.1.3",
|
48
|
+
"jest-cli": "^28.1.3",
|
48
49
|
"jest-environment-node-debug": "^2.0.0",
|
49
|
-
"mock-socket": "^9.
|
50
|
-
"mockdate": "^3.0.5",
|
50
|
+
"mock-socket": "^9.1.5",
|
51
51
|
"pre-commit": "^1.2.2",
|
52
|
-
"rimraf": "^
|
53
|
-
"ts-jest": "^
|
52
|
+
"rimraf": "^4.1.2",
|
53
|
+
"ts-jest": "^28.0.8",
|
54
|
+
"ts-node": "^10.9.1",
|
54
55
|
"tslint": "^6.1.3",
|
55
|
-
"typescript": "^
|
56
|
+
"typescript": "^5.0.2",
|
56
57
|
"wait-for-expect": "^3.0.2",
|
57
58
|
"websocket": "^1.0.34"
|
58
59
|
},
|
59
60
|
"main": "./dist/NodeSocket.js",
|
60
|
-
"module": "./dist-es/NodeSocket.js"
|
61
|
+
"module": "./dist-es/NodeSocket.js",
|
62
|
+
"type": "module"
|
61
63
|
}
|
package/src/NodeSocket.ts
CHANGED
package/src/PublicHelpers.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { APISocket, ContextMenuItem, EntityId, ContextMenu } from './types/index.js';
|
2
2
|
import {
|
3
3
|
SelectedMenuItemListenerData, MenuItemListHookData,
|
4
4
|
MenuItemListHookAcceptData, ResponseMenuItemCallbackFields
|
5
|
-
} from './types/public_helpers_internal';
|
5
|
+
} from './types/public_helpers_internal.js';
|
6
6
|
|
7
7
|
|
8
8
|
const checkAccess = <IdT, EntityIdT>(menuItem: ContextMenuItem<IdT, EntityIdT>, permissions: string[]): boolean => {
|
@@ -71,15 +71,15 @@ const parseCallbackData = async <IdT, EntityIdT extends EntityId | undefined = u
|
|
71
71
|
|
72
72
|
export const addContextMenuItems = async <IdT, EntityIdT extends EntityId | undefined = undefined>(
|
73
73
|
socket: APISocket,
|
74
|
-
menuItems: ContextMenuItem<IdT, EntityIdT>[],
|
75
|
-
|
76
|
-
|
74
|
+
menuItems: ContextMenuItem<IdT, EntityIdT>[],
|
75
|
+
menuTypeId: string,
|
76
|
+
menu: ContextMenu
|
77
77
|
) => {
|
78
78
|
const removeListener = await socket.addListener<SelectedMenuItemListenerData<IdT, EntityIdT>, EntityIdT>(
|
79
79
|
'menus',
|
80
|
-
`${
|
80
|
+
`${menuTypeId}_menuitem_selected`,
|
81
81
|
async (data) => {
|
82
|
-
if (data.hook_id ===
|
82
|
+
if (data.hook_id === menu.id) {
|
83
83
|
const menuItem = menuItems.find(i => data.menuitem_id === i.id);
|
84
84
|
if (!!menuItem) {
|
85
85
|
const isValid = await validateItem(menuItem, data);
|
@@ -97,7 +97,7 @@ export const addContextMenuItems = async <IdT, EntityIdT extends EntityId | unde
|
|
97
97
|
MenuItemListHookAcceptData<IdT, EntityIdT> | undefined
|
98
98
|
>(
|
99
99
|
'menus',
|
100
|
-
`${
|
100
|
+
`${menuTypeId}_list_menuitems`,
|
101
101
|
async (data, accept, reject) => {
|
102
102
|
const validItems = [];
|
103
103
|
for (const item of menuItems) {
|
@@ -118,10 +118,11 @@ export const addContextMenuItems = async <IdT, EntityIdT extends EntityId | unde
|
|
118
118
|
}
|
119
119
|
|
120
120
|
accept({
|
121
|
-
menuitems: validItems
|
121
|
+
menuitems: validItems,
|
122
|
+
icon: menu.icon,
|
122
123
|
});
|
123
124
|
},
|
124
|
-
|
125
|
+
menu
|
125
126
|
);
|
126
127
|
|
127
128
|
return () => {
|
package/src/SocketBase.ts
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
import ApiConstants from './ApiConstants';
|
1
|
+
import ApiConstants from './ApiConstants.js';
|
2
2
|
|
3
|
-
import SocketLogger from './SocketLogger';
|
4
|
-
import SocketSubscriptionHandler from './SocketSubscriptionHandler';
|
5
|
-
import SocketRequestHandler from './SocketRequestHandler';
|
3
|
+
import SocketLogger from './SocketLogger.js';
|
4
|
+
import SocketSubscriptionHandler from './SocketSubscriptionHandler.js';
|
5
|
+
import SocketRequestHandler from './SocketRequestHandler.js';
|
6
6
|
|
7
7
|
import invariant from 'invariant';
|
8
|
-
import Promise from './Promise';
|
8
|
+
import Promise from './Promise.js';
|
9
9
|
|
10
|
-
import * as API from './types/api';
|
11
|
-
import * as Options from './types/options';
|
12
|
-
import * as Socket from './types/socket';
|
13
|
-
import * as Requests from './types/requests';
|
10
|
+
import * as API from './types/api.js';
|
11
|
+
import * as Options from './types/options.js';
|
12
|
+
import * as Socket from './types/socket.js';
|
13
|
+
import * as Requests from './types/requests.js';
|
14
14
|
|
15
15
|
|
16
16
|
// INTERNAL TYPES
|
package/src/SocketLogger.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import chalk from 'chalk';
|
2
|
-
|
2
|
+
// @ts-ignore
|
3
|
+
import { isBrowser, isJsDom } from 'is-in-browser';
|
3
4
|
import invariant from 'invariant';
|
4
5
|
|
5
|
-
import * as Options from './types/options';
|
6
|
-
import { Logger } from './types/logger';
|
6
|
+
import * as Options from './types/options.js';
|
7
|
+
import { Logger } from './types/logger.js';
|
7
8
|
|
8
9
|
|
9
10
|
export const LOG_NONE = 'none';
|
@@ -23,11 +24,10 @@ const Severities = {
|
|
23
24
|
|
24
25
|
// Should we format the line with timestamp and coloring or let the logger implementation to handle it?
|
25
26
|
// Do this when running in terminal (node.js/tests in browser env)
|
26
|
-
const shouldFormatLine =
|
27
|
-
(!!global.process && !!global.process.env && global.process.env.NODE_ENV === 'test');
|
27
|
+
const shouldFormatLine = isJsDom || !isBrowser;
|
28
28
|
|
29
29
|
const Logger = ({ logLevel: logSetting = LOG_VERBOSE, logOutput = console }: Options.LoggerOptions) => {
|
30
|
-
const logLevel = Severities[logSetting];
|
30
|
+
const logLevel = Severities[logSetting as keyof typeof Severities];
|
31
31
|
|
32
32
|
invariant(
|
33
33
|
// @ts-ignore: This condition will always return true since the function is always defined
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import chalk from 'chalk';
|
2
2
|
import invariant from 'invariant';
|
3
|
-
import Promise, { PendingResult } from './Promise';
|
3
|
+
import Promise, { PendingResult } from './Promise.js';
|
4
4
|
|
5
|
-
import { eventIgnored } from './utils';
|
5
|
+
import { eventIgnored } from './utils.js';
|
6
6
|
|
7
|
-
import * as API from './types/api';
|
8
|
-
import * as APIInternal from './types/api_internal';
|
9
|
-
import * as Options from './types/options';
|
10
|
-
import * as Socket from './types/socket';
|
11
|
-
import { Logger } from './types/logger';
|
12
|
-
import { SocketRequestMethods, ErrorResponse } from './types/requests';
|
7
|
+
import * as API from './types/api.js';
|
8
|
+
import * as APIInternal from './types/api_internal.js';
|
9
|
+
import * as Options from './types/options.js';
|
10
|
+
import * as Socket from './types/socket.js';
|
11
|
+
import { Logger } from './types/logger.js';
|
12
|
+
import { SocketRequestMethods, ErrorResponse } from './types/requests.js';
|
13
13
|
|
14
14
|
|
15
15
|
interface Callback {
|
@@ -25,7 +25,7 @@ const SocketRequestHandler = (
|
|
25
25
|
{ requestTimeout = 30, ignoredRequestPaths }: Options.SocketRequestOptions
|
26
26
|
) => {
|
27
27
|
|
28
|
-
let callbacks:
|
28
|
+
let callbacks: Record<string, Callback> = {};
|
29
29
|
let currentCallbackId = 0;
|
30
30
|
|
31
31
|
let timeoutReportInterval: any;
|
@@ -85,7 +85,7 @@ const SocketRequestHandler = (
|
|
85
85
|
// Callback
|
86
86
|
const resolver = Promise.pending();
|
87
87
|
|
88
|
-
callbacks[callbackId] = {
|
88
|
+
callbacks[callbackId.toString()] = {
|
89
89
|
time: Date.now(),
|
90
90
|
resolver,
|
91
91
|
ignored,
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import invariant from 'invariant';
|
2
2
|
import { EventEmitter } from 'events';
|
3
3
|
|
4
|
-
import { eventIgnored } from './utils';
|
5
|
-
import Promise, { PendingResult } from './Promise';
|
6
|
-
|
7
|
-
import { Logger } from './types/logger';
|
8
|
-
import * as API from './types/api';
|
9
|
-
import * as APIInternal from './types/api_internal';
|
10
|
-
import * as Options from './types/options';
|
11
|
-
import * as Requests from './types/requests';
|
12
|
-
import * as Socket from './types/socket';
|
13
|
-
import * as Subscriptions from './types/subscriptions';
|
4
|
+
import { eventIgnored } from './utils.js';
|
5
|
+
import Promise, { PendingResult } from './Promise.js';
|
6
|
+
|
7
|
+
import { Logger } from './types/logger.js';
|
8
|
+
import * as API from './types/api.js';
|
9
|
+
import * as APIInternal from './types/api_internal.js';
|
10
|
+
import * as Options from './types/options.js';
|
11
|
+
import * as Requests from './types/requests.js';
|
12
|
+
import * as Socket from './types/socket.js';
|
13
|
+
import * as Subscriptions from './types/subscriptions.js';
|
14
14
|
|
15
15
|
|
16
16
|
interface PendingSubscription {
|