@messenger-box/platform-server 10.0.3-alpha.196 → 10.0.3-alpha.201
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/lib/channels/ack-reactions.d.ts +46 -0
- package/lib/channels/ack-reactions.js +48 -0
- package/lib/channels/ack-reactions.js.map +1 -0
- package/lib/channels/allowlist-match.d.ts +38 -0
- package/lib/channels/allowlist-match.js +67 -0
- package/lib/channels/allowlist-match.js.map +1 -0
- package/lib/channels/channel-config.d.ts +46 -0
- package/lib/channels/channel-config.js +63 -0
- package/lib/channels/channel-config.js.map +1 -0
- package/lib/channels/command-gating.d.ts +47 -0
- package/lib/channels/command-gating.js +52 -0
- package/lib/channels/command-gating.js.map +1 -0
- package/lib/channels/conversation-label.d.ts +23 -0
- package/lib/channels/conversation-label.js +43 -0
- package/lib/channels/conversation-label.js.map +1 -0
- package/lib/channels/index.d.ts +18 -0
- package/lib/channels/mention-gating.d.ts +50 -0
- package/lib/channels/mention-gating.js +72 -0
- package/lib/channels/mention-gating.js.map +1 -0
- package/lib/channels/registry.d.ts +23 -0
- package/lib/channels/registry.js +282 -0
- package/lib/channels/registry.js.map +1 -0
- package/lib/channels/sender-identity.d.ts +11 -0
- package/lib/channels/sender-identity.js +48 -0
- package/lib/channels/sender-identity.js.map +1 -0
- package/lib/channels/session.d.ts +63 -0
- package/lib/channels/session.js +29 -0
- package/lib/channels/session.js.map +1 -0
- package/lib/channels/types.d.ts +147 -0
- package/lib/channels/types.js +28 -0
- package/lib/channels/types.js.map +1 -0
- package/lib/channels/typing.d.ts +62 -0
- package/lib/channels/typing.js +37 -0
- package/lib/channels/typing.js.map +1 -0
- package/lib/channels/typing.test.d.ts +1 -0
- package/lib/constants/default-channel-props.d.ts +11 -0
- package/lib/constants/default-channel-props.js +32 -0
- package/lib/constants/default-channel-props.js.map +1 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/containers/containers.js +5 -1
- package/lib/containers/containers.js.map +1 -1
- package/lib/containers/context-services-from-container.js +3 -3
- package/lib/containers/context-services-from-container.js.map +1 -1
- package/lib/gateway/channel-registry.d.ts +10 -0
- package/lib/gateway/gateway-service.d.ts +23 -0
- package/lib/gateway/index.d.ts +4 -0
- package/lib/gateway/message-router.d.ts +20 -0
- package/lib/gateway/types.d.ts +270 -0
- package/lib/graphql/resolvers/channel-capabilities.d.ts +13 -0
- package/lib/graphql/resolvers/channel-capabilities.js +179 -0
- package/lib/graphql/resolvers/channel-capabilities.js.map +1 -0
- package/lib/graphql/resolvers/channel.js +15 -6
- package/lib/graphql/resolvers/channel.js.map +1 -1
- package/lib/graphql/resolvers/chat-configuration.d.ts +59 -0
- package/lib/graphql/resolvers/chat-configuration.js +89 -0
- package/lib/graphql/resolvers/chat-configuration.js.map +1 -0
- package/lib/graphql/resolvers/gateway.d.ts +18 -0
- package/lib/graphql/resolvers/index.d.ts +52 -1
- package/lib/graphql/resolvers/index.js +1 -1
- package/lib/graphql/resolvers/index.js.map +1 -1
- package/lib/graphql/resolvers/post.js +5 -2
- package/lib/graphql/resolvers/post.js.map +1 -1
- package/lib/graphql/resolvers/streaming.d.ts +20 -0
- package/lib/graphql/resolvers/streaming.js +147 -0
- package/lib/graphql/resolvers/streaming.js.map +1 -0
- package/lib/graphql/schema/channel-capabilities.graphql +492 -0
- package/lib/graphql/schema/channel-capabilities.graphql.js +1 -0
- package/lib/graphql/schema/channel-capabilities.graphql.js.map +1 -0
- package/lib/graphql/schema/channel.graphql +14 -2
- package/lib/graphql/schema/channel.graphql.js +1 -1
- package/lib/graphql/schema/chat-configuration.graphql +77 -0
- package/lib/graphql/schema/chat-configuration.graphql.js +1 -0
- package/lib/graphql/schema/chat-configuration.graphql.js.map +1 -0
- package/lib/graphql/schema/gateway.graphql +363 -0
- package/lib/graphql/schema/index.js +2 -2
- package/lib/graphql/schema/index.js.map +1 -1
- package/lib/graphql/schema/preferences.graphql +190 -3
- package/lib/graphql/schema/preferences.graphql.js +1 -1
- package/lib/graphql/schema/streaming.graphql +224 -0
- package/lib/graphql/schema/streaming.graphql.js +1 -0
- package/lib/graphql/schema/streaming.graphql.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/migrations/dbMigrations/AddChannelConfigurationsMigration.d.ts +42 -0
- package/lib/migrations/dbMigrations/AddChannelConfigurationsMigration.js +60 -0
- package/lib/migrations/dbMigrations/AddChannelConfigurationsMigration.js.map +1 -0
- package/lib/migrations/dbMigrations/AddChatConfigurationsMigration.d.ts +21 -0
- package/lib/migrations/dbMigrations/AddChatConfigurationsMigration.js +30 -0
- package/lib/migrations/dbMigrations/AddChatConfigurationsMigration.js.map +1 -0
- package/lib/migrations/dbMigrations/AddPostsConfigurationsMigration.js +1 -1
- package/lib/migrations/dbMigrations/index.d.ts +2 -0
- package/lib/preferences/settings/channel-settings.d.ts +39 -0
- package/lib/preferences/settings/channel-settings.js +180 -0
- package/lib/preferences/settings/channel-settings.js.map +1 -0
- package/lib/preferences/settings/chat-settings.d.ts +248 -0
- package/lib/preferences/settings/chat-settings.js +1152 -0
- package/lib/preferences/settings/chat-settings.js.map +1 -0
- package/lib/preferences/settings/index.d.ts +3 -0
- package/lib/preferences/settings/messenger-channels-contribution.d.ts +39 -0
- package/lib/preferences/settings/messenger-channels-contribution.js +355 -0
- package/lib/preferences/settings/messenger-channels-contribution.js.map +1 -0
- package/lib/preferences/settings/post-settings.d.ts +14 -0
- package/lib/preferences/settings/post-settings.js +59 -1
- package/lib/preferences/settings/post-settings.js.map +1 -1
- package/lib/services/channel-service.js +46 -5
- package/lib/services/channel-service.js.map +1 -1
- package/lib/services/post-service.d.ts +23 -0
- package/lib/services/post-service.js +77 -1
- package/lib/services/post-service.js.map +1 -1
- package/lib/store/models/channel.js +21 -2
- package/lib/store/models/channel.js.map +1 -1
- package/lib/store/models/post.js.map +1 -1
- package/lib/streaming/block-chunker.d.ts +40 -0
- package/lib/streaming/block-chunker.js +103 -0
- package/lib/streaming/block-chunker.js.map +1 -0
- package/lib/streaming/block-chunker.test.d.ts +1 -0
- package/lib/streaming/index.d.ts +4 -0
- package/lib/streaming/stream-service.d.ts +71 -0
- package/lib/streaming/stream-service.js +325 -0
- package/lib/streaming/stream-service.js.map +1 -0
- package/lib/streaming/stream-service.test.d.ts +16 -0
- package/lib/streaming/streaming-post.integration.test.d.ts +10 -0
- package/lib/streaming/types.d.ts +33 -0
- package/lib/streaming/types.js +37 -0
- package/lib/streaming/types.js.map +1 -0
- package/lib/templates/constants/CONTRIBUTION_POINTS.ts.template +78 -0
- package/lib/templates/constants/SERVER_TYPES.ts.template +1 -0
- package/lib/templates/services/MessengerStreamService.ts.template +131 -0
- package/lib/templates/services/PostService.ts.template +12 -0
- package/package.json +4 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typing indicator system - inspired by openclaw's typing callbacks,
|
|
3
|
+
* adapted to messenger-box's Props architecture with event-driven patterns.
|
|
4
|
+
*
|
|
5
|
+
* Provides typed callbacks and state management for typing indicators
|
|
6
|
+
* across channels, threads, and direct messages.
|
|
7
|
+
*/
|
|
8
|
+
export interface ITypingProps {
|
|
9
|
+
/** Whether to show typing indicators from other users */
|
|
10
|
+
showTypingIndicators: boolean;
|
|
11
|
+
/** Whether to broadcast own typing status */
|
|
12
|
+
broadcastTyping: boolean;
|
|
13
|
+
/** Debounce interval in milliseconds for typing events */
|
|
14
|
+
typingDebounceMs: number;
|
|
15
|
+
/** How long a typing indicator stays visible after last event (ms) */
|
|
16
|
+
typingTimeoutMs: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEFAULT_TYPING_PROPS: ITypingProps;
|
|
19
|
+
export interface ITypingUser {
|
|
20
|
+
userId: string;
|
|
21
|
+
username?: string;
|
|
22
|
+
displayName?: string;
|
|
23
|
+
channelId: string;
|
|
24
|
+
threadId?: string;
|
|
25
|
+
startedAt: Date;
|
|
26
|
+
}
|
|
27
|
+
export interface ITypingState {
|
|
28
|
+
/** Users currently typing in a channel */
|
|
29
|
+
typingUsers: ITypingUser[];
|
|
30
|
+
/** Last typing event timestamp */
|
|
31
|
+
lastEvent?: Date;
|
|
32
|
+
}
|
|
33
|
+
export interface ITypingCallbacks {
|
|
34
|
+
/** Called when a reply starts (user begins typing) */
|
|
35
|
+
onReplyStart: () => Promise<void>;
|
|
36
|
+
/** Called when the user goes idle (stops typing) */
|
|
37
|
+
onIdle?: () => void;
|
|
38
|
+
/** Called when the typing controller is cleaned up */
|
|
39
|
+
onCleanup?: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates typing callbacks with error handling (mirrors openclaw's createTypingCallbacks)
|
|
43
|
+
*/
|
|
44
|
+
export declare function createTypingCallbacks(params: {
|
|
45
|
+
start: () => Promise<void>;
|
|
46
|
+
stop?: () => Promise<void>;
|
|
47
|
+
onStartError: (err: unknown) => void;
|
|
48
|
+
onStopError?: (err: unknown) => void;
|
|
49
|
+
}): ITypingCallbacks;
|
|
50
|
+
export interface ITypingEvent {
|
|
51
|
+
/** User who is typing */
|
|
52
|
+
userId: string;
|
|
53
|
+
/** Channel where typing occurs */
|
|
54
|
+
channelId: string;
|
|
55
|
+
/** Thread ID if typing in a thread */
|
|
56
|
+
threadId?: string;
|
|
57
|
+
/** Whether user started or stopped typing */
|
|
58
|
+
action: 'start' | 'stop';
|
|
59
|
+
/** Event timestamp */
|
|
60
|
+
timestamp: Date;
|
|
61
|
+
}
|
|
62
|
+
export declare const TYPING_SUBSCRIPTION_TOPIC = "TYPING_INDICATOR";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typing indicator system - inspired by openclaw's typing callbacks,
|
|
3
|
+
* adapted to messenger-box's Props architecture with event-driven patterns.
|
|
4
|
+
*
|
|
5
|
+
* Provides typed callbacks and state management for typing indicators
|
|
6
|
+
* across channels, threads, and direct messages.
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_TYPING_PROPS = {
|
|
9
|
+
showTypingIndicators: true,
|
|
10
|
+
broadcastTyping: true,
|
|
11
|
+
typingDebounceMs: 300,
|
|
12
|
+
typingTimeoutMs: 5000
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates typing callbacks with error handling (mirrors openclaw's createTypingCallbacks)
|
|
16
|
+
*/
|
|
17
|
+
function createTypingCallbacks(params) {
|
|
18
|
+
const {
|
|
19
|
+
stop
|
|
20
|
+
} = params;
|
|
21
|
+
const onReplyStart = async () => {
|
|
22
|
+
try {
|
|
23
|
+
await params.start();
|
|
24
|
+
} catch (err) {
|
|
25
|
+
params.onStartError(err);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const fireStop = stop ? () => {
|
|
29
|
+
void stop().catch(err => (params.onStopError ?? params.onStartError)(err));
|
|
30
|
+
} : undefined;
|
|
31
|
+
return {
|
|
32
|
+
onReplyStart,
|
|
33
|
+
onIdle: fireStop,
|
|
34
|
+
onCleanup: fireStop
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const TYPING_SUBSCRIPTION_TOPIC = 'TYPING_INDICATOR';export{DEFAULT_TYPING_PROPS,TYPING_SUBSCRIPTION_TOPIC,createTypingCallbacks};//# sourceMappingURL=typing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typing.js","sources":["../../src/channels/typing.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;AAMG;AAiBI,MAAM,oBAAoB,GAAiB;AAC9C,EAAA,oBAAA,EAAoB,IAAE;AACtB,EAAA,eAAA,EAAe,IAAE;AACjB,EAAA,gBAAA,EAAgB,GAAE;AAClB,EAAA,eAAA,EAAe;;AAoCnB;;AAEG;AACG,SAAU,qBAAqB,CAAC,MAKrC,EAAA;AACG,EAAA,MAAA;AAEA,IAAA;AACI,GAAA,GAAA,MAAI;AACA,EAAA,MAAA,YAAM,GAAA,YAAe;QACzB;YAAE,MAAU,MAAG,EAAA;AACX,IAAA,CAAA,CAAA,OAAA,GAAA,EAAM;YACT,CAAA,YAAA,CAAA,GAAA,CAAA;AACL,IAAA;;QAGI,QAAO,GAAA,IAAA,GAAA,MAAA;aACD,EAAA,CAAA,KAAS,IAAG,IAAK,CAAC,MAAM,CAAA,WAAW,IAAA,MAAW,CAAA,YAAW,EAAA,GAAA,CAAA,CAAA;eAC5D;SACF;IAEL,YAAS;AACb,IAAC,MAAA,EAAA,QAAA;AAmBD,IAAA,SAAa,EAAA;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combined default settings for all channel features.
|
|
3
|
+
* Applied to Channel.settings on creation.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_CHANNEL_SETTINGS: Record<string, unknown>;
|
|
6
|
+
export type DefaultChannelSettings = typeof DEFAULT_CHANNEL_SETTINGS;
|
|
7
|
+
/**
|
|
8
|
+
* Backward-compatible alias.
|
|
9
|
+
* @deprecated Use DEFAULT_CHANNEL_SETTINGS instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_CHANNEL_PROPS: Record<string, unknown>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import'../preferences/settings/post-settings.js';import {ChannelSettings}from'../preferences/settings/channel-settings.js';import'../preferences/settings/messenger-channels-contribution.js';import'../preferences/settings/chat-settings.js';import'../preferences/permissions/inbox-permission-contribution.js';import'../preferences/permissions/inbox-roles-permission-overwrite.js';/**
|
|
2
|
+
* Default Settings for channel features.
|
|
3
|
+
*
|
|
4
|
+
* Derives default values from the ChannelSettings preference schemas.
|
|
5
|
+
* These are used to populate Channel.settings on creation.
|
|
6
|
+
* Follows the same pattern as DEFAULT_NOTIFY_PROPS but covers all
|
|
7
|
+
* openclaw-inspired feature settings.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Builds a settings object from the ChannelSettings schema defaults,
|
|
11
|
+
* using short keys (e.g. "capabilities", "typing") rather than the
|
|
12
|
+
* full dotted preference path.
|
|
13
|
+
*/
|
|
14
|
+
function buildDefaultSettings() {
|
|
15
|
+
const settings = {};
|
|
16
|
+
for (const [fullKey, schema] of Object.entries(ChannelSettings)) {
|
|
17
|
+
// Extract the short key after the last dot
|
|
18
|
+
const shortKey = fullKey.split('.').pop();
|
|
19
|
+
settings[shortKey] = schema.default;
|
|
20
|
+
}
|
|
21
|
+
return settings;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Combined default settings for all channel features.
|
|
25
|
+
* Applied to Channel.settings on creation.
|
|
26
|
+
*/
|
|
27
|
+
const DEFAULT_CHANNEL_SETTINGS = buildDefaultSettings();
|
|
28
|
+
/**
|
|
29
|
+
* Backward-compatible alias.
|
|
30
|
+
* @deprecated Use DEFAULT_CHANNEL_SETTINGS instead.
|
|
31
|
+
*/
|
|
32
|
+
const DEFAULT_CHANNEL_PROPS = DEFAULT_CHANNEL_SETTINGS;export{DEFAULT_CHANNEL_PROPS,DEFAULT_CHANNEL_SETTINGS};//# sourceMappingURL=default-channel-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-channel-props.js","sources":["../../src/constants/default-channel-props.ts"],"sourcesContent":[null],"names":[],"mappings":"0XAAA;;;;;;;AAOG;AAGH;;;;AAIG;AACH,SAAS,oBAAoB,GAAA;QACzB,QAAM,GAAQ,EAA4B;AAC1C,EAAA,KAAA,MAAK,CAAA,OAAO,EAAO,WAAS,MAAI,CAAA,OAAO,CAAA,eAAQ,CAAA,EAAgB;;UAE3D,QAAM,GAAA,OAAW,CAAA,KAAQ,CAAA,GAAK,CAAC,CAAA,GAAI,EAAC;AACpC,IAAA,QAAA,CAAA,QAAS,CAAA,GAAQ,MAAI,CAAA;;AAEzB,EAAA,OAAA;AACJ;AAEA;;;AAGG;AACI,MAAM,wBAAwB,GAAG,oBAAoB;AAI5D;;;AAGG;AACI,MAAM,qBAAqB,GAAG"}
|
package/lib/constants/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ContainerModule}from'inversify';import {ChannelService}from'../services/channel-service.js';import {PostService}from'../services/post-service.js';import {PostThreadService}from'../services/post-thread-service.js';import {ReactionService}from'../services/reaction-service.js';import {MessengerNotificationService}from'../services/messenger-notification-service.js';import {ExtendedTokenAccountService}from'../services/extended-token-account-service.js';import {SERVER_TYPES}from'common/server';import {ChannelRepository}from'../store/repositories/channel-repository.js';import {PostRepository}from'../store/repositories/post-repository.js';import {PostThreadRepository}from'../store/repositories/post-thread-repository.js';import {ReactionRepository}from'../store/repositories/reaction-repository.js';import {MessageNotificationTemplateMigration}from'../migrations/message-notification-template-migration.js';import'../migrations/mail-template-migration.js';import {AddPostsConfigurationsMigration}from'../migrations/dbMigrations/AddPostsConfigurationsMigration.js';import {ChannelProxyService}from'../services/proxy-services/ChannelProxyService.js';import {ExtendedTokenAccountProxyService}from'../services/proxy-services/ExtendedTokenAccountProxyService.js';import {PostProxyService}from'../services/proxy-services/PostProxyService.js';import {PostThreadProxyService}from'../services/proxy-services/PostThreadProxyService.js';import {ReactionProxyService}from'../services/proxy-services/ReactionProxyService.js';import {MessengerNotificationProxyService}from'../services/proxy-services/MessengerNotificationProxyService.js';/**
|
|
1
|
+
import {ContainerModule}from'inversify';import {ChannelService}from'../services/channel-service.js';import {PostService}from'../services/post-service.js';import {PostThreadService}from'../services/post-thread-service.js';import {ReactionService}from'../services/reaction-service.js';import {MessengerNotificationService}from'../services/messenger-notification-service.js';import {ExtendedTokenAccountService}from'../services/extended-token-account-service.js';import {SERVER_TYPES}from'common/server';import {MessengerStreamService}from'../streaming/stream-service.js';import {ChannelRepository}from'../store/repositories/channel-repository.js';import {PostRepository}from'../store/repositories/post-repository.js';import {PostThreadRepository}from'../store/repositories/post-thread-repository.js';import {ReactionRepository}from'../store/repositories/reaction-repository.js';import {MessageNotificationTemplateMigration}from'../migrations/message-notification-template-migration.js';import'../migrations/mail-template-migration.js';import {AddPostsConfigurationsMigration}from'../migrations/dbMigrations/AddPostsConfigurationsMigration.js';import {AddChannelConfigurationsMigration}from'../migrations/dbMigrations/AddChannelConfigurationsMigration.js';import {AddChatConfigurationsMigration}from'../migrations/dbMigrations/AddChatConfigurationsMigration.js';import {ChannelProxyService}from'../services/proxy-services/ChannelProxyService.js';import {ExtendedTokenAccountProxyService}from'../services/proxy-services/ExtendedTokenAccountProxyService.js';import {PostProxyService}from'../services/proxy-services/PostProxyService.js';import {PostThreadProxyService}from'../services/proxy-services/PostThreadProxyService.js';import {ReactionProxyService}from'../services/proxy-services/ReactionProxyService.js';import {MessengerNotificationProxyService}from'../services/proxy-services/MessengerNotificationProxyService.js';/**
|
|
2
2
|
* Local services and exposed microservices to serve remote connections.
|
|
3
3
|
* Operates within in the Gateway.
|
|
4
4
|
*
|
|
@@ -8,12 +8,15 @@ const proxyServiceContainerModule = settings => new ContainerModule(bind => {
|
|
|
8
8
|
bind('MongodbMigration').to(MessageNotificationTemplateMigration).whenTargetNamed(MessageNotificationTemplateMigration.name);
|
|
9
9
|
// add Db migrations
|
|
10
10
|
bind('MongodbMigration').to(AddPostsConfigurationsMigration).whenTargetNamed(AddPostsConfigurationsMigration.name);
|
|
11
|
+
bind('MongodbMigration').to(AddChannelConfigurationsMigration).whenTargetNamed(AddChannelConfigurationsMigration.name);
|
|
12
|
+
bind('MongodbMigration').to(AddChatConfigurationsMigration).whenTargetNamed(AddChatConfigurationsMigration.name);
|
|
11
13
|
bind(SERVER_TYPES.ExtendedTokenAccountService).to(ExtendedTokenAccountProxyService).inSingletonScope().whenTargetIsDefault();
|
|
12
14
|
bind(SERVER_TYPES.ChannelService).to(ChannelProxyService).inSingletonScope().whenTargetIsDefault();
|
|
13
15
|
bind(SERVER_TYPES.PostService).to(PostProxyService).inSingletonScope().whenTargetIsDefault();
|
|
14
16
|
bind(SERVER_TYPES.PostThreadService).to(PostThreadProxyService).inSingletonScope().whenTargetIsDefault();
|
|
15
17
|
bind(SERVER_TYPES.ReactionService).to(ReactionProxyService).inSingletonScope().whenTargetIsDefault();
|
|
16
18
|
bind(SERVER_TYPES.MessengerNotificationService).to(MessengerNotificationProxyService).inSingletonScope();
|
|
19
|
+
bind(SERVER_TYPES.MessengerStreamService).to(MessengerStreamService).inSingletonScope().whenTargetIsDefault();
|
|
17
20
|
});
|
|
18
21
|
/**
|
|
19
22
|
* Operates external to the Gateway. Usually a broker listen to calls and invoke this service
|
|
@@ -32,4 +35,5 @@ const serviceContainerModule = settings => new ContainerModule(bind => {
|
|
|
32
35
|
bind(SERVER_TYPES.PostThreadService).to(PostThreadService).inSingletonScope().whenTargetIsDefault();
|
|
33
36
|
bind(SERVER_TYPES.ReactionService).to(ReactionService).inSingletonScope().whenTargetIsDefault();
|
|
34
37
|
bind(SERVER_TYPES.MessengerNotificationService).to(MessengerNotificationService).inSingletonScope().whenTargetIsDefault();
|
|
38
|
+
bind(SERVER_TYPES.MessengerStreamService).to(MessengerStreamService).inSingletonScope().whenTargetIsDefault();
|
|
35
39
|
});export{proxyServiceContainerModule,serviceContainerModule};//# sourceMappingURL=containers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containers.js","sources":["../../src/containers/containers.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"containers.js","sources":["../../src/containers/containers.ts"],"sourcesContent":[null],"names":[],"mappings":"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"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {SERVER_TYPES}from'common/server'
|
|
2
|
-
const contextServicesFromContainer = container => {
|
|
1
|
+
import {SERVER_TYPES}from'common/server';const contextServicesFromContainer = container => {
|
|
3
2
|
const services = {
|
|
4
3
|
extendedTokenAccountService: container.get(SERVER_TYPES.ExtendedTokenAccountService),
|
|
5
4
|
channelService: container.get(SERVER_TYPES.ChannelService),
|
|
6
5
|
postService: container.get(SERVER_TYPES.PostService),
|
|
7
6
|
postThreadService: container.get(SERVER_TYPES.PostThreadService),
|
|
8
7
|
reactionService: container.get(SERVER_TYPES.ReactionService),
|
|
9
|
-
messengerNotificationService: container.get(SERVER_TYPES.MessengerNotificationService)
|
|
8
|
+
messengerNotificationService: container.get(SERVER_TYPES.MessengerNotificationService),
|
|
9
|
+
messengerStreamService: container.get(SERVER_TYPES.MessengerStreamService)
|
|
10
10
|
};
|
|
11
11
|
return services;
|
|
12
12
|
};export{contextServicesFromContainer};//# sourceMappingURL=context-services-from-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-services-from-container.js","sources":["../../src/containers/context-services-from-container.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context-services-from-container.js","sources":["../../src/containers/context-services-from-container.ts"],"sourcesContent":[null],"names":[],"mappings":"yCAcO,MAAM,4BAA4B,GAAG,SAAC,IAAyD;AAClG,EAAA,MAAA,WAAc;+BACV,EAAA,aAAsC,CAAC,YACnC,CAAA;kBAEJ,EAAA,aAAyB,CAAC,YAAqB,CAAA;eAC/C,EAAA,aAAsB,CAAC,YAAkB,CAAA;qBACzC,EAAA,aAA4B,CAAC,YAAwB,CAAA;mBACrD,EAAA,aAA0B,CAAC,YAAsB,CAAA;gCACjD,EAAA,aAAuC,CAAC,YACpC,CAAA;0BAEJ,EAAA,aAAiC,CAAC,YAA6B,CAAA;;AAEnE,EAAA,OAAA;AACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IExternalChannelProvider, IExternalChannelRegistry, IChannelProviderConfig } from './types';
|
|
2
|
+
export declare class ExternalChannelRegistry implements IExternalChannelRegistry {
|
|
3
|
+
private providers;
|
|
4
|
+
register(provider: IExternalChannelProvider): void;
|
|
5
|
+
unregister(providerType: string): void;
|
|
6
|
+
get(providerType: string): IExternalChannelProvider | undefined;
|
|
7
|
+
listTypes(): string[];
|
|
8
|
+
listProviders(): IChannelProviderConfig[];
|
|
9
|
+
has(providerType: string): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CdmLogger } from '@cdm-logger/core';
|
|
2
|
+
import type { IGatewayService, IExternalChannelRegistry, IMessageRouterService, IInboundMessage, IOutboundMessage, ISendResult, IGatewayChannelStatus } from './types';
|
|
3
|
+
type InboundHandler = (message: IInboundMessage) => void;
|
|
4
|
+
export declare class GatewayService implements IGatewayService {
|
|
5
|
+
private logger;
|
|
6
|
+
private registry;
|
|
7
|
+
private router;
|
|
8
|
+
private inboundHandlers;
|
|
9
|
+
private initialized;
|
|
10
|
+
constructor(registry: IExternalChannelRegistry, router: IMessageRouterService, logger?: CdmLogger.ILogger);
|
|
11
|
+
initialize(): Promise<void>;
|
|
12
|
+
shutdown(): Promise<void>;
|
|
13
|
+
getRegistry(): IExternalChannelRegistry;
|
|
14
|
+
connectChannel(channelType: string, accountId: string, options: Record<string, unknown>): Promise<void>;
|
|
15
|
+
disconnectChannel(channelType: string, accountId: string): Promise<void>;
|
|
16
|
+
sendMessage(message: IOutboundMessage): Promise<ISendResult>;
|
|
17
|
+
getStatus(): IGatewayChannelStatus[];
|
|
18
|
+
getChannelStatus(channelType: string): IGatewayChannelStatus[];
|
|
19
|
+
onInboundMessage(handler: InboundHandler): void;
|
|
20
|
+
/** Forward inbound message to all registered handlers and the router */
|
|
21
|
+
private handleInbound;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CdmLogger } from '@cdm-logger/core';
|
|
2
|
+
import type { IInboundMessage, IOutboundMessage, ISendResult, IMessageRouterService, IExternalChannelRegistry } from './types';
|
|
3
|
+
export declare class MessageRouterService implements IMessageRouterService {
|
|
4
|
+
private logger;
|
|
5
|
+
private registry;
|
|
6
|
+
constructor(registry: IExternalChannelRegistry, logger?: CdmLogger.ILogger);
|
|
7
|
+
/**
|
|
8
|
+
* Route an inbound message from an external channel provider to the platform.
|
|
9
|
+
*
|
|
10
|
+
* This is where external messages get translated into platform Posts.
|
|
11
|
+
* In Go: similar to picoclaw's `pkg/channels/handler.go` HandleInbound.
|
|
12
|
+
*/
|
|
13
|
+
routeInbound(message: IInboundMessage): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Route an outbound message from the platform to the correct external channel provider.
|
|
16
|
+
*
|
|
17
|
+
* Looks up the provider by channelType in the registry and delegates the send.
|
|
18
|
+
*/
|
|
19
|
+
routeOutbound(message: IOutboundMessage): Promise<ISendResult>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway Types — External messaging channel provider interfaces.
|
|
3
|
+
*
|
|
4
|
+
* Designed Go-portable: no Inversify decorators, no Mongoose, no Moleculer.
|
|
5
|
+
* Every interface maps 1:1 to a Go interface. Uses plain constructors,
|
|
6
|
+
* explicit error returns, and typed queues (via EventEmitter or NATS topics).
|
|
7
|
+
*
|
|
8
|
+
* Architecture mapping:
|
|
9
|
+
* openclaw → ChannelProvider / ChannelAccountManager → this file
|
|
10
|
+
* picoclaw → pkg/channels/channel.go → this file
|
|
11
|
+
* clockbook → BOT_TYPES.IChannelRegistry → this file
|
|
12
|
+
*
|
|
13
|
+
* Channel extensions register providers via `contributes.channels` in their
|
|
14
|
+
* package.json and call `channels.registerProvider()` during activation.
|
|
15
|
+
*/
|
|
16
|
+
import type { IChannelCapabilities, IChannelDock, IChannelAccountSnapshot, IChannelStatusIssue } from '../channels/types';
|
|
17
|
+
/** Provider lifecycle state */
|
|
18
|
+
export type ProviderState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error';
|
|
19
|
+
/** Direction of a message relative to the gateway */
|
|
20
|
+
export type MessageDirection = 'inbound' | 'outbound';
|
|
21
|
+
/** Media attachment type */
|
|
22
|
+
export type MediaType = 'image' | 'audio' | 'video' | 'document' | 'sticker' | 'location' | 'contact';
|
|
23
|
+
export interface IMediaAttachment {
|
|
24
|
+
type: MediaType;
|
|
25
|
+
url?: string;
|
|
26
|
+
/** Raw bytes (base64 in JSON, []byte in Go) */
|
|
27
|
+
data?: string;
|
|
28
|
+
mimeType?: string;
|
|
29
|
+
filename?: string;
|
|
30
|
+
caption?: string;
|
|
31
|
+
/** Duration in seconds (audio/video) */
|
|
32
|
+
durationSec?: number;
|
|
33
|
+
/** Thumbnail URL or base64 */
|
|
34
|
+
thumbnail?: string;
|
|
35
|
+
}
|
|
36
|
+
/** An inbound message from an external channel into the gateway */
|
|
37
|
+
export interface IInboundMessage {
|
|
38
|
+
/** Unique message ID from the external platform */
|
|
39
|
+
externalId: string;
|
|
40
|
+
/** Channel provider identifier (e.g. 'whatsapp', 'telegram') */
|
|
41
|
+
channelType: string;
|
|
42
|
+
/** Account ID within the channel provider */
|
|
43
|
+
accountId: string;
|
|
44
|
+
/** Sender identifier on the external platform */
|
|
45
|
+
senderId: string;
|
|
46
|
+
/** Sender display name */
|
|
47
|
+
senderName?: string;
|
|
48
|
+
/** Chat/conversation identifier on the external platform */
|
|
49
|
+
chatId: string;
|
|
50
|
+
/** Chat type */
|
|
51
|
+
chatType?: 'direct' | 'group' | 'channel';
|
|
52
|
+
/** Text content */
|
|
53
|
+
text?: string;
|
|
54
|
+
/** Media attachments */
|
|
55
|
+
media?: IMediaAttachment[];
|
|
56
|
+
/** Whether this is a reply to another message */
|
|
57
|
+
replyToExternalId?: string;
|
|
58
|
+
/** Unix timestamp in ms */
|
|
59
|
+
timestamp: number;
|
|
60
|
+
/** Raw payload from the external platform (for debugging/passthrough) */
|
|
61
|
+
raw?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
/** An outbound message from the gateway to an external channel */
|
|
64
|
+
export interface IOutboundMessage {
|
|
65
|
+
/** Channel provider identifier */
|
|
66
|
+
channelType: string;
|
|
67
|
+
/** Account ID within the channel provider */
|
|
68
|
+
accountId: string;
|
|
69
|
+
/** Target chat/conversation identifier */
|
|
70
|
+
chatId: string;
|
|
71
|
+
/** Text content */
|
|
72
|
+
text?: string;
|
|
73
|
+
/** Media attachments */
|
|
74
|
+
media?: IMediaAttachment[];
|
|
75
|
+
/** Reply to a specific external message ID */
|
|
76
|
+
replyToExternalId?: string;
|
|
77
|
+
/** Arbitrary metadata */
|
|
78
|
+
metadata?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
/** Result of sending an outbound message */
|
|
81
|
+
export interface ISendResult {
|
|
82
|
+
success: boolean;
|
|
83
|
+
/** External message ID assigned by the platform */
|
|
84
|
+
externalId?: string;
|
|
85
|
+
/** Error message if failed */
|
|
86
|
+
error?: string;
|
|
87
|
+
/** Timestamp of delivery (Unix ms) */
|
|
88
|
+
timestamp?: number;
|
|
89
|
+
}
|
|
90
|
+
/** Configuration schema for a channel provider (declared in contributes.channels) */
|
|
91
|
+
export interface IChannelProviderConfig {
|
|
92
|
+
/** Unique provider type identifier (e.g. 'whatsapp', 'telegram') */
|
|
93
|
+
type: string;
|
|
94
|
+
/** Human-readable label */
|
|
95
|
+
label: string;
|
|
96
|
+
/** Provider description */
|
|
97
|
+
description?: string;
|
|
98
|
+
/** Icon name or URL */
|
|
99
|
+
icon?: string;
|
|
100
|
+
/** Provider capabilities */
|
|
101
|
+
capabilities: IChannelCapabilities;
|
|
102
|
+
/** Dock (outbound constraints, streaming, threading config) */
|
|
103
|
+
dock?: Partial<IChannelDock>;
|
|
104
|
+
/** JSON Schema for provider-specific configuration (API keys, tokens, etc.) */
|
|
105
|
+
configSchema?: Record<string, unknown>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* IExternalChannelProvider — the interface that channel extensions implement.
|
|
109
|
+
*
|
|
110
|
+
* Each extension contributes one provider. The gateway discovers providers
|
|
111
|
+
* via `contributes.channels` in the extension manifest and calls
|
|
112
|
+
* `channels.registerProvider(provider)` during extension activation.
|
|
113
|
+
*
|
|
114
|
+
* Go mapping:
|
|
115
|
+
* type ChannelProvider interface {
|
|
116
|
+
* Type() string
|
|
117
|
+
* Connect(ctx context.Context, accountId string, config map[string]any) error
|
|
118
|
+
* Disconnect(ctx context.Context, accountId string) error
|
|
119
|
+
* Send(ctx context.Context, msg OutboundMessage) (SendResult, error)
|
|
120
|
+
* State(accountId string) ProviderState
|
|
121
|
+
* OnMessage(handler func(InboundMessage))
|
|
122
|
+
* }
|
|
123
|
+
*/
|
|
124
|
+
export interface IExternalChannelProvider {
|
|
125
|
+
/** Provider type identifier (e.g. 'whatsapp') */
|
|
126
|
+
readonly type: string;
|
|
127
|
+
/** Provider configuration */
|
|
128
|
+
readonly config: IChannelProviderConfig;
|
|
129
|
+
/**
|
|
130
|
+
* Connect an account to the external platform.
|
|
131
|
+
* @param accountId - Unique account identifier
|
|
132
|
+
* @param options - Provider-specific connection options (API keys, session data, etc.)
|
|
133
|
+
* @param signal - AbortSignal for cancellation (Go: context.Context)
|
|
134
|
+
*/
|
|
135
|
+
connect(accountId: string, options: Record<string, unknown>, signal?: AbortSignal): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Disconnect an account from the external platform.
|
|
138
|
+
* @param accountId - Account to disconnect
|
|
139
|
+
*/
|
|
140
|
+
disconnect(accountId: string): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Send a message to the external platform.
|
|
143
|
+
* @param message - Outbound message to send
|
|
144
|
+
* @returns Send result with external ID on success
|
|
145
|
+
*/
|
|
146
|
+
send(message: IOutboundMessage): Promise<ISendResult>;
|
|
147
|
+
/**
|
|
148
|
+
* Get the current connection state for an account.
|
|
149
|
+
* @param accountId - Account identifier
|
|
150
|
+
*/
|
|
151
|
+
getState(accountId: string): ProviderState;
|
|
152
|
+
/**
|
|
153
|
+
* Get a snapshot of account status (connection info, last message times, etc.)
|
|
154
|
+
* @param accountId - Account identifier
|
|
155
|
+
*/
|
|
156
|
+
getAccountSnapshot(accountId: string): IChannelAccountSnapshot | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* Get any status issues (config problems, auth failures, etc.)
|
|
159
|
+
* @param accountId - Account identifier
|
|
160
|
+
*/
|
|
161
|
+
getStatusIssues(accountId: string): IChannelStatusIssue[];
|
|
162
|
+
/**
|
|
163
|
+
* Register a handler for inbound messages.
|
|
164
|
+
* The gateway calls this once during provider registration.
|
|
165
|
+
* @param handler - Callback invoked for each inbound message
|
|
166
|
+
*/
|
|
167
|
+
onMessage(handler: (message: IInboundMessage) => void): void;
|
|
168
|
+
/**
|
|
169
|
+
* Register a handler for provider state changes.
|
|
170
|
+
* @param handler - Callback invoked when connection state changes
|
|
171
|
+
*/
|
|
172
|
+
onStateChange?(handler: (accountId: string, state: ProviderState) => void): void;
|
|
173
|
+
/**
|
|
174
|
+
* Dispose all resources. Called when the extension is deactivated.
|
|
175
|
+
*/
|
|
176
|
+
dispose(): Promise<void>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* IExternalChannelRegistry — tracks all registered external channel providers.
|
|
180
|
+
*
|
|
181
|
+
* Providers register themselves via extension activation; the gateway looks
|
|
182
|
+
* them up by type when routing messages.
|
|
183
|
+
*
|
|
184
|
+
* Go mapping:
|
|
185
|
+
* type ChannelRegistry struct { providers map[string]ChannelProvider }
|
|
186
|
+
*/
|
|
187
|
+
export interface IExternalChannelRegistry {
|
|
188
|
+
/** Register a channel provider (called during extension activation) */
|
|
189
|
+
register(provider: IExternalChannelProvider): void;
|
|
190
|
+
/** Unregister a channel provider (called during extension deactivation) */
|
|
191
|
+
unregister(providerType: string): void;
|
|
192
|
+
/** Get a provider by type */
|
|
193
|
+
get(providerType: string): IExternalChannelProvider | undefined;
|
|
194
|
+
/** List all registered provider types */
|
|
195
|
+
listTypes(): string[];
|
|
196
|
+
/** List all providers with their configs */
|
|
197
|
+
listProviders(): IChannelProviderConfig[];
|
|
198
|
+
/** Check if a provider type is registered */
|
|
199
|
+
has(providerType: string): boolean;
|
|
200
|
+
}
|
|
201
|
+
/** Gateway status for a single provider/account pair */
|
|
202
|
+
export interface IGatewayChannelStatus {
|
|
203
|
+
channelType: string;
|
|
204
|
+
accountId: string;
|
|
205
|
+
state: ProviderState;
|
|
206
|
+
label: string;
|
|
207
|
+
snapshot?: IChannelAccountSnapshot;
|
|
208
|
+
issues: IChannelStatusIssue[];
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* IGatewayService — the top-level gateway orchestrator.
|
|
212
|
+
*
|
|
213
|
+
* Owns the channel registry, routes inbound messages to the platform,
|
|
214
|
+
* and dispatches outbound messages to the correct provider.
|
|
215
|
+
*
|
|
216
|
+
* Go mapping:
|
|
217
|
+
* type GatewayService struct {
|
|
218
|
+
* registry *ChannelRegistry
|
|
219
|
+
* router *MessageRouter
|
|
220
|
+
* eventBus *nats.Conn
|
|
221
|
+
* }
|
|
222
|
+
*/
|
|
223
|
+
export interface IGatewayService {
|
|
224
|
+
/** Initialize the gateway (called once at startup) */
|
|
225
|
+
initialize(): Promise<void>;
|
|
226
|
+
/** Shut down the gateway gracefully */
|
|
227
|
+
shutdown(): Promise<void>;
|
|
228
|
+
/** Get the channel registry */
|
|
229
|
+
getRegistry(): IExternalChannelRegistry;
|
|
230
|
+
/** Connect an account on a specific channel */
|
|
231
|
+
connectChannel(channelType: string, accountId: string, options: Record<string, unknown>): Promise<void>;
|
|
232
|
+
/** Disconnect an account on a specific channel */
|
|
233
|
+
disconnectChannel(channelType: string, accountId: string): Promise<void>;
|
|
234
|
+
/** Send an outbound message via the appropriate provider */
|
|
235
|
+
sendMessage(message: IOutboundMessage): Promise<ISendResult>;
|
|
236
|
+
/** Get status for all connected channels/accounts */
|
|
237
|
+
getStatus(): IGatewayChannelStatus[];
|
|
238
|
+
/** Get status for a specific channel type */
|
|
239
|
+
getChannelStatus(channelType: string): IGatewayChannelStatus[];
|
|
240
|
+
/**
|
|
241
|
+
* Register a handler for inbound messages (gateway → platform).
|
|
242
|
+
* The resolver/microservice uses this to feed messages into the platform.
|
|
243
|
+
*/
|
|
244
|
+
onInboundMessage(handler: (message: IInboundMessage) => void): void;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* IMessageRouterService — routes inbound messages to the messenger platform.
|
|
248
|
+
*
|
|
249
|
+
* Sits between external channel providers and the platform's channel/post
|
|
250
|
+
* services. Translates IInboundMessage into platform Post creation.
|
|
251
|
+
*
|
|
252
|
+
* Go mapping:
|
|
253
|
+
* type MessageRouter struct { channelSvc ChannelService; postSvc PostService }
|
|
254
|
+
*/
|
|
255
|
+
export interface IMessageRouterService {
|
|
256
|
+
/** Route an inbound message to the platform */
|
|
257
|
+
routeInbound(message: IInboundMessage): Promise<void>;
|
|
258
|
+
/** Route an outbound message from the platform to the external channel */
|
|
259
|
+
routeOutbound(message: IOutboundMessage): Promise<ISendResult>;
|
|
260
|
+
}
|
|
261
|
+
/** Topic for gateway inbound messages */
|
|
262
|
+
export declare const GATEWAY_INBOUND_TOPIC = "GATEWAY_INBOUND";
|
|
263
|
+
/** Topic for gateway outbound messages */
|
|
264
|
+
export declare const GATEWAY_OUTBOUND_TOPIC = "GATEWAY_OUTBOUND";
|
|
265
|
+
/** Topic for gateway channel status changes */
|
|
266
|
+
export declare const GATEWAY_STATUS_TOPIC = "GATEWAY_STATUS";
|
|
267
|
+
/** Build a scoped topic for a specific channel type */
|
|
268
|
+
export declare function gatewayInboundTopic(channelType: string): string;
|
|
269
|
+
export declare function gatewayOutboundTopic(channelType: string): string;
|
|
270
|
+
export declare function gatewayStatusTopic(channelType: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel Capabilities Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles GraphQL queries, mutations, and subscriptions for
|
|
5
|
+
* the openclaw-inspired channel capabilities system.
|
|
6
|
+
*
|
|
7
|
+
* All channel feature configuration lives in Channel.settings
|
|
8
|
+
* (schema driven by ChannelSettings preferences). The resolver
|
|
9
|
+
* reads/writes through that single field.
|
|
10
|
+
*/
|
|
11
|
+
import { IResolverOptions } from '@common-stack/server-core';
|
|
12
|
+
import { IResolvers } from 'common/server';
|
|
13
|
+
export declare const channelCapabilitiesResolvers: (options: IResolverOptions) => IResolvers;
|