@zohoim/client-sdk 1.0.0-poc4 → 1.0.0-poc40
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 +10 -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,86 @@
|
|
|
1
|
+
import { getRegistryConfig } from "../../config/registry";
|
|
2
|
+
import { configRegistry } from "../../infrastructure/sdk/config";
|
|
3
|
+
export default class BaseAPI {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
module
|
|
7
|
+
} = _ref;
|
|
8
|
+
this.httpClient = configRegistry.getHttpClient();
|
|
9
|
+
this.baseURL = configRegistry.getBaseURL();
|
|
10
|
+
this.module = module;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
replacePathParams(url, params) {
|
|
14
|
+
let _url = url;
|
|
15
|
+
Object.entries(params).forEach(_ref2 => {
|
|
16
|
+
let [key, value] = _ref2;
|
|
17
|
+
_url = url.replace(`:${key}`, value);
|
|
18
|
+
});
|
|
19
|
+
return _url;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
buildUrl(_ref3) {
|
|
23
|
+
let {
|
|
24
|
+
url,
|
|
25
|
+
params,
|
|
26
|
+
query
|
|
27
|
+
} = _ref3;
|
|
28
|
+
|
|
29
|
+
const _params = params || {};
|
|
30
|
+
|
|
31
|
+
const _query = query || {};
|
|
32
|
+
|
|
33
|
+
let _url = this.replacePathParams(url, _params);
|
|
34
|
+
|
|
35
|
+
if (this.baseURL) {
|
|
36
|
+
_url = `${this.baseURL}${_url}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const queryString = this.buildQuery(_query);
|
|
40
|
+
|
|
41
|
+
if (queryString) {
|
|
42
|
+
return `${_url}?${queryString}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return _url;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
buildQuery(query) {
|
|
49
|
+
const filteredQuery = Object.entries(query).filter(_ref4 => {
|
|
50
|
+
let [, value] = _ref4;
|
|
51
|
+
return value !== undefined && value !== null && value !== '';
|
|
52
|
+
}).reduce((acc, _ref5) => {
|
|
53
|
+
let [key, value] = _ref5;
|
|
54
|
+
acc[key] = value;
|
|
55
|
+
return acc;
|
|
56
|
+
}, {});
|
|
57
|
+
return new URLSearchParams(filteredQuery).toString();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async request(_ref6) {
|
|
61
|
+
let {
|
|
62
|
+
request,
|
|
63
|
+
operation,
|
|
64
|
+
header
|
|
65
|
+
} = _ref6;
|
|
66
|
+
const config = getRegistryConfig(this.module, operation);
|
|
67
|
+
|
|
68
|
+
if (!config) {
|
|
69
|
+
throw new Error(`Operation "${operation}" not found in registry for module "${this.module}"`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const url = this.buildUrl({
|
|
73
|
+
url: config.endpoint,
|
|
74
|
+
params: request.params || {},
|
|
75
|
+
query: request.query || {}
|
|
76
|
+
});
|
|
77
|
+
const httpRequest = await this.httpClient.request({
|
|
78
|
+
url,
|
|
79
|
+
method: config.method,
|
|
80
|
+
header,
|
|
81
|
+
payload: request.body || {}
|
|
82
|
+
});
|
|
83
|
+
return httpRequest;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getBotsRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
|
+
export default class IBot extends BaseAPI {
|
|
4
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
|
+
async getBots() {
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
|
|
7
|
+
throw new Error('Method not implemented');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getChannelsRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
|
+
export default class IChannel extends BaseAPI {
|
|
4
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
|
+
getChannels() {
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelsRequest();
|
|
7
|
+
throw new Error('Method not implemented.');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
|
+
export default class IChannelAgent extends BaseAPI {
|
|
4
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
|
+
getAgents() {
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
|
|
3
7
|
throw new Error('Method not implemented.');
|
|
4
8
|
}
|
|
5
9
|
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import IChannel from "./IChannel";
|
|
2
|
+
import IChannelAgent from "./IChannelAgent";
|
|
3
|
+
export { IChannel, IChannelAgent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
|
+
export default class ISession extends BaseAPI {
|
|
4
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
|
+
updateAssignee() {
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
|
|
7
|
+
throw new Error('Method not implemented.');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ActorType } from "../../enum";
|
|
2
|
+
const ActorSchema = {
|
|
3
|
+
name: {
|
|
4
|
+
type: 'string',
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
type: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true,
|
|
10
|
+
enum: Object.values(ActorType)
|
|
11
|
+
},
|
|
12
|
+
photoURL: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: false
|
|
15
|
+
},
|
|
16
|
+
extId: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
20
|
+
id: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
email: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: false
|
|
27
|
+
},
|
|
28
|
+
botType: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: false
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default ActorSchema;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ActorType } from "../../enum";
|
|
2
|
+
const AgentSchema = {
|
|
3
|
+
id: {
|
|
4
|
+
type: 'string',
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
name: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
email: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
photoURL: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
required: false
|
|
18
|
+
},
|
|
19
|
+
zuid: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
type: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
required: true,
|
|
26
|
+
enum: [ActorType.AGENT]
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export default AgentSchema;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BotServiceType } from "../../enum";
|
|
2
|
+
const BotSchema = {
|
|
3
|
+
id: {
|
|
4
|
+
type: 'string',
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
botServiceType: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true,
|
|
10
|
+
enum: [BotServiceType.DESK_GC_BOT, BotServiceType.DESK_ZIA_BOT, BotServiceType.ZOHO_GC_BOT, BotServiceType.ZOHO_ZIA_BOT]
|
|
11
|
+
},
|
|
12
|
+
name: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
isActive: {
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
createdTime: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
photoURL: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: false
|
|
27
|
+
},
|
|
28
|
+
createdBy: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: true
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default BotSchema;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IntegrationServiceSchema } from "../integrationService";
|
|
2
|
+
const ChannelSchema = {
|
|
3
|
+
id: {
|
|
4
|
+
type: 'string',
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
integrationService: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
required: true,
|
|
10
|
+
schema: IntegrationServiceSchema
|
|
11
|
+
},
|
|
12
|
+
name: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
defaultBotId: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
20
|
+
isActive: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
createdTime: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
accountName: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: false
|
|
31
|
+
},
|
|
32
|
+
isSubscribed: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
required: false
|
|
35
|
+
},
|
|
36
|
+
createdBy: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
required: false
|
|
39
|
+
},
|
|
40
|
+
isOwner: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
44
|
+
photoURL: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
required: false
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export default ChannelSchema;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IntegrationServices } from "../../enum";
|
|
2
|
+
const IntegrationServiceSchema = {
|
|
3
|
+
label: {
|
|
4
|
+
type: 'string',
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
id: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true,
|
|
10
|
+
enum: Object.values(IntegrationServices)
|
|
11
|
+
},
|
|
12
|
+
provider: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
required: true,
|
|
15
|
+
schema: {
|
|
16
|
+
name: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
domain: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
logoURL: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
required: false
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export default IntegrationServiceSchema;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { IntegrationServices, SessionReplyStatus, SessionStatus } from "../../enum";
|
|
2
|
+
import { ActorSchema } from "../actor";
|
|
3
|
+
const SessionSchema = {
|
|
4
|
+
channelId: {
|
|
5
|
+
type: 'string',
|
|
6
|
+
required: true
|
|
7
|
+
},
|
|
8
|
+
status: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
required: true,
|
|
11
|
+
enum: Object.values(SessionStatus)
|
|
12
|
+
},
|
|
13
|
+
createdTime: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
agentId: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
required: false
|
|
20
|
+
},
|
|
21
|
+
botId: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
required: false
|
|
24
|
+
},
|
|
25
|
+
actor: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
required: true,
|
|
28
|
+
schema: ActorSchema
|
|
29
|
+
},
|
|
30
|
+
subject: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
messagesCount: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
required: true
|
|
37
|
+
},
|
|
38
|
+
agentLastActiveTime: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
required: true
|
|
41
|
+
},
|
|
42
|
+
contactLastActiveTime: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
required: true
|
|
45
|
+
},
|
|
46
|
+
lastActiveTime: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
required: true
|
|
49
|
+
},
|
|
50
|
+
unreadMessagesCount: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
required: true
|
|
53
|
+
},
|
|
54
|
+
integrationServiceId: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
required: true,
|
|
57
|
+
enum: Object.values(IntegrationServices)
|
|
58
|
+
},
|
|
59
|
+
replyStatus: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
required: true,
|
|
62
|
+
enum: Object.values(SessionReplyStatus)
|
|
63
|
+
},
|
|
64
|
+
id: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
required: true
|
|
67
|
+
},
|
|
68
|
+
contactId: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
required: true
|
|
71
|
+
},
|
|
72
|
+
meta: {
|
|
73
|
+
type: 'array',
|
|
74
|
+
required: false
|
|
75
|
+
},
|
|
76
|
+
assignee: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
required: false,
|
|
79
|
+
schema: ActorSchema
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export default SessionSchema;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ResponseUtils } from "../../../core/utils";
|
|
2
|
+
import { BotAdapter } from "../../../infrastructure/adapters";
|
|
3
|
+
import { BotAPI } from "../../../infrastructure/api";
|
|
4
|
+
import { IBot } from "../../interfaces";
|
|
5
|
+
export default class BotService extends IBot {
|
|
6
|
+
constructor(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
botAPI,
|
|
9
|
+
botAdapter
|
|
10
|
+
} = _ref;
|
|
11
|
+
super();
|
|
12
|
+
this.botAPI = botAPI || new BotAPI();
|
|
13
|
+
this.botAdapter = botAdapter || new BotAdapter();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getBots(request) {
|
|
17
|
+
const response = await this.botAPI.getBots(request);
|
|
18
|
+
return ResponseUtils.adaptListResponse(response, this.botAdapter.adapt);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
toJSON() {
|
|
22
|
+
return {
|
|
23
|
+
getBots: this.getBots.bind(this)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ResponseUtils } from "../../../core/utils";
|
|
2
|
+
import { ChannelAgentAdapter } from "../../../infrastructure/adapters";
|
|
3
|
+
import { ChannelAgentAPI } from "../../../infrastructure/api";
|
|
4
|
+
import { IChannelAgent } from "../../interfaces";
|
|
2
5
|
export default class ChannelAgentService extends IChannelAgent {
|
|
3
|
-
constructor(
|
|
6
|
+
constructor(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
channelAgentAPI,
|
|
9
|
+
channelAgentAdapter
|
|
10
|
+
} = _ref;
|
|
4
11
|
super();
|
|
5
|
-
this.
|
|
6
|
-
this.channelAgentAdapter = channelAgentAdapter;
|
|
12
|
+
this.channelAgentAPI = channelAgentAPI || new ChannelAgentAPI();
|
|
13
|
+
this.channelAgentAdapter = channelAgentAdapter || new ChannelAgentAdapter();
|
|
7
14
|
}
|
|
8
15
|
|
|
9
|
-
async
|
|
10
|
-
const
|
|
11
|
-
return
|
|
16
|
+
async getAgents(request) {
|
|
17
|
+
const response = await this.channelAgentAPI.getAgents(request);
|
|
18
|
+
return ResponseUtils.adaptListResponse(response, this.channelAgentAdapter.adapt);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
toJSON() {
|
|
22
|
+
return {
|
|
23
|
+
getAgents: this.getAgents.bind(this)
|
|
24
|
+
};
|
|
12
25
|
}
|
|
13
26
|
|
|
14
27
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ResponseUtils } from "../../../core/utils";
|
|
2
|
+
import { ChannelAdapter } from "../../../infrastructure/adapters";
|
|
3
|
+
import { ChannelAPI } from "../../../infrastructure/api";
|
|
4
|
+
import { IChannel } from "../../interfaces";
|
|
5
|
+
export default class ChannelService extends IChannel {
|
|
6
|
+
constructor() {
|
|
7
|
+
let {
|
|
8
|
+
channelAPI,
|
|
9
|
+
channelAdapter
|
|
10
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
|
+
super();
|
|
12
|
+
this.channelAPI = channelAPI || new ChannelAPI();
|
|
13
|
+
this.channelAdapter = channelAdapter || new ChannelAdapter();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getChannels(request) {
|
|
17
|
+
const response = await this.channelAPI.getChannels(request);
|
|
18
|
+
return ResponseUtils.adaptListResponse(response, this.channelAdapter.adapt);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
toJSON() {
|
|
22
|
+
return {
|
|
23
|
+
getChannels: this.getChannels.bind(this)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import ChannelAgentService from
|
|
2
|
-
|
|
1
|
+
import ChannelAgentService from "./ChannelAgentService";
|
|
2
|
+
import ChannelService from "./ChannelService";
|
|
3
|
+
export { ChannelAgentService, ChannelService };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ResponseUtils } from "../../../core/utils";
|
|
2
|
+
import { SessionAdapter } from "../../../infrastructure/adapters";
|
|
3
|
+
import { SessionAPI } from "../../../infrastructure/api";
|
|
4
|
+
import { ISession } from "../../interfaces";
|
|
5
|
+
export default class SessionService extends ISession {
|
|
6
|
+
constructor(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
sessionAPI,
|
|
9
|
+
sessionAdapter
|
|
10
|
+
} = _ref;
|
|
11
|
+
super();
|
|
12
|
+
this.sessionAPI = sessionAPI || new SessionAPI();
|
|
13
|
+
this.sessionAdapter = sessionAdapter || new SessionAdapter();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async updateAssignee(request) {
|
|
17
|
+
const response = await this.sessionAPI.updateAssignee(request);
|
|
18
|
+
return ResponseUtils.adaptSingleResponse(response, this.sessionAdapter.adapt);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
toJSON() {
|
|
22
|
+
return {
|
|
23
|
+
updateAssignee: this.updateAssignee.bind(this)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
package/es/index.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
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";
|
|
9
|
+
export * from "./core/constants";
|
|
10
|
+
export * from "./config/urls/base";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Bot } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
export default class BotAdapter extends IAdapter {
|
|
5
|
+
adapt(botData) {
|
|
6
|
+
if (!botData) {
|
|
7
|
+
throw new AdapterError('Bot data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Bot({
|
|
12
|
+
id: botData.id,
|
|
13
|
+
botServiceType: botData.botService.id,
|
|
14
|
+
name: botData.name,
|
|
15
|
+
isActive: botData.isActive,
|
|
16
|
+
createdTime: botData.createdTime,
|
|
17
|
+
photoURL: botData.logoURL,
|
|
18
|
+
createdBy: botData.createdBy
|
|
19
|
+
}).toJSON();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new AdapterError(`Failed to adapt bot: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Channel } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
export default class ChannelAdapter extends IAdapter {
|
|
5
|
+
adapt(rawChannel) {
|
|
6
|
+
if (!rawChannel) {
|
|
7
|
+
throw new AdapterError('Channel data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Channel({
|
|
12
|
+
id: rawChannel.id,
|
|
13
|
+
integrationService: rawChannel.integrationService,
|
|
14
|
+
name: rawChannel.name,
|
|
15
|
+
defaultBotId: rawChannel.defaultBotId,
|
|
16
|
+
isActive: rawChannel.isActive,
|
|
17
|
+
createdTime: rawChannel.createdTime,
|
|
18
|
+
accountName: rawChannel.accountName,
|
|
19
|
+
isSubscribed: rawChannel.isSubscribed,
|
|
20
|
+
createdBy: rawChannel.createdBy,
|
|
21
|
+
isOwner: rawChannel.isOwner,
|
|
22
|
+
photoURL: rawChannel.logoURL
|
|
23
|
+
}).toJSON();
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw new AdapterError(`Failed to adapt channel: ${error.message}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|