@zohoim/client-sdk 1.0.0-poc4 → 1.0.0-poc41
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/es/config/registry/bots/botAPIRegistry.js +12 -0
- package/es/config/registry/bots/constructBotEndPoint.js +10 -0
- package/es/config/registry/bots/index.js +2 -0
- package/es/config/registry/channels/channelAPIRegistry.js +16 -0
- package/es/config/registry/channels/channelAgentAPIRegistry.js +12 -0
- package/es/config/registry/channels/constructChannelEndPoint.js +10 -0
- package/es/config/registry/channels/index.js +2 -0
- package/es/config/registry/createAPIRegistry.js +7 -0
- package/es/config/registry/createBaseUrl.js +3 -0
- package/es/config/registry/getRegistryConfig.js +20 -0
- package/es/config/registry/index.js +2 -0
- package/es/config/registry/sessions/constructSessionEndPoint.js +10 -0
- package/es/config/registry/sessions/index.js +2 -0
- package/es/config/registry/sessions/sessionAPIRegistry.js +12 -0
- package/es/core/constants/HttpMethods.js +8 -0
- package/es/core/constants/ModuleNames.js +6 -0
- package/es/core/constants/index.js +4 -0
- package/es/core/errors/AdapterError.js +7 -0
- package/es/core/errors/index.js +3 -0
- package/es/core/utils/ResponseUtils.js +24 -0
- package/es/core/utils/index.js +3 -0
- package/es/core/utils/validateSchema.js +68 -0
- package/es/domain/entities/Actor/Actor.js +23 -0
- package/es/domain/entities/Actor/index.js +2 -2
- package/es/domain/entities/Agent/Agent.js +13 -102
- package/es/domain/entities/Agent/index.js +1 -1
- package/es/domain/entities/Bot/Bot.js +23 -0
- package/es/domain/entities/Bot/index.js +2 -0
- package/es/domain/entities/Channel/Channel.js +38 -0
- package/es/domain/entities/Channel/index.js +2 -0
- package/es/domain/entities/Session/Session.js +35 -0
- package/es/domain/entities/Session/index.js +2 -0
- package/es/domain/entities/index.js +5 -2
- package/es/domain/enum/actor/index.js +2 -0
- package/es/domain/enum/bot/BotServiceType.js +7 -0
- package/es/domain/enum/bot/index.js +2 -0
- package/es/domain/enum/index.js +4 -0
- package/es/domain/enum/integrationServices/IntegrationServices.js +11 -0
- package/es/domain/enum/integrationServices/index.js +2 -0
- package/es/domain/enum/session/SessionReplyStatus.js +20 -0
- package/es/domain/enum/session/SessionStatus.js +9 -0
- package/es/domain/enum/session/index.js +3 -0
- package/es/domain/interfaces/BaseAPI.js +86 -0
- package/es/domain/interfaces/IAdapter.js +6 -0
- package/es/domain/interfaces/bots/IBot.js +10 -0
- package/es/domain/interfaces/bots/index.js +2 -0
- package/es/domain/interfaces/channels/IChannel.js +10 -0
- package/es/domain/interfaces/channels/IChannelAgent.js +6 -2
- package/es/domain/interfaces/channels/index.js +3 -2
- package/es/domain/interfaces/index.js +5 -1
- package/es/domain/interfaces/sessions/ISession.js +10 -0
- package/es/domain/interfaces/sessions/index.js +2 -0
- package/es/domain/schema/actor/ActorSchema.js +33 -0
- package/es/domain/schema/actor/AgentSchema.js +29 -0
- package/es/domain/schema/actor/index.js +3 -0
- package/es/domain/schema/bot/BotSchema.js +33 -0
- package/es/domain/schema/bot/index.js +2 -0
- package/es/domain/schema/channel/ChannelSchema.js +49 -0
- package/es/domain/schema/channel/index.js +2 -0
- package/es/domain/schema/index.js +5 -0
- package/es/domain/schema/integrationService/IntegrationServiceSchema.js +31 -0
- package/es/domain/schema/integrationService/index.js +2 -0
- package/es/domain/schema/session/SessionSchema.js +82 -0
- package/es/domain/schema/session/index.js +2 -0
- package/es/domain/services/bots/BotService.js +27 -0
- package/es/domain/services/bots/index.js +2 -0
- package/es/domain/services/channels/ChannelAgentService.js +20 -7
- package/es/domain/services/channels/ChannelService.js +27 -0
- package/es/domain/services/channels/index.js +3 -2
- package/es/domain/services/index.js +3 -1
- package/es/domain/services/sessions/SessionService.js +27 -0
- package/es/domain/services/sessions/index.js +2 -0
- package/es/index.js +9 -1
- package/es/infrastructure/adapters/bots/BotAdapter.js +25 -0
- package/es/infrastructure/adapters/bots/index.js +2 -0
- package/es/infrastructure/adapters/channels/ChannelAdapter.js +29 -0
- package/es/infrastructure/adapters/channels/ChannelAgentAdapter.js +30 -0
- package/es/infrastructure/adapters/channels/index.js +3 -0
- package/es/infrastructure/adapters/index.js +3 -0
- package/es/infrastructure/adapters/sessions/SessionAdapter.js +36 -0
- package/es/infrastructure/adapters/sessions/index.js +2 -0
- package/es/infrastructure/api/bots/BotAPI.js +21 -0
- package/es/infrastructure/api/bots/index.js +2 -0
- package/es/infrastructure/api/channels/ChannelAPI.js +21 -0
- package/es/infrastructure/api/channels/ChannelAgentAPI.js +29 -0
- package/es/infrastructure/api/channels/index.js +3 -0
- package/es/infrastructure/api/index.js +3 -0
- package/es/infrastructure/api/sessions/SessionAPI.js +21 -0
- package/es/infrastructure/api/sessions/index.js +2 -0
- package/es/infrastructure/interfaces/api/base/RequestBuilder.js +42 -0
- package/es/infrastructure/interfaces/api/base/index.js +2 -0
- package/es/infrastructure/interfaces/api/bots/getBotsRequest.js +19 -0
- package/es/infrastructure/interfaces/api/bots/index.js +2 -0
- package/es/infrastructure/interfaces/api/channels/agents/getChannelAgentsRequest.js +19 -0
- package/es/infrastructure/interfaces/api/channels/agents/index.js +2 -0
- package/es/infrastructure/interfaces/api/channels/getChannelsRequest.js +27 -0
- package/es/infrastructure/interfaces/api/channels/index.js +3 -0
- package/es/infrastructure/interfaces/api/index.js +3 -0
- package/es/infrastructure/interfaces/api/sessions/index.js +2 -0
- package/es/infrastructure/interfaces/api/sessions/updateSessionAssigneeRequest.js +18 -0
- package/es/infrastructure/interfaces/index.js +1 -0
- package/es/infrastructure/managers/ModuleFactory.js +31 -0
- package/es/infrastructure/managers/ModuleManager.js +44 -0
- package/es/infrastructure/managers/index.js +2 -0
- package/es/infrastructure/sdk/IMSDK.js +47 -0
- package/es/infrastructure/sdk/bots/BotSDK.js +20 -0
- package/es/infrastructure/sdk/bots/index.js +2 -0
- package/es/infrastructure/sdk/channels/ChannelSDK.js +30 -0
- package/es/infrastructure/sdk/channels/index.js +2 -0
- package/es/infrastructure/sdk/config/configRegistry.js +27 -0
- package/es/infrastructure/sdk/config/index.js +2 -0
- package/es/infrastructure/sdk/index.js +2 -0
- package/es/infrastructure/sdk/sessions/SessionSDK.js +20 -0
- package/es/infrastructure/sdk/sessions/index.js +2 -0
- package/package.json +1 -1
- package/es/domain/index.js +0 -3
- /package/es/{domain → core}/errors/ValidationError.js +0 -0
- /package/es/domain/{entities/Actor → enum/actor}/ActorType.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Agent } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
export default class ChannelAgentAdapter extends IAdapter {
|
|
5
|
+
/**
|
|
6
|
+
* Adapts channel agent data to Agent entity
|
|
7
|
+
* @param {Object} channelAgent - Channel agent data to adapt
|
|
8
|
+
* @returns {Object} Adapted agent data
|
|
9
|
+
* @throws {AdapterError} When adaptation fails
|
|
10
|
+
*/
|
|
11
|
+
adapt(channelAgent) {
|
|
12
|
+
if (!channelAgent) {
|
|
13
|
+
throw new AdapterError('Channel agent data is required');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
return new Agent({
|
|
18
|
+
id: channelAgent.id,
|
|
19
|
+
name: channelAgent.name,
|
|
20
|
+
email: channelAgent.email,
|
|
21
|
+
photoURL: channelAgent.photoURL || '',
|
|
22
|
+
zuid: channelAgent.zuid,
|
|
23
|
+
type: channelAgent.type
|
|
24
|
+
}).toJSON();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
throw new AdapterError(`Failed to adapt channel agent: ${error.message}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Session } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
export default class SessionAdapter extends IAdapter {
|
|
5
|
+
adapt(sessionData) {
|
|
6
|
+
if (!sessionData) {
|
|
7
|
+
throw new AdapterError('Session data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Session({
|
|
12
|
+
id: sessionData.id,
|
|
13
|
+
channelId: sessionData.channelId,
|
|
14
|
+
status: sessionData.status,
|
|
15
|
+
createdTime: sessionData.createdTime,
|
|
16
|
+
agentId: sessionData.agentId,
|
|
17
|
+
botId: sessionData.botId,
|
|
18
|
+
actor: sessionData.actor,
|
|
19
|
+
subject: sessionData.subject,
|
|
20
|
+
messagesCount: sessionData.messagesCount,
|
|
21
|
+
agentLastActiveTime: sessionData.agentLastActiveTime,
|
|
22
|
+
contactLastActiveTime: sessionData.contactLastActiveTime,
|
|
23
|
+
lastActiveTime: sessionData.lastActiveTime,
|
|
24
|
+
unreadMessagesCount: sessionData.unreadMessagesCount,
|
|
25
|
+
integrationServiceId: sessionData.integrationServiceId,
|
|
26
|
+
replyStatus: sessionData.replyStatus,
|
|
27
|
+
contactId: sessionData.contactId,
|
|
28
|
+
meta: sessionData.meta,
|
|
29
|
+
assignee: sessionData.assignee
|
|
30
|
+
}).toJSON();
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new AdapterError(`Failed to adapt session: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModuleNames } from "../../../core/constants";
|
|
2
|
+
import { IBot } from "../../../domain/interfaces";
|
|
3
|
+
import { getBotsRequest } from "../../interfaces/api";
|
|
4
|
+
export default class BotAPI extends IBot {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({
|
|
7
|
+
module: ModuleNames.BOTS
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getBots() {
|
|
12
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
|
|
13
|
+
const operation = 'getBots';
|
|
14
|
+
const httpRequest = await this.request({
|
|
15
|
+
request,
|
|
16
|
+
operation
|
|
17
|
+
});
|
|
18
|
+
return httpRequest;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModuleNames } from "../../../core/constants";
|
|
2
|
+
import { IChannel } from "../../../domain/interfaces";
|
|
3
|
+
import { getChannelsRequest } from "../../interfaces/api";
|
|
4
|
+
export default class ChannelAPI extends IChannel {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({
|
|
7
|
+
module: ModuleNames.CHANNELS
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getChannels() {
|
|
12
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelsRequest();
|
|
13
|
+
const operation = 'getChannels';
|
|
14
|
+
const httpRequest = await this.request({
|
|
15
|
+
request,
|
|
16
|
+
operation
|
|
17
|
+
});
|
|
18
|
+
return httpRequest;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ModuleNames } from "../../../core/constants";
|
|
2
|
+
import IChannelAgent from "../../../domain/interfaces/channels/IChannelAgent";
|
|
3
|
+
import { getChannelAgentsRequest } from "../../interfaces/api";
|
|
4
|
+
export default class ChannelAgentAPI extends IChannelAgent {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({
|
|
7
|
+
module: `${ModuleNames.CHANNELS}.agents`
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getAgents() {
|
|
12
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
|
|
13
|
+
const {
|
|
14
|
+
searchStr
|
|
15
|
+
} = request.query;
|
|
16
|
+
|
|
17
|
+
if (searchStr) {
|
|
18
|
+
request.query.searchStr = `*${encodeURIComponent(searchStr)}*`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const operation = 'getAgents';
|
|
22
|
+
const httpRequest = await this.request({
|
|
23
|
+
request,
|
|
24
|
+
operation
|
|
25
|
+
});
|
|
26
|
+
return httpRequest;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModuleNames } from "../../../core/constants";
|
|
2
|
+
import { ISession } from "../../../domain/interfaces";
|
|
3
|
+
import { updateSessionAssigneeRequest } from "../../interfaces/api";
|
|
4
|
+
export default class SessionAPI extends ISession {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({
|
|
7
|
+
module: ModuleNames.SESSIONS
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async updateAssignee() {
|
|
12
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
|
|
13
|
+
const operation = 'updateAssignee';
|
|
14
|
+
const httpRequest = await this.request({
|
|
15
|
+
request,
|
|
16
|
+
operation
|
|
17
|
+
});
|
|
18
|
+
return httpRequest;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
class RequestBuilder {
|
|
2
|
+
constructor() {
|
|
3
|
+
this._params = {};
|
|
4
|
+
this._query = {};
|
|
5
|
+
this._body = {};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
withParams() {
|
|
9
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10
|
+
this._params = { ...this._params,
|
|
11
|
+
...params
|
|
12
|
+
};
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
withQuery() {
|
|
17
|
+
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18
|
+
this._query = { ...this._query,
|
|
19
|
+
...query
|
|
20
|
+
};
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
withBody() {
|
|
25
|
+
let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26
|
+
this._body = { ...this._body,
|
|
27
|
+
...body
|
|
28
|
+
};
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
build() {
|
|
33
|
+
return {
|
|
34
|
+
params: this._params,
|
|
35
|
+
query: this._query,
|
|
36
|
+
body: Object.keys(this._body).length ? this._body : undefined
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default RequestBuilder;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestBuilder } from "../base";
|
|
2
|
+
|
|
3
|
+
function getBotsRequest() {
|
|
4
|
+
let {
|
|
5
|
+
query = {}
|
|
6
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
return new RequestBuilder().withQuery({
|
|
8
|
+
from: 0,
|
|
9
|
+
limit: 10,
|
|
10
|
+
modifiedAfter: null,
|
|
11
|
+
botServiceId: null,
|
|
12
|
+
externalAccountId: null,
|
|
13
|
+
searchStr: null,
|
|
14
|
+
isActive: false,
|
|
15
|
+
...query
|
|
16
|
+
}).build();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default getBotsRequest;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestBuilder } from "../../base";
|
|
2
|
+
|
|
3
|
+
function getChannelAgentsRequest() {
|
|
4
|
+
let {
|
|
5
|
+
query = {},
|
|
6
|
+
params = {}
|
|
7
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8
|
+
return new RequestBuilder().withQuery({
|
|
9
|
+
from: 0,
|
|
10
|
+
limit: 10,
|
|
11
|
+
searchStr: null,
|
|
12
|
+
...query
|
|
13
|
+
}).withParams({
|
|
14
|
+
channelId: null,
|
|
15
|
+
...params
|
|
16
|
+
}).build();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default getChannelAgentsRequest;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RequestBuilder } from "../base";
|
|
2
|
+
|
|
3
|
+
function getChannelsRequest() {
|
|
4
|
+
let {
|
|
5
|
+
query = {}
|
|
6
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
return new RequestBuilder().withQuery({
|
|
8
|
+
from: null,
|
|
9
|
+
limit: null,
|
|
10
|
+
modifiedAfter: null,
|
|
11
|
+
integrationServiceId: null,
|
|
12
|
+
externalAccountId: null,
|
|
13
|
+
isSandBox: null,
|
|
14
|
+
isActive: null,
|
|
15
|
+
includeDeleted: null,
|
|
16
|
+
onlyDeleted: null,
|
|
17
|
+
configName: null,
|
|
18
|
+
configValue: null,
|
|
19
|
+
channelIds: null,
|
|
20
|
+
include: null,
|
|
21
|
+
// meta|configParams
|
|
22
|
+
includeUnsubscribed: null,
|
|
23
|
+
...query
|
|
24
|
+
}).build();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default getChannelsRequest;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RequestBuilder } from "../base";
|
|
2
|
+
|
|
3
|
+
function updateSessionAssigneeRequest() {
|
|
4
|
+
let {
|
|
5
|
+
params = {},
|
|
6
|
+
body = {}
|
|
7
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8
|
+
return new RequestBuilder().withParams({
|
|
9
|
+
sessionId: null,
|
|
10
|
+
...params
|
|
11
|
+
}).withBody({
|
|
12
|
+
agentId: null,
|
|
13
|
+
botId: null,
|
|
14
|
+
...body
|
|
15
|
+
}).build();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default updateSessionAssigneeRequest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ModuleNames } from "../../core/constants";
|
|
2
|
+
import { BotSDK } from "../sdk/bots";
|
|
3
|
+
import { ChannelSDK } from "../sdk/channels";
|
|
4
|
+
import { SessionSDK } from "../sdk/sessions";
|
|
5
|
+
const ModuleFactory = {
|
|
6
|
+
[ModuleNames.CHANNELS]: _ref => {
|
|
7
|
+
let {
|
|
8
|
+
config
|
|
9
|
+
} = _ref;
|
|
10
|
+
return new ChannelSDK({
|
|
11
|
+
config
|
|
12
|
+
}).toJSON();
|
|
13
|
+
},
|
|
14
|
+
[ModuleNames.SESSIONS]: _ref2 => {
|
|
15
|
+
let {
|
|
16
|
+
config
|
|
17
|
+
} = _ref2;
|
|
18
|
+
return new SessionSDK({
|
|
19
|
+
config
|
|
20
|
+
}).toJSON();
|
|
21
|
+
},
|
|
22
|
+
[ModuleNames.BOTS]: _ref3 => {
|
|
23
|
+
let {
|
|
24
|
+
config
|
|
25
|
+
} = _ref3;
|
|
26
|
+
return new BotSDK({
|
|
27
|
+
config
|
|
28
|
+
}).toJSON();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export default ModuleFactory;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ModuleNames } from "../../core/constants";
|
|
2
|
+
import ModuleFactory from "./ModuleFactory";
|
|
3
|
+
export default class ModuleManager {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._modules = new Map();
|
|
6
|
+
this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
initialize(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
apiConfig
|
|
12
|
+
} = _ref;
|
|
13
|
+
this.supportedModules.forEach(moduleName => {
|
|
14
|
+
const moduleConfig = apiConfig ? apiConfig[moduleName] || {} : {};
|
|
15
|
+
this.initializeModule({
|
|
16
|
+
moduleName,
|
|
17
|
+
config: moduleConfig
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
initializeModule(_ref2) {
|
|
23
|
+
let {
|
|
24
|
+
moduleName,
|
|
25
|
+
config
|
|
26
|
+
} = _ref2;
|
|
27
|
+
const createModule = ModuleFactory[moduleName];
|
|
28
|
+
|
|
29
|
+
if (createModule) {
|
|
30
|
+
this._modules.set(moduleName, createModule({
|
|
31
|
+
config
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getModule(moduleName) {
|
|
37
|
+
return this._modules.get(moduleName);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
hasModule(moduleName) {
|
|
41
|
+
return this._modules.has(moduleName);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ModuleNames } from "../../core/constants";
|
|
2
|
+
import { ModuleManager } from "../managers";
|
|
3
|
+
import { configRegistry } from "./config";
|
|
4
|
+
export default class IMSDK {
|
|
5
|
+
constructor(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
baseURL,
|
|
8
|
+
apiConfig = {},
|
|
9
|
+
httpClient
|
|
10
|
+
} = _ref;
|
|
11
|
+
configRegistry.setConfig({
|
|
12
|
+
baseURL,
|
|
13
|
+
httpClient
|
|
14
|
+
});
|
|
15
|
+
this._moduleManager = new ModuleManager();
|
|
16
|
+
|
|
17
|
+
this._moduleManager.initialize({
|
|
18
|
+
apiConfig
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get channels() {
|
|
23
|
+
return this._moduleManager.getModule(ModuleNames.CHANNELS);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get sessions() {
|
|
27
|
+
return this._moduleManager.getModule(ModuleNames.SESSIONS);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get bots() {
|
|
31
|
+
return this._moduleManager.getModule(ModuleNames.BOTS);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
hasModule(moduleName) {
|
|
35
|
+
return this._moduleManager.hasModule(moduleName);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toJSON() {
|
|
39
|
+
return {
|
|
40
|
+
channels: this.channels,
|
|
41
|
+
sessions: this.sessions,
|
|
42
|
+
bots: this.bots,
|
|
43
|
+
hasModule: this.hasModule.bind(this)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BotService } from "../../../domain/services";
|
|
2
|
+
|
|
3
|
+
class BotSDK extends BotService {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
config
|
|
7
|
+
} = _ref;
|
|
8
|
+
const {
|
|
9
|
+
botAPI,
|
|
10
|
+
botAdapter
|
|
11
|
+
} = config;
|
|
12
|
+
super({
|
|
13
|
+
botAPI,
|
|
14
|
+
botAdapter
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default BotSDK;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ChannelAgentService, ChannelService } from "../../../domain/services";
|
|
2
|
+
export default class ChannelSDK {
|
|
3
|
+
constructor(_ref) {
|
|
4
|
+
let {
|
|
5
|
+
config
|
|
6
|
+
} = _ref;
|
|
7
|
+
const {
|
|
8
|
+
channelAPI,
|
|
9
|
+
channelAdapter,
|
|
10
|
+
channelAgentAPI,
|
|
11
|
+
channelAgentAdapter
|
|
12
|
+
} = config;
|
|
13
|
+
const channelAgentService = new ChannelAgentService({
|
|
14
|
+
channelAgentAPI,
|
|
15
|
+
channelAgentAdapter
|
|
16
|
+
}).toJSON();
|
|
17
|
+
const channelService = new ChannelService({
|
|
18
|
+
channelAPI,
|
|
19
|
+
channelAdapter
|
|
20
|
+
}).toJSON();
|
|
21
|
+
this.services = { ...channelService,
|
|
22
|
+
agents: channelAgentService
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
toJSON() {
|
|
27
|
+
return this.services;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class ConfigRegistry {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.baseURL = null;
|
|
4
|
+
this.httpClient = null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
setConfig(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
baseURL,
|
|
10
|
+
httpClient
|
|
11
|
+
} = _ref;
|
|
12
|
+
this.baseURL = baseURL;
|
|
13
|
+
this.httpClient = httpClient;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getBaseURL() {
|
|
17
|
+
return this.baseURL;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getHttpClient() {
|
|
21
|
+
return this.httpClient;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const configRegistry = new ConfigRegistry();
|
|
27
|
+
export default configRegistry;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SessionService } from "../../../domain/services";
|
|
2
|
+
|
|
3
|
+
class SessionSDK extends SessionService {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
config
|
|
7
|
+
} = _ref;
|
|
8
|
+
const {
|
|
9
|
+
sessionAPI,
|
|
10
|
+
sessionAdapter
|
|
11
|
+
} = config;
|
|
12
|
+
super({
|
|
13
|
+
sessionAPI,
|
|
14
|
+
sessionAdapter
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default SessionSDK;
|
package/package.json
CHANGED
package/es/domain/index.js
DELETED
|
File without changes
|
|
File without changes
|