@ariva-mds/mds 2.1.0 → 2.3.0

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/lib/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MdsConnection = exports.MdsAuthdata = void 0;
6
+ exports.MdsConnection = exports.MarketstateUpdate = exports.MdsAuthdata = void 0;
7
7
  const reconnecting_websocket_1 = __importDefault(require("reconnecting-websocket"));
8
8
  const rxjs_1 = require("rxjs");
9
9
  class MdsAuthdata {
@@ -12,22 +12,32 @@ class MdsAuthdata {
12
12
  }
13
13
  }
14
14
  exports.MdsAuthdata = MdsAuthdata;
15
+ class MarketstateUpdate {
16
+ constructor(state, update) {
17
+ this.state = state;
18
+ this.update = update;
19
+ }
20
+ }
21
+ exports.MarketstateUpdate = MarketstateUpdate;
15
22
  class MdsConnection {
16
23
  constructor(websocketUrl, authdataCallback, options = {}) {
17
24
  this.counter = 0;
18
25
  this.runningRequestsObservable = new Map();
19
26
  this.runningRequestsPromise = new Map();
27
+ this.runningRequestsParameters = new Map();
20
28
  this.authdataCallback = authdataCallback;
21
29
  this.websocketUrl = websocketUrl;
22
30
  this.websocket = new reconnecting_websocket_1.default(this.websocketUrl, [], options.wsOptions);
23
31
  this.stayAuthenticated();
32
+ const outer = this;
24
33
  this.websocket.onopen = function () {
25
- console.log("connected");
34
+ for (let [key, value] of outer.runningRequestsParameters) {
35
+ outer.websocket.send(JSON.stringify(value));
36
+ }
26
37
  };
27
38
  this.websocket.onclose = function () {
28
39
  console.log("close");
29
40
  };
30
- const outer = this;
31
41
  this.websocket.onmessage = function (e) {
32
42
  outer.processWebsocketMessageEvent(e);
33
43
  };
@@ -37,9 +47,29 @@ class MdsConnection {
37
47
  .pipe((0, rxjs_1.map)((x) => x.dataHeartbeat));
38
48
  }
39
49
  marketstates(marketstateQueries) {
50
+ const full = new Map();
51
+ return this.marketstateUpdates(marketstateQueries)
52
+ .pipe((0, rxjs_1.map)((update) => {
53
+ let existingEntry = full.get(update.marketstateId);
54
+ if (existingEntry) {
55
+ for (let key in update) {
56
+ existingEntry[key] = update[key];
57
+ }
58
+ }
59
+ else {
60
+ existingEntry = update;
61
+ full.set(update.marketstateId, existingEntry);
62
+ }
63
+ return new MarketstateUpdate(existingEntry, update);
64
+ }));
65
+ }
66
+ marketstateUpdates(marketstateQueries) {
40
67
  return this.observable({ 'subscribeMarketstates': { 'marketstateQueries': marketstateQueries } })
41
68
  .pipe((0, rxjs_1.map)((x) => x.dataMarketstate));
42
69
  }
70
+ marketstatesStates(marketstateQueries) {
71
+ return this.marketstates(marketstateQueries).pipe((0, rxjs_1.map)((x) => x.state));
72
+ }
43
73
  priority(sources) {
44
74
  return this.promise({ 'priority': { 'sources': sources } });
45
75
  }
@@ -70,11 +100,13 @@ class MdsConnection {
70
100
  const outer = this;
71
101
  const observable = new rxjs_1.Observable((subscriber) => {
72
102
  outer.runningRequestsObservable.set(requestId, subscriber);
103
+ outer.runningRequestsParameters.set(requestId, req);
73
104
  outer.websocket.send(JSON.stringify(req));
74
105
  // Provide a way of canceling and disposing the resources
75
106
  return function unsubscribe() {
76
107
  if (outer.runningRequestsObservable.has(requestId)) {
77
108
  outer.runningRequestsObservable.delete(requestId);
109
+ outer.runningRequestsParameters.delete(requestId);
78
110
  outer.websocket.send(JSON.stringify({
79
111
  'cancel': { 'requestId': requestId }
80
112
  }));
@@ -89,6 +121,7 @@ class MdsConnection {
89
121
  const outer = this;
90
122
  const promise = new Promise((resolve, reject) => {
91
123
  outer.runningRequestsPromise.set(requestId, { 'resolve': resolve, 'reject': reject });
124
+ outer.runningRequestsParameters.set(requestId, req);
92
125
  outer.websocket.send(JSON.stringify(req));
93
126
  });
94
127
  return promise;
@@ -101,23 +134,28 @@ class MdsConnection {
101
134
  if (msg.isError) {
102
135
  promise.reject(msg.errorMessage);
103
136
  this.runningRequestsPromise.delete(msg.requestId);
137
+ this.runningRequestsParameters.delete(msg.requestId);
104
138
  }
105
139
  else if (msg.isComplete == true) {
106
140
  promise.resolve(msg);
107
141
  this.runningRequestsPromise.delete(msg.requestId);
142
+ this.runningRequestsParameters.delete(msg.requestId);
108
143
  }
109
144
  else {
110
145
  promise.reject("strange message " + msg);
111
146
  this.runningRequestsPromise.delete(msg.requestId);
147
+ this.runningRequestsParameters.delete(msg.requestId);
112
148
  }
113
149
  }
114
150
  else if (subscriber) {
115
151
  if (msg.isError) {
116
152
  this.runningRequestsObservable.delete(msg.requestId);
153
+ this.runningRequestsParameters.delete(msg.requestId);
117
154
  subscriber.error(msg.errorMessage);
118
155
  }
119
156
  else if (msg.isComplete == true) {
120
157
  this.runningRequestsObservable.delete(msg.requestId);
158
+ this.runningRequestsParameters.delete(msg.requestId);
121
159
  subscriber.complete();
122
160
  }
123
161
  else {
@@ -4,6 +4,11 @@ export declare class MdsAuthdata {
4
4
  token: string;
5
5
  constructor(token: string);
6
6
  }
7
+ export declare class MarketstateUpdate {
8
+ state: any;
9
+ update: any;
10
+ constructor(state: any, update: any);
11
+ }
7
12
  export type Options = {
8
13
  wsOptions?: ReconnectingWebSocketOptions;
9
14
  };
@@ -13,10 +18,13 @@ export declare class MdsConnection {
13
18
  private counter;
14
19
  private readonly runningRequestsObservable;
15
20
  private readonly runningRequestsPromise;
21
+ private readonly runningRequestsParameters;
16
22
  private readonly authdataCallback;
17
23
  constructor(websocketUrl: string, authdataCallback: () => Promise<MdsAuthdata>, options?: Options);
18
24
  heartbeat(): Observable<String>;
19
- marketstates(marketstateQueries: String[]): Observable<any>;
25
+ marketstates(marketstateQueries: String[]): Observable<MarketstateUpdate>;
26
+ marketstateUpdates(marketstateQueries: String[]): Observable<any>;
27
+ marketstatesStates(marketstateQueries: String[]): Observable<any>;
20
28
  priority(sources: string[]): Promise<any>;
21
29
  private stayAuthenticated;
22
30
  private generateNextRequestId;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,UAAU,EAAqB,MAAM,MAAM,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,4BAA4B,EAAC,MAAM,wBAAwB,CAAC;AAE/E,qBAAa,WAAW;IAEb,KAAK,EAAE,MAAM,CAAC;gBAET,KAAK,EAAE,MAAM;CAI5B;AAED,MAAM,MAAM,OAAO,GAAG;IAClB,SAAS,CAAC,EAAE,4BAA4B,CAAC;CAC5C,CAAC;AAEF,qBAAa,aAAa;IAEtB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,SAAS,CAAwB;IAEzC,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAA2C;IACrF,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA+B;IAEtE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6B;gBAElD,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,GAAE,OAAY;IAsB9F,SAAS,IAAI,UAAU,CAAC,MAAM,CAAC;IAK/B,YAAY,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC;IAK3D,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAQhD,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,UAAU;IA0BlB,OAAO,CAAC,OAAO;IAiBf,OAAO,CAAC,4BAA4B;CA6BvC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,UAAU,EAAqB,MAAM,MAAM,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,4BAA4B,EAAC,MAA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index.mjs CHANGED
@@ -6,25 +6,36 @@ export class MdsAuthdata {
6
6
  this.token = token;
7
7
  }
8
8
  }
9
+ export class MarketstateUpdate {
10
+ state;
11
+ update;
12
+ constructor(state, update) {
13
+ this.state = state;
14
+ this.update = update;
15
+ }
16
+ }
9
17
  export class MdsConnection {
10
18
  websocketUrl;
11
19
  websocket;
12
20
  counter = 0;
13
21
  runningRequestsObservable = new Map();
14
22
  runningRequestsPromise = new Map();
23
+ runningRequestsParameters = new Map();
15
24
  authdataCallback;
16
25
  constructor(websocketUrl, authdataCallback, options = {}) {
17
26
  this.authdataCallback = authdataCallback;
18
27
  this.websocketUrl = websocketUrl;
19
28
  this.websocket = new ReconnectingWebSocket(this.websocketUrl, [], options.wsOptions);
20
29
  this.stayAuthenticated();
30
+ const outer = this;
21
31
  this.websocket.onopen = function () {
22
- console.log("connected");
32
+ for (let [key, value] of outer.runningRequestsParameters) {
33
+ outer.websocket.send(JSON.stringify(value));
34
+ }
23
35
  };
24
36
  this.websocket.onclose = function () {
25
37
  console.log("close");
26
38
  };
27
- const outer = this;
28
39
  this.websocket.onmessage = function (e) {
29
40
  outer.processWebsocketMessageEvent(e);
30
41
  };
@@ -34,9 +45,29 @@ export class MdsConnection {
34
45
  .pipe(map((x) => x.dataHeartbeat));
35
46
  }
36
47
  marketstates(marketstateQueries) {
48
+ const full = new Map();
49
+ return this.marketstateUpdates(marketstateQueries)
50
+ .pipe(map((update) => {
51
+ let existingEntry = full.get(update.marketstateId);
52
+ if (existingEntry) {
53
+ for (let key in update) {
54
+ existingEntry[key] = update[key];
55
+ }
56
+ }
57
+ else {
58
+ existingEntry = update;
59
+ full.set(update.marketstateId, existingEntry);
60
+ }
61
+ return new MarketstateUpdate(existingEntry, update);
62
+ }));
63
+ }
64
+ marketstateUpdates(marketstateQueries) {
37
65
  return this.observable({ 'subscribeMarketstates': { 'marketstateQueries': marketstateQueries } })
38
66
  .pipe(map((x) => x.dataMarketstate));
39
67
  }
68
+ marketstatesStates(marketstateQueries) {
69
+ return this.marketstates(marketstateQueries).pipe(map((x) => x.state));
70
+ }
40
71
  priority(sources) {
41
72
  return this.promise({ 'priority': { 'sources': sources } });
42
73
  }
@@ -67,11 +98,13 @@ export class MdsConnection {
67
98
  const outer = this;
68
99
  const observable = new Observable((subscriber) => {
69
100
  outer.runningRequestsObservable.set(requestId, subscriber);
101
+ outer.runningRequestsParameters.set(requestId, req);
70
102
  outer.websocket.send(JSON.stringify(req));
71
103
  // Provide a way of canceling and disposing the resources
72
104
  return function unsubscribe() {
73
105
  if (outer.runningRequestsObservable.has(requestId)) {
74
106
  outer.runningRequestsObservable.delete(requestId);
107
+ outer.runningRequestsParameters.delete(requestId);
75
108
  outer.websocket.send(JSON.stringify({
76
109
  'cancel': { 'requestId': requestId }
77
110
  }));
@@ -86,6 +119,7 @@ export class MdsConnection {
86
119
  const outer = this;
87
120
  const promise = new Promise((resolve, reject) => {
88
121
  outer.runningRequestsPromise.set(requestId, { 'resolve': resolve, 'reject': reject });
122
+ outer.runningRequestsParameters.set(requestId, req);
89
123
  outer.websocket.send(JSON.stringify(req));
90
124
  });
91
125
  return promise;
@@ -98,23 +132,28 @@ export class MdsConnection {
98
132
  if (msg.isError) {
99
133
  promise.reject(msg.errorMessage);
100
134
  this.runningRequestsPromise.delete(msg.requestId);
135
+ this.runningRequestsParameters.delete(msg.requestId);
101
136
  }
102
137
  else if (msg.isComplete == true) {
103
138
  promise.resolve(msg);
104
139
  this.runningRequestsPromise.delete(msg.requestId);
140
+ this.runningRequestsParameters.delete(msg.requestId);
105
141
  }
106
142
  else {
107
143
  promise.reject("strange message " + msg);
108
144
  this.runningRequestsPromise.delete(msg.requestId);
145
+ this.runningRequestsParameters.delete(msg.requestId);
109
146
  }
110
147
  }
111
148
  else if (subscriber) {
112
149
  if (msg.isError) {
113
150
  this.runningRequestsObservable.delete(msg.requestId);
151
+ this.runningRequestsParameters.delete(msg.requestId);
114
152
  subscriber.error(msg.errorMessage);
115
153
  }
116
154
  else if (msg.isComplete == true) {
117
155
  this.runningRequestsObservable.delete(msg.requestId);
156
+ this.runningRequestsParameters.delete(msg.requestId);
118
157
  subscriber.complete();
119
158
  }
120
159
  else {
@@ -4,6 +4,11 @@ export declare class MdsAuthdata {
4
4
  token: string;
5
5
  constructor(token: string);
6
6
  }
7
+ export declare class MarketstateUpdate {
8
+ state: any;
9
+ update: any;
10
+ constructor(state: any, update: any);
11
+ }
7
12
  export type Options = {
8
13
  wsOptions?: ReconnectingWebSocketOptions;
9
14
  };
@@ -13,10 +18,13 @@ export declare class MdsConnection {
13
18
  private counter;
14
19
  private readonly runningRequestsObservable;
15
20
  private readonly runningRequestsPromise;
21
+ private readonly runningRequestsParameters;
16
22
  private readonly authdataCallback;
17
23
  constructor(websocketUrl: string, authdataCallback: () => Promise<MdsAuthdata>, options?: Options);
18
24
  heartbeat(): Observable<String>;
19
- marketstates(marketstateQueries: String[]): Observable<any>;
25
+ marketstates(marketstateQueries: String[]): Observable<MarketstateUpdate>;
26
+ marketstateUpdates(marketstateQueries: String[]): Observable<any>;
27
+ marketstatesStates(marketstateQueries: String[]): Observable<any>;
20
28
  priority(sources: string[]): Promise<any>;
21
29
  private stayAuthenticated;
22
30
  private generateNextRequestId;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,UAAU,EAAqB,MAAM,MAAM,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,4BAA4B,EAAC,MAAM,wBAAwB,CAAC;AAE/E,qBAAa,WAAW;IAEb,KAAK,EAAE,MAAM,CAAC;gBAET,KAAK,EAAE,MAAM;CAI5B;AAED,MAAM,MAAM,OAAO,GAAG;IAClB,SAAS,CAAC,EAAE,4BAA4B,CAAC;CAC5C,CAAC;AAEF,qBAAa,aAAa;IAEtB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,SAAS,CAAwB;IAEzC,OAAO,CAAC,OAAO,CAAa;IA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