retold-data-service 2.0.7 → 2.0.8
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/debug/Harness.js +81 -2
- package/package.json +4 -2
- package/source/Retold-Data-Service.js +44 -13
- package/test/model/{json/MeadowModel-Extended.json → MeadowModel-Extended.json} +969 -5
- package/{debug/model/generated_documentation → test/model/doc}/Dictionary.md +1 -1
- package/{debug/model/generated_documentation → test/model/doc}/Model-Author.md +5 -5
- package/{debug/model/generated_documentation → test/model/doc}/Model-Book.md +6 -6
- package/{debug/model/generated_documentation → test/model/doc}/Model-BookAuthorJoin.md +4 -4
- package/{debug/model/generated_documentation → test/model/doc}/Model-BookPrice.md +6 -6
- package/{debug/model/generated_documentation → test/model/doc}/Model-Review.md +7 -7
- package/{debug/model/generated_documentation → test/model/doc}/ModelChangeTracking.md +1 -1
- package/{debug/model/generated_diagram/Stricture_Output.dot → test/model/doc/diagrams/Relationships.dot} +1 -1
- package/test/model/doc/diagrams/RelationshipsFull.dot +13 -0
- package/test/model/doc/diagrams/RelationshipsFull.png +0 -0
- package/test/model/meadow/MeadowSchemaAuthor.json +431 -0
- package/test/model/meadow/MeadowSchemaBook.json +527 -0
- package/test/model/meadow/MeadowSchemaBookAuthorJoin.json +335 -0
- package/test/model/meadow/MeadowSchemaBookPrice.json +511 -0
- package/test/model/meadow/MeadowSchemaReview.json +463 -0
- package/{debug/model/sql_create/BookStore-CreateDatabase.mysql.sql → test/model/mysql_create/MeadowModel-CreateMySQLDatabase.mysql.sql} +6 -6
- package/debug/bookstore-configuration.json +0 -26
- package/debug/model/Model-Extended.json +0 -915
- package/debug/model/Model-PICT.json +0 -1
- package/debug/model/Model.json +0 -280
- package/debug/model/bookstore-api-endpoint-exercises.paw +0 -0
- package/debug/model/ddl/BookStore.ddl +0 -66
- package/debug/model/generated_diagram/README.md +0 -1
- package/debug/model/generated_documentation/README.md +0 -1
- package/debug/model/manual_scripts/DropTables.sql +0 -5
- package/debug/model/manual_scripts/MySQL-Laden-Entry-ServicesOnly.sh +0 -28
- package/debug/model/manual_scripts/MySQL-Laden-Entry.sh +0 -17
- package/debug/model/manual_scripts/MySQL-Security.sql +0 -5
- package/debug/model/manual_scripts/README.md +0 -2
- package/debug/model/manual_scripts/my.cnf +0 -4
- package/debug/model/meadow/Model-MeadowSchema-Author.json +0 -220
- package/debug/model/meadow/Model-MeadowSchema-Book.json +0 -268
- package/debug/model/meadow/Model-MeadowSchema-BookAuthorJoin.json +0 -172
- package/debug/model/meadow/Model-MeadowSchema-BookPrice.json +0 -260
- package/debug/model/meadow/Model-MeadowSchema-Review.json +0 -236
- package/debug/model/meadow/README.md +0 -1
- package/debug/model/sql_create/BookStore-CreateAndPopulateTables.sql +0 -194
- package/debug/model/sql_create/README.md +0 -1
- package/test/model/Model-Extended.json +0 -915
- package/test/model/Model.ddl +0 -66
- package/test/model/Model.json +0 -280
- package/test/model/meadow/Model-MeadowSchema-Author.json +0 -220
- package/test/model/meadow/Model-MeadowSchema-Book.json +0 -268
- package/test/model/meadow/Model-MeadowSchema-BookAuthorJoin.json +0 -172
- package/test/model/meadow/Model-MeadowSchema-BookPrice.json +0 -260
- package/test/model/meadow/Model-MeadowSchema-Review.json +0 -236
- /package/test/model/{json/MeadowModel-PICT.json → MeadowModel-PICT.json} +0 -0
- /package/test/model/{json/MeadowModel.json → MeadowModel.json} +0 -0
- /package/{debug/model/generated_diagram/Stricture_Output.png → test/model/doc/diagrams/Relationships.png} +0 -0
package/debug/Harness.js
CHANGED
|
@@ -1,14 +1,60 @@
|
|
|
1
|
-
const _Settings =
|
|
1
|
+
const _Settings = (
|
|
2
|
+
{
|
|
3
|
+
"Product": "MeadowEndpointsTestHarness",
|
|
4
|
+
|
|
5
|
+
"ProductVersion": "1.0.0",
|
|
6
|
+
"UUID":
|
|
7
|
+
{
|
|
8
|
+
"DataCenter": 0,
|
|
9
|
+
"Worker": 0
|
|
10
|
+
},
|
|
11
|
+
"LogStreams":
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
"streamtype": "console"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
"APIServerPort": 8087,
|
|
19
|
+
|
|
20
|
+
"RetoldDataServiceOptions":
|
|
21
|
+
{
|
|
22
|
+
"StorageProvider": "MySQL",
|
|
23
|
+
"StorageProviderModule": "meadow-connection-mysql",
|
|
24
|
+
|
|
25
|
+
"FullMeadowSchemaPath": `${__dirname}/../test/model/`,
|
|
26
|
+
"FullMeadowSchemaFilename": `MeadowModel-Extended.json`,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
"MySQL":
|
|
30
|
+
{
|
|
31
|
+
"Server": "127.0.0.1",
|
|
32
|
+
"Port": 31306,
|
|
33
|
+
"User": "root",
|
|
34
|
+
"Password": "123456789",
|
|
35
|
+
"Database": "bookstore",
|
|
36
|
+
"ConnectionPoolLimit": 20
|
|
37
|
+
},
|
|
38
|
+
"MeadowConnectionMySQLAutoConnect": true
|
|
39
|
+
});
|
|
2
40
|
|
|
3
41
|
const libFable = require('fable');
|
|
4
42
|
|
|
5
43
|
_Fable = new libFable(_Settings);
|
|
6
44
|
|
|
7
|
-
_Fable.serviceManager.
|
|
45
|
+
_Fable.serviceManager.addServiceType('RetoldDataService', require('../source/Retold-Data-Service.js'));
|
|
46
|
+
_Fable.serviceManager.instantiateServiceProvider('RetoldDataService', _Settings.RetoldDataServiceOptions);
|
|
8
47
|
|
|
9
48
|
_Fable.RetoldDataService.initializeService(
|
|
10
49
|
(pError) =>
|
|
11
50
|
{
|
|
51
|
+
if (pError)
|
|
52
|
+
{
|
|
53
|
+
_Fable.log.error(`Error initializing the Retold Data Service: ${pError}`);
|
|
54
|
+
throw pError;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Inject a behavior to load all authors for a book on single record read
|
|
12
58
|
_Fable.MeadowEndpoints.Book.controller.BehaviorInjection.setBehavior('Read-PostOperation',
|
|
13
59
|
(pRequest, pRequestState, fComplete) =>
|
|
14
60
|
{
|
|
@@ -37,4 +83,37 @@ _Fable.RetoldDataService.initializeService(
|
|
|
37
83
|
}
|
|
38
84
|
});
|
|
39
85
|
});
|
|
86
|
+
|
|
87
|
+
const fGracefullyStopService = function ()
|
|
88
|
+
{
|
|
89
|
+
if (_Fable.RetoldDataService.serviceInitialized)
|
|
90
|
+
{
|
|
91
|
+
_Fable.RetoldDataService.stopService(
|
|
92
|
+
function (pStopError)
|
|
93
|
+
{
|
|
94
|
+
if (pStopError)
|
|
95
|
+
{
|
|
96
|
+
_Fable.log.error(`Error stopping Retold Data Service: ${pStopError}`);
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
{
|
|
100
|
+
_Fable.log.info('Retold Data Service stopped. Exiting.');
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
process.on('SIGINT',
|
|
107
|
+
function ()
|
|
108
|
+
{
|
|
109
|
+
_Fable.log.info('Received SIGINT. Shutting down gracefully...');
|
|
110
|
+
fGracefullyStopService();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
process.on('SIGTERM',
|
|
114
|
+
function ()
|
|
115
|
+
{
|
|
116
|
+
_Fable.log.info('Received SIGTERM. Shutting down gracefully...');
|
|
117
|
+
fGracefullyStopService();
|
|
118
|
+
});
|
|
40
119
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "retold-data-service",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Serve up a whole model!",
|
|
5
5
|
"main": "source/Retold-Data-Service.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"coverage": "./node_modules/.bin/nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec",
|
|
9
9
|
"test": "./node_modules/.bin/mocha -u tdd -R spec",
|
|
10
10
|
"build": "npx quack build",
|
|
11
|
+
"build-test-model": "cd test && npx stricture -i model/ddl/BookStore.ddl",
|
|
11
12
|
"docker-dev-build": "docker build ./ -f Dockerfile_LUXURYCode -t retold-data-service-image:local",
|
|
12
13
|
"docker-dev-run": "docker run -it -d --name retold-data-service-dev -p 44444:8080 -p 43306:3306 -p 48086:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/retold-data-service\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" retold-data-service-image:local",
|
|
13
14
|
"docker-dev-shell": "docker exec -it retold-data-service-dev /bin/bash",
|
|
@@ -50,7 +51,8 @@
|
|
|
50
51
|
},
|
|
51
52
|
"homepage": "https://github.com/stevenvelozo/retold-data-service",
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"quackage": "^1.0.41"
|
|
54
|
+
"quackage": "^1.0.41",
|
|
55
|
+
"stricture": "^1.0.37"
|
|
54
56
|
},
|
|
55
57
|
"dependencies": {
|
|
56
58
|
"fable": "^3.1.11",
|
|
@@ -15,12 +15,11 @@ const libMeadowEndpoints = require('meadow-endpoints');
|
|
|
15
15
|
|
|
16
16
|
const defaultDataServiceSettings = (
|
|
17
17
|
{
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
StorageProvider: 'MySQL',
|
|
19
|
+
StorageProviderModule: 'meadow-connection-mysql',
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
DALMeadowSchemaPostfix: ``,
|
|
21
|
+
FullMeadowSchemaPath: `${process.cwd()}/model/`,
|
|
22
|
+
FullMeadowSchemaFilename: `MeadowModel-Extended.json`,
|
|
24
23
|
|
|
25
24
|
AutoInitializeDataService: true,
|
|
26
25
|
AutoStartOrator: true
|
|
@@ -71,10 +70,12 @@ class RetoldDataService extends libFableServiceProviderBase
|
|
|
71
70
|
{
|
|
72
71
|
return fCallback();
|
|
73
72
|
}
|
|
73
|
+
|
|
74
74
|
onInitialize(fCallback)
|
|
75
75
|
{
|
|
76
76
|
return fCallback();
|
|
77
77
|
}
|
|
78
|
+
|
|
78
79
|
onAfterInitialize(fCallback)
|
|
79
80
|
{
|
|
80
81
|
return fCallback();
|
|
@@ -84,9 +85,10 @@ class RetoldDataService extends libFableServiceProviderBase
|
|
|
84
85
|
{
|
|
85
86
|
// TODO: Change this to an option (e.g. we might want to do ALASQL)
|
|
86
87
|
// Load the mysql connection for meadow if it doesn't exist yet
|
|
87
|
-
this.fable.serviceManager.addAndInstantiateServiceType(
|
|
88
|
+
this.fable.serviceManager.addAndInstantiateServiceType(`Meadow${this.options.StorageProvider}Provider`, require(this.options.StorageProviderModule));
|
|
88
89
|
return fCallback();
|
|
89
90
|
}
|
|
91
|
+
|
|
90
92
|
initializeDataEndpoints(fCallback)
|
|
91
93
|
{
|
|
92
94
|
this.fable.log.info("Retold Data Service initializing Endpoints...");
|
|
@@ -108,14 +110,15 @@ class RetoldDataService extends libFableServiceProviderBase
|
|
|
108
110
|
{
|
|
109
111
|
// 4. Create the DAL for each entry (e.g. it would be at _DAL.Movie for the Movie entity)
|
|
110
112
|
let tmpDALEntityName = this.entityList[i];
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.
|
|
113
|
+
let tmpDALPackageObject = this.fullModel.Tables[tmpDALEntityName];
|
|
114
|
+
// We no longer need to load it from a package file; it's all in the full model
|
|
115
|
+
this.fable.log.info(`Initializing the ${tmpDALEntityName} DAL...`);
|
|
116
|
+
this._DAL[tmpDALEntityName] = this._Meadow.loadFromPackageObject(tmpDALPackageObject.MeadowSchema);
|
|
117
|
+
// 5. Tell this DAL object to use the specified storage provider
|
|
118
|
+
this.fable.log.info(`...defaulting the ${tmpDALEntityName} DAL to use ${this.options.StorageProvider}`);
|
|
119
|
+
this._DAL[tmpDALEntityName].setProvider(this.options.StorageProvider);
|
|
117
120
|
// 6. Create a Meadow Endpoints class for this DAL
|
|
118
|
-
this.fable.log.info(`...initializing the ${tmpDALEntityName} Meadow Endpoints to use
|
|
121
|
+
this.fable.log.info(`...initializing the ${tmpDALEntityName} Meadow Endpoints to use ${this.options.StorageProvider}`);
|
|
119
122
|
this._MeadowEndpoints[tmpDALEntityName] = libMeadowEndpoints.new(this._DAL[tmpDALEntityName]);
|
|
120
123
|
// 8. Expose the meadow endpoints on Orator
|
|
121
124
|
this.fable.log.info(`...mapping the ${tmpDALEntityName} Meadow Endpoints to Orator`);
|
|
@@ -174,6 +177,34 @@ class RetoldDataService extends libFableServiceProviderBase
|
|
|
174
177
|
});
|
|
175
178
|
}
|
|
176
179
|
}
|
|
180
|
+
|
|
181
|
+
stopService(fCallback)
|
|
182
|
+
{
|
|
183
|
+
if (!this.serviceInitialized)
|
|
184
|
+
{
|
|
185
|
+
return fCallback(new Error("Retold Data Service Application is being stopped but is not initialized..."));
|
|
186
|
+
}
|
|
187
|
+
else
|
|
188
|
+
{
|
|
189
|
+
this.fable.log.info(`The Retold Data Service is stopping Orator`);
|
|
190
|
+
|
|
191
|
+
let tmpAnticipate = this.fable.newAnticipate();
|
|
192
|
+
|
|
193
|
+
tmpAnticipate.anticipate(this.fable.Orator.stopWebServer.bind(this.fable.Orator));
|
|
194
|
+
|
|
195
|
+
tmpAnticipate.wait(
|
|
196
|
+
(pError)=>
|
|
197
|
+
{
|
|
198
|
+
if (pError)
|
|
199
|
+
{
|
|
200
|
+
this.log.error(`Error stopping Retold Data Service: ${pError}`);
|
|
201
|
+
return fCallback(pError);
|
|
202
|
+
}
|
|
203
|
+
this.serviceInitialized = false;
|
|
204
|
+
return fCallback();
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
177
208
|
}
|
|
178
209
|
|
|
179
210
|
module.exports = RetoldDataService;
|