fable 3.0.57 → 3.0.59

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.0.57",
3
+ "version": "3.0.59",
4
4
  "description": "An entity behavior management and API bundling library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -14,7 +14,7 @@ class FableServiceDataGeneration extends libFableServiceBase
14
14
  // Return a random integer between pMinimum and pMaximum
15
15
  randomIntegerBetween(pMinimum, pMaximum)
16
16
  {
17
- return Math.floor(Math.random() * (pMaximum - pMinimum + 1)) + pMinimum;
17
+ return Math.floor(Math.random() * (pMaximum - pMinimum)) + pMinimum;
18
18
  }
19
19
  // Return a random integer up to the passed-in maximum
20
20
  randomIntegerUpTo(pMaximum)
@@ -103,6 +103,15 @@ class FableServiceRestClient extends libFableServiceBase
103
103
 
104
104
  let tmpOptions = this.preRequest(pOptions);
105
105
 
106
+ if (!tmpOptions.hasOwnProperty('headers'))
107
+ {
108
+ tmpOptions.headers = {};
109
+ }
110
+ if (!tmpOptions.headers.hasOwnProperty('Content-Type'))
111
+ {
112
+ tmpOptions.headers['Content-Type'] = 'application/json';
113
+ }
114
+
106
115
  tmpOptions.RequestStartTime = this.fable.log.getTimeStamp();
107
116
 
108
117
  if (this.TraceLog)
@@ -124,6 +133,8 @@ class FableServiceRestClient extends libFableServiceBase
124
133
  this.fable.log.debug(`--> JSON ${tmpOptions.method} connected in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpConnectTime)}ms code ${pResponse.statusCode}`);
125
134
  }
126
135
 
136
+ let tmpJSONData = '';
137
+
127
138
  pResponse.on('data', (pChunk) =>
128
139
  {
129
140
  if (this.TraceLog)
@@ -131,8 +142,7 @@ class FableServiceRestClient extends libFableServiceBase
131
142
  let tmpChunkTime = this.fable.log.getTimeStamp();
132
143
  this.fable.log.debug(`--> JSON ${tmpOptions.method} data chunk size ${pChunk.length}b received in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpChunkTime)}ms`);
133
144
  }
134
- // In a JSON request, the chunk is the serialized method.
135
- return fCallback(pError, pResponse, JSON.parse(pChunk));
145
+ tmpJSONData += pChunk;
136
146
  });
137
147
 
138
148
  pResponse.on('end', ()=>
@@ -141,6 +151,7 @@ class FableServiceRestClient extends libFableServiceBase
141
151
  {
142
152
  let tmpCompletionTime = this.fable.log.getTimeStamp();
143
153
  this.fable.log.debug(`==> JSON ${tmpOptions.method} completed - received in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpCompletionTime)}ms`);
154
+ return fCallback(pError, pResponse, JSON.parse(tmpJSONData));
144
155
  }
145
156
  });
146
157
  });