fable 3.0.45 → 3.0.47
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/.browserslistrc +1 -1
- package/.config/configstore/update-notifier-npm.json +1 -1
- package/.config/vscode-sqltools/runningInfo.json +1 -1
- package/Dockerfile_LUXURYCode +4 -5
- package/dist/fable.compatible.js +277 -4005
- package/dist/fable.compatible.min.js +18 -30
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +208 -3936
- package/dist/fable.min.js +18 -30
- package/dist/fable.min.js.map +1 -1
- package/gulpfile-config.json +2 -2
- package/package.json +7 -7
- package/retold-harness/bookstore-serve-api.js +41 -0
- package/retold-harness/configuration-bookstore-serve-api.js +30 -0
- package/retold-harness/model/manual_scripts/MySQL-Laden-Entry.sh +17 -0
- package/retold-harness/model/manual_scripts/my.cnf +4 -0
- package/retold-harness/model/sql_create/BookStore-DeleteAndRepopulateTables.sql +194 -0
- package/retold-harness/model/sql_create/MySQL-Security.sql +5 -0
- package/source/services/Fable-Service-MetaTemplate/MetaTemplate-StringParser.js +281 -0
- package/source/services/Fable-Service-MetaTemplate/MetaTemplate-WordTree.js +97 -0
- package/source/services/Fable-Service-MetaTemplate.js +20 -6
- package/source/services/Fable-Service-Operation-DefaultSettings.js +1 -1
- package/source/services/Fable-Service-Operation.js +4 -11
- package/test/MetaTemplating_tests.js +241 -29
- package/test/RestClient_test.js +1 -1
- package/retold-harness/Bookstore-Import-Books.sh +0 -4
- package/retold-harness/bookstore-configuration.json +0 -28
- package/retold-harness/bookstore-import-books-run.js +0 -9
- package/retold-harness/bookstore-import-books.js +0 -214
- package/retold-harness/bookstore-serve-meadow-endpoint-apis-IPC.js +0 -137
- package/retold-harness/bookstore-serve-meadow-endpoint-apis-run.js +0 -6
- package/retold-harness/bookstore-serve-meadow-endpoint-apis.js +0 -129
- package/retold-harness/data/books.csv +0 -10001
- package/retold-harness/model/json_schema/README.md +0 -1
- package/retold-harness/package.json +0 -22
- package/retold-harness/test_old/Tests.js +0 -3243
- package/retold-harness/test_old/untitled.js +0 -88
- /package/retold-harness/{MySQL-Laden-Entry.sh → docker_scripts/MySQL-Laden-Entry.sh} +0 -0
- /package/retold-harness/model/{json_schema/BookStore-Extended.json → Model-Extended.json} +0 -0
- /package/retold-harness/model/{json_schema/BookStore-PICT.json → Model-PICT.json} +0 -0
- /package/retold-harness/model/{json_schema/BookStore.json → Model.json} +0 -0
- /package/retold-harness/{bookstore-api-endpoint-exercises.paw → model/bookstore-api-endpoint-exercises.paw} +0 -0
- /package/retold-harness/{MySQL-Security.sql → model/manual_scripts/MySQL-Security.sql} +0 -0
- /package/retold-harness/model/{meadow_schema/BookStore-MeadowSchema-Author.json → meadow/Model-MeadowSchema-Author.json} +0 -0
- /package/retold-harness/model/{meadow_schema/BookStore-MeadowSchema-Book.json → meadow/Model-MeadowSchema-Book.json} +0 -0
- /package/retold-harness/model/{meadow_schema/BookStore-MeadowSchema-BookAuthorJoin.json → meadow/Model-MeadowSchema-BookAuthorJoin.json} +0 -0
- /package/retold-harness/model/{meadow_schema/BookStore-MeadowSchema-BookPrice.json → meadow/Model-MeadowSchema-BookPrice.json} +0 -0
- /package/retold-harness/model/{meadow_schema/BookStore-MeadowSchema-Review.json → meadow/Model-MeadowSchema-Review.json} +0 -0
- /package/retold-harness/model/{meadow_schema → meadow}/README.md +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
An example of Meadow Endpoints, Fable and Orator
|
|
3
|
-
*/
|
|
4
|
-
const libWhyMe = require('why-is-node-running');
|
|
5
|
-
/**
|
|
6
|
-
* @author <steven@velozo.com>
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// Server Settings
|
|
10
|
-
const _Settings = require('./bookstore-configuration.json');
|
|
11
|
-
// Fable is logging and settings
|
|
12
|
-
const libFable = require('fable');
|
|
13
|
-
// Orator is the web server
|
|
14
|
-
const libOrator = require('orator');
|
|
15
|
-
// Official MySQL Client
|
|
16
|
-
const libMySQL = require('mysql2');
|
|
17
|
-
// Meadow is the DAL
|
|
18
|
-
const libMeadow = require('meadow');
|
|
19
|
-
// Meadow-endpoints maps the DAL to restify endpoints automagically
|
|
20
|
-
const libMeadowEndpoints = require('meadow-endpoints');
|
|
21
|
-
|
|
22
|
-
let _Fable = new libFable(_Settings);
|
|
23
|
-
let _Orator = new libOrator(_Fable);
|
|
24
|
-
|
|
25
|
-
let fStartServiceServer = (fInitializeCallback) =>
|
|
26
|
-
{
|
|
27
|
-
_Orator.initializeServiceServer((pError) =>
|
|
28
|
-
{
|
|
29
|
-
let _Meadow = libMeadow.new(_Fable);
|
|
30
|
-
|
|
31
|
-
_Fable.log.info("Application is starting up...");
|
|
32
|
-
|
|
33
|
-
_Fable.log.info("...Creating SQL Connection pools at "+_Fable.settings.MySQL.Server+"...");
|
|
34
|
-
_Fable.MeadowMySQLConnectionPool = libMySQL.createPool
|
|
35
|
-
(
|
|
36
|
-
{
|
|
37
|
-
connectionLimit: _Fable.settings.MySQL.ConnectionPoolLimit,
|
|
38
|
-
host: _Fable.settings.MySQL.Server,
|
|
39
|
-
port: _Fable.settings.MySQL.Port,
|
|
40
|
-
user: _Fable.settings.MySQL.User,
|
|
41
|
-
password: _Fable.settings.MySQL.Password,
|
|
42
|
-
database: _Fable.settings.MySQL.Database,
|
|
43
|
-
namedPlaceholders: true
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
// Create DAL objects for each table in the schema
|
|
48
|
-
let _DAL = {};
|
|
49
|
-
let _MeadowEndpoints = {};
|
|
50
|
-
|
|
51
|
-
// 1. Load full compiled schema of the model from stricture
|
|
52
|
-
_Fable.log.info(`...Loading stricture schemas...`);
|
|
53
|
-
const _BookStoreModel = require (__dirname+'/model/json_schema/BookStore-Extended.json');
|
|
54
|
-
|
|
55
|
-
// 2. Extract an array of each table in the schema
|
|
56
|
-
const _BookStoreTableList = Object.keys(_BookStoreModel.Tables);
|
|
57
|
-
|
|
58
|
-
// 3. Enumerate each entry in the compiled model and load a DAL for that table
|
|
59
|
-
_Fable.log.info(`...Creating ${_BookStoreTableList.length} DAL entries...`);
|
|
60
|
-
for (let i = 0; i < _BookStoreTableList.length; i++)
|
|
61
|
-
{
|
|
62
|
-
let tmpDALEntityName = _BookStoreTableList[i];
|
|
63
|
-
_Fable.log.info(` -> Creating the ${tmpDALEntityName} DAL...`);
|
|
64
|
-
// 4. Create the DAL for each entry (e.g. it would be at _DAL.Book or _DAL.Author)
|
|
65
|
-
_DAL[tmpDALEntityName] = _Meadow.loadFromPackage(__dirname+'/model/meadow_schema/BookStore-MeadowSchema-'+tmpDALEntityName+'.json');
|
|
66
|
-
// 5. Tell this DAL object to use MySQL
|
|
67
|
-
_DAL[tmpDALEntityName].setProvider('MySQL');
|
|
68
|
-
// 6. Set the User ID to 10 just for fun
|
|
69
|
-
_DAL[tmpDALEntityName].setIDUser(1);
|
|
70
|
-
// 7. Create a Meadow Endpoints class for this DAL
|
|
71
|
-
_MeadowEndpoints[tmpDALEntityName] = libMeadowEndpoints.new(_DAL[tmpDALEntityName]);
|
|
72
|
-
// 8. Expose the meadow endpoints on Orator
|
|
73
|
-
_MeadowEndpoints[tmpDALEntityName].connectRoutes(_Orator.webServer);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// 100. Add a post processing hook to the Book DAL on single reads
|
|
77
|
-
/*
|
|
78
|
-
This post processing step will look for all book author joins then
|
|
79
|
-
load all appropriate authors and stuff them in the book record before
|
|
80
|
-
returning it.
|
|
81
|
-
*/
|
|
82
|
-
_MeadowEndpoints.Book.controller.BehaviorInjection.setBehavior('Read-PostOperation',
|
|
83
|
-
(pRequest, pRequestState, fComplete) =>
|
|
84
|
-
{
|
|
85
|
-
// Get the join records
|
|
86
|
-
_DAL.BookAuthorJoin.doReads(_DAL.BookAuthorJoin.query.addFilter('IDBook', pRequestState.Record.IDBook),
|
|
87
|
-
(pJoinReadError, pJoinReadQuery, pJoinRecords)=>
|
|
88
|
-
{
|
|
89
|
-
let tmpAuthorList = [];
|
|
90
|
-
for (let j = 0; j < pJoinRecords.length; j++)
|
|
91
|
-
{
|
|
92
|
-
tmpAuthorList.push(pJoinRecords[j].IDAuthor);
|
|
93
|
-
}
|
|
94
|
-
if (tmpAuthorList.length < 1)
|
|
95
|
-
{
|
|
96
|
-
pRequestState.Record.Authors = [];
|
|
97
|
-
return fComplete();
|
|
98
|
-
}
|
|
99
|
-
else
|
|
100
|
-
{
|
|
101
|
-
_DAL.Author.doReads(_DAL.Author.query.addFilter('IDAuthor', tmpAuthorList, 'IN'),
|
|
102
|
-
(pReadsError, pReadsQuery, pAuthors)=>
|
|
103
|
-
{
|
|
104
|
-
pRequestState.Record.Authors = pAuthors;
|
|
105
|
-
return fComplete();
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Static site mapping
|
|
112
|
-
_Orator.log.info("...Mapping static route for web site...");
|
|
113
|
-
|
|
114
|
-
//_Orator.addStaticRoute(__dirname+'/../web/');
|
|
115
|
-
|
|
116
|
-
// Start the web server (ctrl+c to end it)
|
|
117
|
-
_Orator.startWebServer(
|
|
118
|
-
(pError) =>
|
|
119
|
-
{
|
|
120
|
-
// Now do a GET!
|
|
121
|
-
let tmpURI = `/1.0/Book/1`;
|
|
122
|
-
_Orator.invoke('GET', tmpURI, null,
|
|
123
|
-
(pError, pResponseData) =>
|
|
124
|
-
{
|
|
125
|
-
_Orator.log.info(`Response to [${tmpURI}] came back from IPC resulting in [${pResponseData}]!`);
|
|
126
|
-
_Fable.MeadowMySQLConnectionPool.end();
|
|
127
|
-
libWhyMe();
|
|
128
|
-
return true;
|
|
129
|
-
});
|
|
130
|
-
fInitializeCallback(pError);
|
|
131
|
-
}
|
|
132
|
-
);
|
|
133
|
-
});
|
|
134
|
-
return _Orator;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
module.exports = fStartServiceServer;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
An example of Meadow Endpoints, Fable and Orator
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @license MIT
|
|
7
|
-
* @author <steven@velozo.com>
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// Server Settings
|
|
11
|
-
const _Settings = require('./bookstore-configuration.json');
|
|
12
|
-
// Fable is logging and settings
|
|
13
|
-
const libFable = require('fable');
|
|
14
|
-
// Orator is the web server
|
|
15
|
-
const libOrator = require('orator');
|
|
16
|
-
const libOratorServiceServerRestify = require('orator-serviceserver-restify');
|
|
17
|
-
// Official MySQL Client
|
|
18
|
-
const libMySQL = require('mysql2');
|
|
19
|
-
// Meadow is the DAL
|
|
20
|
-
const libMeadow = require('meadow');
|
|
21
|
-
// Meadow-endpoints maps the DAL to restify endpoints automagically
|
|
22
|
-
const libMeadowEndpoints = require('meadow-endpoints');
|
|
23
|
-
|
|
24
|
-
let _Fable = new libFable(_Settings);
|
|
25
|
-
let _Orator = new libOrator(_Fable, libOratorServiceServerRestify);
|
|
26
|
-
|
|
27
|
-
let fStartServiceServer = (fInitializeCallback) =>
|
|
28
|
-
{
|
|
29
|
-
_Orator.initializeServiceServer(() =>
|
|
30
|
-
{
|
|
31
|
-
let _Meadow = libMeadow.new(_Fable);
|
|
32
|
-
|
|
33
|
-
_Fable.log.info("Application is starting up...");
|
|
34
|
-
|
|
35
|
-
_Fable.log.info("...Creating SQL Connection pools at "+_Fable.settings.MySQL.Server+"...");
|
|
36
|
-
_Fable.MeadowMySQLConnectionPool = libMySQL.createPool
|
|
37
|
-
(
|
|
38
|
-
{
|
|
39
|
-
connectionLimit: _Fable.settings.MySQL.ConnectionPoolLimit,
|
|
40
|
-
host: _Fable.settings.MySQL.Server,
|
|
41
|
-
port: _Fable.settings.MySQL.Port,
|
|
42
|
-
user: _Fable.settings.MySQL.User,
|
|
43
|
-
password: _Fable.settings.MySQL.Password,
|
|
44
|
-
database: _Fable.settings.MySQL.Database,
|
|
45
|
-
namedPlaceholders: true
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
// Create DAL objects for each table in the schema
|
|
50
|
-
let _DAL = {};
|
|
51
|
-
let _MeadowEndpoints = {};
|
|
52
|
-
|
|
53
|
-
// 1. Load full compiled schema of the model from stricture
|
|
54
|
-
_Fable.log.info(`...Loading stricture schemas...`);
|
|
55
|
-
const _BookStoreModel = require (__dirname+'/model/json_schema/BookStore-Extended.json');
|
|
56
|
-
|
|
57
|
-
// 2. Extract an array of each table in the schema
|
|
58
|
-
const _BookStoreTableList = Object.keys(_BookStoreModel.Tables);
|
|
59
|
-
|
|
60
|
-
// 3. Enumerate each entry in the compiled model and load a DAL for that table
|
|
61
|
-
_Fable.log.info(`...Creating ${_BookStoreTableList.length} DAL entries...`);
|
|
62
|
-
for (let i = 0; i < _BookStoreTableList.length; i++)
|
|
63
|
-
{
|
|
64
|
-
let tmpDALEntityName = _BookStoreTableList[i];
|
|
65
|
-
_Fable.log.info(` -> Creating the ${tmpDALEntityName} DAL...`);
|
|
66
|
-
// 4. Create the DAL for each entry (e.g. it would be at _DAL.Book or _DAL.Author)
|
|
67
|
-
_DAL[tmpDALEntityName] = _Meadow.loadFromPackage(__dirname+'/model/meadow_schema/BookStore-MeadowSchema-'+tmpDALEntityName+'.json');
|
|
68
|
-
// 5. Tell this DAL object to use MySQL
|
|
69
|
-
_DAL[tmpDALEntityName].setProvider('MySQL');
|
|
70
|
-
// 6. Set the User ID to 10 just for fun
|
|
71
|
-
_DAL[tmpDALEntityName].setIDUser(1);
|
|
72
|
-
// 7. Create a Meadow Endpoints class for this DAL
|
|
73
|
-
_MeadowEndpoints[tmpDALEntityName] = libMeadowEndpoints.new(_DAL[tmpDALEntityName]);
|
|
74
|
-
// 8. Expose the meadow endpoints on Orator
|
|
75
|
-
_MeadowEndpoints[tmpDALEntityName].connectRoutes(_Orator.webServer);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 100. Add a post processing hook to the Book DAL on single reads
|
|
79
|
-
/*
|
|
80
|
-
This post processing step will look for all book author joins then
|
|
81
|
-
load all appropriate authors and stuff them in the book record before
|
|
82
|
-
returning it.
|
|
83
|
-
*/
|
|
84
|
-
_MeadowEndpoints.Book.controller.BehaviorInjection.setBehavior('Read-PostOperation',
|
|
85
|
-
(pRequest, pRequestState, fComplete) =>
|
|
86
|
-
{
|
|
87
|
-
// Get the join records
|
|
88
|
-
_DAL.BookAuthorJoin.doReads(_DAL.BookAuthorJoin.query.addFilter('IDBook', pRequestState.Record.IDBook),
|
|
89
|
-
(pJoinReadError, pJoinReadQuery, pJoinRecords)=>
|
|
90
|
-
{
|
|
91
|
-
let tmpAuthorList = [];
|
|
92
|
-
for (let j = 0; j < pJoinRecords.length; j++)
|
|
93
|
-
{
|
|
94
|
-
tmpAuthorList.push(pJoinRecords[j].IDAuthor);
|
|
95
|
-
}
|
|
96
|
-
if (tmpAuthorList.length < 1)
|
|
97
|
-
{
|
|
98
|
-
pRequestState.Record.Authors = [];
|
|
99
|
-
return fComplete();
|
|
100
|
-
}
|
|
101
|
-
else
|
|
102
|
-
{
|
|
103
|
-
_DAL.Author.doReads(_DAL.Author.query.addFilter('IDAuthor', tmpAuthorList, 'IN'),
|
|
104
|
-
(pReadsError, pReadsQuery, pAuthors)=>
|
|
105
|
-
{
|
|
106
|
-
pRequestState.Record.Authors = pAuthors;
|
|
107
|
-
return fComplete();
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// Static site mapping
|
|
114
|
-
_Orator.log.info("...Mapping static route for web site...");
|
|
115
|
-
|
|
116
|
-
//_Orator.addStaticRoute(__dirname+'/../web/');
|
|
117
|
-
|
|
118
|
-
// Start the web server (ctrl+c to end it)
|
|
119
|
-
_Orator.startWebServer(
|
|
120
|
-
(pError) =>
|
|
121
|
-
{
|
|
122
|
-
fInitializeCallback(pError);
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
return _Orator;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = fStartServiceServer;
|