hgs-twilio-class-lib 1.1.73 → 1.1.74

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 (52) hide show
  1. package/README.md +5 -5
  2. package/lib/config/DatabaseConfig.d.ts +2 -29
  3. package/lib/config/DatabaseConfig.js +31 -29
  4. package/lib/controller/RealTimeDashboardController.d.ts +39 -0
  5. package/lib/controller/RealTimeDashboardController.js +267 -0
  6. package/lib/controller/twilio/AgentActionsController.js +5 -5
  7. package/lib/controller/twilio/AgentScorecardController.js +4 -4
  8. package/lib/controller/twilio/AuditLogController.js +1 -1
  9. package/lib/controller/twilio/CallLogsController.js +5 -5
  10. package/lib/controller/twilio/CallbackAndVoicemailController.js +5 -5
  11. package/lib/controller/twilio/ChannelSettingTaskInfoController.js +5 -5
  12. package/lib/controller/twilio/ChannelSettingsController.js +1 -1
  13. package/lib/controller/twilio/CxConfigAssetController.js +5 -5
  14. package/lib/controller/twilio/CxConfigController.js +1 -1
  15. package/lib/controller/twilio/CxConfigExternalNumbersController.js +5 -5
  16. package/lib/controller/twilio/CxConfigOther.js +5 -5
  17. package/lib/controller/twilio/CxConfigQueueMenuController.js +5 -5
  18. package/lib/controller/twilio/CxConfigUIconfigController.js +5 -5
  19. package/lib/controller/twilio/GPMController.js +5 -5
  20. package/lib/controller/twilio/HoopHolidaysController.js +5 -5
  21. package/lib/controller/twilio/HoopMainController.js +3 -3
  22. package/lib/controller/twilio/HoopNotesController.js +5 -5
  23. package/lib/controller/twilio/HoopOperationsController.js +5 -5
  24. package/lib/controller/twilio/HoopOverrideBranchesController.js +5 -5
  25. package/lib/controller/twilio/HoopPartialDaysController.js +5 -5
  26. package/lib/controller/twilio/HoopProfilesListController.js +5 -5
  27. package/lib/controller/twilio/NavigationController.js +5 -5
  28. package/lib/controller/twilio/QualityFormsController.js +5 -5
  29. package/lib/controller/twilio/QuickLinkController.js +4 -4
  30. package/lib/controller/twilio/RealTimeReportQueueDetailsController.js +1 -1
  31. package/lib/controller/twilio/RealTimeReportsWGDetailsController.js +4 -4
  32. package/lib/controller/twilio/TaskInfoPanelController.js +1 -1
  33. package/lib/models/impl/DailySummaryModel.d.ts +60 -0
  34. package/lib/models/impl/DailySummaryModel.js +247 -0
  35. package/lib/models/impl/IntervalSummaryModel.d.ts +63 -0
  36. package/lib/models/impl/IntervalSummaryModel.js +261 -0
  37. package/lib/models/index.d.ts +2 -0
  38. package/lib/models/index.js +5 -1
  39. package/lib/models/types/RealtimeSyncMapDetails.type.d.ts +6 -0
  40. package/lib/models/types/RealtimeSyncMapDetails.type.js +7 -0
  41. package/lib/server.js +2 -0
  42. package/lib/twilio/impl/sync/SyncMap.js +11 -69
  43. package/lib/twilio/impl/sync/SyncMapItem.d.ts +24 -4
  44. package/lib/twilio/impl/sync/SyncMapItem.js +134 -2
  45. package/lib/twilio/impl/sync/SyncMapItemsTransaction.d.ts +22 -0
  46. package/lib/twilio/impl/sync/SyncMapItemsTransaction.js +38 -0
  47. package/lib/twilio/impl/sync/SyncMapTransaction.js +2 -2
  48. package/lib/twilio/impl/sync/SyncResource.d.ts +1 -0
  49. package/lib/twilio/impl/sync/SyncResource.js +7 -0
  50. package/lib/twilio/impl/sync/SyncServiceFactory.d.ts +1 -1
  51. package/lib/twilio/impl/sync/SyncServiceFactory.js +1 -2
  52. package/package.json +56 -56
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntervalSummaryModel = void 0;
4
+ const BaseModel_1 = require("../abstract/BaseModel");
5
+ class IntervalSummaryModel extends BaseModel_1.BaseModel {
6
+ constructor(id, uniqueName, periodNumber, intOffr, intAns, intAbn, slaTarget, totalServiceLevel, sumTalkTime, sumHoldTime, sumWaitTime, longestWaitTime, longestHoldTime, longestTalkTime, longestInboundACDIntereaction, longestOutboundACDIntereaction, createdAt, updatedAt, eventId) {
7
+ super();
8
+ this._id = id;
9
+ this._uniqueName = uniqueName;
10
+ this._periodNumber = periodNumber;
11
+ this._intOffr = intOffr;
12
+ this._intAns = intAns;
13
+ this._intAbn = intAbn;
14
+ this._slaTarget = slaTarget;
15
+ this._totalServiceLevel = totalServiceLevel;
16
+ this._sumTalkTime = sumTalkTime;
17
+ this._sumHoldTime = sumHoldTime;
18
+ this._sumWaitTime = sumWaitTime;
19
+ this._longestWaitTime = longestWaitTime;
20
+ this._longestHoldTime = longestHoldTime;
21
+ this._longestTalkTime = longestTalkTime;
22
+ this._longestInboundACDIntereaction = longestInboundACDIntereaction;
23
+ this._longestOutboundACDIntereaction = longestOutboundACDIntereaction;
24
+ this._createdAt = createdAt;
25
+ this._updatedAt = updatedAt;
26
+ this._eventId = eventId;
27
+ }
28
+ // Getters and Setters
29
+ get id() {
30
+ return this._id;
31
+ }
32
+ set id(value) {
33
+ this._id = value;
34
+ }
35
+ get uniqueName() {
36
+ return this._uniqueName;
37
+ }
38
+ set uniqueName(value) {
39
+ this._uniqueName = value;
40
+ }
41
+ get periodNumber() {
42
+ return this._periodNumber;
43
+ }
44
+ set periodNumber(value) {
45
+ this._periodNumber = value;
46
+ }
47
+ get intOffr() {
48
+ return this.intOffr;
49
+ }
50
+ set intOffr(value) {
51
+ this.intOffr = value;
52
+ }
53
+ get intAns() {
54
+ return this._intAns;
55
+ }
56
+ set intAns(value) {
57
+ this._intAns = value;
58
+ }
59
+ get intAbn() {
60
+ return this._intAbn;
61
+ }
62
+ set intAbn(value) {
63
+ this._intAbn = value;
64
+ }
65
+ get slaTarget() {
66
+ return this._slaTarget;
67
+ }
68
+ set slaTarget(value) {
69
+ this._slaTarget = value;
70
+ }
71
+ get totalServiceLevel() {
72
+ return this._totalServiceLevel;
73
+ }
74
+ set totalServiceLevel(value) {
75
+ this._totalServiceLevel = value;
76
+ }
77
+ get sumTalkTime() {
78
+ return this._sumTalkTime;
79
+ }
80
+ set sumTalkTime(value) {
81
+ this._sumTalkTime = value;
82
+ }
83
+ get sumHoldTime() {
84
+ return this._sumHoldTime;
85
+ }
86
+ set sumHoldTime(value) {
87
+ this._sumHoldTime = value;
88
+ }
89
+ get sumWaitTime() {
90
+ return this._sumWaitTime;
91
+ }
92
+ set sumWaitTime(value) {
93
+ this._sumWaitTime = value;
94
+ }
95
+ get longestWaitTime() {
96
+ return this._longestWaitTime;
97
+ }
98
+ set longestWaitTime(value) {
99
+ this._longestWaitTime = value;
100
+ }
101
+ get longestHoldTime() {
102
+ return this._longestHoldTime;
103
+ }
104
+ set longestHoldTime(value) {
105
+ this._longestHoldTime = value;
106
+ }
107
+ get longestTalkTime() {
108
+ return this._longestTalkTime;
109
+ }
110
+ set longestTalkTime(value) {
111
+ this._longestTalkTime = value;
112
+ }
113
+ get longestInboundACDIntereaction() {
114
+ return this._longestInboundACDIntereaction;
115
+ }
116
+ set longestInboundACDIntereaction(value) {
117
+ this._longestInboundACDIntereaction = value;
118
+ }
119
+ get longestOutboundACDIntereaction() {
120
+ return this._longestOutboundACDIntereaction;
121
+ }
122
+ set longestOutboundACDIntereaction(value) {
123
+ this._longestOutboundACDIntereaction = value;
124
+ }
125
+ get createdAt() {
126
+ return this._createdAt;
127
+ }
128
+ set createdAt(value) {
129
+ this._createdAt = value;
130
+ }
131
+ get updatedAt() {
132
+ return this._updatedAt;
133
+ }
134
+ set updatedAt(value) {
135
+ this._updatedAt = value;
136
+ }
137
+ get eventId() {
138
+ return this._eventId;
139
+ }
140
+ set eventId(value) {
141
+ this._eventId = value;
142
+ }
143
+ // Validation Method
144
+ validateData() {
145
+ this.validationMessages = [];
146
+ if (typeof this._id !== "string" || !this._id.trim()) {
147
+ this.validationMessages.push({
148
+ type: "Error",
149
+ fieldDescription: "id",
150
+ message: "ID must be a non-empty string",
151
+ });
152
+ }
153
+ if (typeof this._uniqueName !== "string" || !this._uniqueName.trim()) {
154
+ this.validationMessages.push({
155
+ type: "Error",
156
+ fieldDescription: "uniqueName",
157
+ message: "Unique name must be a non-empty string",
158
+ });
159
+ }
160
+ if (typeof this._periodNumber !== "string" || !this._periodNumber.trim()) {
161
+ this.validationMessages.push({
162
+ type: "Error",
163
+ fieldDescription: "periodNumber",
164
+ message: "Period number must be a non-empty string",
165
+ });
166
+ }
167
+ if (typeof this._intOffr !== "number" || this.intOffr < 0) {
168
+ this.validationMessages.push({
169
+ type: "Error",
170
+ fieldDescription: "intOffr",
171
+ message: "intOffr must be a non-negative number",
172
+ });
173
+ }
174
+ if (typeof this._intAns !== "number" || this._intAns < 0) {
175
+ this.validationMessages.push({
176
+ type: "Error",
177
+ fieldDescription: "intAns",
178
+ message: "intAns must be a non-negative number",
179
+ });
180
+ }
181
+ if (typeof this._intAbn !== "number" || this._intAbn < 0) {
182
+ this.validationMessages.push({
183
+ type: "Error",
184
+ fieldDescription: "intAbn",
185
+ message: "intAbn must be a non-negative number",
186
+ });
187
+ }
188
+ if (typeof this._slaTarget !== "number" || this._slaTarget < 0) {
189
+ this.validationMessages.push({
190
+ type: "Error",
191
+ fieldDescription: "slaTarget",
192
+ message: "slaTarget must be a non-negative number",
193
+ });
194
+ }
195
+ if (typeof this._totalServiceLevel !== "number" || this._totalServiceLevel < 0) {
196
+ this.validationMessages.push({
197
+ type: "Error",
198
+ fieldDescription: "totalServiceLevel",
199
+ message: "totalServiceLevel must be a non-negative number",
200
+ });
201
+ }
202
+ if (typeof this._sumTalkTime !== "number" || this._sumTalkTime < 0) {
203
+ this.validationMessages.push({
204
+ type: "Error",
205
+ fieldDescription: "sumTalkTime",
206
+ message: "sumTalkTime must be a non-negative number",
207
+ });
208
+ }
209
+ if (typeof this._sumHoldTime !== "number" || this._sumHoldTime < 0) {
210
+ this.validationMessages.push({
211
+ type: "Error",
212
+ fieldDescription: "sumHoldTime",
213
+ message: "sumHoldTime must be a non-negative number",
214
+ });
215
+ }
216
+ if (typeof this._sumWaitTime !== "number" || this._sumWaitTime < 0) {
217
+ this.validationMessages.push({
218
+ type: "Error",
219
+ fieldDescription: "sumWaitTime",
220
+ message: "sumWaitTime must be a non-negative number",
221
+ });
222
+ }
223
+ if (typeof this._longestWaitTime !== "number" || this._longestWaitTime < 0) {
224
+ this.validationMessages.push({
225
+ type: "Error",
226
+ fieldDescription: "longestWaitTime",
227
+ message: "longestWaitTime must be a non-negative number",
228
+ });
229
+ }
230
+ if (typeof this._longestHoldTime !== "number" || this._longestHoldTime < 0) {
231
+ this.validationMessages.push({
232
+ type: "Error",
233
+ fieldDescription: "longestHoldTime",
234
+ message: "longestHoldTime must be a non-negative number",
235
+ });
236
+ }
237
+ if (typeof this._longestTalkTime !== "number" || this._longestTalkTime < 0) {
238
+ this.validationMessages.push({
239
+ type: "Error",
240
+ fieldDescription: "longestTalkTime",
241
+ message: "longestTalkTime must be a non-negative number",
242
+ });
243
+ }
244
+ if (typeof this._longestInboundACDIntereaction !== "number" || this._longestInboundACDIntereaction < 0) {
245
+ this.validationMessages.push({
246
+ type: "Error",
247
+ fieldDescription: "longestInboundACDIntereaction",
248
+ message: "longestInboundACDIntereaction must be a non-negative number",
249
+ });
250
+ }
251
+ if (typeof this._longestOutboundACDIntereaction !== "number" || this._longestOutboundACDIntereaction < 0) {
252
+ this.validationMessages.push({
253
+ type: "Error",
254
+ fieldDescription: "longestOutboundACDIntereaction",
255
+ message: "longestOutboundACDIntereaction must be a non-negative number",
256
+ });
257
+ }
258
+ return this.validationMessages;
259
+ }
260
+ }
261
+ exports.IntervalSummaryModel = IntervalSummaryModel;
@@ -23,3 +23,5 @@ export { TaskInfoModel } from "./impl/channelsettings/TaskInfoModel";
23
23
  export { CxConfigurator } from "./impl/cxconfig/CxConfigNamespace";
24
24
  export { AgentActionsModel } from "./impl/AgentActionsModel";
25
25
  export { AgentActionsLogsModel } from "./impl/AgentActionsLogsModel";
26
+ export { IntervalSummaryModel } from "./impl/IntervalSummaryModel";
27
+ export { DailySummaryModel } from "./impl/DailySummaryModel";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgentActionsLogsModel = exports.AgentActionsModel = exports.CxConfigurator = exports.TaskInfoModel = exports.TaskInfoAttributeModel = exports.ChannelSettingTaskInfoModel = exports.ChannelSettingModel = exports.WorkGroupDetailsModel = exports.TaskModel = exports.TaskAttributesModel = exports.StatisticsTimeDetailsModel = exports.StatisticsNumberDetailsModel = exports.QuickLinkModel = exports.QueueModel = exports.QuestionDetailsModel = exports.QualityFormsModel = exports.ProfileModel = exports.PlaybackScreenrecordingsModel = exports.PerformanceStatisticsModel = exports.NavigationModel = exports.CategoryDetailModel = exports.CallbackVoicemail = exports.CallStatisticsModel = exports.CallLogsModel = exports.AuditLogModel = void 0;
3
+ exports.DailySummaryModel = exports.IntervalSummaryModel = exports.AgentActionsLogsModel = exports.AgentActionsModel = exports.CxConfigurator = exports.TaskInfoModel = exports.TaskInfoAttributeModel = exports.ChannelSettingTaskInfoModel = exports.ChannelSettingModel = exports.WorkGroupDetailsModel = exports.TaskModel = exports.TaskAttributesModel = exports.StatisticsTimeDetailsModel = exports.StatisticsNumberDetailsModel = exports.QuickLinkModel = exports.QueueModel = exports.QuestionDetailsModel = exports.QualityFormsModel = exports.ProfileModel = exports.PlaybackScreenrecordingsModel = exports.PerformanceStatisticsModel = exports.NavigationModel = exports.CategoryDetailModel = exports.CallbackVoicemail = exports.CallStatisticsModel = exports.CallLogsModel = exports.AuditLogModel = void 0;
4
4
  var AuditLogsModel_1 = require("./impl/AuditLogsModel");
5
5
  Object.defineProperty(exports, "AuditLogModel", { enumerable: true, get: function () { return AuditLogsModel_1.AuditLogModel; } });
6
6
  var CallLogsModel_1 = require("./impl/CallLogsModel");
@@ -51,3 +51,7 @@ var AgentActionsModel_1 = require("./impl/AgentActionsModel");
51
51
  Object.defineProperty(exports, "AgentActionsModel", { enumerable: true, get: function () { return AgentActionsModel_1.AgentActionsModel; } });
52
52
  var AgentActionsLogsModel_1 = require("./impl/AgentActionsLogsModel");
53
53
  Object.defineProperty(exports, "AgentActionsLogsModel", { enumerable: true, get: function () { return AgentActionsLogsModel_1.AgentActionsLogsModel; } });
54
+ var IntervalSummaryModel_1 = require("./impl/IntervalSummaryModel");
55
+ Object.defineProperty(exports, "IntervalSummaryModel", { enumerable: true, get: function () { return IntervalSummaryModel_1.IntervalSummaryModel; } });
56
+ var DailySummaryModel_1 = require("./impl/DailySummaryModel");
57
+ Object.defineProperty(exports, "DailySummaryModel", { enumerable: true, get: function () { return DailySummaryModel_1.DailySummaryModel; } });
@@ -0,0 +1,6 @@
1
+ export type RealtimeSyncMapFilterFields = {
2
+ syncServiceName: "string";
3
+ };
4
+ export declare enum RealtimeSyncMapAllowedFields {
5
+ syncServiceName = 0
6
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RealtimeSyncMapAllowedFields = void 0;
4
+ var RealtimeSyncMapAllowedFields;
5
+ (function (RealtimeSyncMapAllowedFields) {
6
+ RealtimeSyncMapAllowedFields[RealtimeSyncMapAllowedFields["syncServiceName"] = 0] = "syncServiceName";
7
+ })(RealtimeSyncMapAllowedFields || (exports.RealtimeSyncMapAllowedFields = RealtimeSyncMapAllowedFields = {}));
package/lib/server.js CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const express_1 = __importDefault(require("express"));
7
7
  const MainController_1 = require("./controller/MainController");
8
+ const RealTimeDashboardController_1 = require("./controller/RealTimeDashboardController");
8
9
  var cors = require('cors');
9
10
  const app = (0, express_1.default)();
10
11
  const PORT = 3010;
@@ -32,6 +33,7 @@ app.use(cors());
32
33
  Do not remove Below code
33
34
  */
34
35
  // app.use(validateRequiredCommonParams, validateRequiredParams)
36
+ app.use('/realtime', (req, res) => new RealTimeDashboardController_1.RealTimeDashboardController().routeHandler(req, res));
35
37
  app.use('/', (req, res, next) => new MainController_1.MainController().routeHandler(req, res));
36
38
  // Start the server
37
39
  app.listen(PORT, () => {
@@ -2,13 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SyncMap = void 0;
4
4
  const pagination_1 = require("../../../common/utils/pagination");
5
- const sort_1 = require("../../../common/utils/sort");
6
- const search_1 = require("../../../common/utils/search");
7
- const newFilter_1 = require("../../../common/utils/newFilter");
8
- const dateFormat_1 = require("../../../common/utils/dateFormat");
9
5
  const ServiceObjectStore_1 = require("../../abstract/ServiceObjectStore");
10
6
  const SyncMapTransaction_1 = require("./SyncMapTransaction");
11
- const Filter_1 = require("../../../common/abstract/Filter");
12
7
  class SyncMap extends ServiceObjectStore_1.ServiceObjectStore {
13
8
  constructor(name, transaction, autoIncrement, indexNames, keyPath) {
14
9
  super(name, transaction, autoIncrement, indexNames, keyPath);
@@ -19,8 +14,7 @@ class SyncMap extends ServiceObjectStore_1.ServiceObjectStore {
19
14
  });
20
15
  }
21
16
  add(value, key, ttl) {
22
- console.log('value ', value, key);
23
- return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMapItems.create({ key: key, data: value, ttl: ttl });
17
+ return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMaps.create({ uniqueName: value, ttl: ttl });
24
18
  }
25
19
  clear() {
26
20
  throw new Error("Method not implemented.");
@@ -32,8 +26,8 @@ class SyncMap extends ServiceObjectStore_1.ServiceObjectStore {
32
26
  throw new Error("Method not implemented.");
33
27
  }
34
28
  delete(query) {
35
- return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMapItems(query).remove().then((mapItem) => {
36
- console.log('delete map item ', mapItem);
29
+ return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMaps(query).remove().then((map) => {
30
+ console.log('delete map ', map);
37
31
  return "success";
38
32
  }).catch((error) => {
39
33
  throw error;
@@ -43,65 +37,14 @@ class SyncMap extends ServiceObjectStore_1.ServiceObjectStore {
43
37
  throw new Error("Method not implemented.");
44
38
  }
45
39
  get(query) {
46
- return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMapItems(query).fetch().then((mapItem) => {
47
- return mapItem.data;
40
+ return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMaps(query).fetch().then((map) => {
41
+ return map;
48
42
  });
49
43
  }
50
44
  getAll(query, count) {
51
- return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMapItems.list().then((mapItems) => {
52
- let items = mapItems.map((item) => item.data);
45
+ return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMaps.list().then((map) => {
46
+ let items = map;
53
47
  let totalPages = 0;
54
- if (query && typeof query === 'object' && "sortOptions" in query) {
55
- let sortBy;
56
- let direction;
57
- if (typeof query.sortOptions === "string") {
58
- query.sortOptions = JSON.parse(query.sortOptions);
59
- }
60
- if (Array.isArray(query.sortOptions)) {
61
- query.sortOptions.forEach(item => {
62
- if (Object.keys(item)[0] && item[Object.keys(item)[0]]) {
63
- sortBy = Object.keys(item)[0];
64
- direction = item[Object.keys(item)[0]].toUpperCase() === 'ASC' ? true : false;
65
- }
66
- items = (0, sort_1.sortData)(items, sortBy, direction);
67
- });
68
- }
69
- else if (query.sortOptions) {
70
- let sortOptions;
71
- sortOptions = query.sortOptions;
72
- Object.keys(query.sortOptions).forEach(item => {
73
- if (sortOptions[item]) {
74
- sortBy = item;
75
- direction = sortOptions[item].toUpperCase() === 'ASC' ? true : false;
76
- }
77
- items = (0, sort_1.sortData)(items, sortBy, direction);
78
- });
79
- }
80
- }
81
- let filterOptions = null;
82
- if (query && typeof query === 'object' && "allowedFields" in query) {
83
- filterOptions = Filter_1.Filter.generateFilterOptions(items, query.allowedFields);
84
- }
85
- if (query && typeof query === 'object' && ("timezone" in query || "dateFormat" in query || "timeFormat" in query)) {
86
- let timezone = "timezone" in query ? query.timezone : "";
87
- let dateFormat = "dateFormat" in query ? query.dateFormat : "";
88
- let timeFormat = "timeFormat" in query ? query.timeFormat : "";
89
- items = (0, dateFormat_1.dateFormatData)(items, dateFormat, timeFormat, timezone);
90
- }
91
- if (query && typeof query === "object" && "filters" in query && "category" in query) {
92
- let filters = query.filters;
93
- let category = typeof query.category === "string" ? query.category : "";
94
- items = (0, newFilter_1.filterData)(items, filters, category);
95
- }
96
- if (query && typeof query === 'object' && "searchOptions" in query && query.searchOptions) {
97
- let searchOptions = typeof query === 'object' && "searchOptions" in query ? query.searchOptions : "";
98
- items = (0, search_1.searchData)(items, searchOptions);
99
- }
100
- // if (query && typeof query === 'object' && "filters" in query && query.filters) {
101
- // let filters: any = typeof query === 'object' && "filters" in query ? query.filters : "";
102
- // // console.log("filtered data:::", typeof JSON.parse(filters));
103
- // items = filterData(items, filters)
104
- // }
105
48
  if (query && typeof query === 'object' && "itemsPerPage" in query) {
106
49
  let itemsPerPage = typeof query === 'object' && "itemsPerPage" in query ? query.itemsPerPage : 5;
107
50
  let pageNo = typeof query === 'object' && "pageNo" in query ? query.pageNo : 1;
@@ -110,8 +53,7 @@ class SyncMap extends ServiceObjectStore_1.ServiceObjectStore {
110
53
  }
111
54
  return {
112
55
  totalPages,
113
- items,
114
- filterOptions
56
+ items
115
57
  };
116
58
  });
117
59
  }
@@ -130,9 +72,9 @@ class SyncMap extends ServiceObjectStore_1.ServiceObjectStore {
130
72
  openKeyCursor(query, direction) {
131
73
  throw new Error("Method not implemented.");
132
74
  }
133
- put(value, key) {
134
- return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMapItems(key).update({ data: value }).then((mapItem) => {
135
- return mapItem.key;
75
+ put(value, name) {
76
+ return SyncMapTransaction_1.SyncMapTransaction.syncMapInstance.syncMaps(name).update({ ttl: value }).then((map) => {
77
+ return map;
136
78
  });
137
79
  }
138
80
  }
@@ -1,5 +1,25 @@
1
- import { SyncServiceItemResource } from "../../abstract/SyncServiceItemResource";
2
- export declare class SyncMapItem extends SyncServiceItemResource {
3
- key: string;
4
- sid: string;
1
+ import { SearchParameterType } from "../../../common/type/SearchParameterType";
2
+ import { ServiceObjectStore } from "../../abstract/ServiceObjectStore";
3
+ export declare class SyncMapItem extends ServiceObjectStore {
4
+ constructor(name: string, transaction?: IDBTransaction, autoIncrement?: boolean, indexNames?: DOMStringList, keyPath?: string);
5
+ getMap(): IDBRequest<any>;
6
+ add(value: any, key?: IDBValidKey | undefined, ttl?: Number | undefined): IDBRequest<IDBValidKey>;
7
+ clear(): IDBRequest<undefined>;
8
+ count(query?: IDBValidKey | IDBKeyRange | undefined): IDBRequest<number>;
9
+ createIndex(name: string, keyPath: string | string[], options?: IDBIndexParameters | undefined): IDBIndex;
10
+ createIndex(name: string, keyPath: string | Iterable<string>, options?: IDBIndexParameters | undefined): IDBIndex;
11
+ createIndex(name: unknown, keyPath: unknown, options?: unknown): IDBIndex;
12
+ delete(query: IDBValidKey | IDBKeyRange): IDBRequest<undefined>;
13
+ delete(query: IDBValidKey | IDBKeyRange): Promise<IDBRequest<undefined>>;
14
+ deleteIndex(name: string): void;
15
+ get(query: IDBValidKey | IDBKeyRange): IDBRequest<any>;
16
+ getAll(query?: IDBValidKey | IDBKeyRange | null | undefined, count?: number | undefined): IDBRequest<any[]>;
17
+ getAll(query: SearchParameterType, count?: number | undefined): Promise<IDBRequest<any[]>>;
18
+ getAllKeys(query?: IDBValidKey | IDBKeyRange | null | undefined, count?: number | undefined): IDBRequest<IDBValidKey[]>;
19
+ getKey(query: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey | undefined>;
20
+ index(name: string): IDBIndex;
21
+ openCursor(query?: IDBValidKey | IDBKeyRange | null | undefined, direction?: IDBCursorDirection | undefined): IDBRequest<IDBCursorWithValue | null>;
22
+ openKeyCursor(query?: IDBValidKey | IDBKeyRange | null | undefined, direction?: IDBCursorDirection | undefined): IDBRequest<IDBCursor | null>;
23
+ put(value: any, key?: IDBValidKey | undefined): IDBRequest<IDBValidKey>;
24
+ put(value: Object, key: IDBValidKey): Promise<IDBRequest<IDBValidKey>>;
5
25
  }
@@ -1,7 +1,139 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SyncMapItem = void 0;
4
- const SyncServiceItemResource_1 = require("../../abstract/SyncServiceItemResource");
5
- class SyncMapItem extends SyncServiceItemResource_1.SyncServiceItemResource {
4
+ const pagination_1 = require("../../../common/utils/pagination");
5
+ const sort_1 = require("../../../common/utils/sort");
6
+ const search_1 = require("../../../common/utils/search");
7
+ const newFilter_1 = require("../../../common/utils/newFilter");
8
+ const dateFormat_1 = require("../../../common/utils/dateFormat");
9
+ const ServiceObjectStore_1 = require("../../abstract/ServiceObjectStore");
10
+ const SyncMapItemsTransaction_1 = require("./SyncMapItemsTransaction");
11
+ const Filter_1 = require("../../../common/abstract/Filter");
12
+ class SyncMapItem extends ServiceObjectStore_1.ServiceObjectStore {
13
+ constructor(name, transaction, autoIncrement, indexNames, keyPath) {
14
+ super(name, transaction, autoIncrement, indexNames, keyPath);
15
+ }
16
+ getMap() {
17
+ return SyncMapItemsTransaction_1.SyncMapItemTransaction.syncMapInstance.fetch().then((map) => {
18
+ return map;
19
+ });
20
+ }
21
+ add(value, key, ttl) {
22
+ console.log('value ', value, key);
23
+ return SyncMapItemsTransaction_1.SyncMapItemTransaction.syncMapInstance.syncMapItems.create({ key: key, data: value, ttl: ttl });
24
+ }
25
+ clear() {
26
+ throw new Error("Method not implemented.");
27
+ }
28
+ count(query) {
29
+ throw new Error("Method not implemented.");
30
+ }
31
+ createIndex(name, keyPath, options) {
32
+ throw new Error("Method not implemented.");
33
+ }
34
+ delete(query) {
35
+ return SyncMapItemsTransaction_1.SyncMapItemTransaction.syncMapInstance.syncMapItems(query).remove().then((mapItem) => {
36
+ console.log('delete map item ', mapItem);
37
+ return "success";
38
+ }).catch((error) => {
39
+ throw error;
40
+ });
41
+ }
42
+ deleteIndex(name) {
43
+ throw new Error("Method not implemented.");
44
+ }
45
+ get(query) {
46
+ return SyncMapItemsTransaction_1.SyncMapItemTransaction.syncMapInstance.syncMapItems(query).fetch().then((mapItem) => {
47
+ return mapItem.data;
48
+ });
49
+ }
50
+ getAll(query, count) {
51
+ return SyncMapItemsTransaction_1.SyncMapItemTransaction.syncMapInstance.syncMapItems.list().then((mapItems) => {
52
+ let items = mapItems.map((item) => item.data);
53
+ let totalPages = 0;
54
+ if (query && typeof query === 'object' && "sortOptions" in query) {
55
+ let sortBy;
56
+ let direction;
57
+ if (typeof query.sortOptions === "string") {
58
+ query.sortOptions = JSON.parse(query.sortOptions);
59
+ }
60
+ if (Array.isArray(query.sortOptions)) {
61
+ query.sortOptions.forEach(item => {
62
+ if (Object.keys(item)[0] && item[Object.keys(item)[0]]) {
63
+ sortBy = Object.keys(item)[0];
64
+ direction = item[Object.keys(item)[0]].toUpperCase() === 'ASC' ? true : false;
65
+ }
66
+ items = (0, sort_1.sortData)(items, sortBy, direction);
67
+ });
68
+ }
69
+ else if (query.sortOptions) {
70
+ let sortOptions;
71
+ sortOptions = query.sortOptions;
72
+ Object.keys(query.sortOptions).forEach(item => {
73
+ if (sortOptions[item]) {
74
+ sortBy = item;
75
+ direction = sortOptions[item].toUpperCase() === 'ASC' ? true : false;
76
+ }
77
+ items = (0, sort_1.sortData)(items, sortBy, direction);
78
+ });
79
+ }
80
+ }
81
+ let filterOptions = null;
82
+ if (query && typeof query === 'object' && "allowedFields" in query) {
83
+ filterOptions = Filter_1.Filter.generateFilterOptions(items, query.allowedFields);
84
+ }
85
+ if (query && typeof query === 'object' && ("timezone" in query || "dateFormat" in query || "timeFormat" in query)) {
86
+ let timezone = "timezone" in query ? query.timezone : "";
87
+ let dateFormat = "dateFormat" in query ? query.dateFormat : "";
88
+ let timeFormat = "timeFormat" in query ? query.timeFormat : "";
89
+ items = (0, dateFormat_1.dateFormatData)(items, dateFormat, timeFormat, timezone);
90
+ }
91
+ if (query && typeof query === "object" && "filters" in query && "category" in query) {
92
+ let filters = query.filters;
93
+ let category = typeof query.category === "string" ? query.category : "";
94
+ items = (0, newFilter_1.filterData)(items, filters, category);
95
+ }
96
+ if (query && typeof query === 'object' && "searchOptions" in query && query.searchOptions) {
97
+ let searchOptions = typeof query === 'object' && "searchOptions" in query ? query.searchOptions : "";
98
+ items = (0, search_1.searchData)(items, searchOptions);
99
+ }
100
+ // if (query && typeof query === 'object' && "filters" in query && query.filters) {
101
+ // let filters: any = typeof query === 'object' && "filters" in query ? query.filters : "";
102
+ // // console.log("filtered data:::", typeof JSON.parse(filters));
103
+ // items = filterData(items, filters)
104
+ // }
105
+ if (query && typeof query === 'object' && "itemsPerPage" in query) {
106
+ let itemsPerPage = typeof query === 'object' && "itemsPerPage" in query ? query.itemsPerPage : 5;
107
+ let pageNo = typeof query === 'object' && "pageNo" in query ? query.pageNo : 1;
108
+ totalPages = (items.length !== 0) && ((itemsPerPage < items.length) || (itemsPerPage > items.length)) ? Math.ceil(items.length / itemsPerPage) : 1;
109
+ items = (0, pagination_1.paginateData)(items, itemsPerPage, pageNo);
110
+ }
111
+ return {
112
+ totalPages,
113
+ items,
114
+ filterOptions
115
+ };
116
+ });
117
+ }
118
+ getAllKeys(query, count) {
119
+ throw new Error("Method not implemented.");
120
+ }
121
+ getKey(query) {
122
+ throw new Error("Method not implemented.");
123
+ }
124
+ index(name) {
125
+ throw new Error("Method not implemented.");
126
+ }
127
+ openCursor(query, direction) {
128
+ throw new Error("Method not implemented.");
129
+ }
130
+ openKeyCursor(query, direction) {
131
+ throw new Error("Method not implemented.");
132
+ }
133
+ put(value, key) {
134
+ return SyncMapItemsTransaction_1.SyncMapItemTransaction.syncMapInstance.syncMapItems(key).update({ data: value }).then((mapItem) => {
135
+ return mapItem.key;
136
+ });
137
+ }
6
138
  }
7
139
  exports.SyncMapItem = SyncMapItem;
@@ -0,0 +1,22 @@
1
+ import { ServiceTransaction } from "../../abstract/ServiceTransaction";
2
+ import { IServiceResource } from "../../interface/IServiceResource";
3
+ import { IServiceTransaction } from "../../interface/IServiceTransation";
4
+ import { SyncMapItem } from "./SyncMapItem";
5
+ export declare class SyncMapItemTransaction extends ServiceTransaction {
6
+ private static _syncMapInstance;
7
+ constructor(db: IServiceResource, mode: IDBTransactionMode, error?: DOMException | null, objectStoreNames?: DOMStringList, durability?: IDBTransactionDurability);
8
+ static get syncMapInstance(): any;
9
+ onabort: ((this: IDBTransaction, ev: Event) => any) | null;
10
+ oncomplete: ((this: IDBTransaction, ev: Event) => any) | null;
11
+ onerror: ((this: IDBTransaction, ev: Event) => any) | null;
12
+ abort(): void;
13
+ commit(): void;
14
+ objectStore(name: string): SyncMapItem;
15
+ addEventListener<K extends keyof IDBTransactionEventMap>(type: K, listener: (this: IServiceTransaction, ev: IDBTransactionEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
16
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
17
+ addEventListener(type: unknown, listener: unknown, options?: unknown): void;
18
+ removeEventListener<K extends keyof IDBTransactionEventMap>(type: K, listener: (this: IServiceTransaction, ev: IDBTransactionEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
19
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
20
+ removeEventListener(type: unknown, listener: unknown, options?: unknown): void;
21
+ dispatchEvent(event: Event): boolean;
22
+ }