api_connect_nodejs 2.0.13 → 2.0.14

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 (46) hide show
  1. package/README.md +30 -30
  2. package/conf/settings.ini +17 -20
  3. package/enums/actionType.js +10 -10
  4. package/enums/assetType.js +25 -25
  5. package/enums/chartExchangeType.js +16 -16
  6. package/enums/chartType.js +13 -13
  7. package/enums/eodIntervalType.js +11 -11
  8. package/enums/exchangeType.js +15 -15
  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/segmentType.js +10 -10
  15. package/enums/streamingConstants.js +13 -13
  16. package/enums/termsType.js +12 -12
  17. package/enums/validity.js +22 -22
  18. package/index.js +3 -3
  19. package/package.json +25 -25
  20. package/src/apiConnect.js +2682 -2559
  21. package/src/apiUtils.js +221 -221
  22. package/src/chart.js +404 -404
  23. package/src/config.js +347 -342
  24. package/src/feed/depthFeed.js +136 -136
  25. package/src/feed/feed.js +170 -170
  26. package/src/feed/liveNewsFeed.js +112 -112
  27. package/src/feed/miniQuoteFeed.js +122 -121
  28. package/src/feed/ordersFeed.js +125 -124
  29. package/src/feed/quotesFeed.js +123 -122
  30. package/src/http.js +260 -197
  31. package/src/iniparser.js +45 -45
  32. package/src/liveNews.js +362 -362
  33. package/src/logger.js +16 -16
  34. package/src/order.js +48 -48
  35. package/src/quote.js +75 -75
  36. package/src/report.js +49 -49
  37. package/src/researchCalls.js +175 -175
  38. package/src/watchlist.js +378 -378
  39. package/validations/apiConnectValidator.js +701 -698
  40. package/validations/chartValidator.js +125 -125
  41. package/validations/feedStreamerValidator.js +162 -162
  42. package/validations/liveNewsValidator.js +60 -60
  43. package/validations/quoteValidator.js +19 -19
  44. package/validations/reportValidator.js +35 -35
  45. package/validations/researchCallsValidator.js +86 -86
  46. package/validations/watchlistValidator.js +60 -60
package/src/apiUtils.js CHANGED
@@ -1,221 +1,221 @@
1
- const fs = require("fs");
2
- const configData = require("./iniparser.js");
3
- const log4js = require("./logger.js");
4
- const path = require("path");
5
- class __Constants {
6
- __VendorSession = "";
7
- __ApiKey = "";
8
- __eqAccId = "";
9
- __coAccId = "";
10
- __profileId = "";
11
- __JSessionId = "";
12
- __AppIdKey = "";
13
- __Data = "";
14
- __Prds = "";
15
-
16
- constructor() {
17
- this.__AppIdKey = configData.ApiIdKey;
18
- }
19
-
20
- get VendorSession() {
21
- return this.__VendorSession;
22
- }
23
-
24
- set VendorSession(val) {
25
- this.__VendorSession = val;
26
- }
27
-
28
- get ApiKey() {
29
- return this.__ApiKey;
30
- }
31
-
32
- set ApiKey(val) {
33
- this.__ApiKey = val;
34
- }
35
-
36
- get profileId() {
37
- return this.__profileId;
38
- }
39
-
40
- set profileId(val) {
41
- this.__profileId = val;
42
- }
43
-
44
- get eqAccId() {
45
- return this.__eqAccId;
46
- }
47
-
48
- set eqAccId(val) {
49
- this.__eqAccId = val;
50
- }
51
-
52
- get coAccId() {
53
- return this.__coAccId;
54
- }
55
-
56
- set coAccId(val) {
57
- this.__coAccId = val;
58
- }
59
-
60
- get JSession() {
61
- return this.__JSessionId;
62
- }
63
-
64
- set JSession(val) {
65
- this.__JSessionId = val;
66
- }
67
-
68
- get AppIdKey() {
69
- return this.__AppIdKey;
70
- }
71
-
72
- set AppIdKey(val) {
73
- this.__AppIdKey = val;
74
- }
75
-
76
- get Data() {
77
- return this.__Data;
78
- }
79
-
80
- set Data(val) {
81
- this.__Data = val;
82
- }
83
-
84
- get Prds() {
85
- return this.__Prds;
86
- }
87
-
88
- set Prds(val) {
89
- this.__Prds = val;
90
- }
91
-
92
- //Check file exist or not
93
- fileExistOrNot = (path) => {
94
- let flag = false;
95
- try {
96
- if (fs.existsSync(path)) {
97
- flag = true;
98
- }
99
- } catch (error) {
100
- log4js.debug("error - " + error);
101
- }
102
- return flag;
103
- };
104
-
105
- //Read file
106
- readFile = (path) => {
107
- let data = {};
108
- try {
109
- data = fs.readFileSync(path, "utf8");
110
- } catch (err) {
111
- log4js.debug("error - " + error);
112
- }
113
- return data;
114
- };
115
-
116
- //Write data in file
117
- writeInFile = (path, data) => {
118
- try {
119
- fs.writeFileSync(path, data);
120
- return true;
121
- } catch (err) {
122
- log4js.debug("error - " + error);
123
- return false;
124
- }
125
- };
126
-
127
- isEmptyNullString = (val) => {
128
- if (val === null) {
129
- return true;
130
- }
131
- if (typeof val === "string" && val.length === 0) {
132
- return true;
133
- }
134
-
135
- return false;
136
- };
137
-
138
- getProductsAndExchange = (prds) => {
139
- let res = {
140
- exc: [],
141
- prd: {},
142
- };
143
- prds.map((item) => {
144
- const exc = item.exc;
145
- res.exc.push(exc);
146
- res.prd[exc] = [];
147
- item.prd.map((item2) => {
148
- res.prd[exc].push(item2.prdVal);
149
- });
150
- });
151
- return Object.freeze(res);
152
- };
153
-
154
- readSessionFile = (sessionFile) => {
155
- let absolutePath = path.resolve(`../../${sessionFile}`);
156
- let data = fs.readFileSync(absolutePath, 'utf-8')
157
- return JSON.parse(data);
158
- }
159
-
160
- getExchangesFromSession = (sessionFile) => {
161
- let exchanges = []
162
- let loginData = this.readSessionFile(sessionFile)
163
- loginData.data.data.lgnData.prds.forEach(item => {
164
- exchanges.push(item.exc)
165
- });
166
- return exchanges;
167
- }
168
-
169
- getValidProductCode = (sessionFile, userExchange, userProductCode) => {
170
- let prdVal
171
- //check if user exchange exist in session file
172
- if (!this.getExchangesFromSession(sessionFile).includes(userExchange))
173
- throw new Error('Invalid Exchange Passed')
174
-
175
- let loginData = this.readSessionFile(sessionFile)
176
-
177
- loginData.data.data.lgnData.prds.forEach(item => {
178
- if (item.exc == userExchange) {
179
- item.prd.forEach(x => {
180
- if (x.prdVal == userProductCode) {
181
- console.log(x.prdVal)
182
- prdVal = x.prdVal
183
- }
184
-
185
- if (this.productCodeMap[userProductCode] === undefined) {
186
- throw new Error('Product Code Does not exists')
187
- }
188
- if(prdVal === undefined)
189
- prdVal = this.productCodeMap[userProductCode]
190
- })
191
- }
192
- });
193
- return prdVal;
194
- }
195
-
196
- productCodeMap = {
197
- 'B': 'BO',
198
- 'C': 'CNC',
199
- 'F': 'MTF',
200
- 'H': 'CO',
201
- 'I': 'MIS',
202
- 'M': 'NRML',
203
- 'BO': 'B',
204
- 'CNC': 'C',
205
- 'MTF': 'F',
206
- 'CO': 'H',
207
- 'MIS': 'I',
208
- 'NRML': 'M'
209
- }
210
-
211
- getAlternateActionName = (actionString) => {
212
- let alternateExchange = ""
213
- if (actionString.toUpperCase() == "BUY") {
214
- alternateExchange = "B"
215
- }else if (actionString.toUpperCase() == "SELL") {
216
- alternateExchange = "S"
217
- }
218
- return alternateExchange;
219
- }
220
- }
221
- module.exports = __Constants;
1
+ const fs = require("fs");
2
+ const configData = require("./iniparser.js");
3
+ const log4js = require("./logger.js");
4
+ const path = require("path");
5
+ class __Constants {
6
+ __VendorSession = "";
7
+ __ApiKey = "";
8
+ __eqAccId = "";
9
+ __coAccId = "";
10
+ __profileId = "";
11
+ __JSessionId = "";
12
+ __AppIdKey = "";
13
+ __Data = "";
14
+ __Prds = "";
15
+
16
+ constructor() {
17
+ this.__AppIdKey = configData.ApiIdKey;
18
+ }
19
+
20
+ get VendorSession() {
21
+ return this.__VendorSession;
22
+ }
23
+
24
+ set VendorSession(val) {
25
+ this.__VendorSession = val;
26
+ }
27
+
28
+ get ApiKey() {
29
+ return this.__ApiKey;
30
+ }
31
+
32
+ set ApiKey(val) {
33
+ this.__ApiKey = val;
34
+ }
35
+
36
+ get profileId() {
37
+ return this.__profileId;
38
+ }
39
+
40
+ set profileId(val) {
41
+ this.__profileId = val;
42
+ }
43
+
44
+ get eqAccId() {
45
+ return this.__eqAccId;
46
+ }
47
+
48
+ set eqAccId(val) {
49
+ this.__eqAccId = val;
50
+ }
51
+
52
+ get coAccId() {
53
+ return this.__coAccId;
54
+ }
55
+
56
+ set coAccId(val) {
57
+ this.__coAccId = val;
58
+ }
59
+
60
+ get JSession() {
61
+ return this.__JSessionId;
62
+ }
63
+
64
+ set JSession(val) {
65
+ this.__JSessionId = val;
66
+ }
67
+
68
+ get AppIdKey() {
69
+ return this.__AppIdKey;
70
+ }
71
+
72
+ set AppIdKey(val) {
73
+ this.__AppIdKey = val;
74
+ }
75
+
76
+ get Data() {
77
+ return this.__Data;
78
+ }
79
+
80
+ set Data(val) {
81
+ this.__Data = val;
82
+ }
83
+
84
+ get Prds() {
85
+ return this.__Prds;
86
+ }
87
+
88
+ set Prds(val) {
89
+ this.__Prds = val;
90
+ }
91
+
92
+ //Check file exist or not
93
+ fileExistOrNot = (path) => {
94
+ let flag = false;
95
+ try {
96
+ if (fs.existsSync(path)) {
97
+ flag = true;
98
+ }
99
+ } catch (error) {
100
+ log4js.debug("error - " + error);
101
+ }
102
+ return flag;
103
+ };
104
+
105
+ //Read file
106
+ readFile = (path) => {
107
+ let data = {};
108
+ try {
109
+ data = fs.readFileSync(path, "utf8");
110
+ } catch (err) {
111
+ log4js.debug("error - " + error);
112
+ }
113
+ return data;
114
+ };
115
+
116
+ //Write data in file
117
+ writeInFile = (path, data) => {
118
+ try {
119
+ fs.writeFileSync(path, data);
120
+ return true;
121
+ } catch (err) {
122
+ log4js.debug("error - " + error);
123
+ return false;
124
+ }
125
+ };
126
+
127
+ isEmptyNullString = (val) => {
128
+ if (val === null) {
129
+ return true;
130
+ }
131
+ if (typeof val === "string" && val.length === 0) {
132
+ return true;
133
+ }
134
+
135
+ return false;
136
+ };
137
+
138
+ getProductsAndExchange = (prds) => {
139
+ let res = {
140
+ exc: [],
141
+ prd: {},
142
+ };
143
+ prds.map((item) => {
144
+ const exc = item.exc;
145
+ res.exc.push(exc);
146
+ res.prd[exc] = [];
147
+ item.prd.map((item2) => {
148
+ res.prd[exc].push(item2.prdVal);
149
+ });
150
+ });
151
+ return Object.freeze(res);
152
+ };
153
+
154
+ readSessionFile = (sessionFile) => {
155
+ let absolutePath = path.resolve(`../../${sessionFile}`);
156
+ let data = fs.readFileSync(absolutePath, 'utf-8')
157
+ return JSON.parse(data);
158
+ }
159
+
160
+ getExchangesFromSession = (sessionFile) => {
161
+ let exchanges = []
162
+ let loginData = this.readSessionFile(sessionFile)
163
+ loginData.data.data.lgnData.prds.forEach(item => {
164
+ exchanges.push(item.exc)
165
+ });
166
+ return exchanges;
167
+ }
168
+
169
+ getValidProductCode = (sessionFile, userExchange, userProductCode) => {
170
+ let prdVal
171
+ //check if user exchange exist in session file
172
+ if (!this.getExchangesFromSession(sessionFile).includes(userExchange))
173
+ throw new Error('Invalid Exchange Passed')
174
+
175
+ let loginData = this.readSessionFile(sessionFile)
176
+
177
+ loginData.data.data.lgnData.prds.forEach(item => {
178
+ if (item.exc == userExchange) {
179
+ item.prd.forEach(x => {
180
+ if (x.prdVal == userProductCode) {
181
+ console.log(x.prdVal)
182
+ prdVal = x.prdVal
183
+ }
184
+
185
+ if (this.productCodeMap[userProductCode] === undefined) {
186
+ throw new Error('Product Code Does not exists')
187
+ }
188
+ if(prdVal === undefined)
189
+ prdVal = this.productCodeMap[userProductCode]
190
+ })
191
+ }
192
+ });
193
+ return prdVal;
194
+ }
195
+
196
+ productCodeMap = {
197
+ 'B': 'BO',
198
+ 'C': 'CNC',
199
+ 'F': 'MTF',
200
+ 'H': 'CO',
201
+ 'I': 'MIS',
202
+ 'M': 'NRML',
203
+ 'BO': 'B',
204
+ 'CNC': 'C',
205
+ 'MTF': 'F',
206
+ 'CO': 'H',
207
+ 'MIS': 'I',
208
+ 'NRML': 'M'
209
+ }
210
+
211
+ getAlternateActionName = (actionString) => {
212
+ let alternateExchange = ""
213
+ if (actionString.toUpperCase() == "BUY") {
214
+ alternateExchange = "B"
215
+ }else if (actionString.toUpperCase() == "SELL") {
216
+ alternateExchange = "S"
217
+ }
218
+ return alternateExchange;
219
+ }
220
+ }
221
+ module.exports = __Constants;