chatbot-nc 1.0.57 → 1.0.58

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.
@@ -6,4 +6,5 @@ import BaseDynamoDBRepository from "./repository/dynamodb";
6
6
  import BaseCommunicationService from "./communication";
7
7
  import HashService from "./hashing";
8
8
  import UrlService from "./shortner";
9
- export { AWS, axios, ENUM, BaseCommunicationService, WebHookEvent, BaseDynamoDBRepository, HashService, UrlService };
9
+ import { Utils } from "./utils";
10
+ export { AWS, axios, ENUM, Utils, BaseCommunicationService, WebHookEvent, BaseDynamoDBRepository, HashService, UrlService };
package/dist/cjs/index.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.UrlService = exports.HashService = exports.BaseDynamoDBRepository = exports.WebHookEvent = exports.BaseCommunicationService = exports.ENUM = exports.axios = exports.AWS = void 0;
29
+ exports.UrlService = exports.HashService = exports.BaseDynamoDBRepository = exports.WebHookEvent = exports.BaseCommunicationService = exports.Utils = exports.ENUM = exports.axios = exports.AWS = void 0;
30
30
  const aws_1 = require("./aws");
31
31
  Object.defineProperty(exports, "AWS", { enumerable: true, get: function () { return aws_1.AWS; } });
32
32
  const axios_1 = __importDefault(require("axios"));
@@ -43,4 +43,6 @@ const hashing_1 = __importDefault(require("./hashing"));
43
43
  exports.HashService = hashing_1.default;
44
44
  const shortner_1 = __importDefault(require("./shortner"));
45
45
  exports.UrlService = shortner_1.default;
46
+ const utils_1 = require("./utils");
47
+ Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return utils_1.Utils; } });
46
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4B;AAUzB,oFAVM,SAAG,OAUN;AATN,kDAAyB;AAUtB,gBAVI,eAAK,CAUJ;AATR,6CAA+B;AAU5B,oBAAI;AATP,kEAA0C;AAWvC,uBAXI,sBAAY,CAWJ;AAVf,qEAA2D;AAWxD,iCAXI,kBAAsB,CAWJ;AAVzB,oEAAuD;AAQpD,mCARI,uBAAwB,CAQJ;AAP3B,wDAAoC;AAUjC,sBAVI,iBAAW,CAUJ;AATd,0DAAoC;AAUjC,qBAVI,kBAAU,CAUJ"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4B;AAWzB,oFAXM,SAAG,OAWN;AAVN,kDAAyB;AAWtB,gBAXI,eAAK,CAWJ;AAVR,6CAA+B;AAW5B,oBAAI;AAVP,kEAA0C;AAavC,uBAbI,sBAAY,CAaJ;AAZf,qEAA2D;AAaxD,iCAbI,kBAAsB,CAaJ;AAZzB,oEAAuD;AAUpD,mCAVI,uBAAwB,CAUJ;AAT3B,wDAAoC;AAYjC,sBAZI,iBAAW,CAYJ;AAXd,0DAAoC;AAYjC,qBAZI,kBAAU,CAYJ;AAXb,mCAAgC;AAM7B,sFANM,aAAK,OAMN"}
@@ -0,0 +1,4 @@
1
+ export declare const Common: {
2
+ parseText: (stringWithPlaceholders: any, replacements: any) => any;
3
+ maskData: (text: any) => any;
4
+ };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Common = void 0;
4
+ /**
5
+ *
6
+ * @param stringWithPlaceholders
7
+ * @param replacements
8
+ * @returns parsed object
9
+ */
10
+ const parseText = (stringWithPlaceholders, replacements) => {
11
+ try {
12
+ if (typeof stringWithPlaceholders === 'object') {
13
+ stringWithPlaceholders = JSON.stringify(stringWithPlaceholders);
14
+ }
15
+ let string = stringWithPlaceholders.replace(/{\w+}/g, (placeholder) => replacements[placeholder.substring(1, placeholder.length - 1)] || placeholder);
16
+ string = string.replace(/{@mask-\w+}/g, (placeholder) => maskData(replacements[placeholder.replace("@mask-", "").substring(1, placeholder.replace("@mask-", "").length - 1)]) || placeholder);
17
+ if (typeof string === 'string') {
18
+ return JSON.parse(string);
19
+ }
20
+ return string;
21
+ }
22
+ catch (error) {
23
+ throw error;
24
+ }
25
+ };
26
+ /**
27
+ *
28
+ * @param text
29
+ * @returns
30
+ */
31
+ const maskData = (text) => {
32
+ try {
33
+ if (typeof text === 'number') {
34
+ //Add Logic to mask
35
+ text = text.toString().substring(0, text.toString().length < 2 ? 1 : Math.floor(text.toString().length / 2)).padEnd(text.toString().length, "*");
36
+ }
37
+ if (typeof text === 'string') {
38
+ if (/^\d+\.\d+$/.test(text))
39
+ text = text.substring(0, text.indexOf(".") <= 2 ? 1 : text.indexOf(".") - 2).padEnd(text.length > 3 ? text.length : text.length - 1, "*");
40
+ else
41
+ text = text.substring(0, text.length < 2 ? 1 : Math.floor(text.length / 2)).padEnd(text.length, "*");
42
+ }
43
+ return text;
44
+ }
45
+ catch (error) {
46
+ throw error;
47
+ }
48
+ };
49
+ exports.Common = { parseText, maskData };
50
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../utils/common.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,sBAA2B,EAAE,YAAiB,EAAE,EAAE;IACpE,IAAI;QACH,IAAI,OAAO,sBAAsB,KAAK,QAAQ,EAAE;YAC/C,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;SAChE;QACD,IAAI,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,WAAgB,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAA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AC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAE,CAAC,EAAC,GAAG,CAAC,CAAC;;gBAE9H,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAC,GAAG,CAAC,CAAC;SACzG;QACD,OAAO,IAAI,CAAC;KACZ;IAAC,OAAO,KAAK,EAAE;QACf,MAAM,KAAK,CAAC;KACZ;AACF,CAAC,CAAA;AAEY,QAAA,MAAM,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ export declare const Utils: {
2
+ Intents: {
3
+ getSessionAttributes: (intentRequest: any) => any;
4
+ getSessionAttributeValue: (intentRequest: any, name: string) => any;
5
+ getSlots: (intentRequest: any) => any;
6
+ getSlotValue: (intentRequest: any, slotName: string) => any;
7
+ getConfidenceScore: (intentRequest: any) => any;
8
+ getDateSlotValue: (intentRequest: any, slotName: string) => string;
9
+ getTimeSlotValue: (intentRequest: any, slotName: string) => string | null;
10
+ getProposedSlot: (intentRequest: any) => any;
11
+ getRequestAttributes: (intentRequest: any) => any;
12
+ getOrginalSlotValue: (intentRequest: any, slotName: string) => any;
13
+ };
14
+ Common: {
15
+ parseText: (stringWithPlaceholders: any, replacements: any) => any;
16
+ maskData: (text: any) => any;
17
+ };
18
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Utils = void 0;
4
+ const common_1 = require("./common");
5
+ const intent_1 = require("./intent");
6
+ exports.Utils = {
7
+ Intents: intent_1.Intents,
8
+ Common: common_1.Common
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":";;;AACA,qCAAkC;AAClC,qCAAmC;AAGtB,QAAA,KAAK,GAAG;IACjB,OAAO,EAAP,gBAAO;IACP,MAAM,EAAN,eAAM;CACT,CAAA"}
@@ -0,0 +1,12 @@
1
+ export declare const Intents: {
2
+ getSessionAttributes: (intentRequest: any) => any;
3
+ getSessionAttributeValue: (intentRequest: any, name: string) => any;
4
+ getSlots: (intentRequest: any) => any;
5
+ getSlotValue: (intentRequest: any, slotName: string) => any;
6
+ getConfidenceScore: (intentRequest: any) => any;
7
+ getDateSlotValue: (intentRequest: any, slotName: string) => string;
8
+ getTimeSlotValue: (intentRequest: any, slotName: string) => string | null;
9
+ getProposedSlot: (intentRequest: any) => any;
10
+ getRequestAttributes: (intentRequest: any) => any;
11
+ getOrginalSlotValue: (intentRequest: any, slotName: string) => any;
12
+ };
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Intents = void 0;
4
+ /**
5
+ *
6
+ * @param intentRequest lex event Request
7
+ * @returns list of slots
8
+ */
9
+ const getSlots = (intentRequest) => {
10
+ try {
11
+ return intentRequest['sessionState']['intent']['slots'];
12
+ }
13
+ catch (error) {
14
+ console.log("Error in Get Slots", error);
15
+ throw error;
16
+ }
17
+ };
18
+ /**
19
+ *
20
+ * @param intentRequest lex event request
21
+ * @param slotName slot name
22
+ * @returns slot resolved value
23
+ */
24
+ const getSlotValue = (intentRequest, slotName) => {
25
+ try {
26
+ let slots;
27
+ slots = getSlots(intentRequest);
28
+ if (slots != null && slots[slotName] != null) {
29
+ return slots[slotName]['value']['interpretedValue'] || slots[slotName]['value']['resolvedValues'][0] || null;
30
+ }
31
+ else {
32
+ return null;
33
+ }
34
+ }
35
+ catch (error) {
36
+ console.log("Error in Get Slot Value", error);
37
+ throw error;
38
+ }
39
+ };
40
+ /**
41
+ *
42
+ * @param intentRequest lex event request
43
+ * @param slotName slot name
44
+ * @returns slot original value
45
+ */
46
+ const getOrginalSlotValue = (intentRequest, slotName) => {
47
+ try {
48
+ let slots;
49
+ slots = getSlots(intentRequest);
50
+ if (slots != null && slots[slotName] != null) {
51
+ return slots[slotName]['value']['originalValue'] || slots[slotName]['value']['originalValue'] || null;
52
+ }
53
+ else {
54
+ return null;
55
+ }
56
+ }
57
+ catch (error) {
58
+ console.log("Error in Get Slot Value", error);
59
+ throw error;
60
+ }
61
+ };
62
+ /**
63
+ *
64
+ * @param intentRequest lex event
65
+ * @returns session attributes object
66
+ */
67
+ const getSessionAttributes = (intentRequest) => {
68
+ try {
69
+ let sessionState;
70
+ sessionState = intentRequest['sessionState'];
71
+ if (sessionState['sessionAttributes'] != null) {
72
+ return sessionState['sessionAttributes'];
73
+ }
74
+ return {};
75
+ }
76
+ catch (error) {
77
+ console.log("Error in Get Session Attributes", error);
78
+ throw error;
79
+ }
80
+ };
81
+ /**
82
+ *
83
+ * @param intentRequest lex event
84
+ * @param name attribute name
85
+ * @returns session attribute value
86
+ */
87
+ const getSessionAttributeValue = (intentRequest, name) => {
88
+ try {
89
+ let sessionState;
90
+ sessionState = intentRequest['sessionState'];
91
+ if (sessionState['sessionAttributes'] != null) {
92
+ let sessionAttributeValue = sessionState['sessionAttributes'][name];
93
+ if (sessionAttributeValue)
94
+ return sessionAttributeValue;
95
+ return null;
96
+ }
97
+ return null;
98
+ }
99
+ catch (error) {
100
+ console.log("Error in Get Session Attribute Value", error);
101
+ throw error;
102
+ }
103
+ };
104
+ /**
105
+ *
106
+ * @param intentRequest
107
+ * @param slotName
108
+ * @returns
109
+ */
110
+ const getDateSlotValue = (intentRequest, slotName) => {
111
+ try {
112
+ let selectDate = null, date = getSlotValue(intentRequest, slotName);
113
+ let month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
114
+ try {
115
+ selectDate = month[date.split('-')[1] - 1] + ' ' + date.split('-')[2];
116
+ return selectDate;
117
+ }
118
+ catch (err) {
119
+ return '';
120
+ }
121
+ }
122
+ catch (error) {
123
+ console.log("Error in Get Date Slot Value", error);
124
+ throw error;
125
+ }
126
+ };
127
+ /**
128
+ *
129
+ * @param intentRequest
130
+ * @param slotName
131
+ * @returns
132
+ */
133
+ const getTimeSlotValue = (intentRequest, slotName) => {
134
+ try {
135
+ let selectTime = null, time = getSlotValue(intentRequest, slotName);
136
+ try {
137
+ if (Number(time.split(':')[0]) < 12) {
138
+ selectTime = time + ' AM';
139
+ }
140
+ else {
141
+ selectTime = Number(time.split(':')[0]) - 12 + ':' + time.split(':')[1] + ' PM';
142
+ }
143
+ return selectTime !== null ? selectTime : null;
144
+ }
145
+ catch (err) {
146
+ return '';
147
+ }
148
+ }
149
+ catch (error) {
150
+ console.log("Error in Get Date Slot Value", error);
151
+ throw error;
152
+ }
153
+ };
154
+ /**
155
+ *
156
+ * @param intentRequest
157
+ * @returns
158
+ */
159
+ const getProposedSlot = (intentRequest) => {
160
+ try {
161
+ if (intentRequest.proposedNextState) {
162
+ return intentRequest.proposedNextState.dialogAction.slotToElicit;
163
+ }
164
+ else {
165
+ return null;
166
+ }
167
+ }
168
+ catch (error) {
169
+ console.log("Error in Get Proposed Slot", error);
170
+ throw error;
171
+ }
172
+ };
173
+ /**
174
+ *
175
+ * @param intentRequest
176
+ * @returns
177
+ */
178
+ const getRequestAttributes = (intentRequest) => {
179
+ try {
180
+ if (intentRequest.requestAttributes) {
181
+ return intentRequest.requestAttributes;
182
+ }
183
+ else {
184
+ return null;
185
+ }
186
+ }
187
+ catch (error) {
188
+ console.log("Error in Get Requested Attributes", error);
189
+ throw error;
190
+ }
191
+ };
192
+ /**
193
+ *
194
+ * @param intentRequest
195
+ * @returns
196
+ */
197
+ const getConfidenceScore = (intentRequest) => {
198
+ try {
199
+ return intentRequest['interpretations'][0]['nluConfidence'];
200
+ }
201
+ catch (error) {
202
+ console.log("Error in Get Confidence Score", error);
203
+ throw error;
204
+ }
205
+ };
206
+ exports.Intents = { getSessionAttributes, getSessionAttributeValue, getSlots, getSlotValue, getConfidenceScore, getDateSlotValue, getTimeSlotValue, getProposedSlot, getRequestAttributes, getOrginalSlotValue };
207
+ //# sourceMappingURL=intent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.js","sourceRoot":"","sources":["../../../utils/intent.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,aAAkB,EAAE,EAAE;IACpC,IAAI;QACA,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;KAC3D;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAA;QACxC,MAAM,KAAK,CAAC;KACf;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CAAC,aAAkB,EAAE,QAAgB,EAAE,EAAE;IAC1D,IAAI;QACA,IAAI,KAAK,CAAC;QACV,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;QAChC,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE;YAC1C,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;SAChH;aAAM;YACH,OAAO,IAAI,CAAC;SACf;KACJ;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAA;QAC7C,MAAM,KAAK,CAAC;KACf;AACL,CAAC,CAA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AAC;SACf;KACJ;IACD,OAAO,KAAK,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAA;QACvD,MAAM,KAAK,CAAC;KACf;AACL,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,aAAkB,EAAE,EAAE;IAC9C,IAAI;QACA,OAAO,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;KAC/D;IACD,OAAO,KAAK,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAA;QACnD,MAAM,KAAK,CAAC;KACf;AACL,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC"}
@@ -6,4 +6,5 @@ import BaseDynamoDBRepository from "./repository/dynamodb";
6
6
  import BaseCommunicationService from "./communication";
7
7
  import HashService from "./hashing";
8
8
  import UrlService from "./shortner";
9
- export { AWS, axios, ENUM, BaseCommunicationService, WebHookEvent, BaseDynamoDBRepository, HashService, UrlService };
9
+ import { Utils } from "./utils";
10
+ export { AWS, axios, ENUM, Utils, BaseCommunicationService, WebHookEvent, BaseDynamoDBRepository, HashService, UrlService };
package/dist/esm/index.js CHANGED
@@ -6,5 +6,6 @@ import BaseDynamoDBRepository from "./repository/dynamodb";
6
6
  import BaseCommunicationService from "./communication";
7
7
  import HashService from "./hashing";
8
8
  import UrlService from "./shortner";
9
- export { AWS, axios, ENUM, BaseCommunicationService, WebHookEvent, BaseDynamoDBRepository, HashService, UrlService };
9
+ import { Utils } from "./utils";
10
+ export { AWS, axios, ENUM, Utils, BaseCommunicationService, WebHookEvent, BaseDynamoDBRepository, HashService, UrlService };
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,sBAAsB,MAAM,uBAAuB,CAAC;AAC3D,OAAO,wBAAwB,MAAM,iBAAiB,CAAC;AACvD,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EACJ,GAAG,EACH,KAAK,EACL,IAAI,EACJ,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,WAAW,EACX,UAAU,EACZ,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,sBAAsB,MAAM,uBAAuB,CAAC;AAC3D,OAAO,wBAAwB,MAAM,iBAAiB,CAAC;AACvD,OAAO,WAAW,MAAM,WAAW,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EACJ,GAAG,EACH,KAAK,EACL,IAAI,EACJ,KAAK,EACL,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,WAAW,EACX,UAAU,EACZ,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare const Common: {
2
+ parseText: (stringWithPlaceholders: any, replacements: any) => any;
3
+ maskData: (text: any) => any;
4
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ *
3
+ * @param stringWithPlaceholders
4
+ * @param replacements
5
+ * @returns parsed object
6
+ */
7
+ const parseText = (stringWithPlaceholders, replacements) => {
8
+ try {
9
+ if (typeof stringWithPlaceholders === 'object') {
10
+ stringWithPlaceholders = JSON.stringify(stringWithPlaceholders);
11
+ }
12
+ let string = stringWithPlaceholders.replace(/{\w+}/g, (placeholder) => replacements[placeholder.substring(1, placeholder.length - 1)] || placeholder);
13
+ string = string.replace(/{@mask-\w+}/g, (placeholder) => maskData(replacements[placeholder.replace("@mask-", "").substring(1, placeholder.replace("@mask-", "").length - 1)]) || placeholder);
14
+ if (typeof string === 'string') {
15
+ return JSON.parse(string);
16
+ }
17
+ return string;
18
+ }
19
+ catch (error) {
20
+ throw error;
21
+ }
22
+ };
23
+ /**
24
+ *
25
+ * @param text
26
+ * @returns
27
+ */
28
+ const maskData = (text) => {
29
+ try {
30
+ if (typeof text === 'number') {
31
+ //Add Logic to mask
32
+ text = text.toString().substring(0, text.toString().length < 2 ? 1 : Math.floor(text.toString().length / 2)).padEnd(text.toString().length, "*");
33
+ }
34
+ if (typeof text === 'string') {
35
+ if (/^\d+\.\d+$/.test(text))
36
+ text = text.substring(0, text.indexOf(".") <= 2 ? 1 : text.indexOf(".") - 2).padEnd(text.length > 3 ? text.length : text.length - 1, "*");
37
+ else
38
+ text = text.substring(0, text.length < 2 ? 1 : Math.floor(text.length / 2)).padEnd(text.length, "*");
39
+ }
40
+ return text;
41
+ }
42
+ catch (error) {
43
+ throw error;
44
+ }
45
+ };
46
+ export const Common = { parseText, maskData };
47
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../utils/common.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,sBAA2B,EAAE,YAAiB,EAAE,EAAE;IACpE,IAAI;QACH,IAAI,OAAO,sBAAsB,KAAK,QAAQ,EAAE;YAC/C,sBAAsB,GAAG,IAAI,C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I;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAC;YAC5B,IAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC1B,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAE,CAAC,EAAC,GAAG,CAAC,CAAC;;gBAE9H,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAC,GAAG,CAAC,CAAC;SACzG;QACD,OAAO,IAAI,CAAC;KACZ;IAAC,OAAO,KAAK,EAAE;QACf,MAAM,KAAK,CAAC;KACZ;AACF,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ export declare const Utils: {
2
+ Intents: {
3
+ getSessionAttributes: (intentRequest: any) => any;
4
+ getSessionAttributeValue: (intentRequest: any, name: string) => any;
5
+ getSlots: (intentRequest: any) => any;
6
+ getSlotValue: (intentRequest: any, slotName: string) => any;
7
+ getConfidenceScore: (intentRequest: any) => any;
8
+ getDateSlotValue: (intentRequest: any, slotName: string) => string;
9
+ getTimeSlotValue: (intentRequest: any, slotName: string) => string | null;
10
+ getProposedSlot: (intentRequest: any) => any;
11
+ getRequestAttributes: (intentRequest: any) => any;
12
+ getOrginalSlotValue: (intentRequest: any, slotName: string) => any;
13
+ };
14
+ Common: {
15
+ parseText: (stringWithPlaceholders: any, replacements: any) => any;
16
+ maskData: (text: any) => any;
17
+ };
18
+ };
@@ -0,0 +1,7 @@
1
+ import { Common } from "./common";
2
+ import { Intents } from "./intent";
3
+ export const Utils = {
4
+ Intents,
5
+ Common
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,OAAO;IACP,MAAM;CACT,CAAA"}
@@ -0,0 +1,12 @@
1
+ export declare const Intents: {
2
+ getSessionAttributes: (intentRequest: any) => any;
3
+ getSessionAttributeValue: (intentRequest: any, name: string) => any;
4
+ getSlots: (intentRequest: any) => any;
5
+ getSlotValue: (intentRequest: any, slotName: string) => any;
6
+ getConfidenceScore: (intentRequest: any) => any;
7
+ getDateSlotValue: (intentRequest: any, slotName: string) => string;
8
+ getTimeSlotValue: (intentRequest: any, slotName: string) => string | null;
9
+ getProposedSlot: (intentRequest: any) => any;
10
+ getRequestAttributes: (intentRequest: any) => any;
11
+ getOrginalSlotValue: (intentRequest: any, slotName: string) => any;
12
+ };
@@ -0,0 +1,204 @@
1
+ /**
2
+ *
3
+ * @param intentRequest lex event Request
4
+ * @returns list of slots
5
+ */
6
+ const getSlots = (intentRequest) => {
7
+ try {
8
+ return intentRequest['sessionState']['intent']['slots'];
9
+ }
10
+ catch (error) {
11
+ console.log("Error in Get Slots", error);
12
+ throw error;
13
+ }
14
+ };
15
+ /**
16
+ *
17
+ * @param intentRequest lex event request
18
+ * @param slotName slot name
19
+ * @returns slot resolved value
20
+ */
21
+ const getSlotValue = (intentRequest, slotName) => {
22
+ try {
23
+ let slots;
24
+ slots = getSlots(intentRequest);
25
+ if (slots != null && slots[slotName] != null) {
26
+ return slots[slotName]['value']['interpretedValue'] || slots[slotName]['value']['resolvedValues'][0] || null;
27
+ }
28
+ else {
29
+ return null;
30
+ }
31
+ }
32
+ catch (error) {
33
+ console.log("Error in Get Slot Value", error);
34
+ throw error;
35
+ }
36
+ };
37
+ /**
38
+ *
39
+ * @param intentRequest lex event request
40
+ * @param slotName slot name
41
+ * @returns slot original value
42
+ */
43
+ const getOrginalSlotValue = (intentRequest, slotName) => {
44
+ try {
45
+ let slots;
46
+ slots = getSlots(intentRequest);
47
+ if (slots != null && slots[slotName] != null) {
48
+ return slots[slotName]['value']['originalValue'] || slots[slotName]['value']['originalValue'] || null;
49
+ }
50
+ else {
51
+ return null;
52
+ }
53
+ }
54
+ catch (error) {
55
+ console.log("Error in Get Slot Value", error);
56
+ throw error;
57
+ }
58
+ };
59
+ /**
60
+ *
61
+ * @param intentRequest lex event
62
+ * @returns session attributes object
63
+ */
64
+ const getSessionAttributes = (intentRequest) => {
65
+ try {
66
+ let sessionState;
67
+ sessionState = intentRequest['sessionState'];
68
+ if (sessionState['sessionAttributes'] != null) {
69
+ return sessionState['sessionAttributes'];
70
+ }
71
+ return {};
72
+ }
73
+ catch (error) {
74
+ console.log("Error in Get Session Attributes", error);
75
+ throw error;
76
+ }
77
+ };
78
+ /**
79
+ *
80
+ * @param intentRequest lex event
81
+ * @param name attribute name
82
+ * @returns session attribute value
83
+ */
84
+ const getSessionAttributeValue = (intentRequest, name) => {
85
+ try {
86
+ let sessionState;
87
+ sessionState = intentRequest['sessionState'];
88
+ if (sessionState['sessionAttributes'] != null) {
89
+ let sessionAttributeValue = sessionState['sessionAttributes'][name];
90
+ if (sessionAttributeValue)
91
+ return sessionAttributeValue;
92
+ return null;
93
+ }
94
+ return null;
95
+ }
96
+ catch (error) {
97
+ console.log("Error in Get Session Attribute Value", error);
98
+ throw error;
99
+ }
100
+ };
101
+ /**
102
+ *
103
+ * @param intentRequest
104
+ * @param slotName
105
+ * @returns
106
+ */
107
+ const getDateSlotValue = (intentRequest, slotName) => {
108
+ try {
109
+ let selectDate = null, date = getSlotValue(intentRequest, slotName);
110
+ let month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
111
+ try {
112
+ selectDate = month[date.split('-')[1] - 1] + ' ' + date.split('-')[2];
113
+ return selectDate;
114
+ }
115
+ catch (err) {
116
+ return '';
117
+ }
118
+ }
119
+ catch (error) {
120
+ console.log("Error in Get Date Slot Value", error);
121
+ throw error;
122
+ }
123
+ };
124
+ /**
125
+ *
126
+ * @param intentRequest
127
+ * @param slotName
128
+ * @returns
129
+ */
130
+ const getTimeSlotValue = (intentRequest, slotName) => {
131
+ try {
132
+ let selectTime = null, time = getSlotValue(intentRequest, slotName);
133
+ try {
134
+ if (Number(time.split(':')[0]) < 12) {
135
+ selectTime = time + ' AM';
136
+ }
137
+ else {
138
+ selectTime = Number(time.split(':')[0]) - 12 + ':' + time.split(':')[1] + ' PM';
139
+ }
140
+ return selectTime !== null ? selectTime : null;
141
+ }
142
+ catch (err) {
143
+ return '';
144
+ }
145
+ }
146
+ catch (error) {
147
+ console.log("Error in Get Date Slot Value", error);
148
+ throw error;
149
+ }
150
+ };
151
+ /**
152
+ *
153
+ * @param intentRequest
154
+ * @returns
155
+ */
156
+ const getProposedSlot = (intentRequest) => {
157
+ try {
158
+ if (intentRequest.proposedNextState) {
159
+ return intentRequest.proposedNextState.dialogAction.slotToElicit;
160
+ }
161
+ else {
162
+ return null;
163
+ }
164
+ }
165
+ catch (error) {
166
+ console.log("Error in Get Proposed Slot", error);
167
+ throw error;
168
+ }
169
+ };
170
+ /**
171
+ *
172
+ * @param intentRequest
173
+ * @returns
174
+ */
175
+ const getRequestAttributes = (intentRequest) => {
176
+ try {
177
+ if (intentRequest.requestAttributes) {
178
+ return intentRequest.requestAttributes;
179
+ }
180
+ else {
181
+ return null;
182
+ }
183
+ }
184
+ catch (error) {
185
+ console.log("Error in Get Requested Attributes", error);
186
+ throw error;
187
+ }
188
+ };
189
+ /**
190
+ *
191
+ * @param intentRequest
192
+ * @returns
193
+ */
194
+ const getConfidenceScore = (intentRequest) => {
195
+ try {
196
+ return intentRequest['interpretations'][0]['nluConfidence'];
197
+ }
198
+ catch (error) {
199
+ console.log("Error in Get Confidence Score", error);
200
+ throw error;
201
+ }
202
+ };
203
+ export const Intents = { getSessionAttributes, getSessionAttributeValue, getSlots, getSlotValue, getConfidenceScore, getDateSlotValue, getTimeSlotValue, getProposedSlot, getRequestAttributes, getOrginalSlotValue };
204
+ //# sourceMappingURL=intent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.js","sourceRoot":"","sources":["../../../utils/intent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,aAAkB,EAAE,EAAE;IACpC,IAAI;QACA,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;KAC3D;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAA;QACxC,MAAM,KAAK,CAAC;KACf;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CAAC,aAAkB,EAAE,QAAgB,EAAE,EAAE;IAC1D,IAAI;QACA,IAAI,KAAK,CAAC;QACV,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;QAChC,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE;YAC1C,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;SAChH;aAAM;YACH,OAAO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AoB,GAAG,CAAC,aAAkB,EAAE,EAAE;IAChD,IAAI;QACA,IAAI,aAAa,CAAC,iBAAiB,EAAE;YACjC,OAAO,aAAa,CAAC,iBAAiB,CAAC;SAC1C;aAAM;YACH,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,KAAK,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAA;QACvD,MAAM,KAAK,CAAC;KACf;AACL,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,aAAkB,EAAE,EAAE;IAC9C,IAAI;QACA,OAAO,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;KAC/D;IACD,OAAO,KAAK,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAA;QACnD,MAAM,KAAK,CAAC;KACf;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatbot-nc",
3
- "version": "1.0.57",
3
+ "version": "1.0.58",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",