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
|
@@ -28,9 +28,11 @@ const defaultDataServiceSettings = (
|
|
|
28
28
|
|
|
29
29
|
class RetoldDataService extends libFableServiceProviderBase
|
|
30
30
|
{
|
|
31
|
-
constructor(pFable,
|
|
31
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
32
32
|
{
|
|
33
|
-
|
|
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(
|
|
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
|
-
|
|
97
|
+
this.fable.log.info(`...loading full model stricture schema...`);
|
|
96
98
|
this.fullModel = require (`${this.options.FullMeadowSchemaPath}${this.options.FullMeadowSchemaFilename}`);
|
|
97
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
(
|
|
143
|
+
(fInitCallback) =>
|
|
142
144
|
{
|
|
143
145
|
if (this.options.AutoStartOrator)
|
|
144
146
|
{
|
|
145
|
-
this.fable.Orator.startWebServer(
|
|
147
|
+
this.fable.Orator.startWebServer(fInitCallback);
|
|
146
148
|
}
|
|
147
149
|
else
|
|
148
150
|
{
|
|
149
|
-
return
|
|
151
|
+
return fInitCallback();
|
|
150
152
|
}
|
|
151
153
|
});
|
|
152
154
|
|