chatbot-nc 1.0.52 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/aws/index.d.ts +1 -0
- package/dist/cjs/aws/services/AWSLexRuntime.d.ts +2 -1
- package/dist/cjs/aws/services/AWSLexRuntime.js +21 -1
- package/dist/cjs/aws/services/AWSLexRuntime.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/shortner/index.d.ts +4 -0
- package/dist/cjs/shortner/index.js +48 -0
- package/dist/cjs/shortner/index.js.map +1 -0
- package/dist/esm/aws/index.d.ts +1 -0
- package/dist/esm/aws/services/AWSLexRuntime.d.ts +2 -1
- package/dist/esm/aws/services/AWSLexRuntime.js +22 -2
- package/dist/esm/aws/services/AWSLexRuntime.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/shortner/index.d.ts +4 -0
- package/dist/esm/shortner/index.js +42 -0
- package/dist/esm/shortner/index.js.map +1 -0
- package/package.json +1 -1
package/dist/cjs/aws/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const AWS: {
|
|
|
13
13
|
};
|
|
14
14
|
LexRuntime: {
|
|
15
15
|
recognizeText: (lexParams: import("@aws-sdk/client-lex-runtime-v2").RecognizeTextCommandInput) => Promise<import("@aws-sdk/client-lex-runtime-v2").RecognizeTextCommandOutput>;
|
|
16
|
+
getSession: (lexSessionParams: import("@aws-sdk/client-lex-runtime-v2").GetSessionCommandInput) => Promise<import("@aws-sdk/client-lex-runtime-v2").GetSessionCommandOutput>;
|
|
16
17
|
};
|
|
17
18
|
LexModel: {
|
|
18
19
|
createBot: (botInput: import("@aws-sdk/client-lex-models-v2").CreateBotCommandInput) => Promise<import("@aws-sdk/client-lex-models-v2").CreateBotCommandOutput>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RecognizeTextCommandInput } from "@aws-sdk/client-lex-runtime-v2";
|
|
1
|
+
import { GetSessionCommandInput, RecognizeTextCommandInput } from "@aws-sdk/client-lex-runtime-v2";
|
|
2
2
|
export declare const LexRuntime: {
|
|
3
3
|
recognizeText: (lexParams: RecognizeTextCommandInput) => Promise<import("@aws-sdk/client-lex-runtime-v2").RecognizeTextCommandOutput>;
|
|
4
|
+
getSession: (lexSessionParams: GetSessionCommandInput) => Promise<import("@aws-sdk/client-lex-runtime-v2").GetSessionCommandOutput>;
|
|
4
5
|
};
|
|
@@ -32,7 +32,27 @@ const recognizeText = (lexParams) => __awaiter(void 0, void 0, void 0, function*
|
|
|
32
32
|
throw new Error('lex Error');
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
+
/**
|
|
36
|
+
* This method to use get lex bot session
|
|
37
|
+
* @param lexSessionParams
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
const getSession = (lexSessionParams) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
try {
|
|
42
|
+
let param = lexSessionParams;
|
|
43
|
+
const command = new client_lex_runtime_v2_1.GetSessionCommand(param);
|
|
44
|
+
const response = yield client.send(command);
|
|
45
|
+
console.log("response received from lex with session");
|
|
46
|
+
console.log(JSON.stringify(response));
|
|
47
|
+
return response;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.log(error);
|
|
51
|
+
throw new Error('lex Error to get session');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
35
54
|
exports.LexRuntime = {
|
|
36
|
-
recognizeText
|
|
55
|
+
recognizeText,
|
|
56
|
+
getSession
|
|
37
57
|
};
|
|
38
58
|
//# sourceMappingURL=AWSLexRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AWSLexRuntime.js","sourceRoot":"","sources":["../../../../aws/services/AWSLexRuntime.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AWSLexRuntime.js","sourceRoot":"","sources":["../../../../aws/services/AWSLexRuntime.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0EAMwC;AAExC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,WAAW,CAAC;AAChE,MAAM,MAAM,GAAG,IAAI,0CAAkB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAO,SAAoC,EAAE,EAAE;IACnE,IAAI;QACF,IAAI,KAAK,GAAG,SAAS,CAAC;QACtB,MAAM,OAAO,GAAG,IAAI,4CAAoB,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE5C,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC;KAEjB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;KAC9B;AACH,CAAC,CAAA,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAO,gBAAwC,EAAE,EAAE;IACpE,IAAI;QACF,IAAI,KAAK,GAAG,gBAAgB,CAAC;QAC7B,MAAM,OAAO,GAAG,IAAI,yCAAiB,CAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE5C,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC;KAEjB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C;AACH,CAAC,CAAA,CAAA;AAIY,QAAA,UAAU,GAAG;IACxB,aAAa;IACb,UAAU;CACX,CAAA"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ import WebHookEvent from "./webbookEvent";
|
|
|
5
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 };
|
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.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.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"));
|
|
@@ -41,4 +41,6 @@ const communication_1 = __importDefault(require("./communication"));
|
|
|
41
41
|
exports.BaseCommunicationService = communication_1.default;
|
|
42
42
|
const hashing_1 = __importDefault(require("./hashing"));
|
|
43
43
|
exports.HashService = hashing_1.default;
|
|
44
|
+
const shortner_1 = __importDefault(require("./shortner"));
|
|
45
|
+
exports.UrlService = shortner_1.default;
|
|
44
46
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4B;
|
|
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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
class UrlService {
|
|
17
|
+
constructor() {
|
|
18
|
+
}
|
|
19
|
+
shortenURL(longURL, apiUrl) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
let shortURL = "";
|
|
23
|
+
let reqHeaders = {
|
|
24
|
+
"Content-Type": "application/json"
|
|
25
|
+
};
|
|
26
|
+
let url = encodeURIComponent(longURL);
|
|
27
|
+
let requestBody = {
|
|
28
|
+
"longUrl": url
|
|
29
|
+
};
|
|
30
|
+
let postURL = `${apiUrl}urlshortener`;
|
|
31
|
+
let response = yield axios_1.default.post(postURL, requestBody, { "headers": reqHeaders });
|
|
32
|
+
if (response && response.status === 200) {
|
|
33
|
+
shortURL = response.data.shortUrlCode;
|
|
34
|
+
}
|
|
35
|
+
return shortURL;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.log(`error occurred while shortening url - ${longURL}`);
|
|
39
|
+
console.log(error);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = UrlService;
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../shortner/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,MAAqB,UAAU;IAC3B;IAEA,CAAC;IAEK,UAAU,CAAE,OAAc,EAAC,MAAa;;YAChD,IAAG;gBACO,IAAI,QAAQ,GAAG,EAAE,CAAC;gBAElB,IAAI,UAAU,GAAG;oBACb,cAAc,EAAE,kBAAkB;iBACrC,CAAC;gBAEX,IAAI,GAAG,GAAG,kBAAkB,CAAE,OAAO,CAAE,CAAC;gBAExC,IAAI,WAAW,GAAG;oBACjB,SAAS,EAAC,GAAG;iBACb,CAAC;gBAEF,IAAI,OAAO,GAAG,GAAG,MAAM,cAAc,CAAC;gBACtC,IAAI,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAE,OAAO,EAAE,WAAW,EAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAE,CAAC;gBAClF,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;oBACxC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC;iBACtC;gBACE,OAAO,QAAQ,CAAC;aACnB;YAAA,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,GAAG,CAAE,0CAA0C,OAAO,EAAE,CAAE,CAAC;gBACnE,OAAO,CAAC,GAAG,CAAE,KAAK,CAAE,CAAC;aACrB;oBAAO;gBACE,OAAO,EAAE,CAAC;aACb;QACR,CAAC;KAAA;CACD;AAhCD,6BAgCC"}
|
package/dist/esm/aws/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const AWS: {
|
|
|
13
13
|
};
|
|
14
14
|
LexRuntime: {
|
|
15
15
|
recognizeText: (lexParams: import("@aws-sdk/client-lex-runtime-v2").RecognizeTextCommandInput) => Promise<import("@aws-sdk/client-lex-runtime-v2").RecognizeTextCommandOutput>;
|
|
16
|
+
getSession: (lexSessionParams: import("@aws-sdk/client-lex-runtime-v2").GetSessionCommandInput) => Promise<import("@aws-sdk/client-lex-runtime-v2").GetSessionCommandOutput>;
|
|
16
17
|
};
|
|
17
18
|
LexModel: {
|
|
18
19
|
createBot: (botInput: import("@aws-sdk/client-lex-models-v2").CreateBotCommandInput) => Promise<import("@aws-sdk/client-lex-models-v2").CreateBotCommandOutput>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RecognizeTextCommandInput } from "@aws-sdk/client-lex-runtime-v2";
|
|
1
|
+
import { GetSessionCommandInput, RecognizeTextCommandInput } from "@aws-sdk/client-lex-runtime-v2";
|
|
2
2
|
export declare const LexRuntime: {
|
|
3
3
|
recognizeText: (lexParams: RecognizeTextCommandInput) => Promise<import("@aws-sdk/client-lex-runtime-v2").RecognizeTextCommandOutput>;
|
|
4
|
+
getSession: (lexSessionParams: GetSessionCommandInput) => Promise<import("@aws-sdk/client-lex-runtime-v2").GetSessionCommandOutput>;
|
|
4
5
|
};
|
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { LexRuntimeV2Client, RecognizeTextCommand } from "@aws-sdk/client-lex-runtime-v2";
|
|
10
|
+
import { GetSessionCommand, LexRuntimeV2Client, RecognizeTextCommand } from "@aws-sdk/client-lex-runtime-v2";
|
|
11
11
|
const awsRegion = process.env.AWS_DEFAULT_REGION || 'us-east-1';
|
|
12
12
|
const client = new LexRuntimeV2Client({ region: awsRegion });
|
|
13
13
|
/**
|
|
@@ -29,7 +29,27 @@ const recognizeText = (lexParams) => __awaiter(void 0, void 0, void 0, function*
|
|
|
29
29
|
throw new Error('lex Error');
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
+
/**
|
|
33
|
+
* This method to use get lex bot session
|
|
34
|
+
* @param lexSessionParams
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
const getSession = (lexSessionParams) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
try {
|
|
39
|
+
let param = lexSessionParams;
|
|
40
|
+
const command = new GetSessionCommand(param);
|
|
41
|
+
const response = yield client.send(command);
|
|
42
|
+
console.log("response received from lex with session");
|
|
43
|
+
console.log(JSON.stringify(response));
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.log(error);
|
|
48
|
+
throw new Error('lex Error to get session');
|
|
49
|
+
}
|
|
50
|
+
});
|
|
32
51
|
export const LexRuntime = {
|
|
33
|
-
recognizeText
|
|
52
|
+
recognizeText,
|
|
53
|
+
getSession
|
|
34
54
|
};
|
|
35
55
|
//# sourceMappingURL=AWSLexRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AWSLexRuntime.js","sourceRoot":"","sources":["../../../../aws/services/AWSLexRuntime.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AWSLexRuntime.js","sourceRoot":"","sources":["../../../../aws/services/AWSLexRuntime.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,iBAAiB,EAEjB,kBAAkB,EAClB,oBAAoB,EAErB,MAAM,gCAAgC,CAAC;AAExC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,WAAW,CAAC;AAChE,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAO,SAAoC,EAAE,EAAE;IACnE,IAAI;QACF,IAAI,KAAK,GAAG,SAAS,CAAC;QACtB,MAAM,OAAO,GAAG,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE5C,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC;KAEjB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;KAC9B;AACH,CAAC,CAAA,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAO,gBAAwC,EAAE,EAAE;IACpE,IAAI;QACF,IAAI,KAAK,GAAG,gBAAgB,CAAC;QAC7B,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE5C,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC;KAEjB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C;AACH,CAAC,CAAA,CAAA;AAID,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,aAAa;IACb,UAAU;CACX,CAAA"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ import WebHookEvent from "./webbookEvent";
|
|
|
5
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 };
|
package/dist/esm/index.js
CHANGED
|
@@ -5,5 +5,6 @@ import WebHookEvent from "./webbookEvent";
|
|
|
5
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
10
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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;AAEpC,OAAO,EACJ,GAAG,EACH,KAAK,EACL,IAAI,EACJ,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,WAAW,
|
|
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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import axios from "axios";
|
|
11
|
+
export default class UrlService {
|
|
12
|
+
constructor() {
|
|
13
|
+
}
|
|
14
|
+
shortenURL(longURL, apiUrl) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
let shortURL = "";
|
|
18
|
+
let reqHeaders = {
|
|
19
|
+
"Content-Type": "application/json"
|
|
20
|
+
};
|
|
21
|
+
let url = encodeURIComponent(longURL);
|
|
22
|
+
let requestBody = {
|
|
23
|
+
"longUrl": url
|
|
24
|
+
};
|
|
25
|
+
let postURL = `${apiUrl}urlshortener`;
|
|
26
|
+
let response = yield axios.post(postURL, requestBody, { "headers": reqHeaders });
|
|
27
|
+
if (response && response.status === 200) {
|
|
28
|
+
shortURL = response.data.shortUrlCode;
|
|
29
|
+
}
|
|
30
|
+
return shortURL;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.log(`error occurred while shortening url - ${longURL}`);
|
|
34
|
+
console.log(error);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../shortner/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B;IAEA,CAAC;IAEK,UAAU,CAAE,OAAc,EAAC,MAAa;;YAChD,IAAG;gBACO,IAAI,QAAQ,GAAG,EAAE,CAAC;gBAElB,IAAI,UAAU,GAAG;oBACb,cAAc,EAAE,kBAAkB;iBACrC,CAAC;gBAEX,IAAI,GAAG,GAAG,kBAAkB,CAAE,OAAO,CAAE,CAAC;gBAExC,IAAI,WAAW,GAAG;oBACjB,SAAS,EAAC,GAAG;iBACb,CAAC;gBAEF,IAAI,OAAO,GAAG,GAAG,MAAM,cAAc,CAAC;gBACtC,IAAI,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAE,OAAO,EAAE,WAAW,EAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAE,CAAC;gBAClF,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;oBACxC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC;iBACtC;gBACE,OAAO,QAAQ,CAAC;aACnB;YAAA,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,GAAG,CAAE,0CAA0C,OAAO,EAAE,CAAE,CAAC;gBACnE,OAAO,CAAC,GAAG,CAAE,KAAK,CAAE,CAAC;aACrB;oBAAO;gBACE,OAAO,EAAE,CAAC;aACb;QACR,CAAC;KAAA;CACD"}
|