@or-sdk/hitl 0.35.0-beta.2816.0 → 0.35.0

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 (219) hide show
  1. package/CHANGELOG.md +271 -0
  2. package/README.md +65 -0
  3. package/dist/cjs/AppError.js.map +1 -1
  4. package/dist/cjs/EKS.js.map +1 -1
  5. package/dist/cjs/HITL.js +1 -1
  6. package/dist/cjs/HITL.js.map +1 -1
  7. package/dist/cjs/api/Agents.js +108 -104
  8. package/dist/cjs/api/Agents.js.map +1 -1
  9. package/dist/cjs/api/CannedMessages.js +54 -40
  10. package/dist/cjs/api/CannedMessages.js.map +1 -1
  11. package/dist/cjs/api/Commands.js +31 -16
  12. package/dist/cjs/api/Commands.js.map +1 -1
  13. package/dist/cjs/api/Conferences.js +44 -31
  14. package/dist/cjs/api/Conferences.js.map +1 -1
  15. package/dist/cjs/api/ContactRuleGroups.js +56 -33
  16. package/dist/cjs/api/ContactRuleGroups.js.map +1 -1
  17. package/dist/cjs/api/Contacts.js +14 -7
  18. package/dist/cjs/api/Contacts.js.map +1 -1
  19. package/dist/cjs/api/ContactsMeta.js +19 -9
  20. package/dist/cjs/api/ContactsMeta.js.map +1 -1
  21. package/dist/cjs/api/EventTemplates.js +55 -37
  22. package/dist/cjs/api/EventTemplates.js.map +1 -1
  23. package/dist/cjs/api/Filters.js +48 -45
  24. package/dist/cjs/api/Filters.js.map +1 -1
  25. package/dist/cjs/api/HITLBase.js +4 -0
  26. package/dist/cjs/api/HITLBase.js.map +1 -1
  27. package/dist/cjs/api/Helpers.js +14 -6
  28. package/dist/cjs/api/Helpers.js.map +1 -1
  29. package/dist/cjs/api/Listeners.js +58 -44
  30. package/dist/cjs/api/Listeners.js.map +1 -1
  31. package/dist/cjs/api/Migrations.js +66 -57
  32. package/dist/cjs/api/Migrations.js.map +1 -1
  33. package/dist/cjs/api/RuleGroups.js +56 -33
  34. package/dist/cjs/api/RuleGroups.js.map +1 -1
  35. package/dist/cjs/api/SessionEvents.js +66 -40
  36. package/dist/cjs/api/SessionEvents.js.map +1 -1
  37. package/dist/cjs/api/SessionRelations.js +26 -21
  38. package/dist/cjs/api/SessionRelations.js.map +1 -1
  39. package/dist/cjs/api/Sessions.js +128 -126
  40. package/dist/cjs/api/Sessions.js.map +1 -1
  41. package/dist/cjs/api/Settings.js +76 -35
  42. package/dist/cjs/api/Settings.js.map +1 -1
  43. package/dist/cjs/api/Tasks.js +28 -16
  44. package/dist/cjs/api/Tasks.js.map +1 -1
  45. package/dist/cjs/api/Versions.js +15 -8
  46. package/dist/cjs/api/Versions.js.map +1 -1
  47. package/dist/cjs/constants.js +2 -1
  48. package/dist/cjs/constants.js.map +1 -1
  49. package/dist/cjs/index.js +21 -1
  50. package/dist/cjs/index.js.map +1 -1
  51. package/dist/cjs/types/agents.js.map +1 -1
  52. package/dist/cjs/types/commands.js.map +1 -1
  53. package/dist/cjs/types/common.js.map +1 -1
  54. package/dist/cjs/types/conferences.js.map +1 -1
  55. package/dist/cjs/types/listeners.js.map +1 -1
  56. package/dist/cjs/types/migrations.js.map +1 -1
  57. package/dist/cjs/types/tasks.js.map +1 -1
  58. package/dist/esm/EKS.js.map +1 -1
  59. package/dist/esm/HITL.js +1 -1
  60. package/dist/esm/HITL.js.map +1 -1
  61. package/dist/esm/api/Agents.js +61 -81
  62. package/dist/esm/api/Agents.js.map +1 -1
  63. package/dist/esm/api/CannedMessages.js +30 -31
  64. package/dist/esm/api/CannedMessages.js.map +1 -1
  65. package/dist/esm/api/Commands.js +17 -10
  66. package/dist/esm/api/Commands.js.map +1 -1
  67. package/dist/esm/api/Conferences.js +34 -29
  68. package/dist/esm/api/Conferences.js.map +1 -1
  69. package/dist/esm/api/ContactRuleGroups.js +34 -30
  70. package/dist/esm/api/ContactRuleGroups.js.map +1 -1
  71. package/dist/esm/api/Contacts.js +1 -5
  72. package/dist/esm/api/Contacts.js.map +1 -1
  73. package/dist/esm/api/ContactsMeta.js +4 -7
  74. package/dist/esm/api/ContactsMeta.js.map +1 -1
  75. package/dist/esm/api/EventTemplates.js +25 -28
  76. package/dist/esm/api/EventTemplates.js.map +1 -1
  77. package/dist/esm/api/Filters.js +39 -43
  78. package/dist/esm/api/Filters.js.map +1 -1
  79. package/dist/esm/api/HITLBase.js +3 -0
  80. package/dist/esm/api/HITLBase.js.map +1 -1
  81. package/dist/esm/api/Helpers.js +1 -4
  82. package/dist/esm/api/Helpers.js.map +1 -1
  83. package/dist/esm/api/Listeners.js +34 -37
  84. package/dist/esm/api/Listeners.js.map +1 -1
  85. package/dist/esm/api/Migrations.js +34 -49
  86. package/dist/esm/api/Migrations.js.map +1 -1
  87. package/dist/esm/api/RuleGroups.js +34 -30
  88. package/dist/esm/api/RuleGroups.js.map +1 -1
  89. package/dist/esm/api/SessionEvents.js +36 -34
  90. package/dist/esm/api/SessionEvents.js.map +1 -1
  91. package/dist/esm/api/SessionRelations.js +10 -19
  92. package/dist/esm/api/SessionRelations.js.map +1 -1
  93. package/dist/esm/api/Sessions.js +80 -102
  94. package/dist/esm/api/Sessions.js.map +1 -1
  95. package/dist/esm/api/Settings.js +38 -27
  96. package/dist/esm/api/Settings.js.map +1 -1
  97. package/dist/esm/api/Tasks.js +14 -10
  98. package/dist/esm/api/Tasks.js.map +1 -1
  99. package/dist/esm/api/Versions.js +2 -6
  100. package/dist/esm/api/Versions.js.map +1 -1
  101. package/dist/esm/constants.js +1 -0
  102. package/dist/esm/constants.js.map +1 -1
  103. package/dist/esm/index.js +1 -0
  104. package/dist/esm/index.js.map +1 -1
  105. package/dist/esm/types/agents.js.map +1 -1
  106. package/dist/esm/types/commands.js.map +1 -1
  107. package/dist/esm/types/common.js.map +1 -1
  108. package/dist/esm/types/conferences.js.map +1 -1
  109. package/dist/esm/types/listeners.js.map +1 -1
  110. package/dist/esm/types/migrations.js.map +1 -1
  111. package/dist/esm/types/tasks.js.map +1 -1
  112. package/dist/types/EKS.d.ts.map +1 -1
  113. package/dist/types/HITL.d.ts.map +1 -1
  114. package/dist/types/api/Agents.d.ts +7 -5
  115. package/dist/types/api/Agents.d.ts.map +1 -1
  116. package/dist/types/api/CannedMessages.d.ts +3 -3
  117. package/dist/types/api/CannedMessages.d.ts.map +1 -1
  118. package/dist/types/api/Commands.d.ts +1 -1
  119. package/dist/types/api/Commands.d.ts.map +1 -1
  120. package/dist/types/api/Conferences.d.ts +3 -3
  121. package/dist/types/api/Conferences.d.ts.map +1 -1
  122. package/dist/types/api/ContactRuleGroups.d.ts +4 -4
  123. package/dist/types/api/ContactRuleGroups.d.ts.map +1 -1
  124. package/dist/types/api/Contacts.d.ts.map +1 -1
  125. package/dist/types/api/ContactsMeta.d.ts.map +1 -1
  126. package/dist/types/api/EventTemplates.d.ts +2 -2
  127. package/dist/types/api/EventTemplates.d.ts.map +1 -1
  128. package/dist/types/api/Filters.d.ts +2 -2
  129. package/dist/types/api/Filters.d.ts.map +1 -1
  130. package/dist/types/api/HITLBase.d.ts +3 -0
  131. package/dist/types/api/HITLBase.d.ts.map +1 -1
  132. package/dist/types/api/Helpers.d.ts.map +1 -1
  133. package/dist/types/api/Listeners.d.ts +4 -4
  134. package/dist/types/api/Listeners.d.ts.map +1 -1
  135. package/dist/types/api/Migrations.d.ts +7 -6
  136. package/dist/types/api/Migrations.d.ts.map +1 -1
  137. package/dist/types/api/RuleGroups.d.ts +4 -4
  138. package/dist/types/api/RuleGroups.d.ts.map +1 -1
  139. package/dist/types/api/SessionEvents.d.ts +11 -5
  140. package/dist/types/api/SessionEvents.d.ts.map +1 -1
  141. package/dist/types/api/SessionRelations.d.ts +1 -1
  142. package/dist/types/api/SessionRelations.d.ts.map +1 -1
  143. package/dist/types/api/Sessions.d.ts +21 -19
  144. package/dist/types/api/Sessions.d.ts.map +1 -1
  145. package/dist/types/api/Settings.d.ts +5 -3
  146. package/dist/types/api/Settings.d.ts.map +1 -1
  147. package/dist/types/api/Tasks.d.ts +2 -2
  148. package/dist/types/api/Tasks.d.ts.map +1 -1
  149. package/dist/types/api/Versions.d.ts +1 -1
  150. package/dist/types/api/Versions.d.ts.map +1 -1
  151. package/dist/types/constants.d.ts +4 -3
  152. package/dist/types/constants.d.ts.map +1 -1
  153. package/dist/types/index.d.ts +1 -0
  154. package/dist/types/index.d.ts.map +1 -1
  155. package/dist/types/types/agents.d.ts.map +1 -1
  156. package/dist/types/types/canned-messages.d.ts.map +1 -1
  157. package/dist/types/types/commands.d.ts.map +1 -1
  158. package/dist/types/types/common.d.ts +2 -1
  159. package/dist/types/types/common.d.ts.map +1 -1
  160. package/dist/types/types/conferences.d.ts.map +1 -1
  161. package/dist/types/types/contacts-meta.d.ts.map +1 -1
  162. package/dist/types/types/contacts.d.ts.map +1 -1
  163. package/dist/types/types/event-templates.d.ts.map +1 -1
  164. package/dist/types/types/filters.d.ts.map +1 -1
  165. package/dist/types/types/listeners.d.ts.map +1 -1
  166. package/dist/types/types/migrations.d.ts.map +1 -1
  167. package/dist/types/types/read-events.d.ts.map +1 -1
  168. package/dist/types/types/rule-groups.d.ts.map +1 -1
  169. package/dist/types/types/session-events.d.ts +2 -0
  170. package/dist/types/types/session-events.d.ts.map +1 -1
  171. package/dist/types/types/session-relations.d.ts.map +1 -1
  172. package/dist/types/types/sessions.d.ts +1 -0
  173. package/dist/types/types/sessions.d.ts.map +1 -1
  174. package/dist/types/types/settings.d.ts +1 -0
  175. package/dist/types/types/settings.d.ts.map +1 -1
  176. package/dist/types/types/tasks.d.ts.map +1 -1
  177. package/package.json +8 -8
  178. package/src/EKS.ts +1 -2
  179. package/src/HITL.ts +15 -2
  180. package/src/api/Agents.ts +90 -27
  181. package/src/api/CannedMessages.ts +42 -12
  182. package/src/api/Commands.ts +12 -7
  183. package/src/api/Conferences.ts +45 -19
  184. package/src/api/ContactRuleGroups.ts +41 -15
  185. package/src/api/Contacts.ts +9 -0
  186. package/src/api/ContactsMeta.ts +12 -2
  187. package/src/api/EventTemplates.ts +32 -10
  188. package/src/api/Filters.ts +67 -28
  189. package/src/api/HITLBase.ts +4 -0
  190. package/src/api/Helpers.ts +6 -0
  191. package/src/api/Listeners.ts +49 -13
  192. package/src/api/Migrations.ts +62 -15
  193. package/src/api/RuleGroups.ts +41 -15
  194. package/src/api/SessionEvents.ts +70 -21
  195. package/src/api/SessionRelations.ts +31 -8
  196. package/src/api/Sessions.ts +158 -52
  197. package/src/api/Settings.ts +56 -13
  198. package/src/api/Tasks.ts +9 -8
  199. package/src/api/Versions.ts +12 -1
  200. package/src/constants.ts +3 -3
  201. package/src/index.ts +21 -0
  202. package/src/types/agents.ts +1 -0
  203. package/src/types/canned-messages.ts +1 -0
  204. package/src/types/commands.ts +1 -0
  205. package/src/types/common.ts +2 -1
  206. package/src/types/conferences.ts +1 -0
  207. package/src/types/contacts-meta.ts +1 -0
  208. package/src/types/contacts.ts +1 -0
  209. package/src/types/event-templates.ts +1 -0
  210. package/src/types/filters.ts +1 -0
  211. package/src/types/listeners.ts +1 -0
  212. package/src/types/migrations.ts +1 -0
  213. package/src/types/read-events.ts +1 -0
  214. package/src/types/rule-groups.ts +1 -0
  215. package/src/types/session-events.ts +6 -0
  216. package/src/types/session-relations.ts +1 -0
  217. package/src/types/sessions.ts +2 -0
  218. package/src/types/settings.ts +4 -0
  219. package/src/types/tasks.ts +1 -0
@@ -1,6 +1,6 @@
1
- import _ from 'lodash';
2
1
  import URI from 'urijs';
3
2
 
3
+ import { DEFAULT_OMIT_FIELDS } from '../constants';
4
4
  import {
5
5
  Session,
6
6
  GetSessionsOptions,
@@ -23,99 +23,139 @@ import {
23
23
  DeleteClosedSessionOptions,
24
24
  CreateSessionsOptions,
25
25
  CreateSessionsResponse,
26
+ BulkDeleteSessionsOptions,
26
27
  } from '../types/sessions';
28
+
27
29
  import { HITLBase } from './HITLBase';
28
30
 
29
31
  export class Sessions extends HITLBase {
30
32
  protected static MODULE_URL = 'sessions';
31
33
 
32
- protected static SEARCH_URL = 'search';
33
- protected static SEARCH_WITH_CONTACTS_URL = 'search-with-contacts';
34
- protected static GET_TRIGGERS_URL = 'helpers/triggers';
35
- protected static GET_QUEUE_SESSION_URL = 'helpers/queue';
36
-
37
- protected static CLAIM_URL = 'claim';
38
- protected static TRANSFER_TO_BOT_URL = 'transfer-to-bot';
39
- protected static START_CONVERSATION_URL = 'start-conversation';
40
- protected static CLOSE_URL = 'close';
41
- protected static REOPEN_URL = 'reopen';
42
-
34
+ protected static SEARCH_URL = 'search' as const;
35
+ protected static SEARCH_WITH_CONTACTS_URL = 'search-with-contacts' as const;
36
+ protected static GET_TRIGGERS_URL = 'helpers/triggers' as const;
37
+ protected static GET_QUEUE_SESSION_URL = 'helpers/queue' as const;
38
+
39
+ protected static CLAIM_URL = 'claim' as const;
40
+ protected static TRANSFER_TO_BOT_URL = 'transfer-to-bot' as const;
41
+ protected static START_CONVERSATION_URL = 'start-conversation' as const;
42
+ protected static CLOSE_URL = 'close' as const;
43
+ protected static REOPEN_URL = 'reopen' as const;
44
+
45
+ /**
46
+ * @description Get HitL Sessions
47
+ * @param options
48
+ */
43
49
  public static async getSessions(
44
50
  options: GetSessionsOptions = {}
45
51
  ): Promise<GetSessionsResponse> {
46
52
  const route = this.getBaseUrl(options);
47
- const params = _.omit(options, ['version']);
53
+ const params = Object.fromEntries(
54
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
55
+ );
48
56
 
49
57
  return this.request({
50
58
  method: 'GET',
51
59
  route,
52
60
  params,
61
+ ...this.getBaseSettings(options),
53
62
  });
54
63
  }
55
64
 
65
+ /**
66
+ * @description Get HitL Session by id
67
+ * @param options
68
+ */
56
69
  public static async getSessionById(
57
- options: GetSessionByIdOptions
70
+ { agentId, projection, ...options }: GetSessionByIdOptions
58
71
  ): Promise<Session> {
59
72
  const baseUrl = this.getBaseUrl(options);
60
73
  const route = new URI(baseUrl).segment(options.sessionId).href();
61
- const params = _.pick(options, ['agentId', 'projection']);
62
74
 
63
75
  return this.request({
64
76
  method: 'GET',
65
77
  route,
66
- params,
78
+ params: {
79
+ agentId,
80
+ projection,
81
+ },
82
+ ...this.getBaseSettings(options),
67
83
  });
68
84
  }
69
85
 
86
+ /**
87
+ * @description Search HitL Sessions
88
+ * @param options
89
+ */
70
90
  public static async searchSessions(
71
- options: SearchSessionsOptions = {}
91
+ { agentId, ...options }: SearchSessionsOptions = {}
72
92
  ): Promise<SearchSessionsResponse> {
73
93
  const baseUrl = this.getBaseUrl(options);
74
94
  const route = new URI(baseUrl).segment(this.SEARCH_URL).href();
75
- const params = _.pick(options, ['agentId']);
76
- const data = _.omit(options, ['agentId', 'version']);
95
+ const data = Object.fromEntries(
96
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
97
+ );
77
98
 
78
99
  return this.request({
79
100
  method: 'POST',
80
101
  route,
81
- params,
102
+ params: { agentId },
82
103
  data,
104
+ ...this.getBaseSettings(options),
83
105
  });
84
106
  }
85
107
 
108
+ /**
109
+ * @description Search HitL Sessions and return a list of found Sessions with their Contacts
110
+ * @param options
111
+ */
86
112
  public static async searchSessionsWithContacts(
87
- options: SearchSessionsWithContactsOptions = {}
113
+ { agentId, ...options }: SearchSessionsWithContactsOptions = {}
88
114
  ): Promise<SearchSessionsWithContactsResponse> {
89
115
  const baseUrl = this.getBaseUrl(options);
90
116
  const route = new URI(baseUrl)
91
117
  .segment(this.SEARCH_WITH_CONTACTS_URL)
92
118
  .href();
93
119
 
94
- const params = _.pick(options, ['agentId']);
95
- const data = _.omit(options, ['agentId', 'version']);
120
+ const data = Object.fromEntries(
121
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
122
+ );
96
123
 
97
124
  return this.request({
98
125
  method: 'POST',
99
126
  route,
100
- params,
127
+ params: { agentId },
101
128
  data,
129
+ ...this.getBaseSettings(options),
102
130
  });
103
131
  }
104
132
 
133
+ /**
134
+ * @description Get next HitL Session in the NEEDS_ACTION status
135
+ * @param options
136
+ */
105
137
  public static async getQueueSession(
106
- options: GetQueueSessionOptions
138
+ { agentId, ruleTags, ...options }: GetQueueSessionOptions
107
139
  ): Promise<GetQueueSessionResponse> {
108
140
  const baseUrl = this.getBaseUrl(options);
109
141
  const route = new URI(baseUrl).segment(this.GET_QUEUE_SESSION_URL).href();
110
- const params = _.pick(options, ['agentId', 'ruleTags']);
111
142
 
112
143
  return this.request({
113
144
  method: 'GET',
114
145
  route,
115
- params,
146
+ params: {
147
+ agentId,
148
+ ruleTags,
149
+ },
150
+ ...this.getBaseSettings(options),
116
151
  });
117
152
  }
118
153
 
154
+ /**
155
+ * @description Get a list of "init triggers" for HitL Sessions that
156
+ * can be started from Agent UI
157
+ * @param options
158
+ */
119
159
  public static async getSessionInitTriggers(
120
160
  options: GetInitTriggersOptions = {}
121
161
  ): Promise<GetInitTriggersResponse> {
@@ -125,11 +165,18 @@ export class Sessions extends HITLBase {
125
165
  return this.request({
126
166
  method: 'GET',
127
167
  route,
168
+ ...this.getBaseSettings(options),
128
169
  });
129
170
  }
130
171
 
172
+ /**
173
+ * @description Claim HitL Session by Agent. This will add an Agent id to claimedBy
174
+ * list of a HitL Session and send a "claimed" event to Request Agent Assistance (HitL)
175
+ * step in a flow currently in control of that HitL Session
176
+ * @param options
177
+ */
131
178
  public static async claimSessionByAgent(
132
- options: ClaimSessionByAgentOptions
179
+ { claimBy, params, ...options }: ClaimSessionByAgentOptions
133
180
  ): Promise<Session> {
134
181
  const baseUrl = this.getBaseUrl(options);
135
182
  const route = new URI(baseUrl)
@@ -137,19 +184,23 @@ export class Sessions extends HITLBase {
137
184
  .segment(this.CLAIM_URL)
138
185
  .href();
139
186
 
140
- const params = _.pick(options, ['claimBy']);
141
- const data = _.pick(options, ['params']);
142
-
143
187
  return this.request({
144
188
  method: 'POST',
145
189
  route,
146
- params,
147
- data,
190
+ params: { claimBy },
191
+ data: { params },
192
+ ...this.getBaseSettings(options),
148
193
  });
149
194
  }
150
195
 
196
+ /**
197
+ * @description Transfer HitL Session execution to bot.
198
+ * This will send an "Unpause" event to Pause Execution (HitL) step in a
199
+ * flow currently in control of the HitL Session
200
+ * @param options
201
+ */
151
202
  public static async transferToBot(
152
- options: TransferToBotOptions
203
+ { agentId, params, ...options }: TransferToBotOptions
153
204
  ): Promise<Session> {
154
205
  const baseUrl = this.getBaseUrl(options);
155
206
  const route = new URI(baseUrl)
@@ -157,60 +208,79 @@ export class Sessions extends HITLBase {
157
208
  .segment(this.TRANSFER_TO_BOT_URL)
158
209
  .href();
159
210
 
160
- const params = _.pick(options, ['agentId']);
161
- const data = _.pick(options, ['params']);
162
-
163
211
  return this.request({
164
212
  method: 'POST',
165
213
  route,
166
- params,
167
- data,
214
+ params: { agentId },
215
+ data: { params },
216
+ ...this.getBaseSettings(options),
168
217
  });
169
218
  }
170
219
 
220
+ /**
221
+ * @description Start new HitL Session
222
+ * @param options
223
+ */
171
224
  public static async startConversation(
172
- options: StartConversationOptions
225
+ { contactId, triggerId, params, ...options }: StartConversationOptions
173
226
  ): Promise<Session> {
174
227
  const baseUrl = this.getBaseUrl(options);
175
228
  const route = new URI(baseUrl).segment(this.START_CONVERSATION_URL).href();
176
229
 
177
- const params = _.pick(options, ['contactId', 'triggerId']);
178
- const data = _.pick(options, ['params']);
179
-
180
230
  return this.request({
181
231
  method: 'POST',
182
232
  route,
183
- params,
184
- data,
233
+ params: {
234
+ contactId,
235
+ triggerId,
236
+ },
237
+ data: { params },
238
+ ...this.getBaseSettings(options),
185
239
  });
186
240
  }
187
241
 
242
+ /**
243
+ * @description Update HitL Session
244
+ * @param options
245
+ */
188
246
  public static async updateSession(
189
- options: UpdateSessionOptions
247
+ { tags, contactId, meta, ...options }: UpdateSessionOptions
190
248
  ): Promise<Session> {
191
249
  const baseUrl = this.getBaseUrl(options);
192
250
  const route = new URI(baseUrl).segment(options.sessionId).href();
193
251
 
194
- const data = _.pick(options, ['tags', 'contactId', 'meta']);
195
252
  return this.request({
196
253
  method: 'PUT',
197
254
  route,
198
- data,
255
+ data: {
256
+ tags,
257
+ contactId,
258
+ meta,
259
+ },
260
+ ...this.getBaseSettings(options),
199
261
  });
200
262
  }
201
263
 
264
+ /**
265
+ * @description Create HitL Session
266
+ * @param options
267
+ */
202
268
  public static async createSessions(
203
- options: CreateSessionsOptions
269
+ { sessions, ...options }: CreateSessionsOptions
204
270
  ): Promise<CreateSessionsResponse> {
205
271
  const route = this.getBaseUrl(options);
206
- const data = _.pick(options, ['sessions']);
207
272
  return this.request({
208
273
  method: 'POST',
209
274
  route,
210
- data,
275
+ data: { sessions },
276
+ ...this.getBaseSettings(options),
211
277
  });
212
278
  }
213
279
 
280
+ /**
281
+ * @description Close HitL Session
282
+ * @param options
283
+ */
214
284
  public static async closeSession(
215
285
  options: CloseSessionOptions
216
286
  ): Promise<Session> {
@@ -223,10 +293,14 @@ export class Sessions extends HITLBase {
223
293
  return this.request({
224
294
  method: 'POST',
225
295
  route,
296
+ ...this.getBaseSettings(options),
226
297
  });
227
298
  }
228
299
 
229
-
300
+ /**
301
+ * @description Reopen closed HitL Session
302
+ * @param options
303
+ */
230
304
  public static async reopenSession(
231
305
  options: ReopenSessionOptions
232
306
  ): Promise<Session> {
@@ -239,9 +313,14 @@ export class Sessions extends HITLBase {
239
313
  return this.request({
240
314
  method: 'POST',
241
315
  route,
316
+ ...this.getBaseSettings(options),
242
317
  });
243
318
  }
244
319
 
320
+ /**
321
+ * @description Delete closed HitL Session
322
+ * @param options
323
+ */
245
324
  public static async deleteClosedSession(
246
325
  options: DeleteClosedSessionOptions
247
326
  ) {
@@ -250,6 +329,33 @@ export class Sessions extends HITLBase {
250
329
  return this.request({
251
330
  method: 'DELETE',
252
331
  route,
332
+ ...this.getBaseSettings(options),
333
+ });
334
+ }
335
+
336
+ // TODO delete method with typo
337
+ public static async buldDeleteSessions(
338
+ { sessionIds, ...options }: BulkDeleteSessionsOptions
339
+ ) {
340
+ return this.bulkDeleteSessions({
341
+ sessionIds,
342
+ ...options,
343
+ });
344
+ }
345
+
346
+ /**
347
+ * @description Delete HitL Sessions in bulk
348
+ * @param options
349
+ */
350
+ public static async bulkDeleteSessions(
351
+ { sessionIds, ...options }: BulkDeleteSessionsOptions
352
+ ) {
353
+ const route = this.getBaseUrl(options);
354
+ return this.request({
355
+ method: 'DELETE',
356
+ route,
357
+ params: { sessionIds },
358
+ ...this.getBaseSettings(options),
253
359
  });
254
360
  }
255
361
  }
@@ -1,60 +1,103 @@
1
- import _ from 'lodash';
1
+ import URI from 'urijs';
2
2
 
3
+ import { DEFAULT_OMIT_FIELDS } from '../constants';
3
4
  import {
4
5
  DeleteSettingOptions,
6
+ GetContactBookInfoSettingOptions,
5
7
  GetSettingsOptions,
6
8
  GetSettingsResponse,
7
9
  UpdateSettingsOptions,
8
10
  UpdateSettingsResponse,
11
+ Settings as SettingsType,
9
12
  } from '../types/settings';
13
+
10
14
  import { HITLBase } from './HITLBase';
11
15
 
12
16
  export class Settings extends HITLBase {
13
17
  protected static readonly MODULE_URL = 'settings';
18
+ protected static readonly CONTACT_BOOK_INFO_URL = 'contact-book-info';
14
19
  protected static readonly IGNORE_RULE_TAGS_HEADER = 'X-Ignore-Rule-Tags';
15
20
 
21
+ /**
22
+ * @description Get settings
23
+ * @param options
24
+ */
16
25
  public static async getSettings(
17
- options: GetSettingsOptions = {}
26
+ { ignoreRuleTags = false, ...options }: GetSettingsOptions = {}
18
27
  ): Promise<GetSettingsResponse> {
19
28
  const route = this.getBaseUrl(options);
20
- const params = _.omit(options, ['version', 'accountId', 'ignoreRuleTags']);
21
- const customHeaders = { [this.IGNORE_RULE_TAGS_HEADER]: `${_.get(options, ['ignoreRuleTags']) || false}` };
29
+ const params = Object.fromEntries(
30
+ Object.entries(options).filter(([key]) => ![...DEFAULT_OMIT_FIELDS, 'accountId'].includes(key))
31
+ );
32
+ const customHeaders = { [this.IGNORE_RULE_TAGS_HEADER]: `${ignoreRuleTags}` };
22
33
 
23
34
  return this.request({
24
35
  route,
25
36
  params,
26
37
  customHeaders,
38
+ ...this.getBaseSettings(options),
39
+ });
40
+ }
41
+
42
+ /**
43
+ * @description Get contact book info setting using agent rule groups for triggers
44
+ * @param options
45
+ */
46
+ public static async getContactBookInfoSetting(
47
+ options: GetContactBookInfoSettingOptions = {}
48
+ ): Promise<SettingsType> {
49
+ const baseUrl = this.getBaseUrl(options);
50
+ const route = new URI(baseUrl).segment(this.CONTACT_BOOK_INFO_URL).href();
51
+ const params = Object.fromEntries(
52
+ Object.entries(options).filter(([key]) => ![...DEFAULT_OMIT_FIELDS, 'accountId'].includes(key))
53
+ );
54
+
55
+ return this.request({
56
+ route,
57
+ params,
58
+ ...this.getBaseSettings(options),
27
59
  });
28
60
  }
29
61
 
62
+ /**
63
+ * @description Update setting
64
+ * @param options
65
+ */
30
66
  public static async updateSettings(
31
- options: UpdateSettingsOptions
67
+ { isCommon, data, settings, ...options }: UpdateSettingsOptions
32
68
  ): Promise<UpdateSettingsResponse> {
33
69
  const route = this.getBaseUrl(options);
34
- const params = _.pick(options, ['isCommon']);
35
- const data = {
36
- data: options.data,
37
- settings: options.settings,
38
- };
39
70
 
40
71
  return this.request({
41
72
  route,
42
73
  method: 'PUT',
43
- params,
44
- data,
74
+ params: { isCommon },
75
+ data: {
76
+ data,
77
+ settings,
78
+ },
79
+ ...this.getBaseSettings(options),
45
80
  });
46
81
  }
47
82
 
83
+ /**
84
+ * @description Delete setting
85
+ * @param options
86
+ */
87
+
48
88
  public static async deleteSetting(
49
89
  options: DeleteSettingOptions
50
90
  ): Promise<GetSettingsResponse> {
51
91
  const route = this.getBaseUrl(options);
52
- const params = _.omit(options, ['version']);
92
+ const params = Object.fromEntries(
93
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
94
+ );
53
95
 
54
96
  return this.request({
55
97
  route,
56
98
  method: 'DELETE',
57
99
  params,
100
+ ...this.getBaseSettings(options),
58
101
  });
59
102
  }
60
103
  }
package/src/api/Tasks.ts CHANGED
@@ -1,23 +1,24 @@
1
- import _ from 'lodash';
1
+ import { RunTaskOptions } from '../types/tasks';
2
2
 
3
3
  import { HITLBase } from './HITLBase';
4
- import { RunTaskOptions } from '../types/tasks';
5
4
 
6
5
  export class Tasks extends HITLBase {
7
6
  protected static MODULE_URL = 'tasks';
8
-
7
+ /**
8
+ * @description Run task: send events, broadcasting, remove rule group etc
9
+ * @param options
10
+ */
9
11
  public static async runTask(
10
- options: RunTaskOptions
12
+ { task, data, ...options }: RunTaskOptions
11
13
  ): Promise<void> {
12
14
  const route = this.getBaseUrl(options);
13
- const params = _.pick(options, ['task']);
14
- const data = _.pick(options, ['data']);
15
15
 
16
16
  return this.request({
17
17
  method: 'POST',
18
18
  route,
19
- params,
20
- data,
19
+ params: { task },
20
+ data: { data },
21
+ ...this.getBaseSettings(options),
21
22
  });
22
23
  }
23
24
  }
@@ -1,13 +1,18 @@
1
1
  import URI from 'urijs';
2
2
 
3
3
  import { ApiVersionOptions } from '../types';
4
- import { HITLBase } from './HITLBase';
5
4
  import { GetVersionsListResponse, GetVersionInfoResponse } from '../types/versions';
6
5
 
6
+ import { HITLBase } from './HITLBase';
7
+
7
8
  export class Versions extends HITLBase {
8
9
  protected static MODULE_URL = 'ui-versions';
9
10
  protected static VERSION_INFO = 'version-info';
10
11
 
12
+ /**
13
+ * @description Get UI available versions
14
+ * @param options
15
+ */
11
16
  public static async getVersionsList(
12
17
  options: ApiVersionOptions
13
18
  ): Promise<GetVersionsListResponse> {
@@ -15,9 +20,14 @@ export class Versions extends HITLBase {
15
20
 
16
21
  return this.request({
17
22
  route,
23
+ ...this.getBaseSettings(options),
18
24
  });
19
25
  }
20
26
 
27
+ /**
28
+ * @description Get version info
29
+ * @param options
30
+ */
21
31
  public static async getVersionInfo(
22
32
  options: ApiVersionOptions
23
33
  ): Promise<GetVersionInfoResponse> {
@@ -26,6 +36,7 @@ export class Versions extends HITLBase {
26
36
 
27
37
  return this.request({
28
38
  route,
39
+ ...this.getBaseSettings(options),
29
40
  });
30
41
  }
31
42
  }
package/src/constants.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const SERVICE_KEY = 'hitl-api';
2
- export const EKS_SERVICE_KEY = 'hitl-eks-api';
1
+ export const SERVICE_KEY = 'hitl-api' as const;
2
+ export const EKS_SERVICE_KEY = 'hitl-eks-api' as const;
3
3
  export const HITL_API_SERVICE_KEY = SERVICE_KEY;
4
-
4
+ export const DEFAULT_OMIT_FIELDS = ['version', 'timeout'];
package/src/index.ts CHANGED
@@ -1,3 +1,24 @@
1
1
  export { HITL, AppError } from './HITL';
2
2
  export * from './types';
3
3
  export * from './constants';
4
+ export {
5
+ Migrations as MigrationsApi,
6
+ Settings as SettingsApi,
7
+ Agents as AgentsApi,
8
+ RuleGroups as RuleGroupsApi,
9
+ ContactRuleGroups as ContactRuleGroupsApi,
10
+ EventTemplates as EventTemplatesApi,
11
+ Conferences as ConferencesApi,
12
+ Filters as FiltersApi,
13
+ CannedMessages as CannedMessagesApi,
14
+ Sessions as SessionsApi,
15
+ SessionEvents as SessionEventsApi,
16
+ Listeners as ListenersApi,
17
+ Commands as CommandsApi,
18
+ ContactsMeta as ContactsMetaApi,
19
+ Helpers as HelpersApi,
20
+ Versions as VersionsApi,
21
+ Tasks as TasksApi,
22
+ SessionRelations as SessionRelationsApi,
23
+ Contacts as ContactsApi,
24
+ } from './api';
@@ -4,6 +4,7 @@ import {
4
4
  AGENT_BROADCAST_EVENTS,
5
5
  USER_ROLE,
6
6
  } from '@onereach/types-hitl-api';
7
+
7
8
  import { ApiVersionOptions, NoAccountId } from './common';
8
9
 
9
10
  /* eslint-disable @typescript-eslint/indent */
@@ -1,4 +1,5 @@
1
1
  import { CannedMessages } from '@onereach/types-hitl-api';
2
+
2
3
  import { ApiVersionOptions, NoAccountId } from './common';
3
4
 
4
5
  /* eslint-disable @typescript-eslint/indent */
@@ -1,4 +1,5 @@
1
1
  import { Commands, COMMANDS } from '@onereach/types-hitl-api';
2
+
2
3
  import { ApiVersionOptions } from './common';
3
4
 
4
5
  /* eslint-disable @typescript-eslint/indent */
@@ -1,4 +1,3 @@
1
- import { Token, CalApiParams } from '@or-sdk/base';
2
1
  import {
3
2
  AGENT_STATUS,
4
3
  APP_ERROR_TYPE,
@@ -8,6 +7,7 @@ import {
8
7
  CALL_MEMBER_TYPE,
9
8
  SESSION_STATUS,
10
9
  } from '@onereach/types-hitl-api';
10
+ import { Token, CalApiParams } from '@or-sdk/base';
11
11
 
12
12
  export type HITLConfig = {
13
13
  readonly token: Token;
@@ -22,6 +22,7 @@ export type Request = <T>(params: CalApiParams) => Promise<T>;
22
22
 
23
23
  export interface ApiVersionOptions {
24
24
  readonly version?: number | string;
25
+ readonly timeout?: number;
25
26
  }
26
27
 
27
28
  export interface BaseUrlOptions extends ApiVersionOptions {
@@ -1,4 +1,5 @@
1
1
  import { Conferences, CALL_MEMBER_TYPE, CALL_MEMBER_STATUS } from '@onereach/types-hitl-api';
2
+
2
3
  import { ApiVersionOptions, NoAccountId } from './common';
3
4
 
4
5
  /* eslint-disable @typescript-eslint/indent */
@@ -1,4 +1,5 @@
1
1
  import { ContactsMeta, IDateToString } from '@onereach/types-hitl-api';
2
+
2
3
  import { ApiVersionOptions, NoAccountId } from './common';
3
4
 
4
5
  export type ContactMeta = IDateToString<ContactsMeta.IContactMeta>;
@@ -1,4 +1,5 @@
1
1
  import { Contacts } from '@onereach/types-hitl-api';
2
+
2
3
  import { ApiVersionOptions } from './common';
3
4
 
4
5
  /* eslint-disable @typescript-eslint/indent */
@@ -1,4 +1,5 @@
1
1
  import { EventTemplates } from '@onereach/types-hitl-api';
2
+
2
3
  import { ApiVersionOptions, NoAccountId } from './common';
3
4
 
4
5
  /* eslint-disable @typescript-eslint/indent */
@@ -1,4 +1,5 @@
1
1
  import { Filters } from '@onereach/types-hitl-api';
2
+
2
3
  import { ApiVersionOptions, NoAccountId } from './common';
3
4
 
4
5
  /* eslint-disable @typescript-eslint/indent */