meadow-endpoints 3.0.7 → 4.0.3
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/Dockerfile_LUXURYCode +1 -1
- package/README.md +48 -14
- package/debug/Animal.json +62 -0
- package/debug/Harness-Configuration.json +31 -0
- package/debug/Harness.js +7 -108
- package/debug/KillHarness.sh +10 -0
- package/dist/meadowendpoints.js +4402 -0
- package/dist/meadowendpoints.min.js +92 -0
- package/dist/meadowendpoints.min.js.map +1 -0
- package/gulpfile.js +83 -0
- package/package.json +27 -15
- package/source/Controller/Meadow-Endpoints-Controller-Base.js +161 -0
- package/source/Controller/components/Meadow-Endpoints-Controller-BehaviorInjection.js +125 -0
- package/source/Controller/components/Meadow-Endpoints-Controller-Error-StatusCodes.txt +189 -0
- package/source/Controller/components/Meadow-Endpoints-Controller-Error.js +118 -0
- package/source/Controller/components/Meadow-Endpoints-Controller-Log.js +103 -0
- package/source/Controller/utility/Meadow-Endpoints-Filter-Parser.js +225 -0
- package/source/Controller/utility/Meadow-Endpoints-Session-Marshaler.js +48 -0
- package/source/Controller/utility/Meadow-Endpoints-Stream-RecordArray.js +66 -0
- package/source/Meadow-Endpoints-Browser-Shim.js +14 -0
- package/source/Meadow-Endpoints.js +176 -565
- package/source/endpoints/count/Meadow-Endpoint-Count.js +49 -0
- package/source/endpoints/count/Meadow-Endpoint-CountBy.js +40 -0
- package/source/endpoints/create/Meadow-Endpoint-BulkCreate.js +53 -0
- package/source/endpoints/create/Meadow-Endpoint-Create.js +58 -0
- package/source/endpoints/create/Meadow-Operation-Create.js +83 -0
- package/source/endpoints/delete/Meadow-Endpoint-Delete.js +93 -0
- package/source/endpoints/delete/Meadow-Endpoint-Undelete.js +108 -0
- package/source/endpoints/read/Meadow-Endpoint-Read.js +72 -0
- package/source/endpoints/read/Meadow-Endpoint-ReadDistinctList.js +92 -0
- package/source/endpoints/read/Meadow-Endpoint-ReadLiteList.js +85 -0
- package/source/endpoints/read/Meadow-Endpoint-ReadMax.js +55 -0
- package/source/endpoints/read/Meadow-Endpoint-ReadSelectList.js +89 -0
- package/source/endpoints/read/Meadow-Endpoint-Reads.js +75 -0
- package/source/endpoints/read/Meadow-Endpoint-ReadsBy.js +100 -0
- package/source/{crud → endpoints/read}/Meadow-Marshal-DistinctList.js +4 -13
- package/source/{crud → endpoints/read}/Meadow-Marshal-LiteList.js +5 -14
- package/source/endpoints/schema/Meadow-Endpoint-New.js +36 -0
- package/source/endpoints/schema/Meadow-Endpoint-Schema.js +36 -0
- package/source/endpoints/schema/Meadow-Endpoint-Validate.js +41 -0
- package/source/endpoints/update/Meadow-Endpoint-BulkUpdate.js +50 -0
- package/source/endpoints/update/Meadow-Endpoint-Update.js +58 -0
- package/source/endpoints/update/Meadow-Operation-Update.js +115 -0
- package/source/endpoints/upsert/Meadow-Endpoint-BulkUpsert.js +53 -0
- package/source/endpoints/upsert/Meadow-Endpoint-Upsert.js +58 -0
- package/source/endpoints/upsert/Meadow-Operation-Upsert.js +132 -0
- package/test/MeadowEndpoints_basic_tests.js +50 -2408
- package/test_support/bookstore-api-endpoint-exercises.paw +0 -0
- package/test_support/bookstore-configuration.json +28 -0
- package/test_support/bookstore-import-books-run.js +1 -0
- package/test_support/bookstore-import-books.js +215 -0
- package/test_support/bookstore-serve-meadow-endpoint-apis-IPC.js +138 -0
- package/test_support/bookstore-serve-meadow-endpoint-apis-run.js +6 -0
- package/test_support/bookstore-serve-meadow-endpoint-apis.js +129 -0
- package/test_support/data/books.csv +10001 -0
- package/test_support/model/ddl/BookStore.ddl +66 -0
- package/test_support/model/generated_diagram/README.md +1 -0
- package/test_support/model/generated_diagram/Stricture_Output.dot +13 -0
- package/test_support/model/generated_diagram/Stricture_Output.png +0 -0
- package/test_support/model/generated_documentation/Dictionary.md +18 -0
- package/test_support/model/generated_documentation/Model-Author.md +20 -0
- package/test_support/model/generated_documentation/Model-Book.md +26 -0
- package/test_support/model/generated_documentation/Model-BookAuthorJoin.md +14 -0
- package/test_support/model/generated_documentation/Model-BookPrice.md +25 -0
- package/test_support/model/generated_documentation/Model-Review.md +22 -0
- package/test_support/model/generated_documentation/ModelChangeTracking.md +17 -0
- package/test_support/model/generated_documentation/README.md +1 -0
- package/test_support/model/manual_scripts/DropTables.sql +5 -0
- package/test_support/model/manual_scripts/README.md +2 -0
- package/test_support/model/sql_create/BookStore-CreateDatabase.mysql.sql +116 -0
- package/test_support/model/sql_create/README.md +1 -0
- package/test_support/test_old/Tests.js +3243 -0
- package/test_support/test_old/untitled.js +88 -0
- package/source/Meadow-Authenticator.js +0 -31
- package/source/Meadow-Authorizers.js +0 -214
- package/source/Meadow-BehaviorModifications.js +0 -170
- package/source/Meadow-CommonServices.js +0 -206
- package/source/Meadow-MarshallSessionData.js +0 -64
- package/source/Restify-RouteParser.js +0 -114
- package/source/authorizers/Meadow-Authorizer-Allow.js +0 -17
- package/source/authorizers/Meadow-Authorizer-Deny.js +0 -17
- package/source/authorizers/Meadow-Authorizer-Mine.js +0 -47
- package/source/authorizers/Meadow-Authorizer-MyCustomer.js +0 -48
- package/source/crud/Meadow-Endpoint-BulkCreate.js +0 -67
- package/source/crud/Meadow-Endpoint-BulkUpdate.js +0 -74
- package/source/crud/Meadow-Endpoint-BulkUpsert.js +0 -76
- package/source/crud/Meadow-Endpoint-Count.js +0 -93
- package/source/crud/Meadow-Endpoint-CountBy.js +0 -101
- package/source/crud/Meadow-Endpoint-Create.js +0 -77
- package/source/crud/Meadow-Endpoint-Delete.js +0 -139
- package/source/crud/Meadow-Endpoint-Read.js +0 -109
- package/source/crud/Meadow-Endpoint-ReadDistinctList.js +0 -146
- package/source/crud/Meadow-Endpoint-ReadLiteList.js +0 -139
- package/source/crud/Meadow-Endpoint-ReadMax.js +0 -86
- package/source/crud/Meadow-Endpoint-ReadSelectList.js +0 -145
- package/source/crud/Meadow-Endpoint-Reads.js +0 -129
- package/source/crud/Meadow-Endpoint-ReadsBy.js +0 -155
- package/source/crud/Meadow-Endpoint-Undelete.js +0 -161
- package/source/crud/Meadow-Endpoint-Update.js +0 -80
- package/source/crud/Meadow-Endpoint-Upsert.js +0 -78
- package/source/crud/Meadow-Operation-Create.js +0 -105
- package/source/crud/Meadow-Operation-Update.js +0 -145
- package/source/crud/Meadow-Operation-Upsert.js +0 -106
- package/source/crud/Meadow-StreamRecordArray.js +0 -45
- package/source/schema/Meadow-Endpoint-New.js +0 -37
- package/source/schema/Meadow-Endpoint-Schema.js +0 -37
- package/source/schema/Meadow-Endpoint-Validate.js +0 -43
- package/test/Animal.json +0 -140
- package/test/MeadowEndpoints_disabledAuth_tests.js +0 -1325
- package/test/MeadowEndpoints_trustedSession_tests.js +0 -1731
- package/test/load/artillery-low.yml +0 -10
- package/test/load/cloud9setup.sh +0 -25
- package/test/load/package.json +0 -19
- package/test/load/test-schema-initializedatabase.sql +0 -29
- package/test/load/test-schema.json +0 -119
- package/test/load/test-server.js +0 -157
- package/test/scripts/InitializeDatabase-C9.sql +0 -7
- /package/{test/schemas → test_support/model}/json_schema/BookStore-Extended.json +0 -0
- /package/{test/schemas → test_support/model}/json_schema/BookStore-PICT.json +0 -0
- /package/{test/schemas → test_support/model}/json_schema/BookStore.json +0 -0
- /package/{test/schemas → test_support/model}/json_schema/README.md +0 -0
- /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Author.json +0 -0
- /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Book.json +0 -0
- /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-BookAuthorJoin.json +0 -0
- /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-BookPrice.json +0 -0
- /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Review.json +0 -0
- /package/{test/schemas → test_support/model}/meadow_schema/README.md +0 -0
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-Endpoints-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: `MeadowEndpoints`,
|
|
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: `meadowendpoints.js`,
|
|
19
|
+
|
|
20
|
+
// The name of the minified version of the packaged library, for production release:
|
|
21
|
+
LibraryMinifiedFileName: `meadowendpoints.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,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meadow-endpoints",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Automatic API endpoints for Meadow data.",
|
|
5
5
|
"main": "source/Meadow-Endpoints.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "node source/Meadow-Endpoints.js",
|
|
8
|
-
"
|
|
8
|
+
"harness": "node debug/Harness.js",
|
|
9
|
+
"killharness": "debug/KillHarness.sh",
|
|
10
|
+
"coverage": "./node_modules/.bin/nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec",
|
|
9
11
|
"test": "./node_modules/.bin/mocha --exit -u tdd -R spec",
|
|
12
|
+
"tests": "./node_modules/.bin/mocha -u tdd --exit -R spec --grep",
|
|
10
13
|
"build": "./node_modules/.bin/gulp build",
|
|
11
14
|
"docker-dev-build-image": "docker build ./ -f Dockerfile_LUXURYCode -t retold/meadow-endpoints:local",
|
|
12
|
-
"docker-dev-run": "docker run -it -d --name meadow-endpoints-dev -p
|
|
15
|
+
"docker-dev-run": "docker run -it -d --name meadow-endpoints-dev -p 12343:8080 -p 12305:3306 -p 18086:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/meadow-endpoints\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" retold/meadow-endpoints:local"
|
|
13
16
|
},
|
|
14
17
|
"mocha": {
|
|
15
18
|
"diff": true,
|
|
@@ -19,7 +22,6 @@
|
|
|
19
22
|
"package": "./package.json",
|
|
20
23
|
"reporter": "spec",
|
|
21
24
|
"slow": "75",
|
|
22
|
-
"timeout": "5000",
|
|
23
25
|
"ui": "tdd",
|
|
24
26
|
"watch-files": [
|
|
25
27
|
"source/**/*.js",
|
|
@@ -44,20 +46,30 @@
|
|
|
44
46
|
},
|
|
45
47
|
"homepage": "https://github.com/stevenvelozo/meadow-endpoints",
|
|
46
48
|
"devDependencies": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
49
|
+
"alasql": "^4.0.0",
|
|
50
|
+
"browserify": "^17.0.0",
|
|
51
|
+
"chai": "4.3.7",
|
|
52
|
+
"chance": "^1.1.11",
|
|
53
|
+
"gulp": "^4.0.2",
|
|
54
|
+
"gulp-babel": "^8.0.0",
|
|
55
|
+
"gulp-sourcemaps": "^3.0.0",
|
|
56
|
+
"gulp-terser": "^2.1.0",
|
|
57
|
+
"gulp-util": "^3.0.8",
|
|
58
|
+
"mocha": "10.2.0",
|
|
59
|
+
"mysql2": "^3.3.1",
|
|
52
60
|
"nyc": "^15.1.0",
|
|
53
|
-
"
|
|
61
|
+
"orator-serviceserver-restify": "^1.0.4",
|
|
62
|
+
"papaparse": "^5.4.1",
|
|
63
|
+
"supertest": "^6.3.3",
|
|
64
|
+
"vinyl-buffer": "^1.0.1",
|
|
65
|
+
"vinyl-source-stream": "^2.0.0",
|
|
66
|
+
"why-is-node-running": "^2.2.2"
|
|
54
67
|
},
|
|
55
68
|
"dependencies": {
|
|
56
|
-
"async": "2.
|
|
69
|
+
"async": "3.2.4",
|
|
70
|
+
"fable": "^3.0.37",
|
|
57
71
|
"JSONStream": "^1.3.5",
|
|
58
|
-
"meadow": "
|
|
59
|
-
"
|
|
60
|
-
"orator": "~2.0.2",
|
|
61
|
-
"underscore": "1.12.1"
|
|
72
|
+
"meadow": "^2.0.4",
|
|
73
|
+
"orator": "^3.0.11"
|
|
62
74
|
}
|
|
63
75
|
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const libAsyncWaterfall = require('async/waterfall');
|
|
2
|
+
|
|
3
|
+
const libBaseLogController = require('./components/Meadow-Endpoints-Controller-Log.js')
|
|
4
|
+
|
|
5
|
+
const libBaseErrorController = require('./components/Meadow-Endpoints-Controller-Error.js');
|
|
6
|
+
const libBaseBehaviorInjectionController = require('./components/Meadow-Endpoints-Controller-BehaviorInjection.js');
|
|
7
|
+
|
|
8
|
+
const libMeadowEndpointsFilterParser = require('./utility/Meadow-Endpoints-Filter-Parser.js');
|
|
9
|
+
const libMeadowEndpointsSessionMarshaler = require('./utility/Meadow-Endpoints-Session-Marshaler.js');
|
|
10
|
+
const libMeadowEndpointsStreamRecordArray = require('./utility/Meadow-Endpoints-Stream-RecordArray.js');
|
|
11
|
+
|
|
12
|
+
class MeadowEndpointControllerBase
|
|
13
|
+
{
|
|
14
|
+
constructor(pMeadowEndpoints)
|
|
15
|
+
{
|
|
16
|
+
this.DAL = pMeadowEndpoints.DAL;
|
|
17
|
+
this.ControllerOptions = pMeadowEndpoints._ControllerOptions
|
|
18
|
+
|
|
19
|
+
// Application Services
|
|
20
|
+
this._Settings = false;
|
|
21
|
+
this._LogController = false;
|
|
22
|
+
|
|
23
|
+
// Logic and Behavior
|
|
24
|
+
this._BehaviorInjectionController = false;
|
|
25
|
+
this._ErrorController = false;
|
|
26
|
+
|
|
27
|
+
// Internal async utility functions
|
|
28
|
+
this.waterfall = this.DAL.fable.Utility.waterfall;
|
|
29
|
+
this.eachLimit = this.DAL.fable.Utility.eachLimit;
|
|
30
|
+
this.extend = this.DAL.fable.Utility.extend;
|
|
31
|
+
|
|
32
|
+
if ((typeof(pControllerOptions) != 'object') || pControllerOptions.hasOwnProperty('ControllerClass'))
|
|
33
|
+
{
|
|
34
|
+
this.initializeDefaultUnsetControllers(this);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Behavior functions
|
|
38
|
+
this._FilterParser = new libMeadowEndpointsFilterParser(this);
|
|
39
|
+
this._SessionMarshaler = new libMeadowEndpointsSessionMarshaler(this);
|
|
40
|
+
this._StreamRecordArray = new libMeadowEndpointsStreamRecordArray(this);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
initializeDefaultUnsetControllers(pController)
|
|
44
|
+
{
|
|
45
|
+
// Application Services
|
|
46
|
+
if (!this._Settings)
|
|
47
|
+
{
|
|
48
|
+
this._Settings = pController.DAL.fable.settings;
|
|
49
|
+
}
|
|
50
|
+
if (!this._Settings.hasOwnProperty('MeadowEndpointsDefaultSessionObject'))
|
|
51
|
+
{
|
|
52
|
+
this._Settings.MeadowEndpointsDefaultSessionObject = (
|
|
53
|
+
{
|
|
54
|
+
CustomerID: 0,
|
|
55
|
+
SessionID: '0x0000',
|
|
56
|
+
DeviceID: 'Unset',
|
|
57
|
+
UserID: 0,
|
|
58
|
+
UserRole: 'None',
|
|
59
|
+
UserRoleIndex: 0,
|
|
60
|
+
LoggedIn: false
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (!this._LogController)
|
|
64
|
+
{
|
|
65
|
+
this._LogController = new libBaseLogController(pController);
|
|
66
|
+
}
|
|
67
|
+
if (!this._BehaviorInjectionController)
|
|
68
|
+
{
|
|
69
|
+
this._BehaviorInjectionController = new libBaseBehaviorInjectionController(pController);
|
|
70
|
+
}
|
|
71
|
+
if (!this._ErrorController)
|
|
72
|
+
{
|
|
73
|
+
this._ErrorController = new libBaseErrorController(pController);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
initializeRequestState(pRequest, pVerb)
|
|
78
|
+
{
|
|
79
|
+
let tmpRequestState = {};
|
|
80
|
+
|
|
81
|
+
tmpRequestState.Verb = (typeof(pVerb) == 'string') ? pVerb : 'Unnamed_Custom_Behavior';
|
|
82
|
+
tmpRequestState.SessionData = this.getSessionData(pRequest);
|
|
83
|
+
|
|
84
|
+
return tmpRequestState;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Clone the session data and verb to a new request state object
|
|
88
|
+
cloneAsyncSafeRequestState(pRequestState, pNewVerb)
|
|
89
|
+
{
|
|
90
|
+
let tmpSafeRequestState = (
|
|
91
|
+
{
|
|
92
|
+
ParentRequestState: pRequestState,
|
|
93
|
+
SessionData: pRequestState.SessionData
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
tmpSafeRequestState.Verb = (typeof(pNewVerb) == 'string') ? pNewVerb : pRequestState.Verb;
|
|
97
|
+
|
|
98
|
+
return tmpSafeRequestState;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Override this to provide an alternate ending function that is run with every endpoint.
|
|
102
|
+
_BeginDataRequestFunction(pRequest, pResponse, fNext)
|
|
103
|
+
{
|
|
104
|
+
return fNext();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
beginMeadowRequest(pRequest, pResponse, fNext)
|
|
108
|
+
{
|
|
109
|
+
this._BeginDataRequestFunction(pRequest, pResponse, fNext);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Override this to provide an alternate ending function that is run with every endpoint.
|
|
113
|
+
_EndDataRequestFunction(pRequest, pResponse, fNext)
|
|
114
|
+
{
|
|
115
|
+
return fNext();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
endMeadowRequest(pRequest, pResponse, fNext)
|
|
119
|
+
{
|
|
120
|
+
this._EndDataRequestFunction(pRequest, pResponse, fNext);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Application Services
|
|
124
|
+
get settings() {return this._Settings; }
|
|
125
|
+
set settings(pSettings) { this._Settings = pSettings; }
|
|
126
|
+
|
|
127
|
+
get log() {return this._LogController; }
|
|
128
|
+
set log(pLogController) { this._LogController = pLogController; }
|
|
129
|
+
|
|
130
|
+
// Logic and Behavior
|
|
131
|
+
get BehaviorInjection() {return this._BehaviorInjectionController; }
|
|
132
|
+
set BehaviorInjection(pBehaviorInjectionController) { this._BehaviorInjectionController = pBehaviorInjectionController; }
|
|
133
|
+
|
|
134
|
+
get ErrorHandler() {return this._ErrorController; }
|
|
135
|
+
set ErrorHandler(pErrorController) { this._ErrorController = pErrorController; }
|
|
136
|
+
|
|
137
|
+
parseFilter(pFilterString, pQuery)
|
|
138
|
+
{
|
|
139
|
+
return this._FilterParser.parseFilter(pFilterString, pQuery);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
doStreamRecordArray(pResponse, pRecords, fCallback)
|
|
143
|
+
{
|
|
144
|
+
return this._StreamRecordArray.streamRecordArray(pResponse, pRecords, fCallback);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getSessionData(pRequest)
|
|
148
|
+
{
|
|
149
|
+
return this._SessionMarshaler.getSessionData(pRequest);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
module.exports = MeadowEndpointControllerBase;
|
|
154
|
+
|
|
155
|
+
// Export the base classes for the controller components, for inheritance
|
|
156
|
+
module.exports.BaseErrorController = libBaseErrorController;
|
|
157
|
+
module.exports.BaseBehaviorInjectionController = libBaseBehaviorInjectionController;
|
|
158
|
+
|
|
159
|
+
module.exports.BaseFilterParser = libMeadowEndpointsFilterParser;
|
|
160
|
+
module.exports.BaseSessionMarshaler = libMeadowEndpointsSessionMarshaler;
|
|
161
|
+
module.exports.BaseStreamRecordArray = libMeadowEndpointsStreamRecordArray;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
class MeadowEndpointsControllerBehaviorInjectionBase
|
|
2
|
+
{
|
|
3
|
+
constructor(pController)
|
|
4
|
+
{
|
|
5
|
+
this._Controller = pController;
|
|
6
|
+
|
|
7
|
+
// The template compilation function
|
|
8
|
+
this.template = this._Controller.DAL.fable.Utility.template;
|
|
9
|
+
|
|
10
|
+
// An object to hold modifications to specific behaviors.
|
|
11
|
+
this._BehaviorFunctions = {};
|
|
12
|
+
|
|
13
|
+
// A set of objects to hold the specific templates and their compiled functions
|
|
14
|
+
this._Templates = {};
|
|
15
|
+
this._TemplateFunctions = {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set a specific behavior.
|
|
20
|
+
*
|
|
21
|
+
* The anatomy of a behavior function is as follows:
|
|
22
|
+
*
|
|
23
|
+
* var someBehavior = function(pRequest, fCallback)
|
|
24
|
+
* {
|
|
25
|
+
* // Do some stuff with pRequest...
|
|
26
|
+
* if (pRequest.UserSession.UserRoleIndex < 5)
|
|
27
|
+
* tmpRequestState.Query.addFilter('Customer', pRequest.UserSession.IDCustomer);
|
|
28
|
+
* return fCallback(false);
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* It is important to note that the fCallback function expects false if no error, or a string message if there is one.
|
|
32
|
+
*/
|
|
33
|
+
setBehavior(pBehaviorHash, fBehavior)
|
|
34
|
+
{
|
|
35
|
+
this._BehaviorFunctions[pBehaviorHash] = fBehavior;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This method runs a behavior at a specific hash, and returns true.
|
|
40
|
+
* Or it returns false if there was no behavior there.
|
|
41
|
+
* Behaviors should expect their state to be in the pRequest object, per the example in setBehavior
|
|
42
|
+
*/
|
|
43
|
+
runBehavior(pBehaviorHash, pController, pRequest, pRequestState, fCallback)
|
|
44
|
+
{
|
|
45
|
+
// Run an injected behavior (if it exists)
|
|
46
|
+
if (this._BehaviorFunctions.hasOwnProperty(pBehaviorHash))
|
|
47
|
+
{
|
|
48
|
+
try
|
|
49
|
+
{
|
|
50
|
+
// Call the behavior with the scoped [this] of the Meadow behavior
|
|
51
|
+
// NOTE: If you define a behavior with lambda arrow syntax, it will *not* respect the call
|
|
52
|
+
return this._BehaviorFunctions[pBehaviorHash].call(pController, pRequest, pRequestState, fCallback);
|
|
53
|
+
}
|
|
54
|
+
catch (pInjectedBehaviorError)
|
|
55
|
+
{
|
|
56
|
+
return fCallback(pInjectedBehaviorError);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return fCallback();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get a template.
|
|
65
|
+
*/
|
|
66
|
+
getTemplate(pTemplateHash)
|
|
67
|
+
{
|
|
68
|
+
if (this._Templates.hasOwnProperty(pTemplateHash))
|
|
69
|
+
{
|
|
70
|
+
return this._Templates[pTemplateHash];
|
|
71
|
+
}
|
|
72
|
+
else
|
|
73
|
+
{
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Set a template.
|
|
80
|
+
*/
|
|
81
|
+
setTemplate(pTemplateHash, pTemplate)
|
|
82
|
+
{
|
|
83
|
+
// Store both the cached text as well as the function
|
|
84
|
+
this._Templates[pTemplateHash] = pTemplate;
|
|
85
|
+
this._TemplateFunctions[pTemplateHash] = this.template(pTemplate);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get a template function.
|
|
90
|
+
*/
|
|
91
|
+
getTemplateFunction(pTemplateHash)
|
|
92
|
+
{
|
|
93
|
+
if (this._TemplateFunctions.hasOwnProperty(pTemplateHash))
|
|
94
|
+
{
|
|
95
|
+
return this._TemplateFunctions[pTemplateHash];
|
|
96
|
+
}
|
|
97
|
+
else
|
|
98
|
+
{
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Process a template at a hash, and return the result.
|
|
105
|
+
*/
|
|
106
|
+
processTemplate(pTemplateHash, pTemplateData, pDefaultTemplate)
|
|
107
|
+
{
|
|
108
|
+
var tmpTemplateFunction = this.getTemplateFunction(pTemplateHash);
|
|
109
|
+
var tmpTemplateData = (typeof(pTemplateData) === 'undefined') ? {} : pTemplateData;
|
|
110
|
+
|
|
111
|
+
// This makes the function fairly laziliy loading.
|
|
112
|
+
if (tmpTemplateFunction === false)
|
|
113
|
+
{
|
|
114
|
+
// If the template doesn't exist, try to use the passed-in default and set that as the template.
|
|
115
|
+
// Otherwise make it empty.
|
|
116
|
+
this.setTemplate(pTemplateHash, (typeof(pDefaultTemplate) === 'undefined') ? '' : pDefaultTemplate);
|
|
117
|
+
tmpTemplateFunction = this.getTemplateFunction(pTemplateHash);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Now process and return the underscore template.
|
|
121
|
+
return tmpTemplateFunction(tmpTemplateData);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = MeadowEndpointsControllerBehaviorInjectionBase;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
PULLED FROM https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
|
2
|
+
|
|
3
|
+
Internet Assigned Numbers Authority
|
|
4
|
+
|
|
5
|
+
Hypertext Transfer Protocol (HTTP) Status Code Registry
|
|
6
|
+
|
|
7
|
+
Last Updated
|
|
8
|
+
2022-06-08
|
|
9
|
+
|
|
10
|
+
Available Formats
|
|
11
|
+
[IMG]
|
|
12
|
+
XML [IMG]
|
|
13
|
+
HTML [IMG]
|
|
14
|
+
Plain text
|
|
15
|
+
|
|
16
|
+
Registry included below
|
|
17
|
+
|
|
18
|
+
* HTTP Status Codes
|
|
19
|
+
|
|
20
|
+
HTTP Status Codes
|
|
21
|
+
|
|
22
|
+
Registration Procedure(s)
|
|
23
|
+
|
|
24
|
+
IETF Review
|
|
25
|
+
|
|
26
|
+
Reference
|
|
27
|
+
[RFC9110, Section 16.2.1]
|
|
28
|
+
|
|
29
|
+
Note
|
|
30
|
+
|
|
31
|
+
1xx: Informational - Request received, continuing process
|
|
32
|
+
2xx: Success - The action was successfully received, understood, and accepted
|
|
33
|
+
3xx: Redirection - Further action must be taken in order to complete the request
|
|
34
|
+
4xx: Client Error - The request contains bad syntax or cannot be fulfilled
|
|
35
|
+
5xx: Server Error - The server failed to fulfill an apparently valid request
|
|
36
|
+
|
|
37
|
+
Value Description Reference
|
|
38
|
+
100 Continue [RFC9110, Section 15.2.1]
|
|
39
|
+
101 Switching Protocols [RFC9110, Section 15.2.2]
|
|
40
|
+
102 Processing [RFC2518]
|
|
41
|
+
103 Early Hints [RFC8297]
|
|
42
|
+
104-199 Unassigned
|
|
43
|
+
200 OK [RFC9110, Section 15.3.1]
|
|
44
|
+
201 Created [RFC9110, Section 15.3.2]
|
|
45
|
+
202 Accepted [RFC9110, Section 15.3.3]
|
|
46
|
+
203 Non-Authoritative Information [RFC9110, Section 15.3.4]
|
|
47
|
+
204 No Content [RFC9110, Section 15.3.5]
|
|
48
|
+
205 Reset Content [RFC9110, Section 15.3.6]
|
|
49
|
+
206 Partial Content [RFC9110, Section 15.3.7]
|
|
50
|
+
207 Multi-Status [RFC4918]
|
|
51
|
+
208 Already Reported [RFC5842]
|
|
52
|
+
209-225 Unassigned
|
|
53
|
+
226 IM Used [RFC3229]
|
|
54
|
+
227-299 Unassigned
|
|
55
|
+
300 Multiple Choices [RFC9110, Section 15.4.1]
|
|
56
|
+
301 Moved Permanently [RFC9110, Section 15.4.2]
|
|
57
|
+
302 Found [RFC9110, Section 15.4.3]
|
|
58
|
+
303 See Other [RFC9110, Section 15.4.4]
|
|
59
|
+
304 Not Modified [RFC9110, Section 15.4.5]
|
|
60
|
+
305 Use Proxy [RFC9110, Section 15.4.6]
|
|
61
|
+
306 (Unused) [RFC9110, Section 15.4.7]
|
|
62
|
+
307 Temporary Redirect [RFC9110, Section 15.4.8]
|
|
63
|
+
308 Permanent Redirect [RFC9110, Section 15.4.9]
|
|
64
|
+
309-399 Unassigned
|
|
65
|
+
400 Bad Request [RFC9110, Section 15.5.1]
|
|
66
|
+
401 Unauthorized [RFC9110, Section 15.5.2]
|
|
67
|
+
402 Payment Required [RFC9110, Section 15.5.3]
|
|
68
|
+
403 Forbidden [RFC9110, Section 15.5.4]
|
|
69
|
+
404 Not Found [RFC9110, Section 15.5.5]
|
|
70
|
+
405 Method Not Allowed [RFC9110, Section 15.5.6]
|
|
71
|
+
406 Not Acceptable [RFC9110, Section 15.5.7]
|
|
72
|
+
407 Proxy Authentication Required [RFC9110, Section 15.5.8]
|
|
73
|
+
408 Request Timeout [RFC9110, Section 15.5.9]
|
|
74
|
+
409 Conflict [RFC9110, Section 15.5.10]
|
|
75
|
+
410 Gone [RFC9110, Section 15.5.11]
|
|
76
|
+
411 Length Required [RFC9110, Section 15.5.12]
|
|
77
|
+
412 Precondition Failed [RFC9110, Section 15.5.13]
|
|
78
|
+
413 Content Too Large [RFC9110, Section 15.5.14]
|
|
79
|
+
414 URI Too Long [RFC9110, Section 15.5.15]
|
|
80
|
+
415 Unsupported Media Type [RFC9110, Section 15.5.16]
|
|
81
|
+
416 Range Not Satisfiable [RFC9110, Section 15.5.17]
|
|
82
|
+
417 Expectation Failed [RFC9110, Section 15.5.18]
|
|
83
|
+
418 (Unused) [RFC9110, Section 15.5.19]
|
|
84
|
+
419-420 Unassigned
|
|
85
|
+
421 Misdirected Request [RFC9110, Section 15.5.20]
|
|
86
|
+
422 Unprocessable Content [RFC9110, Section 15.5.21]
|
|
87
|
+
423 Locked [RFC4918]
|
|
88
|
+
424 Failed Dependency [RFC4918]
|
|
89
|
+
425 Too Early [RFC8470]
|
|
90
|
+
426 Upgrade Required [RFC9110, Section 15.5.22]
|
|
91
|
+
427 Unassigned
|
|
92
|
+
428 Precondition Required [RFC6585]
|
|
93
|
+
429 Too Many Requests [RFC6585]
|
|
94
|
+
430 Unassigned
|
|
95
|
+
431 Request Header Fields Too Large [RFC6585]
|
|
96
|
+
432-450 Unassigned
|
|
97
|
+
451 Unavailable For Legal Reasons [RFC7725]
|
|
98
|
+
452-499 Unassigned
|
|
99
|
+
500 Internal Server Error [RFC9110, Section 15.6.1]
|
|
100
|
+
501 Not Implemented [RFC9110, Section 15.6.2]
|
|
101
|
+
502 Bad Gateway [RFC9110, Section 15.6.3]
|
|
102
|
+
503 Service Unavailable [RFC9110, Section 15.6.4]
|
|
103
|
+
504 Gateway Timeout [RFC9110, Section 15.6.5]
|
|
104
|
+
505 HTTP Version Not Supported [RFC9110, Section 15.6.6]
|
|
105
|
+
506 Variant Also Negotiates [RFC2295]
|
|
106
|
+
507 Insufficient Storage [RFC4918]
|
|
107
|
+
508 Loop Detected [RFC5842]
|
|
108
|
+
509 Unassigned
|
|
109
|
+
510 Not Extended (OBSOLETED) [RFC2774][status-change-http-experiments-to-historic]
|
|
110
|
+
511 Network Authentication Required [RFC6585]
|
|
111
|
+
512-599 Unassigned
|
|
112
|
+
|
|
113
|
+
Licensing Terms
|
|
114
|
+
|
|
115
|
+
Value Description Reference
|
|
116
|
+
100 Continue [RFC9110, Section 15.2.1]
|
|
117
|
+
101 Switching Protocols [RFC9110, Section 15.2.2]
|
|
118
|
+
102 Processing [RFC2518]
|
|
119
|
+
103 Early Hints [RFC8297]
|
|
120
|
+
104-199 Unassigned
|
|
121
|
+
200 OK [RFC9110, Section 15.3.1]
|
|
122
|
+
201 Created [RFC9110, Section 15.3.2]
|
|
123
|
+
202 Accepted [RFC9110, Section 15.3.3]
|
|
124
|
+
203 Non-Authoritative Information [RFC9110, Section 15.3.4]
|
|
125
|
+
204 No Content [RFC9110, Section 15.3.5]
|
|
126
|
+
205 Reset Content [RFC9110, Section 15.3.6]
|
|
127
|
+
206 Partial Content [RFC9110, Section 15.3.7]
|
|
128
|
+
207 Multi-Status [RFC4918]
|
|
129
|
+
208 Already Reported [RFC5842]
|
|
130
|
+
209-225 Unassigned
|
|
131
|
+
226 IM Used [RFC3229]
|
|
132
|
+
227-299 Unassigned
|
|
133
|
+
300 Multiple Choices [RFC9110, Section 15.4.1]
|
|
134
|
+
301 Moved Permanently [RFC9110, Section 15.4.2]
|
|
135
|
+
302 Found [RFC9110, Section 15.4.3]
|
|
136
|
+
303 See Other [RFC9110, Section 15.4.4]
|
|
137
|
+
304 Not Modified [RFC9110, Section 15.4.5]
|
|
138
|
+
305 Use Proxy [RFC9110, Section 15.4.6]
|
|
139
|
+
306 (Unused) [RFC9110, Section 15.4.7]
|
|
140
|
+
307 Temporary Redirect [RFC9110, Section 15.4.8]
|
|
141
|
+
308 Permanent Redirect [RFC9110, Section 15.4.9]
|
|
142
|
+
309-399 Unassigned
|
|
143
|
+
400 Bad Request [RFC9110, Section 15.5.1]
|
|
144
|
+
401 Unauthorized [RFC9110, Section 15.5.2]
|
|
145
|
+
402 Payment Required [RFC9110, Section 15.5.3]
|
|
146
|
+
403 Forbidden [RFC9110, Section 15.5.4]
|
|
147
|
+
404 Not Found [RFC9110, Section 15.5.5]
|
|
148
|
+
405 Method Not Allowed [RFC9110, Section 15.5.6]
|
|
149
|
+
406 Not Acceptable [RFC9110, Section 15.5.7]
|
|
150
|
+
407 Proxy Authentication Required [RFC9110, Section 15.5.8]
|
|
151
|
+
408 Request Timeout [RFC9110, Section 15.5.9]
|
|
152
|
+
409 Conflict [RFC9110, Section 15.5.10]
|
|
153
|
+
410 Gone [RFC9110, Section 15.5.11]
|
|
154
|
+
411 Length Required [RFC9110, Section 15.5.12]
|
|
155
|
+
412 Precondition Failed [RFC9110, Section 15.5.13]
|
|
156
|
+
413 Content Too Large [RFC9110, Section 15.5.14]
|
|
157
|
+
414 URI Too Long [RFC9110, Section 15.5.15]
|
|
158
|
+
415 Unsupported Media Type [RFC9110, Section 15.5.16]
|
|
159
|
+
416 Range Not Satisfiable [RFC9110, Section 15.5.17]
|
|
160
|
+
417 Expectation Failed [RFC9110, Section 15.5.18]
|
|
161
|
+
418 (Unused) [RFC9110, Section 15.5.19]
|
|
162
|
+
419-420 Unassigned
|
|
163
|
+
421 Misdirected Request [RFC9110, Section 15.5.20]
|
|
164
|
+
422 Unprocessable Content [RFC9110, Section 15.5.21]
|
|
165
|
+
423 Locked [RFC4918]
|
|
166
|
+
424 Failed Dependency [RFC4918]
|
|
167
|
+
425 Too Early [RFC8470]
|
|
168
|
+
426 Upgrade Required [RFC9110, Section 15.5.22]
|
|
169
|
+
427 Unassigned
|
|
170
|
+
428 Precondition Required [RFC6585]
|
|
171
|
+
429 Too Many Requests [RFC6585]
|
|
172
|
+
430 Unassigned
|
|
173
|
+
431 Request Header Fields Too Large [RFC6585]
|
|
174
|
+
432-450 Unassigned
|
|
175
|
+
451 Unavailable For Legal Reasons [RFC7725]
|
|
176
|
+
452-499 Unassigned
|
|
177
|
+
500 Internal Server Error [RFC9110, Section 15.6.1]
|
|
178
|
+
501 Not Implemented [RFC9110, Section 15.6.2]
|
|
179
|
+
502 Bad Gateway [RFC9110, Section 15.6.3]
|
|
180
|
+
503 Service Unavailable [RFC9110, Section 15.6.4]
|
|
181
|
+
504 Gateway Timeout [RFC9110, Section 15.6.5]
|
|
182
|
+
505 HTTP Version Not Supported [RFC9110, Section 15.6.6]
|
|
183
|
+
506 Variant Also Negotiates [RFC2295]
|
|
184
|
+
507 Insufficient Storage [RFC4918]
|
|
185
|
+
508 Loop Detected [RFC5842]
|
|
186
|
+
509 Unassigned
|
|
187
|
+
510 Not Extended (OBSOLETED) [RFC2774][status-change-http-experiments-to-historic]
|
|
188
|
+
511 Network Authentication Required [RFC6585]
|
|
189
|
+
512-599 Unassigned
|