api_connect_nodejs 2.0.1 → 2.0.2

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 (39) hide show
  1. package/README.md +30 -30
  2. package/conf/settings.ini +19 -19
  3. package/enums/actionType.js +10 -10
  4. package/enums/assetType.js +25 -25
  5. package/enums/chartExchangeType.js +15 -15
  6. package/enums/chartType.js +13 -13
  7. package/enums/eodIntervalType.js +11 -11
  8. package/enums/exchangeType.js +14 -14
  9. package/enums/intradayIntervalType.js +14 -14
  10. package/enums/marketCapType.js +12 -12
  11. package/enums/orderType.js +21 -21
  12. package/enums/productType.js +24 -24
  13. package/enums/segementsType.js +13 -13
  14. package/enums/streamingConstants.js +11 -11
  15. package/enums/termsType.js +12 -12
  16. package/enums/validity.js +22 -22
  17. package/index.js +3 -3
  18. package/package.json +25 -25
  19. package/src/apiConnect.js +2430 -2424
  20. package/src/apiUtils.js +129 -129
  21. package/src/chart.js +258 -258
  22. package/src/config.js +326 -326
  23. package/src/feed/feed.js +139 -139
  24. package/src/feed/liveNewsFeed.js +112 -112
  25. package/src/feed/ordersFeed.js +124 -124
  26. package/src/feed/quotesFeed.js +121 -121
  27. package/src/http.js +197 -197
  28. package/src/iniparser.js +42 -42
  29. package/src/liveNews.js +362 -362
  30. package/src/logger.js +16 -16
  31. package/src/order.js +48 -48
  32. package/src/researchCalls.js +175 -175
  33. package/src/watchlist.js +378 -378
  34. package/validations/apiConnectValidator.js +508 -508
  35. package/validations/chartValidator.js +85 -85
  36. package/validations/feedStreamerValidator.js +68 -68
  37. package/validations/liveNewsValidator.js +60 -60
  38. package/validations/researchCallsValidator.js +86 -86
  39. package/validations/watchlistValidator.js +60 -60
@@ -1,85 +1,85 @@
1
- const Joi = require("Joi");
2
- const JoiDate = require("Joi").extend(require("@joi/date"));
3
- const enumIntradayIntervalType = require("../enums/intradayIntervalType");
4
- const enumEODIntervalType = require("../enums/eodIntervalType");
5
- const enumAssetType = require("../enums/assetType").assetType;
6
- const enumChartExchangeType = require("../enums/chartExchangeType");
7
-
8
- /**
9
- * Conver Enum Object into Array for validation
10
- */
11
- const intradayIntervalTypeArray = Object.values(enumIntradayIntervalType);
12
- const eodIntervalTypeArray = Object.values(enumEODIntervalType);
13
- const assetTypeArray = Object.values(enumAssetType);
14
- const chartExchangeTypeArray = Object.values(enumChartExchangeType);
15
-
16
- /**
17
- * Validate Chart Intraday input params
18
- */
19
- validateChartIntraday = (interval, aType, symbol, exc, tillDate, conti) => {
20
- const paramsObject = {
21
- interval: interval,
22
- aType: aType,
23
- symbol: symbol,
24
- exc: exc,
25
- tillDate: tillDate,
26
- conti: conti,
27
- };
28
- const chartParamsSchema = Joi.object({
29
- interval: Joi.string()
30
- .valid(...intradayIntervalTypeArray)
31
- .required(),
32
- aType: Joi.string()
33
- .valid(...assetTypeArray)
34
- .required(),
35
- symbol: Joi.string().required(),
36
- exc: Joi.string()
37
- .valid(...chartExchangeTypeArray)
38
- .required(),
39
- tillDate: Joi.alternatives().try(
40
- JoiDate.date().format("YYYY-MM-DD").utc(),
41
- Joi.string().valid(null)
42
- ),
43
- conti: Joi.boolean().strict(),
44
- }).options({ abortEarly: false });
45
-
46
- return chartParamsSchema.validate(paramsObject);
47
- };
48
-
49
- /**
50
- * Validate Chart EOD input params
51
- */
52
- validateChartEOD = (interval, aType, symbol, exc, tillDate, conti) => {
53
- const paramsObject = {
54
- interval: interval,
55
- aType: aType,
56
- symbol: symbol,
57
- exc: exc,
58
- tillDate: tillDate,
59
- conti: conti,
60
- };
61
- const chartSchema = Joi.object({
62
- interval: Joi.string()
63
- .valid(...eodIntervalTypeArray)
64
- .required(),
65
- aType: Joi.string()
66
- .valid(...assetTypeArray)
67
- .required(),
68
- symbol: Joi.string().required(),
69
- exc: Joi.string()
70
- .valid(...chartExchangeTypeArray)
71
- .required(),
72
- tillDate: Joi.alternatives().try(
73
- JoiDate.date().format("YYYY-MM-DD").utc(),
74
- Joi.string().valid(null)
75
- ),
76
- conti: Joi.boolean().strict(),
77
- }).options({ abortEarly: false });
78
-
79
- return chartSchema.validate(paramsObject);
80
- };
81
-
82
- module.exports = {
83
- validateChartIntraday,
84
- validateChartEOD,
85
- };
1
+ const Joi = require("Joi");
2
+ const JoiDate = require("Joi").extend(require("@joi/date"));
3
+ const enumIntradayIntervalType = require("../enums/intradayIntervalType");
4
+ const enumEODIntervalType = require("../enums/eodIntervalType");
5
+ const enumAssetType = require("../enums/assetType").assetType;
6
+ const enumChartExchangeType = require("../enums/chartExchangeType");
7
+
8
+ /**
9
+ * Conver Enum Object into Array for validation
10
+ */
11
+ const intradayIntervalTypeArray = Object.values(enumIntradayIntervalType);
12
+ const eodIntervalTypeArray = Object.values(enumEODIntervalType);
13
+ const assetTypeArray = Object.values(enumAssetType);
14
+ const chartExchangeTypeArray = Object.values(enumChartExchangeType);
15
+
16
+ /**
17
+ * Validate Chart Intraday input params
18
+ */
19
+ validateChartIntraday = (interval, aType, symbol, exc, tillDate, conti) => {
20
+ const paramsObject = {
21
+ interval: interval,
22
+ aType: aType,
23
+ symbol: symbol,
24
+ exc: exc,
25
+ tillDate: tillDate,
26
+ conti: conti,
27
+ };
28
+ const chartParamsSchema = Joi.object({
29
+ interval: Joi.string()
30
+ .valid(...intradayIntervalTypeArray)
31
+ .required(),
32
+ aType: Joi.string()
33
+ .valid(...assetTypeArray)
34
+ .required(),
35
+ symbol: Joi.string().required(),
36
+ exc: Joi.string()
37
+ .valid(...chartExchangeTypeArray)
38
+ .required(),
39
+ tillDate: Joi.alternatives().try(
40
+ JoiDate.date().format("YYYY-MM-DD").utc(),
41
+ Joi.string().valid(null)
42
+ ),
43
+ conti: Joi.boolean().strict(),
44
+ }).options({ abortEarly: false });
45
+
46
+ return chartParamsSchema.validate(paramsObject);
47
+ };
48
+
49
+ /**
50
+ * Validate Chart EOD input params
51
+ */
52
+ validateChartEOD = (interval, aType, symbol, exc, tillDate, conti) => {
53
+ const paramsObject = {
54
+ interval: interval,
55
+ aType: aType,
56
+ symbol: symbol,
57
+ exc: exc,
58
+ tillDate: tillDate,
59
+ conti: conti,
60
+ };
61
+ const chartSchema = Joi.object({
62
+ interval: Joi.string()
63
+ .valid(...eodIntervalTypeArray)
64
+ .required(),
65
+ aType: Joi.string()
66
+ .valid(...assetTypeArray)
67
+ .required(),
68
+ symbol: Joi.string().required(),
69
+ exc: Joi.string()
70
+ .valid(...chartExchangeTypeArray)
71
+ .required(),
72
+ tillDate: Joi.alternatives().try(
73
+ JoiDate.date().format("YYYY-MM-DD").utc(),
74
+ Joi.string().valid(null)
75
+ ),
76
+ conti: Joi.boolean().strict(),
77
+ }).options({ abortEarly: false });
78
+
79
+ return chartSchema.validate(paramsObject);
80
+ };
81
+
82
+ module.exports = {
83
+ validateChartIntraday,
84
+ validateChartEOD,
85
+ };
@@ -1,68 +1,68 @@
1
- const Joi = require("joi");
2
-
3
- /**
4
- * Validator For Subsribe LiveNews Feed
5
- */
6
- validateStreamerCallback = (callback) => {
7
- let subcribeLiveNewsObj = {
8
- callback: callback,
9
- };
10
-
11
- const subcribeLiveNewsSchema = Joi.object({
12
- callback: Joi.function().required(),
13
- }).options({ abortEarly: false });
14
-
15
- return subcribeLiveNewsSchema.validate(subcribeLiveNewsObj);
16
- };
17
-
18
- /**
19
- * Validator For Subsribe Quote Feed
20
- */
21
- validateSubscribeQuotesFeed = (callback, symbols) => {
22
- let subcribeFeedQuoteObj = {
23
- callback: callback,
24
- symbols: symbols,
25
- };
26
-
27
- const subcribeFeedQuoteSchema = Joi.object({
28
- callback: Joi.function().required(),
29
- symbols: Joi.array().items(Joi.string().min(1).required()).required(),
30
- }).options({ abortEarly: false });
31
-
32
- return subcribeFeedQuoteSchema.validate(subcribeFeedQuoteObj);
33
- };
34
-
35
- /**
36
- * Validator For Unsubsribe Quote Feed
37
- */
38
- validateUnsubscribeQuotesFeed = (symbols) => {
39
- let unsubcribeFeedQuoteObj = {
40
- symbols: symbols,
41
- };
42
-
43
- const UnsubcribeFeedQuoteSchema = Joi.object({
44
- symbols: Joi.array().items(Joi.string().min(1).required()).required(),
45
- }).options({ abortEarly: false });
46
-
47
- return UnsubcribeFeedQuoteSchema.validate(unsubcribeFeedQuoteObj);
48
- };
49
-
50
- validateSubscribeOrdersFeed = (accId, userId, callback) => {
51
- let subcribeOrdersFeedObj = {
52
- accId: accId,
53
- userId: userId,
54
- callback: callback,
55
- };
56
-
57
- const subcribeOrdersFeedSchema = Joi.object({
58
- accId: Joi.string().required(),
59
- userId: Joi.string().required(),
60
- callback: Joi.function().required(),
61
- }).options({ abortEarly: false });
62
-
63
- return subcribeOrdersFeedSchema.validate(subcribeOrdersFeedObj);
64
- };
65
-
66
-
67
-
68
- module.exports = { validateStreamerCallback, validateSubscribeQuotesFeed, validateUnsubscribeQuotesFeed, validateSubscribeOrdersFeed};
1
+ const Joi = require("joi");
2
+
3
+ /**
4
+ * Validator For Subsribe LiveNews Feed
5
+ */
6
+ validateStreamerCallback = (callback) => {
7
+ let subcribeLiveNewsObj = {
8
+ callback: callback,
9
+ };
10
+
11
+ const subcribeLiveNewsSchema = Joi.object({
12
+ callback: Joi.function().required(),
13
+ }).options({ abortEarly: false });
14
+
15
+ return subcribeLiveNewsSchema.validate(subcribeLiveNewsObj);
16
+ };
17
+
18
+ /**
19
+ * Validator For Subsribe Quote Feed
20
+ */
21
+ validateSubscribeQuotesFeed = (callback, symbols) => {
22
+ let subcribeFeedQuoteObj = {
23
+ callback: callback,
24
+ symbols: symbols,
25
+ };
26
+
27
+ const subcribeFeedQuoteSchema = Joi.object({
28
+ callback: Joi.function().required(),
29
+ symbols: Joi.array().items(Joi.string().min(1).required()).required(),
30
+ }).options({ abortEarly: false });
31
+
32
+ return subcribeFeedQuoteSchema.validate(subcribeFeedQuoteObj);
33
+ };
34
+
35
+ /**
36
+ * Validator For Unsubsribe Quote Feed
37
+ */
38
+ validateUnsubscribeQuotesFeed = (symbols) => {
39
+ let unsubcribeFeedQuoteObj = {
40
+ symbols: symbols,
41
+ };
42
+
43
+ const UnsubcribeFeedQuoteSchema = Joi.object({
44
+ symbols: Joi.array().items(Joi.string().min(1).required()).required(),
45
+ }).options({ abortEarly: false });
46
+
47
+ return UnsubcribeFeedQuoteSchema.validate(unsubcribeFeedQuoteObj);
48
+ };
49
+
50
+ validateSubscribeOrdersFeed = (accId, userId, callback) => {
51
+ let subcribeOrdersFeedObj = {
52
+ accId: accId,
53
+ userId: userId,
54
+ callback: callback,
55
+ };
56
+
57
+ const subcribeOrdersFeedSchema = Joi.object({
58
+ accId: Joi.string().required(),
59
+ userId: Joi.string().required(),
60
+ callback: Joi.function().required(),
61
+ }).options({ abortEarly: false });
62
+
63
+ return subcribeOrdersFeedSchema.validate(subcribeOrdersFeedObj);
64
+ };
65
+
66
+
67
+
68
+ module.exports = { validateStreamerCallback, validateSubscribeQuotesFeed, validateUnsubscribeQuotesFeed, validateSubscribeOrdersFeed};
@@ -1,60 +1,60 @@
1
- const Joi = require("Joi");
2
- const JoiDate = Joi.extend(require("@joi/date"));
3
-
4
- validateLiveNewsParams = (
5
- category,
6
- holdings,
7
- searchText,
8
- pageNumber,
9
- newsCategories
10
- ) => {
11
- const paramsObj = {
12
- category: category,
13
- holdings: holdings,
14
- searchText: searchText,
15
- pageNumber: pageNumber,
16
- };
17
-
18
- const liveNewsBodySchema = Joi.object({
19
- category: Joi.any()
20
- .valid(...newsCategories)
21
- .when("holdings", {
22
- is: false,
23
- then: Joi.required(),
24
- otherwise: Joi.valid(null, ""),
25
- }),
26
- searchText: Joi.string().allow(null, ""),
27
- pageNumber: Joi.number().positive().allow(0),
28
- holdings: Joi.boolean().required(),
29
- }).options({ abortEarly: false });
30
- return liveNewsBodySchema.validate(paramsObj);
31
- };
32
-
33
- validateNewsForResultsAndStocksParams = (holdings, searchText, pageNumber) => {
34
- const paramsObj = {
35
- holdings: holdings,
36
- searchText: searchText,
37
- pageNumber: pageNumber,
38
- };
39
-
40
- const liveNewsBodySchema = Joi.object({
41
- searchText: Joi.string().allow(null, ""),
42
- pageNumber: Joi.number().positive().allow(0),
43
- holdings: Joi.boolean().required(),
44
- }).options({ abortEarly: false });
45
- return liveNewsBodySchema.validate(paramsObj);
46
- };
47
-
48
- validateLatestCorporateActions = (symbol) => {
49
- const LatestCorporateActionsSchema = Joi.object({
50
- symbol: Joi.string().required(),
51
- }).options({ abortEarly: false });
52
-
53
- return LatestCorporateActionsSchema.validate({ symbol: symbol });
54
- };
55
-
56
- module.exports = {
57
- validateLiveNewsParams,
58
- validateLatestCorporateActions,
59
- validateNewsForResultsAndStocksParams,
60
- };
1
+ const Joi = require("Joi");
2
+ const JoiDate = Joi.extend(require("@joi/date"));
3
+
4
+ validateLiveNewsParams = (
5
+ category,
6
+ holdings,
7
+ searchText,
8
+ pageNumber,
9
+ newsCategories
10
+ ) => {
11
+ const paramsObj = {
12
+ category: category,
13
+ holdings: holdings,
14
+ searchText: searchText,
15
+ pageNumber: pageNumber,
16
+ };
17
+
18
+ const liveNewsBodySchema = Joi.object({
19
+ category: Joi.any()
20
+ .valid(...newsCategories)
21
+ .when("holdings", {
22
+ is: false,
23
+ then: Joi.required(),
24
+ otherwise: Joi.valid(null, ""),
25
+ }),
26
+ searchText: Joi.string().allow(null, ""),
27
+ pageNumber: Joi.number().positive().allow(0),
28
+ holdings: Joi.boolean().required(),
29
+ }).options({ abortEarly: false });
30
+ return liveNewsBodySchema.validate(paramsObj);
31
+ };
32
+
33
+ validateNewsForResultsAndStocksParams = (holdings, searchText, pageNumber) => {
34
+ const paramsObj = {
35
+ holdings: holdings,
36
+ searchText: searchText,
37
+ pageNumber: pageNumber,
38
+ };
39
+
40
+ const liveNewsBodySchema = Joi.object({
41
+ searchText: Joi.string().allow(null, ""),
42
+ pageNumber: Joi.number().positive().allow(0),
43
+ holdings: Joi.boolean().required(),
44
+ }).options({ abortEarly: false });
45
+ return liveNewsBodySchema.validate(paramsObj);
46
+ };
47
+
48
+ validateLatestCorporateActions = (symbol) => {
49
+ const LatestCorporateActionsSchema = Joi.object({
50
+ symbol: Joi.string().required(),
51
+ }).options({ abortEarly: false });
52
+
53
+ return LatestCorporateActionsSchema.validate({ symbol: symbol });
54
+ };
55
+
56
+ module.exports = {
57
+ validateLiveNewsParams,
58
+ validateLatestCorporateActions,
59
+ validateNewsForResultsAndStocksParams,
60
+ };
@@ -1,86 +1,86 @@
1
- const Joi = require("joi");
2
- const JoiDate = Joi.extend(require("@joi/date"));
3
- const segments = require("../enums/segementsType");
4
- const terms = require("../enums/termsType");
5
- const marketCap = require("../enums/marketCapType");
6
- const action = require("../enums/actionType");
7
-
8
- /**
9
- * Conver Enum Object into Array for validation
10
- */
11
- const segmentsArr = Object.values(segments);
12
- const termsArr = Object.values(terms);
13
- const marketCapArr = Object.values(marketCap);
14
- const actionArr = Object.values(action);
15
-
16
- validateActiveResearchCalls = (segment, term, marketCap) => {
17
- const activeResearchCallsObj = {
18
- segment: segment,
19
- term: term,
20
- marketCap,
21
- };
22
-
23
- const activeResearchCallsSchema = Joi.object({
24
- segment: Joi.string()
25
- .valid(...segmentsArr)
26
- .required(),
27
- term: Joi.string()
28
- .valid(...termsArr)
29
- .required(),
30
- marketCap: Joi.string().when("segment", {
31
- is: "EQ",
32
- then: Joi.valid(...marketCapArr).required(),
33
- otherwise: Joi.valid(null).messages({
34
- "any.only": `"marketCap" is only applicable for EQ segment type so it's value must be null`,
35
- }),
36
- }),
37
- }).options({ abortEarly: false });
38
-
39
- return activeResearchCallsSchema.validate(activeResearchCallsObj);
40
- };
41
-
42
- validateClosedResearchCalls = (
43
- segment,
44
- term,
45
- action,
46
- fromDate,
47
- toDate,
48
- recommendationType,
49
- marketCap
50
- ) => {
51
- const closedResearchCallsObj = {
52
- fromDate: fromDate,
53
- toDate: toDate,
54
- recommendationType: recommendationType,
55
- action: action,
56
- segment: segment,
57
- term: term,
58
- marketCap: marketCap,
59
- };
60
-
61
- const closedResearchCallsSchema = Joi.object({
62
- fromDate: JoiDate.date().format("YYYY-MM-DD").allow(""),
63
- toDate: JoiDate.date().format("YYYY-MM-DD").allow(""),
64
- action: Joi.string()
65
- .valid(...actionArr)
66
- .allow(""),
67
- recommendationType: Joi.string().allow(""),
68
- segment: Joi.string()
69
- .valid(...segmentsArr)
70
- .required(),
71
- term: Joi.string()
72
- .valid(...termsArr)
73
- .required(),
74
- marketCap: Joi.string().when("segment", {
75
- is: "EQ",
76
- then: Joi.valid(...marketCapArr).required(),
77
- otherwise: Joi.valid(null).messages({
78
- "any.only": `"marketCap" is only applicable for EQ segment type so it's value must be null`,
79
- }),
80
- }),
81
- }).options({ abortEarly: false });
82
-
83
- return closedResearchCallsSchema.validate(closedResearchCallsObj);
84
- };
85
-
86
- module.exports = { validateActiveResearchCalls, validateClosedResearchCalls };
1
+ const Joi = require("joi");
2
+ const JoiDate = Joi.extend(require("@joi/date"));
3
+ const segments = require("../enums/segementsType");
4
+ const terms = require("../enums/termsType");
5
+ const marketCap = require("../enums/marketCapType");
6
+ const action = require("../enums/actionType");
7
+
8
+ /**
9
+ * Conver Enum Object into Array for validation
10
+ */
11
+ const segmentsArr = Object.values(segments);
12
+ const termsArr = Object.values(terms);
13
+ const marketCapArr = Object.values(marketCap);
14
+ const actionArr = Object.values(action);
15
+
16
+ validateActiveResearchCalls = (segment, term, marketCap) => {
17
+ const activeResearchCallsObj = {
18
+ segment: segment,
19
+ term: term,
20
+ marketCap,
21
+ };
22
+
23
+ const activeResearchCallsSchema = Joi.object({
24
+ segment: Joi.string()
25
+ .valid(...segmentsArr)
26
+ .required(),
27
+ term: Joi.string()
28
+ .valid(...termsArr)
29
+ .required(),
30
+ marketCap: Joi.string().when("segment", {
31
+ is: "EQ",
32
+ then: Joi.valid(...marketCapArr).required(),
33
+ otherwise: Joi.valid(null).messages({
34
+ "any.only": `"marketCap" is only applicable for EQ segment type so it's value must be null`,
35
+ }),
36
+ }),
37
+ }).options({ abortEarly: false });
38
+
39
+ return activeResearchCallsSchema.validate(activeResearchCallsObj);
40
+ };
41
+
42
+ validateClosedResearchCalls = (
43
+ segment,
44
+ term,
45
+ action,
46
+ fromDate,
47
+ toDate,
48
+ recommendationType,
49
+ marketCap
50
+ ) => {
51
+ const closedResearchCallsObj = {
52
+ fromDate: fromDate,
53
+ toDate: toDate,
54
+ recommendationType: recommendationType,
55
+ action: action,
56
+ segment: segment,
57
+ term: term,
58
+ marketCap: marketCap,
59
+ };
60
+
61
+ const closedResearchCallsSchema = Joi.object({
62
+ fromDate: JoiDate.date().format("YYYY-MM-DD").allow(""),
63
+ toDate: JoiDate.date().format("YYYY-MM-DD").allow(""),
64
+ action: Joi.string()
65
+ .valid(...actionArr)
66
+ .allow(""),
67
+ recommendationType: Joi.string().allow(""),
68
+ segment: Joi.string()
69
+ .valid(...segmentsArr)
70
+ .required(),
71
+ term: Joi.string()
72
+ .valid(...termsArr)
73
+ .required(),
74
+ marketCap: Joi.string().when("segment", {
75
+ is: "EQ",
76
+ then: Joi.valid(...marketCapArr).required(),
77
+ otherwise: Joi.valid(null).messages({
78
+ "any.only": `"marketCap" is only applicable for EQ segment type so it's value must be null`,
79
+ }),
80
+ }),
81
+ }).options({ abortEarly: false });
82
+
83
+ return closedResearchCallsSchema.validate(closedResearchCallsObj);
84
+ };
85
+
86
+ module.exports = { validateActiveResearchCalls, validateClosedResearchCalls };