@zohoim/client-sdk 1.0.0-poc19 → 1.0.0-poc20

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.
Files changed (37) hide show
  1. package/es/config/urls/bots/bots-api-url.js +11 -0
  2. package/es/config/urls/bots/index.js +2 -0
  3. package/es/config/urls/sessions/index.js +2 -0
  4. package/es/core/constants/ModuleNames.js +2 -1
  5. package/es/domain/entities/Bot/Bot.js +23 -0
  6. package/es/domain/entities/Bot/index.js +2 -0
  7. package/es/domain/entities/index.js +2 -1
  8. package/es/domain/enum/bot/BotServiceType.js +5 -0
  9. package/es/domain/enum/bot/index.js +2 -0
  10. package/es/domain/enum/index.js +2 -1
  11. package/es/domain/interfaces/bots/IBot.js +10 -0
  12. package/es/domain/interfaces/bots/index.js +2 -0
  13. package/es/domain/interfaces/index.js +2 -1
  14. package/es/domain/schema/bot/BotSchema.js +33 -0
  15. package/es/domain/schema/bot/index.js +2 -0
  16. package/es/domain/schema/index.js +2 -1
  17. package/es/domain/services/bots/BotService.js +31 -0
  18. package/es/domain/services/bots/index.js +2 -0
  19. package/es/domain/services/index.js +3 -1
  20. package/es/domain/services/sessions/SessionService.js +3 -3
  21. package/es/infrastructure/adapters/bots/BotAdapter.js +25 -0
  22. package/es/infrastructure/adapters/bots/index.js +2 -0
  23. package/es/infrastructure/adapters/index.js +2 -1
  24. package/es/infrastructure/api/bots/BotAPI.js +22 -0
  25. package/es/infrastructure/api/bots/index.js +2 -0
  26. package/es/infrastructure/api/index.js +3 -1
  27. package/es/infrastructure/interfaces/api/bots/GetBotsRequest.js +14 -0
  28. package/es/infrastructure/interfaces/api/bots/index.js +2 -0
  29. package/es/infrastructure/interfaces/api/index.js +2 -1
  30. package/es/infrastructure/managers/ModuleFactory.js +9 -0
  31. package/es/infrastructure/managers/ModuleManager.js +1 -1
  32. package/es/infrastructure/sdk/IMSDK.js +5 -0
  33. package/es/infrastructure/sdk/bots/BotSDK.js +20 -0
  34. package/es/infrastructure/sdk/bots/index.js +2 -0
  35. package/es/infrastructure/sdk/sessions/SessionSDK.js +1 -1
  36. package/package.json +1 -1
  37. package/es/config/urls/index.js +0 -1
@@ -0,0 +1,11 @@
1
+ import { HTTP_METHODS, IM_API_PREFIX } from '../../../core/constants';
2
+ import { GetBotsRequest } from '../../../infrastructure/interfaces/api';
3
+ const BASE_URL = `${IM_API_PREFIX}/bots`;
4
+ const BOTS_API_URLS = {
5
+ LIST: {
6
+ url: BASE_URL,
7
+ method: HTTP_METHODS.GET,
8
+ ...GetBotsRequest
9
+ }
10
+ };
11
+ export default BOTS_API_URLS;
@@ -0,0 +1,2 @@
1
+ import BOTS_API_URLS from './bots-api-url';
2
+ export { BOTS_API_URLS };
@@ -0,0 +1,2 @@
1
+ import SESSIONS_API_URLS from './sessions-api-url';
2
+ export { SESSIONS_API_URLS };
@@ -1,5 +1,6 @@
1
1
  const ModuleNames = {
2
2
  CHANNELS: 'channels',
3
- SESSIONS: 'sessions'
3
+ SESSIONS: 'sessions',
4
+ BOTS: 'bots'
4
5
  };
5
6
  export default ModuleNames;
@@ -0,0 +1,23 @@
1
+ import { validateSchema } from '../../../core/utils';
2
+ import { BotSchema } from '../../schema';
3
+ export default class Bot {
4
+ constructor() {
5
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
+ const validatedData = validateSchema(BotSchema, data);
7
+ this.data = {
8
+ id: validatedData.id,
9
+ botServiceType: validatedData.botService,
10
+ name: validatedData.name,
11
+ isActive: validatedData.isActive,
12
+ createdTime: validatedData.createdTime,
13
+ logoURL: validatedData.logoURL,
14
+ createdBy: validatedData.createdBy
15
+ };
16
+ }
17
+
18
+ toJSON() {
19
+ return { ...this.data
20
+ };
21
+ }
22
+
23
+ }
@@ -0,0 +1,2 @@
1
+ import Bot from './Bot';
2
+ export { Bot };
@@ -1,3 +1,4 @@
1
1
  export * from './Actor';
2
2
  export * from './Agent';
3
- export * from './Session';
3
+ export * from './Session';
4
+ export * from './Bot';
@@ -0,0 +1,5 @@
1
+ const BotServiceType = {
2
+ DESK_GC_BOT: 'DESK_GC_BOT',
3
+ DESK_ZIA_BOT: 'DESK_ZIA_BOT'
4
+ };
5
+ export default BotServiceType;
@@ -0,0 +1,2 @@
1
+ import BotServiceType from './BotServiceType';
2
+ export { BotServiceType };
@@ -1,3 +1,4 @@
1
1
  export * from './integrationServices';
2
2
  export * from './session';
3
- export * from './actor';
3
+ export * from './actor';
4
+ export * from './bot';
@@ -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,2 @@
1
+ import IBot from './IBot';
2
+ export { IBot };
@@ -1,2 +1,3 @@
1
1
  export * from './channels';
2
- export * from './sessions';
2
+ export * from './sessions';
3
+ export * from './bots';
@@ -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]
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
+ logoURL: {
25
+ type: 'string',
26
+ required: true
27
+ },
28
+ createdBy: {
29
+ type: 'string',
30
+ required: true
31
+ }
32
+ };
33
+ export default BotSchema;
@@ -0,0 +1,2 @@
1
+ import BotSchema from './BotSchema';
2
+ export { BotSchema };
@@ -1,2 +1,3 @@
1
1
  export * from './actor';
2
- export * from './session';
2
+ export * from './session';
3
+ export * from './bot';
@@ -0,0 +1,31 @@
1
+ import { BOTS_API_URLS } from '../../../config/urls/bots';
2
+ import { BotAdapter } from '../../../infrastructure/adapters';
3
+ import { BotAPI } from '../../../infrastructure/api';
4
+ import { GetBotsRequest } from '../../../infrastructure/interfaces/api';
5
+ import { IBot } from '../../interfaces';
6
+ export default class BotService extends IBot {
7
+ constructor(_ref) {
8
+ let {
9
+ botAPI,
10
+ botAdapter
11
+ } = _ref;
12
+ super();
13
+ this.botAPI = botAPI || new BotAPI({
14
+ urlConfig: BOTS_API_URLS
15
+ });
16
+ this.botAdapter = botAdapter || new BotAdapter();
17
+ }
18
+
19
+ async getBots() {
20
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
21
+ const bots = await this.botAPI.getBots(request);
22
+ return bots.map(this.botAdapter.adapt);
23
+ }
24
+
25
+ toJSON() {
26
+ return {
27
+ getBots: this.getBots.bind(this)
28
+ };
29
+ }
30
+
31
+ }
@@ -0,0 +1,2 @@
1
+ import BotService from './BotService';
2
+ export { BotService };
@@ -1 +1,3 @@
1
- export * from './channels';
1
+ export * from './channels';
2
+ export * from './sessions';
3
+ export * from './bots';
@@ -1,6 +1,6 @@
1
- import SESSIONS_API_URLS from '../../../config/urls/sessions/sessions-api-url';
1
+ import { SESSIONS_API_URLS } from '../../../config/urls/sessions';
2
2
  import { SessionAdapter } from '../../../infrastructure/adapters';
3
- import { SessionAPI } from '../../../infrastructure/api/sessions';
3
+ import { SessionAPI } from '../../../infrastructure/api';
4
4
  import { UpdateSessionAssigneeRequest } from '../../../infrastructure/interfaces/api';
5
5
  import { ISession } from '../../interfaces';
6
6
  export default class SessionService extends ISession {
@@ -19,7 +19,7 @@ export default class SessionService extends ISession {
19
19
  async updateAssignee() {
20
20
  let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UpdateSessionAssigneeRequest;
21
21
  const session = await this.sessionAPI.updateAssignee(request);
22
- return this.channelAgentAdapter.adapt(session);
22
+ return this.sessionAdapter.adapt(session);
23
23
  }
24
24
 
25
25
  toJSON() {
@@ -0,0 +1,25 @@
1
+ import { AdapterError } from '../../../core/errors';
2
+ import { Bot } from '../../../domain/entities';
3
+ import BaseAdapter from '../BaseAdapter';
4
+ export default class BotAdapter extends BaseAdapter {
5
+ static 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
+ logoURL: 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,2 @@
1
+ import BotAdapter from './BotAdapter';
2
+ export { BotAdapter };
@@ -1,2 +1,3 @@
1
1
  export * from './channels';
2
- export * from './sessions';
2
+ export * from './sessions';
3
+ export * from './bots';
@@ -0,0 +1,22 @@
1
+ import { IBot } from '../../../domain/interfaces';
2
+ import { GetBotsRequest } from '../../interfaces/api';
3
+ export default class BotAPI extends IBot {
4
+ constructor(_ref) {
5
+ let {
6
+ urlConfig
7
+ } = _ref;
8
+ super();
9
+ this.urlConfig = urlConfig;
10
+ }
11
+
12
+ async getBots() {
13
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
14
+ const urlConfig = this.urlConfig.LIST;
15
+ const httpRequest = await this.request({
16
+ urlConfig,
17
+ request
18
+ });
19
+ return httpRequest;
20
+ }
21
+
22
+ }
@@ -0,0 +1,2 @@
1
+ import BotAPI from './BotAPI';
2
+ export { BotAPI };
@@ -1 +1,3 @@
1
- export * from './channels';
1
+ export * from './channels';
2
+ export * from './sessions';
3
+ export * from './bots';
@@ -0,0 +1,14 @@
1
+ const params = {};
2
+ const query = {
3
+ from: 0,
4
+ limit: 10,
5
+ modifiedAfter: null,
6
+ botServiceId: null,
7
+ externalAccountId: null,
8
+ searchStr: null
9
+ };
10
+ const GetBotsRequest = {
11
+ params,
12
+ query
13
+ };
14
+ export default GetBotsRequest;
@@ -0,0 +1,2 @@
1
+ import GetBotsRequest from './GetBotsRequest';
2
+ export { GetBotsRequest };
@@ -1,2 +1,3 @@
1
1
  export * from './channels';
2
- export * from './sessions';
2
+ export * from './sessions';
3
+ export * from './bots';
@@ -1,4 +1,5 @@
1
1
  import { ModuleNames } from '../../core/constants';
2
+ import { BotSDK } from '../sdk/bots';
2
3
  import { ChannelSDK } from '../sdk/channels';
3
4
  import { SessionSDK } from '../sdk/sessions';
4
5
  const ModuleFactory = {
@@ -17,6 +18,14 @@ const ModuleFactory = {
17
18
  return new SessionSDK({
18
19
  config
19
20
  }).toJSON();
21
+ },
22
+ [ModuleNames.BOTS]: _ref3 => {
23
+ let {
24
+ config
25
+ } = _ref3;
26
+ return new BotSDK({
27
+ config
28
+ }).toJSON();
20
29
  }
21
30
  };
22
31
  export default ModuleFactory;
@@ -3,7 +3,7 @@ import ModuleFactory from './ModuleFactory';
3
3
  export default class ModuleManager {
4
4
  constructor() {
5
5
  this._modules = new Map();
6
- this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS];
6
+ this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS];
7
7
  }
8
8
 
9
9
  initialize(_ref) {
@@ -27,6 +27,10 @@ export default class IMSDK {
27
27
  return this._moduleManager.getModule(ModuleNames.SESSIONS);
28
28
  }
29
29
 
30
+ get bots() {
31
+ return this._moduleManager.getModule(ModuleNames.BOTS);
32
+ }
33
+
30
34
  hasModule(moduleName) {
31
35
  return this._modules.has(moduleName);
32
36
  }
@@ -35,6 +39,7 @@ export default class IMSDK {
35
39
  return {
36
40
  channels: this.channels,
37
41
  sessions: this.sessions,
42
+ bots: this.bots,
38
43
  hasModule: this.hasModule.bind(this)
39
44
  };
40
45
  }
@@ -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,2 @@
1
+ import BotSDK from './BotSDK';
2
+ export { BotSDK };
@@ -1,4 +1,4 @@
1
- import { SessionService } from '../../../domain/services/sessions';
1
+ import { SessionService } from '../../../domain/services';
2
2
 
3
3
  class SessionSDK extends SessionService {
4
4
  constructor(_ref) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "1.0.0-poc19",
3
+ "version": "1.0.0-poc20",
4
4
  "description": "To have the client sdk for the IM",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",
@@ -1 +0,0 @@
1
- export * from './channels';