@zohoim/client-sdk 1.0.0-poc21 → 1.0.0-poc23
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/urls/base/index.js +7 -0
- package/es/config/urls/bots/bots-api-url.js +5 -8
- package/es/config/urls/bots/index.js +1 -1
- package/es/config/urls/channels/channel-agents-api-url.js +5 -8
- package/es/config/urls/channels/index.js +1 -1
- package/es/config/urls/index.js +16 -0
- package/es/config/urls/sessions/index.js +1 -1
- package/es/config/urls/sessions/sessions-api-url.js +5 -8
- package/es/core/constants/index.js +2 -2
- package/es/core/errors/index.js +2 -2
- package/es/core/utils/index.js +1 -1
- package/es/core/utils/validateSchema.js +1 -1
- package/es/domain/entities/Actor/Actor.js +2 -2
- package/es/domain/entities/Actor/index.js +1 -1
- package/es/domain/entities/Agent/Agent.js +2 -2
- package/es/domain/entities/Agent/index.js +1 -1
- package/es/domain/entities/Bot/Bot.js +2 -2
- package/es/domain/entities/Bot/index.js +1 -1
- package/es/domain/entities/Session/Session.js +3 -3
- package/es/domain/entities/Session/index.js +1 -1
- package/es/domain/entities/index.js +4 -4
- package/es/domain/enum/actor/index.js +1 -1
- package/es/domain/enum/bot/index.js +1 -1
- package/es/domain/enum/index.js +4 -4
- package/es/domain/enum/integrationServices/index.js +1 -1
- package/es/domain/enum/session/index.js +2 -2
- package/es/domain/interfaces/BaseAPI.js +3 -2
- package/es/domain/interfaces/bots/IBot.js +3 -3
- package/es/domain/interfaces/bots/index.js +1 -1
- package/es/domain/interfaces/channels/IChannelAgent.js +3 -3
- package/es/domain/interfaces/channels/index.js +1 -1
- package/es/domain/interfaces/index.js +3 -3
- package/es/domain/interfaces/sessions/ISession.js +3 -3
- package/es/domain/interfaces/sessions/index.js +1 -1
- package/es/domain/schema/actor/ActorSchema.js +1 -1
- package/es/domain/schema/actor/AgentSchema.js +1 -1
- package/es/domain/schema/actor/index.js +2 -2
- package/es/domain/schema/bot/BotSchema.js +1 -1
- package/es/domain/schema/bot/index.js +1 -1
- package/es/domain/schema/index.js +3 -3
- package/es/domain/schema/session/SessionSchema.js +2 -2
- package/es/domain/schema/session/index.js +1 -1
- package/es/domain/services/bots/BotService.js +9 -7
- package/es/domain/services/bots/index.js +1 -1
- package/es/domain/services/channels/ChannelAgentService.js +9 -7
- package/es/domain/services/channels/index.js +1 -1
- package/es/domain/services/index.js +3 -3
- package/es/domain/services/sessions/SessionService.js +9 -7
- package/es/domain/services/sessions/index.js +1 -1
- package/es/index.js +8 -8
- package/es/infrastructure/adapters/BaseAdapter.js +1 -1
- package/es/infrastructure/adapters/bots/BotAdapter.js +3 -3
- package/es/infrastructure/adapters/bots/index.js +1 -1
- package/es/infrastructure/adapters/channels/ChannelAgentAdapter.js +3 -3
- package/es/infrastructure/adapters/channels/index.js +1 -1
- package/es/infrastructure/adapters/index.js +3 -3
- package/es/infrastructure/adapters/sessions/SessionAdapter.js +3 -3
- package/es/infrastructure/adapters/sessions/index.js +1 -1
- package/es/infrastructure/api/bots/BotAPI.js +3 -3
- package/es/infrastructure/api/bots/index.js +1 -1
- package/es/infrastructure/api/channels/ChannelAgentAPI.js +3 -3
- package/es/infrastructure/api/channels/index.js +1 -1
- package/es/infrastructure/api/index.js +3 -3
- package/es/infrastructure/api/sessions/SessionAPI.js +3 -3
- package/es/infrastructure/api/sessions/index.js +1 -1
- 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 +14 -0
- package/es/infrastructure/interfaces/api/bots/index.js +2 -2
- package/es/infrastructure/interfaces/api/channels/agents/getChannelAgentsRequest.js +13 -0
- package/es/infrastructure/interfaces/api/channels/agents/index.js +2 -2
- package/es/infrastructure/interfaces/api/channels/index.js +1 -1
- package/es/infrastructure/interfaces/api/index.js +3 -3
- package/es/infrastructure/interfaces/api/sessions/index.js +2 -2
- package/es/infrastructure/interfaces/api/sessions/updateSessionAssigneeRequest.js +12 -0
- package/es/infrastructure/interfaces/index.js +1 -1
- package/es/infrastructure/managers/ModuleFactory.js +4 -4
- package/es/infrastructure/managers/ModuleManager.js +2 -2
- package/es/infrastructure/managers/index.js +1 -1
- package/es/infrastructure/sdk/IMSDK.js +4 -4
- package/es/infrastructure/sdk/bots/BotSDK.js +1 -1
- package/es/infrastructure/sdk/bots/index.js +1 -1
- package/es/infrastructure/sdk/channels/ChannelSDK.js +1 -1
- package/es/infrastructure/sdk/channels/index.js +1 -1
- package/es/infrastructure/sdk/config/index.js +1 -1
- package/es/infrastructure/sdk/index.js +1 -1
- package/es/infrastructure/sdk/sessions/SessionSDK.js +1 -1
- package/es/infrastructure/sdk/sessions/index.js +1 -1
- package/package.json +1 -1
- package/es/infrastructure/interfaces/api/bots/GetBotsRequest.js +0 -14
- package/es/infrastructure/interfaces/api/channels/agents/GetChannelAgentsRequest.js +0 -13
- package/es/infrastructure/interfaces/api/sessions/UpdateSessionAssigneeRequest.js +0 -12
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { HTTP_METHODS
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { HTTP_METHODS } from "../../../core/constants";
|
|
2
|
+
import { getBotsRequest } from "../../../infrastructure/interfaces/api";
|
|
3
|
+
import { createBaseUrl, createEndpoint } from "../base";
|
|
4
|
+
const BASE_URL = createBaseUrl('/bots');
|
|
4
5
|
const BOTS_API_URLS = {
|
|
5
|
-
LIST:
|
|
6
|
-
url: BASE_URL,
|
|
7
|
-
method: HTTP_METHODS.GET,
|
|
8
|
-
...GetBotsRequest
|
|
9
|
-
}
|
|
6
|
+
LIST: createEndpoint(BASE_URL, HTTP_METHODS.GET, getBotsRequest())
|
|
10
7
|
};
|
|
11
8
|
export default BOTS_API_URLS;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BOTS_API_URLS from
|
|
1
|
+
import BOTS_API_URLS from "./bots-api-url";
|
|
2
2
|
export { BOTS_API_URLS };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { HTTP_METHODS
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { HTTP_METHODS } from "../../../core/constants";
|
|
2
|
+
import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api";
|
|
3
|
+
import { createBaseUrl, createEndpoint } from "../base";
|
|
4
|
+
const BASE_URL = createBaseUrl('/channels/:channelId/agents');
|
|
4
5
|
const CHANNEL_AGENTS_API_URLS = {
|
|
5
|
-
LIST:
|
|
6
|
-
url: BASE_URL,
|
|
7
|
-
method: HTTP_METHODS.GET,
|
|
8
|
-
...GetChannelAgentsRequest
|
|
9
|
-
}
|
|
6
|
+
LIST: createEndpoint(BASE_URL, HTTP_METHODS.GET, getChannelAgentsRequest())
|
|
10
7
|
};
|
|
11
8
|
export default CHANNEL_AGENTS_API_URLS;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import CHANNEL_AGENTS_API_URLS from
|
|
1
|
+
import CHANNEL_AGENTS_API_URLS from "./channel-agents-api-url";
|
|
2
2
|
export { CHANNEL_AGENTS_API_URLS };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ModuleNames } from "../../core/constants";
|
|
2
|
+
import { BOTS_API_URLS } from "./bots";
|
|
3
|
+
import { CHANNEL_AGENTS_API_URLS } from "./channels";
|
|
4
|
+
import { SESSIONS_API_URLS } from "./sessions";
|
|
5
|
+
import selectn from 'selectn';
|
|
6
|
+
const urlMapping = {
|
|
7
|
+
[ModuleNames.BOTS]: BOTS_API_URLS,
|
|
8
|
+
[ModuleNames.CHANNELS]: {
|
|
9
|
+
agents: CHANNEL_AGENTS_API_URLS
|
|
10
|
+
},
|
|
11
|
+
[ModuleNames.SESSIONS]: SESSIONS_API_URLS
|
|
12
|
+
};
|
|
13
|
+
export function getUrlConfig(module) {
|
|
14
|
+
const urlConfig = selectn(module, urlMapping) || {};
|
|
15
|
+
return urlConfig;
|
|
16
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import SESSIONS_API_URLS from
|
|
1
|
+
import SESSIONS_API_URLS from "./sessions-api-url";
|
|
2
2
|
export { SESSIONS_API_URLS };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HTTP_METHODS
|
|
3
|
-
|
|
1
|
+
import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import { HTTP_METHODS } from "../../../core/constants";
|
|
3
|
+
import { createBaseUrl, createEndpoint } from "../base";
|
|
4
|
+
const BASE_URL = createBaseUrl('/sessions');
|
|
4
5
|
const SINGLE_SESSION_URL = `${BASE_URL}/:sessionId`;
|
|
5
6
|
const SESSIONS_API_URLS = {
|
|
6
|
-
UPDATE_SESSION_ASSIGNEE:
|
|
7
|
-
url: SINGLE_SESSION_URL,
|
|
8
|
-
method: HTTP_METHODS.PATCH,
|
|
9
|
-
...UpdateSessionAssigneeRequest
|
|
10
|
-
}
|
|
7
|
+
UPDATE_SESSION_ASSIGNEE: createEndpoint(SINGLE_SESSION_URL, HTTP_METHODS.PATCH, updateSessionAssigneeRequest())
|
|
11
8
|
};
|
|
12
9
|
export default SESSIONS_API_URLS;
|
package/es/core/errors/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import AdapterError from
|
|
2
|
-
import ValidationError from
|
|
1
|
+
import AdapterError from "./AdapterError";
|
|
2
|
+
import ValidationError from "./ValidationError";
|
|
3
3
|
export { ValidationError, AdapterError };
|
package/es/core/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { validateSchema } from
|
|
1
|
+
import { validateSchema } from "./validateSchema";
|
|
2
2
|
export { validateSchema };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { validateSchema } from
|
|
2
|
-
import { ActorSchema } from
|
|
1
|
+
import { validateSchema } from "../../../core/utils";
|
|
2
|
+
import { ActorSchema } from "../../schema";
|
|
3
3
|
export default class Actor {
|
|
4
4
|
constructor() {
|
|
5
5
|
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Actor from
|
|
1
|
+
import Actor from "./Actor";
|
|
2
2
|
export { Actor };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { validateSchema } from
|
|
2
|
-
import { AgentSchema } from
|
|
1
|
+
import { validateSchema } from "../../../core/utils";
|
|
2
|
+
import { AgentSchema } from "../../schema";
|
|
3
3
|
export default class Agent {
|
|
4
4
|
constructor() {
|
|
5
5
|
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Agent from
|
|
1
|
+
import Agent from "./Agent";
|
|
2
2
|
export { Agent };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { validateSchema } from
|
|
2
|
-
import { BotSchema } from
|
|
1
|
+
import { validateSchema } from "../../../core/utils";
|
|
2
|
+
import { BotSchema } from "../../schema";
|
|
3
3
|
export default class Bot {
|
|
4
4
|
constructor() {
|
|
5
5
|
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Bot from
|
|
1
|
+
import Bot from "./Bot";
|
|
2
2
|
export { Bot };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { validateSchema } from
|
|
2
|
-
import { SessionSchema } from
|
|
3
|
-
import { Actor } from
|
|
1
|
+
import { validateSchema } from "../../../core/utils";
|
|
2
|
+
import { SessionSchema } from "../../schema";
|
|
3
|
+
import { Actor } from "../Actor";
|
|
4
4
|
export default class Session {
|
|
5
5
|
constructor() {
|
|
6
6
|
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Session from
|
|
1
|
+
import Session from "./Session";
|
|
2
2
|
export { Session };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./Actor";
|
|
2
|
+
export * from "./Agent";
|
|
3
|
+
export * from "./Session";
|
|
4
|
+
export * from "./Bot";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ActorType from
|
|
1
|
+
import ActorType from "./ActorType";
|
|
2
2
|
export { ActorType };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BotServiceType from
|
|
1
|
+
import BotServiceType from "./BotServiceType";
|
|
2
2
|
export { BotServiceType };
|
package/es/domain/enum/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./integrationServices";
|
|
2
|
+
export * from "./session";
|
|
3
|
+
export * from "./actor";
|
|
4
|
+
export * from "./bot";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import IntegrationServices from
|
|
1
|
+
import IntegrationServices from "./IntegrationServices";
|
|
2
2
|
export { IntegrationServices };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import SessionReplyStatus from
|
|
2
|
-
import SessionStatus from
|
|
1
|
+
import SessionReplyStatus from "./SessionReplyStatus";
|
|
2
|
+
import SessionStatus from "./SessionStatus";
|
|
3
3
|
export { SessionStatus, SessionReplyStatus };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { configRegistry } from
|
|
1
|
+
import { configRegistry } from "../../infrastructure/sdk/config";
|
|
2
2
|
export default class BaseAPI {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.httpClient = configRegistry.getHttpClient();
|
|
@@ -55,7 +55,8 @@ export default class BaseAPI {
|
|
|
55
55
|
const httpRequest = await this.httpClient.request({
|
|
56
56
|
url,
|
|
57
57
|
method: urlConfig.method,
|
|
58
|
-
header: urlConfig.header
|
|
58
|
+
header: urlConfig.header,
|
|
59
|
+
payload: request.body || {}
|
|
59
60
|
});
|
|
60
61
|
return httpRequest;
|
|
61
62
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import BaseAPI from
|
|
1
|
+
import { getBotsRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
3
|
export default class IBot extends BaseAPI {
|
|
4
4
|
// eslint-disable-next-line no-unused-vars
|
|
5
5
|
async getBots() {
|
|
6
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
|
|
7
7
|
throw new Error('Method not implemented');
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import IBot from
|
|
1
|
+
import IBot from "./IBot";
|
|
2
2
|
export { IBot };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import BaseAPI from
|
|
1
|
+
import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
3
|
export default class IChannelAgent extends BaseAPI {
|
|
4
4
|
// eslint-disable-next-line no-unused-vars
|
|
5
5
|
getAgents() {
|
|
6
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
|
|
7
7
|
throw new Error('Method not implemented.');
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import IChannelAgent from
|
|
1
|
+
import IChannelAgent from "./IChannelAgent";
|
|
2
2
|
export { IChannelAgent };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./channels";
|
|
2
|
+
export * from "./sessions";
|
|
3
|
+
export * from "./bots";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import BaseAPI from
|
|
1
|
+
import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
3
|
export default class ISession extends BaseAPI {
|
|
4
4
|
// eslint-disable-next-line no-unused-vars
|
|
5
5
|
updateAssignee() {
|
|
6
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
|
|
7
7
|
throw new Error('Method not implemented.');
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ISession from
|
|
1
|
+
import ISession from "./ISession";
|
|
2
2
|
export { ISession };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import ActorSchema from
|
|
2
|
-
import AgentSchema from
|
|
1
|
+
import ActorSchema from "./ActorSchema";
|
|
2
|
+
import AgentSchema from "./AgentSchema";
|
|
3
3
|
export { ActorSchema, AgentSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BotSchema from
|
|
1
|
+
import BotSchema from "./BotSchema";
|
|
2
2
|
export { BotSchema };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./actor";
|
|
2
|
+
export * from "./session";
|
|
3
|
+
export * from "./bot";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IntegrationServices, SessionReplyStatus, SessionStatus } from
|
|
2
|
-
import { ActorSchema } from
|
|
1
|
+
import { IntegrationServices, SessionReplyStatus, SessionStatus } from "../../enum";
|
|
2
|
+
import { ActorSchema } from "../actor";
|
|
3
3
|
const SessionSchema = {
|
|
4
4
|
channelId: {
|
|
5
5
|
type: 'string',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import SessionSchema from
|
|
1
|
+
import SessionSchema from "./SessionSchema";
|
|
2
2
|
export { SessionSchema };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { getUrlConfig } from "../../../config/urls";
|
|
2
|
+
import { ModuleNames } from "../../../core/constants";
|
|
3
|
+
import { BotAdapter } from "../../../infrastructure/adapters";
|
|
4
|
+
import { BotAPI } from "../../../infrastructure/api";
|
|
5
|
+
import { getBotsRequest } from "../../../infrastructure/interfaces/api";
|
|
6
|
+
import { IBot } from "../../interfaces";
|
|
6
7
|
export default class BotService extends IBot {
|
|
7
8
|
constructor(_ref) {
|
|
8
9
|
let {
|
|
@@ -10,14 +11,15 @@ export default class BotService extends IBot {
|
|
|
10
11
|
botAdapter
|
|
11
12
|
} = _ref;
|
|
12
13
|
super();
|
|
14
|
+
const urlConfig = getUrlConfig(ModuleNames.BOTS);
|
|
13
15
|
this.botAPI = botAPI || new BotAPI({
|
|
14
|
-
urlConfig
|
|
16
|
+
urlConfig
|
|
15
17
|
});
|
|
16
18
|
this.botAdapter = botAdapter || new BotAdapter();
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
async getBots() {
|
|
20
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
22
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
|
|
21
23
|
const bots = await this.botAPI.getBots(request);
|
|
22
24
|
return bots.map(this.botAdapter.adapt);
|
|
23
25
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BotService from
|
|
1
|
+
import BotService from "./BotService";
|
|
2
2
|
export { BotService };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { getUrlConfig } from "../../../config/urls";
|
|
2
|
+
import { ModuleNames } from "../../../core/constants";
|
|
3
|
+
import { ChannelAgentAdapter } from "../../../infrastructure/adapters";
|
|
4
|
+
import { ChannelAgentAPI } from "../../../infrastructure/api";
|
|
5
|
+
import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api";
|
|
6
|
+
import { IChannelAgent } from "../../interfaces";
|
|
6
7
|
export default class ChannelAgentService extends IChannelAgent {
|
|
7
8
|
constructor(_ref) {
|
|
8
9
|
let {
|
|
@@ -10,14 +11,15 @@ export default class ChannelAgentService extends IChannelAgent {
|
|
|
10
11
|
channelAgentAdapter
|
|
11
12
|
} = _ref;
|
|
12
13
|
super();
|
|
14
|
+
const urlConfig = getUrlConfig(`${ModuleNames.CHANNELS}.agents`);
|
|
13
15
|
this.channelAgentAPI = channelAgentAPI || new ChannelAgentAPI({
|
|
14
|
-
urlConfig
|
|
16
|
+
urlConfig
|
|
15
17
|
});
|
|
16
18
|
this.channelAgentAdapter = channelAgentAdapter || new ChannelAgentAdapter();
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
async getAgents() {
|
|
20
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
22
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
|
|
21
23
|
const channelAgents = await this.channelAgentAPI.getAgents(request);
|
|
22
24
|
return channelAgents.map(this.channelAgentAdapter.adapt);
|
|
23
25
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ChannelAgentService from
|
|
1
|
+
import ChannelAgentService from "./ChannelAgentService";
|
|
2
2
|
export { ChannelAgentService };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./channels";
|
|
2
|
+
export * from "./sessions";
|
|
3
|
+
export * from "./bots";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { getUrlConfig } from "../../../config/urls";
|
|
2
|
+
import { ModuleNames } from "../../../core/constants";
|
|
3
|
+
import { SessionAdapter } from "../../../infrastructure/adapters";
|
|
4
|
+
import { SessionAPI } from "../../../infrastructure/api";
|
|
5
|
+
import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api";
|
|
6
|
+
import { ISession } from "../../interfaces";
|
|
6
7
|
export default class SessionService extends ISession {
|
|
7
8
|
constructor(_ref) {
|
|
8
9
|
let {
|
|
@@ -10,14 +11,15 @@ export default class SessionService extends ISession {
|
|
|
10
11
|
sessionAdapter
|
|
11
12
|
} = _ref;
|
|
12
13
|
super();
|
|
14
|
+
const urlConfig = getUrlConfig(ModuleNames.SESSIONS);
|
|
13
15
|
this.sessionAPI = sessionAPI || new SessionAPI({
|
|
14
|
-
urlConfig
|
|
16
|
+
urlConfig
|
|
15
17
|
});
|
|
16
18
|
this.sessionAdapter = sessionAdapter || new SessionAdapter();
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
async updateAssignee() {
|
|
20
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
22
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
|
|
21
23
|
const session = await this.sessionAPI.updateAssignee(request);
|
|
22
24
|
return this.sessionAdapter.adapt(session);
|
|
23
25
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import SessionService from
|
|
1
|
+
import SessionService from "./SessionService";
|
|
2
2
|
export { SessionService };
|
package/es/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
1
|
+
export * from "./domain/entities";
|
|
2
|
+
export * from "./domain/enum";
|
|
3
|
+
export * from "./domain/interfaces";
|
|
4
|
+
export * from "./domain/services";
|
|
5
|
+
export * from "./infrastructure/sdk";
|
|
6
|
+
export * from "./infrastructure/adapters";
|
|
7
|
+
export * from "./infrastructure/api";
|
|
8
|
+
export * from "./infrastructure/interfaces/api";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AdapterError } from
|
|
2
|
-
import { Bot } from
|
|
3
|
-
import BaseAdapter from
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Bot } from "../../../domain/entities";
|
|
3
|
+
import BaseAdapter from "../BaseAdapter";
|
|
4
4
|
export default class BotAdapter extends BaseAdapter {
|
|
5
5
|
static adapt(botData) {
|
|
6
6
|
if (!botData) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BotAdapter from
|
|
1
|
+
import BotAdapter from "./BotAdapter";
|
|
2
2
|
export { BotAdapter };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseAdapter from
|
|
2
|
-
import { AdapterError } from
|
|
3
|
-
import { Agent } from
|
|
1
|
+
import BaseAdapter from "../BaseAdapter";
|
|
2
|
+
import { AdapterError } from "../../../core/errors";
|
|
3
|
+
import { Agent } from "../../../domain/entities";
|
|
4
4
|
/**
|
|
5
5
|
* Adapter for Channel Agent data
|
|
6
6
|
* @extends BaseAdapter
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ChannelAgentAdapter from
|
|
1
|
+
import ChannelAgentAdapter from "./ChannelAgentAdapter";
|
|
2
2
|
export { ChannelAgentAdapter };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./channels";
|
|
2
|
+
export * from "./sessions";
|
|
3
|
+
export * from "./bots";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseAdapter from
|
|
2
|
-
import { AdapterError } from
|
|
3
|
-
import { Session } from
|
|
1
|
+
import BaseAdapter from "../BaseAdapter";
|
|
2
|
+
import { AdapterError } from "../../../core/errors";
|
|
3
|
+
import { Session } from "../../../domain/entities";
|
|
4
4
|
export default class SessionAdapter extends BaseAdapter {
|
|
5
5
|
static adapt(sessionData) {
|
|
6
6
|
if (!sessionData) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import SessionAdapter from
|
|
1
|
+
import SessionAdapter from "./SessionAdapter";
|
|
2
2
|
export { SessionAdapter };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBot } from
|
|
2
|
-
import {
|
|
1
|
+
import { IBot } from "../../../domain/interfaces";
|
|
2
|
+
import { getBotsRequest } from "../../interfaces/api";
|
|
3
3
|
export default class BotAPI extends IBot {
|
|
4
4
|
constructor(_ref) {
|
|
5
5
|
let {
|
|
@@ -10,7 +10,7 @@ export default class BotAPI extends IBot {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async getBots() {
|
|
13
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
13
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
|
|
14
14
|
const urlConfig = this.urlConfig.LIST;
|
|
15
15
|
const httpRequest = await this.request({
|
|
16
16
|
urlConfig,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BotAPI from
|
|
1
|
+
import BotAPI from "./BotAPI";
|
|
2
2
|
export { BotAPI };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import IChannelAgent from
|
|
2
|
-
import {
|
|
1
|
+
import IChannelAgent from "../../../domain/interfaces/channels/IChannelAgent";
|
|
2
|
+
import { getChannelAgentsRequest } from "../../interfaces/api";
|
|
3
3
|
export default class ChannelAgentAPI extends IChannelAgent {
|
|
4
4
|
constructor(_ref) {
|
|
5
5
|
let {
|
|
@@ -10,7 +10,7 @@ export default class ChannelAgentAPI extends IChannelAgent {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async getAgents() {
|
|
13
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
13
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
|
|
14
14
|
const urlConfig = this.urlConfig.LIST;
|
|
15
15
|
const httpRequest = await this.request({
|
|
16
16
|
urlConfig,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ChannelAgentAPI from
|
|
1
|
+
import ChannelAgentAPI from "./ChannelAgentAPI";
|
|
2
2
|
export { ChannelAgentAPI };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./channels";
|
|
2
|
+
export * from "./sessions";
|
|
3
|
+
export * from "./bots";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISession } from
|
|
2
|
-
import {
|
|
1
|
+
import { ISession } from "../../../domain/interfaces";
|
|
2
|
+
import { updateSessionAssigneeRequest } from "../../interfaces/api";
|
|
3
3
|
export default class SessionAPI extends ISession {
|
|
4
4
|
constructor(_ref) {
|
|
5
5
|
let {
|
|
@@ -10,7 +10,7 @@ export default class SessionAPI extends ISession {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async updateAssignee() {
|
|
13
|
-
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
13
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
|
|
14
14
|
const urlConfig = this.urlConfig.UPDATE_SESSION_ASSIGNEE;
|
|
15
15
|
const httpRequest = await this.request({
|
|
16
16
|
urlConfig,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import SessionAPI from
|
|
1
|
+
import SessionAPI from "./SessionAPI";
|
|
2
2
|
export { SessionAPI };
|
|
@@ -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,14 @@
|
|
|
1
|
+
import { RequestBuilder } from "../base";
|
|
2
|
+
|
|
3
|
+
function getBotsRequest() {
|
|
4
|
+
return new RequestBuilder().withQuery({
|
|
5
|
+
from: 0,
|
|
6
|
+
limit: 10,
|
|
7
|
+
modifiedAfter: null,
|
|
8
|
+
botServiceId: null,
|
|
9
|
+
externalAccountId: null,
|
|
10
|
+
searchStr: null
|
|
11
|
+
}).build();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default getBotsRequest;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
1
|
+
import getBotsRequest from "./getBotsRequest";
|
|
2
|
+
export { getBotsRequest };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RequestBuilder } from "../../base";
|
|
2
|
+
|
|
3
|
+
function getChannelAgentsRequest() {
|
|
4
|
+
return new RequestBuilder().withQuery({
|
|
5
|
+
from: 0,
|
|
6
|
+
limit: 10,
|
|
7
|
+
searchStr: null
|
|
8
|
+
}).withParams({
|
|
9
|
+
channelId: null
|
|
10
|
+
}).build();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default getChannelAgentsRequest;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
1
|
+
import getChannelAgentsRequest from "./getChannelAgentsRequest";
|
|
2
|
+
export { getChannelAgentsRequest };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./agents";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./channels";
|
|
2
|
+
export * from "./sessions";
|
|
3
|
+
export * from "./bots";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
1
|
+
import updateSessionAssigneeRequest from "./updateSessionAssigneeRequest";
|
|
2
|
+
export { updateSessionAssigneeRequest };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RequestBuilder } from "../base";
|
|
2
|
+
|
|
3
|
+
function updateSessionAssigneeRequest() {
|
|
4
|
+
return new RequestBuilder().withParams({
|
|
5
|
+
channelId: null
|
|
6
|
+
}).withBody({
|
|
7
|
+
agentId: null,
|
|
8
|
+
botId: null
|
|
9
|
+
}).build();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default updateSessionAssigneeRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./api";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModuleNames } from
|
|
2
|
-
import { BotSDK } from
|
|
3
|
-
import { ChannelSDK } from
|
|
4
|
-
import { SessionSDK } from
|
|
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
5
|
const ModuleFactory = {
|
|
6
6
|
[ModuleNames.CHANNELS]: _ref => {
|
|
7
7
|
let {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ModuleNames } from
|
|
2
|
-
import ModuleFactory from
|
|
1
|
+
import { ModuleNames } from "../../core/constants";
|
|
2
|
+
import ModuleFactory from "./ModuleFactory";
|
|
3
3
|
export default class ModuleManager {
|
|
4
4
|
constructor() {
|
|
5
5
|
this._modules = new Map();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ModuleManager from
|
|
1
|
+
import ModuleManager from "./ModuleManager";
|
|
2
2
|
export { ModuleManager };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ModuleNames } from
|
|
2
|
-
import { ModuleManager } from
|
|
3
|
-
import { configRegistry } from
|
|
1
|
+
import { ModuleNames } from "../../core/constants";
|
|
2
|
+
import { ModuleManager } from "../managers";
|
|
3
|
+
import { configRegistry } from "./config";
|
|
4
4
|
export default class IMSDK {
|
|
5
5
|
constructor(_ref) {
|
|
6
6
|
let {
|
|
@@ -32,7 +32,7 @@ export default class IMSDK {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
hasModule(moduleName) {
|
|
35
|
-
return this.
|
|
35
|
+
return this._moduleManager.hasModule(moduleName);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
toJSON() {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BotSDK from
|
|
1
|
+
import BotSDK from "./BotSDK";
|
|
2
2
|
export { BotSDK };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ChannelSDK from
|
|
1
|
+
import ChannelSDK from "./ChannelSDK";
|
|
2
2
|
export { ChannelSDK };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import configRegistry from
|
|
1
|
+
import configRegistry from "./configRegistry";
|
|
2
2
|
export { configRegistry };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import IMSDK from
|
|
1
|
+
import IMSDK from "./IMSDK";
|
|
2
2
|
export { IMSDK };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import SessionSDK from
|
|
1
|
+
import SessionSDK from "./SessionSDK";
|
|
2
2
|
export { SessionSDK };
|
package/package.json
CHANGED