retold-data-service 2.0.4 → 2.0.6

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": "retold-data-service",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Serve up a whole model!",
5
5
  "main": "source/Retold-Data-Service.js",
6
6
  "scripts": {
@@ -28,9 +28,11 @@ const defaultDataServiceSettings = (
28
28
 
29
29
  class RetoldDataService extends libFableServiceProviderBase
30
30
  {
31
- constructor(pFable, pManifest, pServiceHash)
31
+ constructor(pFable, pOptions, pServiceHash)
32
32
  {
33
- super(pFable, pManifest, pServiceHash);
33
+ // Intersect default options, parent constructor, service information
34
+ let tmpOptions = Object.assign({}, JSON.parse(JSON.stringify(defaultDataServiceSettings)), pOptions);
35
+ super(pFable, tmpOptions, pServiceHash);
34
36
 
35
37
  this.serviceType = 'RetoldDataService';
36
38
 
@@ -47,7 +49,7 @@ class RetoldDataService extends libFableServiceProviderBase
47
49
  this.fable.serviceManager.instantiateServiceProvider('Orator', this.options);
48
50
 
49
51
  // TODO: This code will be much cleaner with meadow and meadow-endpoints as services
50
- this._Meadow = libMeadow.new(_Fable);
52
+ this._Meadow = libMeadow.new(pFable);
51
53
 
52
54
  // Create DAL objects for each table in the schema
53
55
  // These will be unnecessary when meadow and meadow-endpoints are full fledged fable services
@@ -92,31 +94,31 @@ class RetoldDataService extends libFableServiceProviderBase
92
94
  // Create DAL objects for each table in the schema
93
95
 
94
96
  // 1. Load full compiled schema of the model from stricture
95
- _Fable.log.info(`...loading full model stricture schema...`);
97
+ this.fable.log.info(`...loading full model stricture schema...`);
96
98
  this.fullModel = require (`${this.options.FullMeadowSchemaPath}${this.options.FullMeadowSchemaFilename}`);
97
- _Fable.log.info(`...full model stricture schema loaded.`);
99
+ this.fable.log.info(`...full model stricture schema loaded.`);
98
100
 
99
101
  // 2. Extract an array of each table in the schema
100
- _Fable.log.info(`...getting entity list...`);
102
+ this.fable.log.info(`...getting entity list...`);
101
103
  this.entityList = Object.keys(this.fullModel.Tables);
102
104
 
103
105
  // 3. Enumerate each entry in the compiled model and load a DAL for that table
104
- _Fable.log.info(`...initializing ${this.entityList.length} DAL objects and corresponding Meadow Endpoints...`);
106
+ this.fable.log.info(`...initializing ${this.entityList.length} DAL objects and corresponding Meadow Endpoints...`);
105
107
  for (let i = 0; i < this.entityList.length; i++)
106
108
  {
107
109
  // 4. Create the DAL for each entry (e.g. it would be at _DAL.Movie for the Movie entity)
108
110
  let tmpDALEntityName = this.entityList[i];
109
111
  let tmpDALPackageFile = `${this.options.DALMeadowSchemaPath}${this.options.DALMeadowSchemaPrefix}${tmpDALEntityName}${this.options.DALMeadowSchemaPostfix}.json`
110
- _Fable.log.info(`Initializing the ${tmpDALEntityName} DAL from [${tmpDALPackageFile}]...`);
112
+ this.fable.log.info(`Initializing the ${tmpDALEntityName} DAL from [${tmpDALPackageFile}]...`);
111
113
  this._DAL[tmpDALEntityName] = this._Meadow.loadFromPackage(tmpDALPackageFile);
112
114
  // 5. Tell this DAL object to use MySQL
113
- _Fable.log.info(`...defaulting the ${tmpDALEntityName} DAL to use MySQL`);
115
+ this.fable.log.info(`...defaulting the ${tmpDALEntityName} DAL to use MySQL`);
114
116
  this._DAL[tmpDALEntityName].setProvider('MySQL');
115
117
  // 6. Create a Meadow Endpoints class for this DAL
116
- _Fable.log.info(`...initializing the ${tmpDALEntityName} Meadow Endpoints to use MySQL`);
118
+ this.fable.log.info(`...initializing the ${tmpDALEntityName} Meadow Endpoints to use MySQL`);
117
119
  this._MeadowEndpoints[tmpDALEntityName] = libMeadowEndpoints.new(this._DAL[tmpDALEntityName]);
118
120
  // 8. Expose the meadow endpoints on Orator
119
- _Fable.log.info(`...mapping the ${tmpDALEntityName} Meadow Endpoints to Orator`);
121
+ this.fable.log.info(`...mapping the ${tmpDALEntityName} Meadow Endpoints to Orator`);
120
122
  this._MeadowEndpoints[tmpDALEntityName].connectRoutes(this.fable.OratorServiceServer);
121
123
  }
122
124
 
@@ -138,15 +140,15 @@ class RetoldDataService extends libFableServiceProviderBase
138
140
  tmpAnticipate.anticipate(this.onBeforeInitialize.bind(this));
139
141
 
140
142
  tmpAnticipate.anticipate(
141
- (fCallback) =>
143
+ (fInitCallback) =>
142
144
  {
143
145
  if (this.options.AutoStartOrator)
144
146
  {
145
- this.fable.Orator.startWebServer(fCallback);
147
+ this.fable.Orator.startWebServer(fInitCallback);
146
148
  }
147
149
  else
148
150
  {
149
- return fCallback();
151
+ return fInitCallback();
150
152
  }
151
153
  });
152
154
 
@@ -42,9 +42,7 @@ suite
42
42
  AutoStartOrator: true
43
43
  });
44
44
 
45
- tmpRetoldDataService.initializeService();
46
-
47
- return fDone();
45
+ tmpRetoldDataService.initializeService(()=>{return fDone()});
48
46
  }
49
47
  );
50
48
  }