fable 3.0.39 → 3.0.40

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.
@@ -5,7 +5,7 @@
5
5
 
6
6
  "LibraryOutputFolder": "./dist/",
7
7
 
8
- "LibraryUniminifiedFileName": "fable.compatible.js",
8
+ "LibraryUniminifiedFileName": "fable.js",
9
9
 
10
- "LibraryMinifiedFileName": "fable.compatible.min.js"
10
+ "LibraryMinifiedFileName": "fable.min.js"
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.0.39",
3
+ "version": "3.0.40",
4
4
  "description": "An entity behavior management and API bundling library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "test": "./node_modules/.bin/mocha -u tdd -R spec",
10
10
  "build": "./node_modules/.bin/gulp build",
11
11
  "build-compatible": "GULP_CUSTOM_BUILD_TARGET=compatible ./node_modules/.bin/gulp build",
12
- "docker-dev-build-image": "docker build ./ -f Dockerfile_LUXURYCode -t retold/fable:local",
12
+ "docker-dev-build": "docker build ./ -f Dockerfile_LUXURYCode -t retold/fable:local",
13
13
  "docker-dev-run": "docker run -it -d --name retold-fable-dev -p 30001:8080 -p 8086:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/fable\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" retold/fable:local",
14
14
  "docker-dev-shell": "docker exec -it retold-fable-dev /bin/bash"
15
15
  },
@@ -17,18 +17,30 @@ class FableServiceRestClient extends libFableServiceBase
17
17
  this.dataFormat = this.fable.defaultServices.DataFormat;
18
18
 
19
19
  this.serviceType = 'RestClient';
20
+
21
+ // This is a function that can be overridden, to allow the management
22
+ // of the request options before they are passed to the request library.
23
+ this.prepareRequestOptions = (pOptions) => { return pOptions; };
24
+ }
25
+
26
+ preRequest(pOptions)
27
+ {
28
+ // Validate the options object
29
+ return this.prepareRequestOptions(pOptions);
20
30
  }
21
31
 
22
32
  executeChunkedRequest(pOptions, fCallback)
23
33
  {
24
- pOptions.RequestStartTime = this.fable.log.getTimeStamp();
34
+ let tmpOptions = this.preRequest(pOptions);
35
+
36
+ tmpOptions.RequestStartTime = this.fable.log.getTimeStamp();
25
37
 
26
38
  if (this.TraceLog)
27
39
  {
28
- this.fable.log.debug(`Beginning ${pOptions.method} request to ${pOptions.url} at ${pOptions.RequestStartTime}`);
40
+ this.fable.log.debug(`Beginning ${tmpOptions.method} request to ${tmpOptions.url} at ${tmpOptions.RequestStartTime}`);
29
41
  }
30
42
 
31
- return libSimpleGet(pOptions,
43
+ return libSimpleGet(tmpOptions,
32
44
  (pError, pResponse)=>
33
45
  {
34
46
  if (pError)
@@ -39,7 +51,7 @@ class FableServiceRestClient extends libFableServiceBase
39
51
  if (this.TraceLog)
40
52
  {
41
53
  let tmpConnectTime = this.fable.log.getTimeStamp();
42
- this.fable.log.debug(`--> ${pOptions.method} connected in ${this.dataFormat.formatTimeDelta(pOptions.RequestStartTime, tmpConnectTime)}ms code ${pResponse.statusCode}`);
54
+ this.fable.log.debug(`--> ${tmpOptions.method} connected in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpConnectTime)}ms code ${pResponse.statusCode}`);
43
55
  }
44
56
 
45
57
  let tmpData = '';
@@ -50,7 +62,7 @@ class FableServiceRestClient extends libFableServiceBase
50
62
  if (this.TraceLog)
51
63
  {
52
64
  let tmpChunkTime = this.fable.log.getTimeStamp();
53
- this.fable.log.debug(`--> ${pOptions.method} data chunk size ${pChunk.length}b received in ${this.dataFormat.formatTimeDelta(pOptions.RequestStartTime, tmpChunkTime)}ms`);
65
+ this.fable.log.debug(`--> ${tmpOptions.method} data chunk size ${pChunk.length}b received in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpChunkTime)}ms`);
54
66
  }
55
67
  tmpData += pChunk;
56
68
  });
@@ -60,7 +72,7 @@ class FableServiceRestClient extends libFableServiceBase
60
72
  if (this.TraceLog)
61
73
  {
62
74
  let tmpCompletionTime = this.fable.log.getTimeStamp();
63
- this.fable.log.debug(`==> ${pOptions.method} completed data size ${tmpData.length}b received in ${this.dataFormat.formatTimeDelta(pOptions.RequestStartTime, tmpCompletionTime)}ms`);
75
+ this.fable.log.debug(`==> ${tmpOptions.method} completed data size ${tmpData.length}b received in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpCompletionTime)}ms`);
64
76
  }
65
77
  return fCallback(pError, pResponse, tmpData);
66
78
  });
@@ -71,14 +83,16 @@ class FableServiceRestClient extends libFableServiceBase
71
83
  {
72
84
  pOptions.json = true;
73
85
 
74
- pOptions.RequestStartTime = this.fable.log.getTimeStamp();
86
+ let tmpOptions = this.preRequest(pOptions);
87
+
88
+ tmpOptions.RequestStartTime = this.fable.log.getTimeStamp();
75
89
 
76
90
  if (this.TraceLog)
77
91
  {
78
- this.fable.log.debug(`Beginning ${pOptions.method} JSON request to ${pOptions.url} at ${pOptions.RequestStartTime}`);
92
+ this.fable.log.debug(`Beginning ${tmpOptions.method} JSON request to ${tmpOptions.url} at ${tmpOptions.RequestStartTime}`);
79
93
  }
80
94
 
81
- return libSimpleGet(pOptions,
95
+ return libSimpleGet(tmpOptions,
82
96
  (pError, pResponse)=>
83
97
  {
84
98
  if (pError)
@@ -89,7 +103,7 @@ class FableServiceRestClient extends libFableServiceBase
89
103
  if (this.TraceLog)
90
104
  {
91
105
  let tmpConnectTime = this.fable.log.getTimeStamp();
92
- this.fable.log.debug(`--> JSON ${pOptions.method} connected in ${this.dataFormat.formatTimeDelta(pOptions.RequestStartTime, tmpConnectTime)}ms code ${pResponse.statusCode}`);
106
+ this.fable.log.debug(`--> JSON ${tmpOptions.method} connected in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpConnectTime)}ms code ${pResponse.statusCode}`);
93
107
  }
94
108
 
95
109
  pResponse.on('data', (pChunk) =>
@@ -97,7 +111,7 @@ class FableServiceRestClient extends libFableServiceBase
97
111
  if (this.TraceLog)
98
112
  {
99
113
  let tmpChunkTime = this.fable.log.getTimeStamp();
100
- this.fable.log.debug(`--> JSON ${pOptions.method} data chunk size ${pChunk.length}b received in ${this.dataFormat.formatTimeDelta(pOptions.RequestStartTime, tmpChunkTime)}ms`);
114
+ this.fable.log.debug(`--> JSON ${tmpOptions.method} data chunk size ${pChunk.length}b received in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpChunkTime)}ms`);
101
115
  }
102
116
  // In a JSON request, the chunk is the serialized method.
103
117
  return fCallback(pError, pResponse, JSON.parse(pChunk));
@@ -108,7 +122,7 @@ class FableServiceRestClient extends libFableServiceBase
108
122
  if (this.TraceLog)
109
123
  {
110
124
  let tmpCompletionTime = this.fable.log.getTimeStamp();
111
- this.fable.log.debug(`==> JSON ${pOptions.method} completed - received in ${this.dataFormat.formatTimeDelta(pOptions.RequestStartTime, tmpCompletionTime)}ms`);
125
+ this.fable.log.debug(`==> JSON ${tmpOptions.method} completed - received in ${this.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime, tmpCompletionTime)}ms`);
112
126
  }
113
127
  });
114
128
  });
@@ -8,9 +8,6 @@
8
8
 
9
9
  var libFable = require('../source/Fable.js');
10
10
 
11
- const libFS = require('fs');
12
- const libReadline = require('readline');
13
-
14
11
  var Chai = require("chai");
15
12
  var Expect = Chai.expect;
16
13
 
@@ -57,6 +57,12 @@ suite
57
57
  // Instantiate the RestClient Service Provider
58
58
  let tmpRestClient = testFable.serviceManager.instantiateServiceProvider('RestClient', {TraceLog: true}, 'RestClient-99');
59
59
 
60
+ tmpRestClient.prepareRequestOptions = (pOptions) =>
61
+ {
62
+ pOptions.headers = {'Content-Type':'application/json'};
63
+ return pOptions;
64
+ };
65
+
60
66
  // Download the wiktionary entry for dog!
61
67
  tmpRestClient.postJSON({url: 'http://localhost:8086/1.0/Author', body:{Name:'Test Author'}},
62
68
  (pError, pResponse, pBody)=>