meadow 1.1.1 → 2.0.1
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/.config/code-server/config.yaml +4 -0
- package/.config/configstore/update-notifier-npm-check-updates.json +4 -0
- package/.config/configstore/update-notifier-npm.json +4 -0
- package/.config/luxury-extras/.vscode/launch.json +46 -0
- package/.config/luxury-extras/Dockerfile +32 -0
- package/.config/luxury-extras/MySQL/Dockerfile +51 -0
- package/.config/luxury-extras/MySQL/MySQL-Laden-Entry.sh +17 -0
- package/.config/luxury-extras/MySQL/MySQL-Security.sql +5 -0
- package/.config/luxury-extras/model/ddl/BookStore.ddl +66 -0
- package/.config/luxury-extras/model/documentation/Dictionary.md +18 -0
- package/.config/luxury-extras/model/documentation/Model-Author.md +20 -0
- package/.config/luxury-extras/model/documentation/Model-Book.md +26 -0
- package/.config/luxury-extras/model/documentation/Model-BookAuthorJoin.md +14 -0
- package/.config/luxury-extras/model/documentation/Model-BookPrice.md +25 -0
- package/.config/luxury-extras/model/documentation/Model-Review.md +22 -0
- package/.config/luxury-extras/model/documentation/ModelChangeTracking.md +17 -0
- package/.config/luxury-extras/model/documentation/README.md +1 -0
- package/.config/luxury-extras/model/documentation/diagram/README.md +1 -0
- package/.config/luxury-extras/model/documentation/diagram/Stricture_Output.dot +13 -0
- package/.config/luxury-extras/model/documentation/diagram/Stricture_Output.png +0 -0
- package/.config/luxury-extras/model/generated_diagram/README.md +1 -0
- package/.config/luxury-extras/model/generated_diagram/Stricture_Output.dot +13 -0
- package/.config/luxury-extras/model/generated_diagram/Stricture_Output.png +0 -0
- package/.config/luxury-extras/model/generated_documentation/Dictionary.md +18 -0
- package/.config/luxury-extras/model/generated_documentation/Model-Author.md +20 -0
- package/.config/luxury-extras/model/generated_documentation/Model-Book.md +26 -0
- package/.config/luxury-extras/model/generated_documentation/Model-BookAuthorJoin.md +14 -0
- package/.config/luxury-extras/model/generated_documentation/Model-BookPrice.md +25 -0
- package/.config/luxury-extras/model/generated_documentation/Model-Review.md +22 -0
- package/.config/luxury-extras/model/generated_documentation/ModelChangeTracking.md +17 -0
- package/.config/luxury-extras/model/generated_documentation/README.md +1 -0
- package/.config/luxury-extras/model/json_schema/BookStore-Extended.json +915 -0
- package/.config/luxury-extras/model/json_schema/BookStore-PICT.json +1 -0
- package/.config/luxury-extras/model/json_schema/BookStore.json +280 -0
- package/.config/luxury-extras/model/json_schema/README.md +1 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-Author.json +220 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-Book.json +268 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-BookAuthorJoin.json +172 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-BookPrice.json +260 -0
- package/.config/luxury-extras/model/json_schema_entities/BookStore-MeadowSchema-Review.json +236 -0
- package/.config/luxury-extras/model/json_schema_entities/README.md +1 -0
- package/.config/luxury-extras/model/json_schema_model/BookStore-Extended.json +915 -0
- package/.config/luxury-extras/model/json_schema_model/BookStore-PICT.json +1 -0
- package/.config/luxury-extras/model/json_schema_model/BookStore.json +280 -0
- package/.config/luxury-extras/model/json_schema_model/README.md +1 -0
- package/.config/luxury-extras/model/manual_scripts/DropTables.sql +5 -0
- package/.config/luxury-extras/model/manual_scripts/README.md +2 -0
- package/.config/luxury-extras/model/meadow_schema/BookStore-MeadowSchema-Author.json +220 -0
- package/.config/luxury-extras/model/meadow_schema/BookStore-MeadowSchema-Book.json +268 -0
- package/.config/luxury-extras/model/meadow_schema/BookStore-MeadowSchema-BookAuthorJoin.json +172 -0
- package/.config/luxury-extras/model/meadow_schema/BookStore-MeadowSchema-BookPrice.json +260 -0
- package/.config/luxury-extras/model/meadow_schema/BookStore-MeadowSchema-Review.json +236 -0
- package/.config/luxury-extras/model/meadow_schema/README.md +1 -0
- package/.config/luxury-extras/model/mysql_create/BookStore-CreateDatabase.mysql.sql +116 -0
- package/.config/luxury-extras/model/mysql_create/README.md +1 -0
- package/.config/luxury-extras/model/sql_create/BookStore-CreateDatabase.mysql.sql +116 -0
- package/.config/luxury-extras/model/sql_create/README.md +1 -0
- package/.vscode/launch.json +46 -0
- package/Dockerfile_LUXURYCode +65 -0
- package/README.md +19 -5
- package/debug/Harness.js +69 -84
- package/dist/meadow.js +1669 -0
- package/dist/meadow.min.js +65 -0
- package/dist/meadow.min.js.map +1 -0
- package/gulpfile.js +83 -0
- package/package.json +42 -20
- package/source/Meadow-Browser-Shim.js +14 -0
- package/source/{Meadow-PackageLoader.js → Meadow-PackageFileLoader.js} +3 -3
- package/source/Meadow-PackageObjectLoader.js +62 -0
- package/source/Meadow.js +21 -3
- package/source/behaviors/Meadow-Count.js +2 -2
- package/source/behaviors/Meadow-Create.js +3 -4
- package/source/behaviors/Meadow-Delete.js +2 -2
- package/source/behaviors/Meadow-Read.js +5 -4
- package/source/behaviors/Meadow-Reads.js +4 -3
- package/source/behaviors/Meadow-Undelete.js +42 -0
- package/source/behaviors/Meadow-Update.js +2 -2
- package/source/providers/Meadow-Provider-ALASQL.js +33 -0
- package/source/providers/Meadow-Provider-MeadowEndpoints.js +3 -4
- package/source/providers/Meadow-Provider-MySQL.js +40 -0
- package/source/providers/Meadow-Provider-None.js +8 -0
- package/test/Meadow-Provider-ALASQL.js +38 -14
- package/test/Meadow-Provider-MeadowEndpoints_tests.js +2 -819
- package/test/Meadow-Provider-MySQL_tests.js +49 -13
- package/test/Meadow-Provider-None_tests.js +19 -16
- package/test/Meadow_tests.js +59 -2
package/gulpfile.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// We aren't abstracting this yet but here's the ... "Config"
|
|
4
|
+
const _CONFIG = (
|
|
5
|
+
{
|
|
6
|
+
// The input source file that should be passed to browserify:
|
|
7
|
+
// (if you need to auto-instantiate an object, for instance)
|
|
8
|
+
EntrypointInputSourceFile: `${__dirname}/source/Meadow-Browser-Shim.js`,
|
|
9
|
+
|
|
10
|
+
// The name of the packaged object to be passed to browserify:
|
|
11
|
+
// (browserify sets this to global scope and window.SOMEOBJECTNAMEHERE where SOMEOBJECTNAMEHERE is the string below)
|
|
12
|
+
LibraryObjectName: `Meadow`,
|
|
13
|
+
|
|
14
|
+
// The folder to write the library files and maps out to:
|
|
15
|
+
LibraryOutputFolder: `${__dirname}/dist/`,
|
|
16
|
+
|
|
17
|
+
// The name of the unminified version of the packaged library, for easy debugging:
|
|
18
|
+
LibraryUniminifiedFileName: `meadow.js`,
|
|
19
|
+
|
|
20
|
+
// The name of the minified version of the packaged library, for production release:
|
|
21
|
+
LibraryMinifiedFileName: `meadow.min.js`
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// ---> Boilerplate Browser Uglification and Packaging <--- \\
|
|
25
|
+
|
|
26
|
+
const libBrowserify = require('browserify');
|
|
27
|
+
const libGulp = require('gulp');
|
|
28
|
+
|
|
29
|
+
const libVinylSourceStream = require('vinyl-source-stream');
|
|
30
|
+
const libVinylBuffer = require('vinyl-buffer');
|
|
31
|
+
|
|
32
|
+
const libSourcemaps = require('gulp-sourcemaps');
|
|
33
|
+
const libGulpUtil = require('gulp-util');
|
|
34
|
+
const libBabel = require('gulp-babel');
|
|
35
|
+
const libTerser = require('gulp-terser');
|
|
36
|
+
|
|
37
|
+
// Build the module for the browser
|
|
38
|
+
libGulp.task('minified',
|
|
39
|
+
() => {
|
|
40
|
+
// set up the custom browserify instance for this task
|
|
41
|
+
var tmpBrowserify = libBrowserify(
|
|
42
|
+
{
|
|
43
|
+
entries: _CONFIG.EntrypointInputSourceFile,
|
|
44
|
+
standalone: _CONFIG.LibraryObjectName,
|
|
45
|
+
debug: true
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return tmpBrowserify.bundle()
|
|
49
|
+
.pipe(libVinylSourceStream(_CONFIG.LibraryMinifiedFileName))
|
|
50
|
+
.pipe(libVinylBuffer())
|
|
51
|
+
.pipe(libSourcemaps.init({loadMaps: true}))
|
|
52
|
+
// Add transformation tasks to the pipeline here.
|
|
53
|
+
.pipe(libBabel())
|
|
54
|
+
.pipe(libTerser())
|
|
55
|
+
.on('error', libGulpUtil.log)
|
|
56
|
+
.pipe(libSourcemaps.write('./'))
|
|
57
|
+
.pipe(libGulp.dest(_CONFIG.LibraryOutputFolder));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Build the module for the browser
|
|
61
|
+
libGulp.task('debug',
|
|
62
|
+
() => {
|
|
63
|
+
// set up the custom browserify instance for this task
|
|
64
|
+
var tmpBrowserify = libBrowserify(
|
|
65
|
+
{
|
|
66
|
+
entries: _CONFIG.EntrypointInputSourceFile,
|
|
67
|
+
standalone: _CONFIG.LibraryObjectName,
|
|
68
|
+
debug: true
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return tmpBrowserify.bundle()
|
|
72
|
+
.pipe(libVinylSourceStream(_CONFIG.LibraryUniminifiedFileName))
|
|
73
|
+
.pipe(libVinylBuffer())
|
|
74
|
+
.pipe(libBabel())
|
|
75
|
+
.on('error', libGulpUtil.log)
|
|
76
|
+
.pipe(libGulp.dest(_CONFIG.LibraryOutputFolder));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
libGulp.task
|
|
80
|
+
(
|
|
81
|
+
'build',
|
|
82
|
+
libGulp.series('debug', 'minified')
|
|
83
|
+
);
|
package/package.json
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meadow",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A data access library.",
|
|
5
5
|
"main": "source/Meadow.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "node source/Meadow.js",
|
|
8
|
-
"coverage": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -u tdd -R spec",
|
|
9
|
-
"test": "./node_modules/mocha/bin/_mocha -u tdd -R spec",
|
|
10
|
-
"tests": "./node_modules/mocha/bin/_mocha -u tdd -R spec --grep",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
8
|
+
"coverage": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -u tdd --exit -R spec",
|
|
9
|
+
"test": "./node_modules/mocha/bin/_mocha -u tdd --exit -R spec",
|
|
10
|
+
"tests": "./node_modules/mocha/bin/_mocha -u tdd --exit -R spec --grep",
|
|
11
|
+
"build": "./node_modules/.bin/gulp build --full-paths",
|
|
12
|
+
"docker-dev-build-image": "docker build ./ -f Dockerfile_LUXURYCode -t retold/meadow:local",
|
|
13
|
+
"docker-dev-run": "docker run -it -d --name meadow-dev -p 127.0.0.1:12342:8080 -p 12106:3306 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/meadow\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" retold/meadow:local"
|
|
14
|
+
},
|
|
15
|
+
"mocha": {
|
|
16
|
+
"diff": true,
|
|
17
|
+
"extension": [
|
|
18
|
+
"js"
|
|
19
|
+
],
|
|
20
|
+
"package": "./package.json",
|
|
21
|
+
"reporter": "spec",
|
|
22
|
+
"slow": "75",
|
|
23
|
+
"timeout": "5000",
|
|
24
|
+
"ui": "tdd",
|
|
25
|
+
"watch-files": [
|
|
26
|
+
"source/**/*.js",
|
|
27
|
+
"test/**/*.js"
|
|
28
|
+
],
|
|
29
|
+
"watch-ignore": [
|
|
30
|
+
"lib/vendor"
|
|
31
|
+
]
|
|
13
32
|
},
|
|
14
33
|
"repository": {
|
|
15
34
|
"type": "git",
|
|
@@ -26,21 +45,24 @@
|
|
|
26
45
|
},
|
|
27
46
|
"homepage": "https://github.com/stevenvelozo/meadow",
|
|
28
47
|
"devDependencies": {
|
|
29
|
-
"alasql": "^
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
48
|
+
"alasql": "^3.1.0",
|
|
49
|
+
"browserify": "^17.0.0",
|
|
50
|
+
"chai": "4.3.7",
|
|
51
|
+
"gulp": "^4.0.2",
|
|
52
|
+
"gulp-babel": "^8.0.0",
|
|
53
|
+
"gulp-sourcemaps": "^3.0.0",
|
|
54
|
+
"gulp-terser": "^2.1.0",
|
|
55
|
+
"gulp-util": "^3.0.8",
|
|
56
|
+
"mocha": "10.2.0",
|
|
57
|
+
"nyc": "^15.1.0",
|
|
58
|
+
"vinyl-buffer": "^1.0.1",
|
|
59
|
+
"vinyl-source-stream": "^2.0.0",
|
|
60
|
+
"mysql2": "^3.1.2"
|
|
37
61
|
},
|
|
38
62
|
"dependencies": {
|
|
39
|
-
"async": "2.4
|
|
40
|
-
"fable": "
|
|
41
|
-
"foxhound": "
|
|
42
|
-
"is-my-json-valid": "2.
|
|
43
|
-
"simple-get": "^4.0.1",
|
|
44
|
-
"underscore": "^1.8.3"
|
|
63
|
+
"async": "3.2.4",
|
|
64
|
+
"fable": "^3.0.4",
|
|
65
|
+
"foxhound": "^2.0.2",
|
|
66
|
+
"is-my-json-valid": "2.20.6"
|
|
45
67
|
}
|
|
46
68
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple browser shim loader - assign the npm module to a window global automatically
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @author <steven@velozo.com>
|
|
6
|
+
*/
|
|
7
|
+
var libNPMModuleWrapper = require('./Meadow.js');
|
|
8
|
+
|
|
9
|
+
if ((typeof(window) === 'object') && !window.hasOwnProperty('Meadow'))
|
|
10
|
+
{
|
|
11
|
+
window.Meadow = libNPMModuleWrapper;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = libNPMModuleWrapper;
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* Load the schema and metadata from a package file
|
|
9
9
|
*
|
|
10
|
-
* @method
|
|
10
|
+
* @method loadFromPackageFile
|
|
11
11
|
* @return {Object} Returns a new Meadow, or false if it failed
|
|
12
12
|
*/
|
|
13
|
-
var
|
|
13
|
+
var loadFromPackageFile = function(pMeadow, pPackage)
|
|
14
14
|
{
|
|
15
15
|
// Use the package loader to grab the configuration objects and clone a new Meadow.
|
|
16
16
|
var tmpPackage = false;
|
|
@@ -63,4 +63,4 @@ var loadFromPackage = function(pMeadow, pPackage)
|
|
|
63
63
|
return tmpNewMeadow;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
module.exports =
|
|
66
|
+
module.exports = loadFromPackageFile;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// ##### Part of the **[retold](https://stevenvelozo.github.io/retold/)** system
|
|
2
|
+
/**
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author <steven@velozo.com>
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Load the schema and metadata from a package object
|
|
9
|
+
*
|
|
10
|
+
* @method loadFromPackageObject
|
|
11
|
+
* @return {Object} Returns a new Meadow, or false if it failed
|
|
12
|
+
*/
|
|
13
|
+
var loadFromPackageObject = function(pMeadow, pPackage)
|
|
14
|
+
{
|
|
15
|
+
// Use the package loader to grab the configuration objects and clone a new Meadow.
|
|
16
|
+
var tmpPackage = (typeof(pPackage) == 'object') ? pPackage : {};
|
|
17
|
+
|
|
18
|
+
if (!pPackage.hasOwnProperty('Scope'))
|
|
19
|
+
{
|
|
20
|
+
pMeadow.fable.log.error('Error loading Fable package -- scope not defined.', {Package:pPackage});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Spool up a new Meadow object
|
|
24
|
+
var tmpNewMeadow = pMeadow.new(pMeadow.fable);
|
|
25
|
+
|
|
26
|
+
// Safely set the parameters
|
|
27
|
+
if (typeof(tmpPackage.Scope) === 'string')
|
|
28
|
+
{
|
|
29
|
+
tmpNewMeadow.setScope(tmpPackage.Scope);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof(tmpPackage.Domain) === 'string')
|
|
33
|
+
{
|
|
34
|
+
tmpNewMeadow.setDomain(tmpPackage.Domain);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof(tmpPackage.DefaultIdentifier) === 'string')
|
|
38
|
+
{
|
|
39
|
+
tmpNewMeadow.setDefaultIdentifier(tmpPackage.DefaultIdentifier);
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(tmpPackage.Schema))
|
|
42
|
+
{
|
|
43
|
+
tmpNewMeadow.setSchema(tmpPackage.Schema);
|
|
44
|
+
}
|
|
45
|
+
if (typeof(tmpPackage.JsonSchema) === 'object')
|
|
46
|
+
{
|
|
47
|
+
tmpNewMeadow.setJsonSchema(tmpPackage.JsonSchema);
|
|
48
|
+
}
|
|
49
|
+
if (typeof(tmpPackage.DefaultObject) === 'object')
|
|
50
|
+
{
|
|
51
|
+
tmpNewMeadow.setDefault(tmpPackage.DefaultObject);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (typeof(tmpPackage.Authorization) === 'object')
|
|
55
|
+
{
|
|
56
|
+
tmpNewMeadow.setAuthorizer(tmpPackage.Authorization);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return tmpNewMeadow;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
module.exports = loadFromPackageObject;
|
package/source/Meadow.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
|
-
var libUnderscore = require('underscore');
|
|
7
6
|
var libFoxHound = require('foxhound');
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -43,6 +42,7 @@ var Meadow = function()
|
|
|
43
42
|
var _ReadsBehavior = require('./behaviors/Meadow-Reads.js');
|
|
44
43
|
var _UpdateBehavior = require('./behaviors/Meadow-Update.js');
|
|
45
44
|
var _DeleteBehavior = require('./behaviors/Meadow-Delete.js');
|
|
45
|
+
var _UndeleteBehavior = require('./behaviors/Meadow-Undelete.js');
|
|
46
46
|
var _CountBehavior = require('./behaviors/Meadow-Count.js');
|
|
47
47
|
|
|
48
48
|
// The data provider
|
|
@@ -61,12 +61,20 @@ var Meadow = function()
|
|
|
61
61
|
/**
|
|
62
62
|
* Load a Meadow Package JSON, create a Meadow object from it.
|
|
63
63
|
*/
|
|
64
|
-
var _MeadowPackageLoader = require('./Meadow-
|
|
64
|
+
var _MeadowPackageLoader = require('./Meadow-PackageFileLoader.js');
|
|
65
65
|
var loadFromPackage = function(pPackage)
|
|
66
66
|
{
|
|
67
67
|
return _MeadowPackageLoader(this, pPackage);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Load a Meadow Package JSON from file, create a Meadow object from it.
|
|
72
|
+
*/
|
|
73
|
+
var _MeadowPackageObjectLoader = require('./Meadow-PackageObjectLoader.js');
|
|
74
|
+
var loadFromPackageObject = function(pPackage)
|
|
75
|
+
{
|
|
76
|
+
return _MeadowPackageObjectLoader(this, pPackage);
|
|
77
|
+
};
|
|
70
78
|
|
|
71
79
|
/**
|
|
72
80
|
* Pass relevant state into the provider
|
|
@@ -268,6 +276,14 @@ var Meadow = function()
|
|
|
268
276
|
return _DeleteBehavior(this, pQuery, fCallBack);
|
|
269
277
|
};
|
|
270
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Undelete a record
|
|
281
|
+
*/
|
|
282
|
+
var doUndelete = function(pQuery, fCallBack)
|
|
283
|
+
{
|
|
284
|
+
return _UndeleteBehavior(this, pQuery, fCallBack);
|
|
285
|
+
};
|
|
286
|
+
|
|
271
287
|
/**
|
|
272
288
|
* Count multiple records
|
|
273
289
|
*/
|
|
@@ -313,7 +329,7 @@ var Meadow = function()
|
|
|
313
329
|
var marshalRecordFromSourceToObject = function(pRecord)
|
|
314
330
|
{
|
|
315
331
|
// Create an object from the default schema object
|
|
316
|
-
var tmpNewObject =
|
|
332
|
+
var tmpNewObject = _Fable.Utility.extend({}, _Schema.defaultObject);
|
|
317
333
|
// Now marshal the values from pRecord into tmpNewObject, based on schema
|
|
318
334
|
_Provider.marshalRecordFromSourceToObject(tmpNewObject, pRecord, _Schema.schema);
|
|
319
335
|
// This turns on magical validation
|
|
@@ -358,6 +374,7 @@ var Meadow = function()
|
|
|
358
374
|
doReads: doReads,
|
|
359
375
|
doUpdate: doUpdate,
|
|
360
376
|
doDelete: doDelete,
|
|
377
|
+
doUndelete: doUndelete,
|
|
361
378
|
doCount: doCount,
|
|
362
379
|
|
|
363
380
|
validateObject: _Schema.validateObject,
|
|
@@ -367,6 +384,7 @@ var Meadow = function()
|
|
|
367
384
|
setIDUser: setIDUser,
|
|
368
385
|
|
|
369
386
|
loadFromPackage: loadFromPackage,
|
|
387
|
+
loadFromPackageObject: loadFromPackageObject,
|
|
370
388
|
setScope: setScope,
|
|
371
389
|
setDomain: setDomain,
|
|
372
390
|
setSchema: setSchema,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
|
-
var
|
|
6
|
+
var libAsyncWaterfall = require('async/waterfall');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Meadow Behavior - Count multiple records
|
|
@@ -15,7 +15,7 @@ var meadowBehaviorCount = function(pMeadow, pQuery, fCallBack)
|
|
|
15
15
|
var tmpProfileStart = new Date(); //for profiling query time
|
|
16
16
|
|
|
17
17
|
// Count the record(s) from the source
|
|
18
|
-
|
|
18
|
+
libAsyncWaterfall(
|
|
19
19
|
[
|
|
20
20
|
// Step 1: Get the record countfrom the data source
|
|
21
21
|
function (fStageComplete)
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
|
-
var
|
|
7
|
-
var libUnderscore = require('underscore');
|
|
6
|
+
var libAsyncWaterfall = require('async/waterfall');
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Meadow Behavior - Create
|
|
@@ -13,7 +12,7 @@ var libUnderscore = require('underscore');
|
|
|
13
12
|
*/
|
|
14
13
|
var meadowBehaviorCreate = function(pMeadow, pQuery, fCallBack)
|
|
15
14
|
{
|
|
16
|
-
|
|
15
|
+
libAsyncWaterfall(
|
|
17
16
|
[
|
|
18
17
|
// Step 0: If GUID is specified, make sure the record does not already exist
|
|
19
18
|
function (fStageComplete)
|
|
@@ -78,7 +77,7 @@ var meadowBehaviorCreate = function(pMeadow, pQuery, fCallBack)
|
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
// Merge in the default record with the passed-in record for completeness
|
|
81
|
-
pQuery.query.records[0] =
|
|
80
|
+
pQuery.query.records[0] = pMeadow.fable.Utility.extend({}, pMeadow.schemaFull.defaultObject, pQuery.query.records[0]);
|
|
82
81
|
// Create override is too complex ... punting for now
|
|
83
82
|
// if (pMeadow.rawQueries.checkQuery('Create'))
|
|
84
83
|
// pQuery.parameters.queryOverride = pMeadow.rawQueries.getQuery('Create');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
|
-
var
|
|
6
|
+
var libAsyncWaterfall = require('async/waterfall');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Meadow Behavior - Delete a single record
|
|
@@ -14,7 +14,7 @@ var meadowBehaviorDelete = function(pMeadow, pQuery, fCallBack)
|
|
|
14
14
|
{
|
|
15
15
|
// TODO: Check if this recordset has implicit delete tracking, branch in this module.
|
|
16
16
|
// Delete the record(s) from the source
|
|
17
|
-
|
|
17
|
+
libAsyncWaterfall(
|
|
18
18
|
[
|
|
19
19
|
// Step 1: Delete the record
|
|
20
20
|
function (fStageComplete)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
|
-
var
|
|
6
|
+
var libAsyncWaterfall = require('async/waterfall');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Meadow Behavior - Read a single record
|
|
@@ -13,7 +13,7 @@ var libAsync = require('async');
|
|
|
13
13
|
var meadowBehaviorRead = function(pMeadow, pQuery, fCallBack)
|
|
14
14
|
{
|
|
15
15
|
// Read the record from the source
|
|
16
|
-
|
|
16
|
+
libAsyncWaterfall(
|
|
17
17
|
[
|
|
18
18
|
// Step 1: Get the record from the data source
|
|
19
19
|
function (fStageComplete)
|
|
@@ -31,7 +31,7 @@ var meadowBehaviorRead = function(pMeadow, pQuery, fCallBack)
|
|
|
31
31
|
// Check that a record was returned
|
|
32
32
|
if (pQuery.parameters.result.value.length < 1)
|
|
33
33
|
{
|
|
34
|
-
return fStageComplete(
|
|
34
|
+
return fStageComplete(undefined, pQuery, false);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
var tmpRecord = pMeadow.marshalRecordFromSourceToObject(pQuery.result.value[0]);
|
|
@@ -39,8 +39,9 @@ var meadowBehaviorRead = function(pMeadow, pQuery, fCallBack)
|
|
|
39
39
|
fStageComplete(pQuery.result.error, pQuery, tmpRecord);
|
|
40
40
|
}
|
|
41
41
|
],
|
|
42
|
-
|
|
42
|
+
(pError, pQuery, pRecord)=>
|
|
43
43
|
{
|
|
44
|
+
console.log('b')
|
|
44
45
|
if (pError)
|
|
45
46
|
{
|
|
46
47
|
pMeadow.fable.log.warn('Error during the read waterfall', {Error:pError, Message: pError.message, Query: pQuery.query});
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
|
-
var
|
|
6
|
+
var libAsyncWaterfall = require('async/waterfall');
|
|
7
|
+
var libAsyncEach = require('async/eachSeries');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Meadow Behavior - Read multiple records
|
|
@@ -15,7 +16,7 @@ var meadowBehaviorReads = function(pMeadow, pQuery, fCallBack)
|
|
|
15
16
|
var tmpProfileStart = new Date(); //for profiling query time
|
|
16
17
|
|
|
17
18
|
// Read the record(s) from the source
|
|
18
|
-
|
|
19
|
+
libAsyncWaterfall(
|
|
19
20
|
[
|
|
20
21
|
// Step 1: Get the record(s) from the data source
|
|
21
22
|
function (fStageComplete)
|
|
@@ -38,7 +39,7 @@ var meadowBehaviorReads = function(pMeadow, pQuery, fCallBack)
|
|
|
38
39
|
|
|
39
40
|
var tmpRecords = [];
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
libAsyncEach
|
|
42
43
|
(
|
|
43
44
|
pQuery.parameters.result.value,
|
|
44
45
|
function(pRow, pQueueCallback)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// ##### Part of the **[retold](https://stevenvelozo.github.io/retold/)** system
|
|
2
|
+
/**
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author <steven@velozo.com>
|
|
5
|
+
*/
|
|
6
|
+
var libAsyncWaterfall = require('async/waterfall');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Meadow Behavior - Undelete a single record
|
|
10
|
+
*
|
|
11
|
+
* @function meadowBehaviorUndelete
|
|
12
|
+
*/
|
|
13
|
+
var meadowBehaviorUndelete = function(pMeadow, pQuery, fCallBack)
|
|
14
|
+
{
|
|
15
|
+
// TODO: Check if this recordset has implicit delete tracking, branch in this module?
|
|
16
|
+
// Undelete the record(s) if they were deleted with a bit
|
|
17
|
+
libAsyncWaterfall(
|
|
18
|
+
[
|
|
19
|
+
// Step 1: Undelete the record
|
|
20
|
+
function (fStageComplete)
|
|
21
|
+
{
|
|
22
|
+
if (pMeadow.rawQueries.checkQuery('Undelete'))
|
|
23
|
+
{
|
|
24
|
+
pQuery.parameters.queryOverride = pMeadow.rawQueries.getQuery('Undelete');
|
|
25
|
+
}
|
|
26
|
+
pMeadow.provider.Undelete(pQuery, function(){ fStageComplete(pQuery.result.error, pQuery, pQuery.result.value); });
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
function(pError, pQuery, pRecord)
|
|
30
|
+
{
|
|
31
|
+
if (pError)
|
|
32
|
+
{
|
|
33
|
+
pMeadow.fable.log.warn('Error during the undelete waterfall', {Error:pError, Message: pError.message, Query: pQuery.query});
|
|
34
|
+
}
|
|
35
|
+
fCallBack(pError, pQuery, pRecord);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return pMeadow;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = meadowBehaviorUndelete;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
|
-
var
|
|
6
|
+
var libAsyncWaterfall = require('async/waterfall');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Meadow Behavior - Update a single record
|
|
@@ -13,7 +13,7 @@ var libAsync = require('async');
|
|
|
13
13
|
var meadowBehaviorUpdate = function(pMeadow, pQuery, fCallBack)
|
|
14
14
|
{
|
|
15
15
|
// Update the record(s) from the source
|
|
16
|
-
|
|
16
|
+
libAsyncWaterfall(
|
|
17
17
|
[
|
|
18
18
|
// Step 1: Update the record
|
|
19
19
|
function (fStageComplete)
|
|
@@ -304,6 +304,38 @@ var MeadowProvider = function()
|
|
|
304
304
|
fCallback();
|
|
305
305
|
};
|
|
306
306
|
|
|
307
|
+
var Undelete = function(pQuery, fCallback)
|
|
308
|
+
{
|
|
309
|
+
var tmpResult = pQuery.parameters.result;
|
|
310
|
+
|
|
311
|
+
checkDataExists(pQuery.parameters);
|
|
312
|
+
|
|
313
|
+
pQuery.setDialect('ALASQL').buildUndeleteQuery();
|
|
314
|
+
var fQuery = libALASQL.compile(pQuery.query.body);
|
|
315
|
+
|
|
316
|
+
if (pQuery.logLevel > 0 ||
|
|
317
|
+
_GlobalLogLevel > 0)
|
|
318
|
+
{
|
|
319
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
try
|
|
323
|
+
{
|
|
324
|
+
tmpResult.error = undefined;
|
|
325
|
+
tmpResult.executed = false;
|
|
326
|
+
|
|
327
|
+
tmpResult.value = fQuery(pQuery.query.parameters);
|
|
328
|
+
|
|
329
|
+
tmpResult.executed = true;
|
|
330
|
+
}
|
|
331
|
+
catch (pError)
|
|
332
|
+
{
|
|
333
|
+
tmpResult.error = pError;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
fCallback();
|
|
337
|
+
};
|
|
338
|
+
|
|
307
339
|
var Count = function(pQuery, fCallback)
|
|
308
340
|
{
|
|
309
341
|
var tmpResult = pQuery.parameters.result;
|
|
@@ -463,6 +495,7 @@ var MeadowProvider = function()
|
|
|
463
495
|
Read: Read,
|
|
464
496
|
Update: Update,
|
|
465
497
|
Delete: Delete,
|
|
498
|
+
Undelete: Undelete,
|
|
466
499
|
Count: Count,
|
|
467
500
|
|
|
468
501
|
new: createNew
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* @author <steven@velozo.com>
|
|
5
5
|
*/
|
|
6
6
|
var libSimpleGet = require('simple-get');
|
|
7
|
-
var libUnderscore = require('underscore');
|
|
8
7
|
|
|
9
8
|
var MeadowProvider = function()
|
|
10
9
|
{
|
|
@@ -50,12 +49,12 @@ var MeadowProvider = function()
|
|
|
50
49
|
let tmpRequestOptions = (
|
|
51
50
|
{
|
|
52
51
|
url: tmpURL,
|
|
53
|
-
headers:
|
|
52
|
+
headers: _Fable.Utility.extend({cookie: ''}, _Headers)
|
|
54
53
|
});
|
|
55
|
-
|
|
54
|
+
|
|
56
55
|
tmpRequestOptions.headers.cookie = _Cookies.join(';');
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
|
|
59
58
|
if (pQuery.logLevel > 0 ||
|
|
60
59
|
_GlobalLogLevel > 0)
|
|
61
60
|
_Fable.log.debug(`Request options built...`,tmpRequestOptions);
|
|
@@ -189,6 +189,45 @@ var MeadowProvider = function()
|
|
|
189
189
|
});
|
|
190
190
|
};
|
|
191
191
|
|
|
192
|
+
var Undelete = function(pQuery, fCallback)
|
|
193
|
+
{
|
|
194
|
+
var tmpResult = pQuery.parameters.result;
|
|
195
|
+
|
|
196
|
+
pQuery.setDialect('MySQL').buildUndeleteQuery();
|
|
197
|
+
|
|
198
|
+
if (pQuery.logLevel > 0 ||
|
|
199
|
+
_GlobalLogLevel > 0)
|
|
200
|
+
{
|
|
201
|
+
_Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
getSQLPool().getConnection(function(pError, pDBConnection)
|
|
205
|
+
{
|
|
206
|
+
pDBConnection.query
|
|
207
|
+
(
|
|
208
|
+
pQuery.query.body,
|
|
209
|
+
pQuery.query.parameters,
|
|
210
|
+
// The MySQL library also returns the Fields as the third parameter
|
|
211
|
+
function(pError, pRows)
|
|
212
|
+
{
|
|
213
|
+
pDBConnection.release();
|
|
214
|
+
tmpResult.error = pError;
|
|
215
|
+
tmpResult.value = false;
|
|
216
|
+
try
|
|
217
|
+
{
|
|
218
|
+
tmpResult.value = pRows.affectedRows;
|
|
219
|
+
}
|
|
220
|
+
catch(pErrorGettingRowcount)
|
|
221
|
+
{
|
|
222
|
+
_Fable.log.warn('Error getting affected rowcount during delete query',{Body:pQuery.query.body, Parameters:pQuery.query.parameters});
|
|
223
|
+
}
|
|
224
|
+
tmpResult.executed = true;
|
|
225
|
+
return fCallback();
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
|
|
192
231
|
var Count = function(pQuery, fCallback)
|
|
193
232
|
{
|
|
194
233
|
var tmpResult = pQuery.parameters.result;
|
|
@@ -235,6 +274,7 @@ var MeadowProvider = function()
|
|
|
235
274
|
Read: Read,
|
|
236
275
|
Update: Update,
|
|
237
276
|
Delete: Delete,
|
|
277
|
+
Undelete: Undelete,
|
|
238
278
|
Count: Count,
|
|
239
279
|
|
|
240
280
|
new: createNew
|
|
@@ -52,6 +52,13 @@ var MeadowProvider = function()
|
|
|
52
52
|
fCallback();
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
+
var Undelete = function(pQuery, fCallback)
|
|
56
|
+
{
|
|
57
|
+
// This does nothing because it's the none data provider!
|
|
58
|
+
pQuery.parameters.result.executed = true;
|
|
59
|
+
fCallback();
|
|
60
|
+
};
|
|
61
|
+
|
|
55
62
|
var Count = function(pQuery, fCallback)
|
|
56
63
|
{
|
|
57
64
|
// This does nothing because it's the none data provider!
|
|
@@ -67,6 +74,7 @@ var MeadowProvider = function()
|
|
|
67
74
|
Read: Read,
|
|
68
75
|
Update: Update,
|
|
69
76
|
Delete: Delete,
|
|
77
|
+
Undelete: Undelete,
|
|
70
78
|
Count: Count,
|
|
71
79
|
|
|
72
80
|
new: createNew
|