meadow-endpoints 3.0.6 → 4.0.2
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 → Dockerfile_LUXURYCode} +43 -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 +29 -16
- package/source/Meadow-Endpoints-Browser-Shim.js +14 -0
- package/source/Meadow-Endpoints.js +176 -562
- 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/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 +52 -0
- package/source/endpoints/upsert/Meadow-Endpoint-Upsert.js +57 -0
- package/source/endpoints/upsert/Meadow-Operation-Upsert.js +137 -0
- package/test/MeadowEndpoints_basic_tests.js +50 -2375
- 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-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
|
@@ -1,620 +1,234 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Meadow Data Broker Library
|
|
2
|
+
* Meadow Endpoints Service Data Broker Library
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
|
-
*
|
|
6
5
|
* @author Steven Velozo <steven@velozo.com>
|
|
7
|
-
* @module Meadow
|
|
8
6
|
*/
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @constructor
|
|
15
|
-
*/
|
|
16
|
-
var MeadowEndpoints = function()
|
|
8
|
+
const libMeadowEndpointsControllerBase = require('./controller/Meadow-Endpoints-Controller-Base.js');
|
|
9
|
+
const libMeadow = require('meadow');
|
|
10
|
+
|
|
11
|
+
class MeadowEndpoints
|
|
17
12
|
{
|
|
18
|
-
|
|
13
|
+
constructor(pMeadow, pControllerOptions)
|
|
19
14
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return {new: createNew};
|
|
24
|
-
}
|
|
25
|
-
var _Meadow = pMeadow;
|
|
26
|
-
var _Fable = pMeadow.fable;
|
|
27
|
-
|
|
28
|
-
var libAsync = require('async');
|
|
29
|
-
var libRestRouteParse = require('./Restify-RouteParser.js');
|
|
15
|
+
this._Meadow = pMeadow;
|
|
16
|
+
// This is for backwards compatibility
|
|
17
|
+
this.DAL = this._Meadow;
|
|
30
18
|
|
|
31
|
-
|
|
19
|
+
this._Controller = false;
|
|
20
|
+
this._ControllerOptions = (typeof(pControllerOptions) == 'object') ? pControllerOptions : {};
|
|
32
21
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// This holds any changed behaviors.
|
|
36
|
-
var _BehaviorModifications = require('./Meadow-BehaviorModifications.js').new(pMeadow);
|
|
37
|
-
|
|
38
|
-
// This holds the authorizers.
|
|
39
|
-
var _Authorizers = require('./Meadow-Authorizers.js').new(pMeadow);
|
|
40
|
-
|
|
41
|
-
// This checks that the user is authenticated. In the future, it will be overloadable.
|
|
42
|
-
var _Authenticator = require('./Meadow-Authenticator.js')(_AuthenticationMode);
|
|
43
|
-
|
|
44
|
-
// The default endpoints
|
|
45
|
-
var _Endpoints = (
|
|
22
|
+
if (typeof(pMeadow) != 'object')
|
|
46
23
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Read: require('./crud/Meadow-Endpoint-Read.js'),
|
|
51
|
-
ReadMax: require('./crud/Meadow-Endpoint-ReadMax.js'),
|
|
52
|
-
|
|
53
|
-
Reads: require('./crud/Meadow-Endpoint-Reads.js'),
|
|
54
|
-
ReadsBy: require('./crud/Meadow-Endpoint-ReadsBy.js'),
|
|
55
|
-
|
|
56
|
-
ReadSelectList: require('./crud/Meadow-Endpoint-ReadSelectList.js'),
|
|
57
|
-
ReadLiteList: require('./crud/Meadow-Endpoint-ReadLiteList.js'),
|
|
58
|
-
ReadDistinctList: require('./crud/Meadow-Endpoint-ReadDistinctList.js'),
|
|
59
|
-
|
|
60
|
-
Update: require('./crud/Meadow-Endpoint-Update.js'),
|
|
61
|
-
Updates: require('./crud/Meadow-Endpoint-BulkUpdate.js'),
|
|
62
|
-
|
|
63
|
-
Upsert: require('./crud/Meadow-Endpoint-Upsert.js'),
|
|
64
|
-
Upserts: require('./crud/Meadow-Endpoint-BulkUpsert.js'),
|
|
65
|
-
|
|
66
|
-
Delete: require('./crud/Meadow-Endpoint-Delete.js'),
|
|
67
|
-
|
|
68
|
-
Count: require('./crud/Meadow-Endpoint-Count.js'),
|
|
69
|
-
CountBy: require('./crud/Meadow-Endpoint-CountBy.js'),
|
|
70
|
-
|
|
71
|
-
// Get the JSONSchema spec schema
|
|
72
|
-
/* http://json-schema.org/examples.html
|
|
73
|
-
* http://json-schema.org/latest/json-schema-core.html
|
|
74
|
-
*/
|
|
75
|
-
Schema: require('./schema/Meadow-Endpoint-Schema.js'),
|
|
76
|
-
// Validate a passed-in JSON object for if it matches the schema
|
|
77
|
-
Validate: require('./schema/Meadow-Endpoint-Validate.js'),
|
|
78
|
-
// Get an empty initialized JSON object for this.
|
|
79
|
-
New: require('./schema/Meadow-Endpoint-New.js')
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Customize a default endpoint (or create more)
|
|
84
|
-
*
|
|
85
|
-
* @method setEndpoint
|
|
86
|
-
*/
|
|
87
|
-
var setEndpoint = function(pEndpointHash, fEndpoint)
|
|
88
|
-
{
|
|
89
|
-
if (typeof(fEndpoint) === 'function')
|
|
90
|
-
{
|
|
91
|
-
_Endpoints[pEndpointHash] = fEndpoint;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return this;
|
|
95
|
-
};
|
|
96
|
-
|
|
24
|
+
throw new Error('Meadow endpoints requires a valid Meadow DAL object as the first parameter of the constructor.');
|
|
25
|
+
}
|
|
97
26
|
|
|
98
|
-
|
|
99
|
-
var _EndpointAuthenticators = (
|
|
27
|
+
if (this._ControllerOptions.hasOwnProperty('ControllerInstance'))
|
|
100
28
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
Delete: _Authenticator,
|
|
106
|
-
Count: _Authenticator,
|
|
107
|
-
|
|
108
|
-
Schema: _Authenticator,
|
|
109
|
-
Validate: _Authenticator,
|
|
110
|
-
New: _Authenticator
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Customize an endpoint Authenticator
|
|
115
|
-
*
|
|
116
|
-
* @method setEndpointAuthenticator
|
|
117
|
-
*/
|
|
118
|
-
var setEndpointAuthenticator = function(pEndpointHash, fAuthenticator)
|
|
29
|
+
// Passed in already instantiated controller instance
|
|
30
|
+
this._Controller = this._ControllerOptions.ControllerInstance;
|
|
31
|
+
}
|
|
32
|
+
else if (this._ControllerOptions.hasOwnProperty('ControllerClass'))
|
|
119
33
|
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return this;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// The default endpoint authorization levels
|
|
130
|
-
var _EndpointAuthorizationLevels = (
|
|
34
|
+
// Passed in controller class, ready to initialize
|
|
35
|
+
this._Controller = new this._ControllerOptions.ControllerClass(this);
|
|
36
|
+
}
|
|
37
|
+
else
|
|
131
38
|
{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Reads: 0,
|
|
135
|
-
Update: 1,
|
|
136
|
-
Delete: 1,
|
|
137
|
-
Count: 0,
|
|
138
|
-
|
|
139
|
-
Schema: 0,
|
|
140
|
-
Validate: 0,
|
|
141
|
-
New: 1
|
|
142
|
-
});
|
|
39
|
+
this._Controller = new libMeadowEndpointsControllerBase(this);
|
|
40
|
+
}
|
|
143
41
|
|
|
42
|
+
// Pull version from the settings; default to 1.0
|
|
43
|
+
this.EndpointVersion = this._Controller.settings.MeadowEndpointVersion || '1.0';
|
|
44
|
+
// Pull endpoint name from settings if the user to override the endpoint "name" eventually.
|
|
45
|
+
this.EndpointName = this.DAL.scope;
|
|
46
|
+
// This allows a wily developer to change what this prefix is....
|
|
47
|
+
this.EndpointPrefix = `/${this.EndpointVersion}/${this.EndpointName}`;
|
|
144
48
|
|
|
145
|
-
// The default
|
|
49
|
+
// The default behavior sets available.
|
|
146
50
|
// Turning these off before wiring the endpoints up will result in their counterpart endpoints not being available.
|
|
147
|
-
|
|
51
|
+
this._EnabledBehaviorSets = (
|
|
148
52
|
{
|
|
149
53
|
Create: true,
|
|
150
|
-
// POST [/1.0/SomeEndpoint]
|
|
151
|
-
|
|
152
54
|
Read: true,
|
|
153
|
-
// GET [/1.0/SomeEndpoint/:IDRecord]
|
|
154
|
-
// GET [/1.0/SomeEndpoint/Max/:ColumnName]
|
|
155
|
-
|
|
156
55
|
Reads: true,
|
|
157
|
-
// GET [/1.0/SomeEndpoints]
|
|
158
|
-
// GET [/1.0/SomeEndpoints/:Begin/:Cap]
|
|
159
|
-
// GET [/1.0/SomeEndpoints/By/:ByField/:ByValue]
|
|
160
|
-
// GET [/1.0/SomeEndpoints/By/:ByField/:ByValue/:Begin/:Cap]
|
|
161
|
-
// GET [/1.0/SomeEndpoints/FilteredTo/:Filter]
|
|
162
|
-
// GET [/1.0/SomeEndpoints/FilteredTo/:Filter/:Begin/:Cap]
|
|
163
|
-
// GET [/1.0/SomeEndpointSelect]
|
|
164
|
-
// GET [/1.0/SomeEndpointSelect/:Begin/:Cap]
|
|
165
|
-
// GET [/1.0/SomeEndpointSelect/FilteredTo/:Filter]
|
|
166
|
-
// GET [/1.0/SomeEndpointSelect/FilteredTo/:Filter/:Begin/:Cap]
|
|
167
|
-
// GET [/1.0/SomeEndpoint/Lite]
|
|
168
|
-
// GET [/1.0/SomeEndpoint/Lite/:Begin/:Cap]
|
|
169
|
-
// GET [/1.0/SomeEndpoint/Lite/FilteredTo/:Filter]
|
|
170
|
-
// GET [/1.0/SomeEndpoint/Lite/FilteredTo/:Filter/:Begin/:Cap]
|
|
171
|
-
// GET [/1.0/SomeEndpoint/LiteExtended/:ExtraColumns]
|
|
172
|
-
// GET [/1.0/SomeEndpoint/LiteExtended/:ExtraColumns/:Begin/:Cap]
|
|
173
|
-
// GET [/1.0/SomeEndpoint/LiteExtended/:ExtraColumns/FilteredTo/:Filter]
|
|
174
|
-
// GET [/1.0/SomeEndpoint/LiteExtended/:ExtraColumns/FilteredTo/:Filter/:Begin/:Cap]
|
|
175
|
-
// GET [/1.0/SomeEndpoint/Distinct/:Columns]
|
|
176
|
-
// GET [/1.0/SomeEndpoint/Distinct/:Columns/:Begin/:Cap]
|
|
177
|
-
// GET [/1.0/SomeEndpoint/Distinct/:Columns/FilteredTo/:Filter]
|
|
178
|
-
// GET [/1.0/SomeEndpoint/Distinct/:Columns/FilteredTo/:Filter/:Begin/:Cap]
|
|
179
|
-
|
|
180
56
|
Update: true,
|
|
181
|
-
// PUT [/1.0/SomeEndpoint]
|
|
182
|
-
// PUT [/1.0/SomeEndpoint/Upsert]
|
|
183
|
-
|
|
184
57
|
Delete: true,
|
|
185
|
-
// DEL [/1.0/SomeEndpoint]
|
|
186
|
-
// DEL [/1.0/SomeEndpoint/:IDRecord]
|
|
187
|
-
|
|
188
58
|
Count: true,
|
|
189
|
-
// GET [/1.0/SomeEndpoints/Count]
|
|
190
|
-
// GET [/1.0/SomeEndpoints/Count/By/:ByField/:ByValue]
|
|
191
|
-
// GET [/1.0/SomeEndpoints/Count/FilteredTo/:Filter]
|
|
192
|
-
|
|
193
59
|
Schema: true,
|
|
194
|
-
// GET [/1.0/SomeEndpoint/Schema]
|
|
195
|
-
|
|
196
60
|
Validate: true,
|
|
197
|
-
// POST [/1.0/SomeEndpoint/Schema/Validate]
|
|
198
|
-
|
|
199
61
|
New: true
|
|
200
|
-
// GET [/1.0/SomeEndpoint/Schema/New]
|
|
201
62
|
});
|
|
202
63
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
*
|
|
206
|
-
* @method setEndpointAuthorization
|
|
207
|
-
*/
|
|
208
|
-
var setEndpointAuthorization = function(pEndpointHash, pAuthorizationLevel)
|
|
209
|
-
{
|
|
210
|
-
_EndpointAuthorizationLevels[pEndpointHash] = pAuthorizationLevel;
|
|
211
|
-
return true;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Add the common services object to the request early in the route chain
|
|
217
|
-
*/
|
|
218
|
-
var wireCommonServices = function (pRequest, pResponse, fNext)
|
|
64
|
+
// The default endpoints
|
|
65
|
+
this._Endpoints = (
|
|
219
66
|
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
fNext();
|
|
223
|
-
};
|
|
224
|
-
|
|
67
|
+
Create: require('./endpoints/create/Meadow-Endpoint-Create.js'),
|
|
68
|
+
Creates: require('./endpoints/create/Meadow-Endpoint-BulkCreate.js'),
|
|
225
69
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
*/
|
|
229
|
-
var wireState = function (pRequest, pResponse, fNext)
|
|
230
|
-
{
|
|
231
|
-
// TODO: There is a shared state issue with using this as the source for the authorization levels. Fix it.
|
|
232
|
-
pRequest.EndpointAuthorizationLevels = _EndpointAuthorizationLevels;
|
|
233
|
-
pRequest.DAL = _Meadow;
|
|
234
|
-
pRequest.BehaviorModifications = _BehaviorModifications;
|
|
235
|
-
pRequest.Authorizers = _Authorizers;
|
|
236
|
-
pRequest.forEachRecord = function(fIterator)
|
|
237
|
-
{
|
|
238
|
-
if (pRequest.Record)
|
|
239
|
-
return fIterator(pRequest.Record)
|
|
240
|
-
else if (pRequest.Records)
|
|
241
|
-
return pRequest.Records.forEach(fIterator);
|
|
242
|
-
}
|
|
70
|
+
Read: require('./endpoints/read/Meadow-Endpoint-Read.js'),
|
|
71
|
+
ReadMax: require('./endpoints/read/Meadow-Endpoint-ReadMax.js'),
|
|
243
72
|
|
|
244
|
-
|
|
245
|
-
|
|
73
|
+
Reads: require('./endpoints/read/Meadow-Endpoint-Reads.js'),
|
|
74
|
+
ReadsBy: require('./endpoints/read/Meadow-Endpoint-ReadsBy.js'),
|
|
246
75
|
|
|
247
|
-
|
|
248
|
-
|
|
76
|
+
ReadSelectList: require('./endpoints/read/Meadow-Endpoint-ReadSelectList.js'),
|
|
77
|
+
ReadLiteList: require('./endpoints/read/Meadow-Endpoint-ReadLiteList.js'),
|
|
78
|
+
ReadDistinctList: require('./endpoints/read/Meadow-Endpoint-ReadDistinctList.js'),
|
|
249
79
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
*/
|
|
253
|
-
var formatRouteParams = function(pRequest, pResponse, fNext)
|
|
254
|
-
{
|
|
255
|
-
if (pRequest.method === 'GET')
|
|
256
|
-
{
|
|
257
|
-
var tmpParams = libRestRouteParse(
|
|
258
|
-
pRequest.route.path,
|
|
259
|
-
pRequest.url
|
|
260
|
-
);
|
|
80
|
+
Update: require('./endpoints/update/Meadow-Endpoint-Update.js'),
|
|
81
|
+
Updates: require('./endpoints/update/Meadow-Endpoint-BulkUpdate.js'),
|
|
261
82
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
var tmpArray = tmpParams[key].split(',');
|
|
265
|
-
if (tmpArray.length > 1)
|
|
266
|
-
{
|
|
267
|
-
for(var i=0; i<tmpArray.length; i++)
|
|
268
|
-
{
|
|
269
|
-
tmpArray[i] = decodeURIComponent(tmpArray[i]);
|
|
270
|
-
}
|
|
83
|
+
Upsert: require('./endpoints/upsert/Meadow-Endpoint-Upsert.js'),
|
|
84
|
+
Upserts: require('./endpoints/upsert/Meadow-Endpoint-BulkUpsert.js'),
|
|
271
85
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
else
|
|
275
|
-
{
|
|
276
|
-
tmpParams[key] = decodeURIComponent(tmpParams[key]);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
86
|
+
Delete: require('./endpoints/delete/Meadow-Endpoint-Delete.js'),
|
|
87
|
+
Undelete: require('./endpoints/delete/Meadow-Endpoint-Undelete.js'),
|
|
279
88
|
|
|
280
|
-
|
|
281
|
-
|
|
89
|
+
Count: require('./endpoints/count/Meadow-Endpoint-Count.js'),
|
|
90
|
+
CountBy: require('./endpoints/count/Meadow-Endpoint-CountBy.js'),
|
|
282
91
|
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
-
|
|
92
|
+
// Get the JSONSchema spec schema
|
|
93
|
+
/* http://json-schema.org/examples.html
|
|
94
|
+
* http://json-schema.org/latest/json-schema-core.html
|
|
95
|
+
*/
|
|
96
|
+
Schema: require('./endpoints/schema/Meadow-Endpoint-Schema.js'),
|
|
97
|
+
// Validate a passed-in JSON object for if it matches the schema
|
|
98
|
+
Validate: require('./endpoints/schema/Meadow-Endpoint-Validate.js'),
|
|
99
|
+
// Get an empty initialized JSON object for this.
|
|
100
|
+
New: require('./endpoints/schema/Meadow-Endpoint-New.js')
|
|
101
|
+
});
|
|
102
|
+
}
|
|
286
103
|
|
|
104
|
+
get controller()
|
|
105
|
+
{
|
|
106
|
+
return this._Controller;
|
|
107
|
+
}
|
|
108
|
+
set controller(pController)
|
|
109
|
+
{
|
|
110
|
+
this._Controller = pController;
|
|
111
|
+
}
|
|
287
112
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Customize a default endpoint (or create more)
|
|
115
|
+
*
|
|
116
|
+
* @method setEndpoint
|
|
117
|
+
*/
|
|
118
|
+
setBehaviorEndpoint(pEndpointHash, fEndpoint)
|
|
119
|
+
{
|
|
120
|
+
if (typeof(fEndpoint) === 'function')
|
|
295
121
|
{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
// TODO: Allow the user to override the endpoint "name" eventually.
|
|
299
|
-
const tmpEndpointName = _Meadow.scope;
|
|
300
|
-
|
|
301
|
-
_Fable.log.trace('Creating endpoint', { Version: tmpEndpointVersion, Name: tmpEndpointName });
|
|
302
|
-
|
|
303
|
-
const tmpEndpointPrefix = `/${tmpEndpointVersion}/${tmpEndpointName}`;
|
|
304
|
-
|
|
305
|
-
if (!pRestServer._AttachedMeadowEndpointsRequestHandlers)
|
|
306
|
-
{
|
|
307
|
-
pRestServer._AttachedMeadowEndpointsRequestHandlers = true;
|
|
308
|
-
// Connect the common services to the route
|
|
309
|
-
pRestServer.use(wireCommonServices);
|
|
310
|
-
|
|
311
|
-
// Build formattedParams route parameters
|
|
312
|
-
pRestServer.use(formatRouteParams);
|
|
313
|
-
|
|
314
|
-
// Marshall session data in, if needed / configured
|
|
315
|
-
pRestServer.use(require('./Meadow-MarshallSessionData')(_Fable));
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// These special schema services must come in the route table before the READ because they
|
|
319
|
-
// technically block out the routes for the IDRecord 'Schema' (e.g. /1.0/EntityName/Schema)
|
|
320
|
-
if (_EnabledBehaviors.Schema)
|
|
321
|
-
{
|
|
322
|
-
pRestServer.get(`${tmpEndpointPrefix}/Schema`, _EndpointAuthenticators.Schema, wireState, _Endpoints.Schema);
|
|
323
|
-
}
|
|
324
|
-
if (_EnabledBehaviors.New)
|
|
325
|
-
{
|
|
326
|
-
pRestServer.get(`${tmpEndpointPrefix}/Schema/New`, _EndpointAuthenticators.New, wireState, _Endpoints.New);
|
|
327
|
-
}
|
|
328
|
-
if (_EnabledBehaviors.Validate)
|
|
329
|
-
{
|
|
330
|
-
pRestServer.post(`${tmpEndpointPrefix}/Schema/Validate`, _CommonServices.bodyParser(), _EndpointAuthenticators.Validate, wireState, _Endpoints.Validate);
|
|
331
|
-
}
|
|
122
|
+
this._Endpoints[pEndpointHash] = fEndpoint;
|
|
123
|
+
}
|
|
332
124
|
|
|
333
|
-
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
334
127
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
pRestServer.post(`${tmpEndpointPrefix}s`, _CommonServices.bodyParser(), _EndpointAuthenticators.Create, wireState, _Endpoints.Creates);
|
|
340
|
-
}
|
|
341
|
-
if (_EnabledBehaviors.Read)
|
|
342
|
-
{
|
|
343
|
-
pRestServer.get(`${tmpEndpointPrefix}/Max/:ColumnName`, _EndpointAuthenticators.Read, wireState, _Endpoints.ReadMax);
|
|
344
|
-
pRestServer.get(`${tmpEndpointPrefix}/:IDRecord`, _EndpointAuthenticators.Read, wireState, _Endpoints.Read);
|
|
345
|
-
}
|
|
346
|
-
if (_EnabledBehaviors.Reads)
|
|
347
|
-
{
|
|
348
|
-
pRestServer.get(`${tmpEndpointPrefix}s`, _EndpointAuthenticators.Reads, wireState, _Endpoints.Reads);
|
|
349
|
-
pRestServer.get(`${tmpEndpointPrefix}s/By/:ByField/:ByValue`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadsBy);
|
|
350
|
-
pRestServer.get(`${tmpEndpointPrefix}s/By/:ByField/:ByValue/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadsBy);
|
|
351
|
-
pRestServer.get(`${tmpEndpointPrefix}s/FilteredTo/:Filter`, _EndpointAuthenticators.Reads, wireState, _Endpoints.Reads);
|
|
352
|
-
pRestServer.get(`${tmpEndpointPrefix}s/FilteredTo/:Filter/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.Reads);
|
|
353
|
-
pRestServer.get(`${tmpEndpointPrefix}Select`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
354
|
-
pRestServer.get(`${tmpEndpointPrefix}Select/FilteredTo/:Filter`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
355
|
-
pRestServer.get(`${tmpEndpointPrefix}Select/FilteredTo/:Filter/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
356
|
-
pRestServer.get(`${tmpEndpointPrefix}Select/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
357
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Lite`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
358
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Lite/FilteredTo/:Filter`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
359
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Lite/FilteredTo/:Filter/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
360
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Lite/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
361
|
-
pRestServer.get(`${tmpEndpointPrefix}s/LiteExtended/:ExtraColumns`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
362
|
-
pRestServer.get(`${tmpEndpointPrefix}s/LiteExtended/:ExtraColumns/FilteredTo/:Filter`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
363
|
-
pRestServer.get(`${tmpEndpointPrefix}s/LiteExtended/:ExtraColumns/FilteredTo/:Filter/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
364
|
-
pRestServer.get(`${tmpEndpointPrefix}s/LiteExtended/:ExtraColumns/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
365
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Distinct/:Columns`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadDistinctList);
|
|
366
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Distinct/:Columns/FilteredTo/:Filter`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadDistinctList);
|
|
367
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Distinct/:Columns/FilteredTo/:Filter/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadDistinctList);
|
|
368
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Distinct/:Columns/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadDistinctList);
|
|
369
|
-
pRestServer.get(`${tmpEndpointPrefix}s/:Begin/:Cap`, _EndpointAuthenticators.Reads, wireState, _Endpoints.Reads);
|
|
370
|
-
}
|
|
371
|
-
if (_EnabledBehaviors.Update)
|
|
372
|
-
{
|
|
373
|
-
pRestServer.put(`${tmpEndpointPrefix}`, _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Update);
|
|
374
|
-
pRestServer.put(`${tmpEndpointPrefix}s`, _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Updates);
|
|
375
|
-
pRestServer.put(`${tmpEndpointPrefix}/Upsert`, _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Upsert);
|
|
376
|
-
pRestServer.put(`${tmpEndpointPrefix}/Upserts`, _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Upserts);
|
|
377
|
-
}
|
|
378
|
-
if (_EnabledBehaviors.Delete)
|
|
379
|
-
{
|
|
380
|
-
pRestServer.del(`${tmpEndpointPrefix}`, _CommonServices.bodyParser(), _EndpointAuthenticators.Delete, wireState, _Endpoints.Delete);
|
|
381
|
-
pRestServer.del(`${tmpEndpointPrefix}/:IDRecord`, _EndpointAuthenticators.Delete, wireState, _Endpoints.Delete);
|
|
382
|
-
}
|
|
383
|
-
if (_EnabledBehaviors.Count)
|
|
384
|
-
{
|
|
385
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Count`, _EndpointAuthenticators.Count, wireState, _Endpoints.Count);
|
|
386
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Count/By/:ByField/:ByValue`, _EndpointAuthenticators.Count, wireState, _Endpoints.CountBy);
|
|
387
|
-
pRestServer.get(`${tmpEndpointPrefix}s/Count/FilteredTo/:Filter`, _EndpointAuthenticators.Count, wireState, _Endpoints.Count);
|
|
388
|
-
}
|
|
389
|
-
};
|
|
128
|
+
connectRoute(pServiceServer, pRequestMethod, pRoutePartial, pEndpointProcessingFunction, pBehaviorName)
|
|
129
|
+
{
|
|
130
|
+
let tmpRoute = `${this.EndpointPrefix}${pRoutePartial}`;
|
|
131
|
+
let tmpBehaviorName = (typeof(pBehaviorName) == 'string') ? pBehaviorName : 'an unnamed custom behavior'
|
|
390
132
|
|
|
133
|
+
this._Controller.log.trace(`...meadow-endpoints mapping a ${pRequestMethod} endpoint for scope ${this.DAL.scope} on route [${tmpRoute}] which runs ${tmpBehaviorName}.`);
|
|
391
134
|
|
|
392
|
-
|
|
393
|
-
* Emulate a response object
|
|
394
|
-
*/
|
|
395
|
-
var wireResponse = function(pResponse, fCallback)
|
|
135
|
+
try
|
|
396
136
|
{
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
this.Records = data;
|
|
406
|
-
}
|
|
407
|
-
else
|
|
408
|
-
{
|
|
409
|
-
this.Record = data;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
Object.defineProperty(pResponse, 'text',
|
|
415
|
-
{
|
|
416
|
-
get: function() { return JSON.stringify(pResponse.body); },
|
|
417
|
-
enumerable: true
|
|
418
|
-
});
|
|
137
|
+
(pServiceServer[pRequestMethod])(tmpRoute, pEndpointProcessingFunction.bind(this._Controller));
|
|
138
|
+
}
|
|
139
|
+
catch (pServiceServerRouteConnectError)
|
|
140
|
+
{
|
|
141
|
+
this._Controller.log.error(`...error mapping ${pBehaviorName} to method ${pRequestMethod} for scope ${this.DAL.scope} to route [${tmpRoute}]: ${pServiceServerRouteConnectError}`, pServiceServerRouteConnectError.stack);
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
419
145
|
|
|
420
|
-
|
|
421
|
-
|
|
146
|
+
connectRoutes(pServiceServer)
|
|
147
|
+
{
|
|
148
|
+
this._Controller.log.trace(`Creating automatic meadow endpoints at prefix [${this.EndpointPrefix}] for scope ${this.DAL.scope}...`);
|
|
422
149
|
|
|
423
|
-
|
|
424
|
-
|
|
150
|
+
// These special schema services must come in the route table before the READ because they
|
|
151
|
+
// technically block out the routes for the IDRecord 'Schema' (e.g. GET[/1.0/EntityName/Schema] ==NEEDS=> GET[/1.0/EntityName/100])
|
|
152
|
+
if (this._EnabledBehaviorSets.Schema)
|
|
425
153
|
{
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
var setInvokeSetupCallback = function(fCallback)
|
|
154
|
+
this.connectRoute(pServiceServer, 'get', `/Schema`, this._Endpoints.Schema, `the internal behavior _Endpoints.Schema`);
|
|
155
|
+
}
|
|
156
|
+
if (this._EnabledBehaviorSets.New)
|
|
430
157
|
{
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Invoke a meadow endpoint programmatically
|
|
436
|
-
*
|
|
437
|
-
* @method invokeEndpoint
|
|
438
|
-
*/
|
|
439
|
-
var invokeEndpoint = function(pMethod, pData, pOptions, fCallback)
|
|
158
|
+
this.connectRoute(pServiceServer, 'get', `/Schema/New`, this._Endpoints.New, `the internal behavior _Endpoints.New`);
|
|
159
|
+
}
|
|
160
|
+
if (this._EnabledBehaviorSets.Validate)
|
|
440
161
|
{
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (!_Endpoints[pMethod])
|
|
444
|
-
{
|
|
445
|
-
_CommonServices.log.error('Endpoint \'' + pMethod + '\' does not exist!');
|
|
446
|
-
return tmpCallback('Endpoint \'' + pMethod + '\' does not exist!'); //might be better as an exception
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// TODO: should switch depending on type
|
|
450
|
-
// TODO: should we keep this around, just make a deep copy of 'pOptions'
|
|
451
|
-
var pRequest = {params: pData, formattedParams: pData, body: pData};
|
|
452
|
-
if (typeof(pOptions) === 'object' && typeof(pOptions.header) === 'function') {
|
|
453
|
-
// carry over header function
|
|
454
|
-
pRequest.header = pOptions.header.bind(pOptions);
|
|
455
|
-
}
|
|
456
|
-
var pResponse = {};
|
|
457
|
-
|
|
458
|
-
libAsync.waterfall([
|
|
459
|
-
function(fStageComplete)
|
|
460
|
-
{
|
|
461
|
-
return wireResponse(pResponse, fStageComplete);
|
|
462
|
-
},
|
|
463
|
-
function(fStageComplete)
|
|
464
|
-
{
|
|
465
|
-
//allow consumer to specify user session data
|
|
466
|
-
if (pOptions.UserSession)
|
|
467
|
-
{
|
|
468
|
-
//make a copy of the UserSession
|
|
469
|
-
pRequest.UserSession = JSON.parse(JSON.stringify(pOptions.UserSession));
|
|
470
|
-
}
|
|
471
|
-
else
|
|
472
|
-
{
|
|
473
|
-
//else fill in default user session data
|
|
474
|
-
pRequest.EndpointInvoked = true; //bypass session auth check
|
|
475
|
-
pRequest.UserSession = { UserID: 0, UserRoleIndex: 0 };
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// The Satchel is a workaround to pass state between query invocation and query decoration
|
|
479
|
-
// Unfortunately, it has other uses, so we can't safely remove it here; this creates a risk of
|
|
480
|
-
// cross-request state contamination (which we have seen cause issues).
|
|
481
|
-
//FIXME: We should rework invokeEndpoint to make this state management unnecessary
|
|
482
|
-
pRequest.Satchel = pOptions.Satchel;
|
|
483
|
-
//internal invoke mark as authenticated (because this is not called via webservice)
|
|
484
|
-
pRequest.EndpointAuthenticated = true;
|
|
485
|
-
|
|
486
|
-
if (_InvokeSetupCallback && typeof(_InvokeSetupCallback) == 'function')
|
|
487
|
-
{
|
|
488
|
-
_InvokeSetupCallback(pRequest, pResponse, typeof(pOptions) === 'object' && pOptions);
|
|
489
|
-
}
|
|
490
|
-
return fStageComplete();
|
|
491
|
-
},
|
|
492
|
-
function(fStageComplete)
|
|
493
|
-
{
|
|
494
|
-
return wireCommonServices(pRequest, pResponse, fStageComplete);
|
|
495
|
-
},
|
|
496
|
-
function(fStageComplete)
|
|
497
|
-
{
|
|
498
|
-
return wireState(pRequest, pResponse, fStageComplete);
|
|
499
|
-
},
|
|
500
|
-
function(fStageComplete)
|
|
501
|
-
{
|
|
502
|
-
//Invoke the endpoint method
|
|
503
|
-
_Endpoints[pMethod](pRequest, pResponse, function(err)
|
|
504
|
-
{
|
|
505
|
-
return fStageComplete(err, pResponse);
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
],
|
|
509
|
-
function complete(err)
|
|
510
|
-
{
|
|
511
|
-
return tmpCallback(err, pResponse);
|
|
512
|
-
});
|
|
513
|
-
};
|
|
514
|
-
|
|
162
|
+
this.connectRoute(pServiceServer, 'postWithBodyParser', `/Schema/Validate`, this._Endpoints.Validate, `the internal behavior _Endpoints.Validate`);
|
|
163
|
+
}
|
|
515
164
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
*/
|
|
519
|
-
var tmpNewMeadowEndpointObject = (
|
|
165
|
+
// Standard CRUD and Count endpoints
|
|
166
|
+
if (this._EnabledBehaviorSets.Create)
|
|
520
167
|
{
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
enumerable: true
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* EndpointAuthenticators
|
|
580
|
-
*
|
|
581
|
-
* @property endpointAuthenticators
|
|
582
|
-
* @type object
|
|
583
|
-
*/
|
|
584
|
-
Object.defineProperty(tmpNewMeadowEndpointObject, 'endpointAuthenticators',
|
|
585
|
-
{
|
|
586
|
-
get: function() { return _EndpointAuthenticators; },
|
|
587
|
-
enumerable: true
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* EnabledBehaviors
|
|
592
|
-
*
|
|
593
|
-
* @property enabledBehaviors
|
|
594
|
-
* @type object
|
|
595
|
-
*/
|
|
596
|
-
Object.defineProperty(tmpNewMeadowEndpointObject, 'enabledBehaviors',
|
|
597
|
-
{
|
|
598
|
-
get: function() { return _EnabledBehaviors; },
|
|
599
|
-
enumerable: true
|
|
600
|
-
});
|
|
168
|
+
this.connectRoute(pServiceServer, 'postWithBodyParser', ``, this._Endpoints.Create, `the internal behavior _Endpoints.Create`);
|
|
169
|
+
this.connectRoute(pServiceServer, 'postWithBodyParser', `s`, this._Endpoints.Creates, `the internal behavior _Endpoints.Creates`);
|
|
170
|
+
}
|
|
171
|
+
if (this._EnabledBehaviorSets.Read)
|
|
172
|
+
{
|
|
173
|
+
this.connectRoute(pServiceServer, 'get', `/Max/:ColumnName`, this._Endpoints.ReadMax, `the internal behavior _Endpoints.ReadMax`);
|
|
174
|
+
this.connectRoute(pServiceServer, 'get', `/:IDRecord`, this._Endpoints.Read, `the internal behavior _Endpoints.Read`);
|
|
175
|
+
}
|
|
176
|
+
if (this._EnabledBehaviorSets.Reads)
|
|
177
|
+
{
|
|
178
|
+
this.connectRoute(pServiceServer, 'get', `s`, this._Endpoints.Reads, `the internal behavior _Endpoints.Reads`);
|
|
179
|
+
this.connectRoute(pServiceServer, 'get', `s/By/:ByField/:ByValue`, this._Endpoints.ReadsBy, `the internal behavior _Endpoints.ReadsBy`);
|
|
180
|
+
this.connectRoute(pServiceServer, 'get', `s/By/:ByField/:ByValue/:Begin/:Cap`, this._Endpoints.ReadsBy, `the internal behavior _Endpoints.ReadsBy`);
|
|
181
|
+
this.connectRoute(pServiceServer, 'get', `s/FilteredTo/:Filter`, this._Endpoints.Reads, `the internal behavior _Endpoints.Reads`);
|
|
182
|
+
this.connectRoute(pServiceServer, 'get', `s/FilteredTo/:Filter/:Begin/:Cap`, this._Endpoints.Reads, `the internal behavior _Endpoints.Reads`);
|
|
183
|
+
this.connectRoute(pServiceServer, 'get', `Select`, this._Endpoints.ReadSelectList, `the internal behavior _Endpoints.ReadSelectList`);
|
|
184
|
+
this.connectRoute(pServiceServer, 'get', `Select/FilteredTo/:Filter`, this._Endpoints.ReadSelectList, `the internal behavior _Endpoints.ReadSelectList`);
|
|
185
|
+
this.connectRoute(pServiceServer, 'get', `Select/FilteredTo/:Filter/:Begin/:Cap`, this._Endpoints.ReadSelectList, `the internal behavior _Endpoints.ReadSelectList`);
|
|
186
|
+
this.connectRoute(pServiceServer, 'get', `Select/:Begin/:Cap`, this._Endpoints.ReadSelectList, `the internal behavior _Endpoints.ReadSelectList`);
|
|
187
|
+
this.connectRoute(pServiceServer, 'get', `s/Lite`, this._Endpoints.ReadLiteList, `the internal behavior _Endpoints.ReadLiteList`);
|
|
188
|
+
this.connectRoute(pServiceServer, 'get', `s/Lite/FilteredTo/:Filter`, this._Endpoints.ReadLiteList, `the internal behavior _Endpoints.ReadLiteList`);
|
|
189
|
+
this.connectRoute(pServiceServer, 'get', `s/Lite/FilteredTo/:Filter/:Begin/:Cap`, this._Endpoints.ReadLiteList, `the internal behavior _Endpoints.ReadLiteList`);
|
|
190
|
+
this.connectRoute(pServiceServer, 'get', `s/Lite/:Begin/:Cap`, this._Endpoints.ReadLiteList, `the internal behavior _Endpoints.ReadLiteList`);
|
|
191
|
+
this.connectRoute(pServiceServer, 'get', `s/LiteExtended/:ExtraColumns`, this._Endpoints.ReadLiteList, `the internal behavior _Endpoints.ReadLiteList`);
|
|
192
|
+
this.connectRoute(pServiceServer, 'get', `s/LiteExtended/:ExtraColumns/FilteredTo/:Filter`, this._Endpoints.ReadLiteList, `the internal behavior _Endpoints.ReadLiteList`);
|
|
193
|
+
this.connectRoute(pServiceServer, 'get', `s/LiteExtended/:ExtraColumns/FilteredTo/:Filter/:Begin/:Cap`, this._Endpoints.ReadLiteList, `the internal behavior _Endpoints.ReadLiteList`);
|
|
194
|
+
this.connectRoute(pServiceServer, 'get', `s/LiteExtended/:ExtraColumns/:Begin/:Cap`, this._Endpoints.ReadLiteList, `the internal behavior _Endpoints.ReadLiteList`);
|
|
195
|
+
this.connectRoute(pServiceServer, 'get', `s/Distinct/:Columns`, this._Endpoints.ReadDistinctList, `the internal behavior _Endpoints.ReadDistinctList`);
|
|
196
|
+
this.connectRoute(pServiceServer, 'get', `s/Distinct/:Columns/FilteredTo/:Filter`, this._Endpoints.ReadDistinctList, `the internal behavior _Endpoints.ReadDistinctList`);
|
|
197
|
+
this.connectRoute(pServiceServer, 'get', `s/Distinct/:Columns/FilteredTo/:Filter/:Begin/:Cap`, this._Endpoints.ReadDistinctList, `the internal behavior _Endpoints.ReadDistinctList`);
|
|
198
|
+
this.connectRoute(pServiceServer, 'get', `s/Distinct/:Columns/:Begin/:Cap`, this._Endpoints.ReadDistinctList, `the internal behavior _Endpoints.ReadDistinctList`);
|
|
199
|
+
this.connectRoute(pServiceServer, 'get', `s/:Begin/:Cap`, this._Endpoints.Reads, `the internal behavior _Endpoints.Reads`);
|
|
200
|
+
}
|
|
201
|
+
if (this._EnabledBehaviorSets.Update)
|
|
202
|
+
{
|
|
203
|
+
this.connectRoute(pServiceServer, 'putWithBodyParser', ``, this._Endpoints.Update, `the internal behavior _Endpoints.Update`);
|
|
204
|
+
this.connectRoute(pServiceServer, 'putWithBodyParser', `s`, this._Endpoints.Updates, `the internal behavior _Endpoints.Updates`);
|
|
205
|
+
this.connectRoute(pServiceServer, 'putWithBodyParser', `/Upsert`, this._Endpoints.Upsert, `the internal behavior _Endpoints.Upsert`);
|
|
206
|
+
this.connectRoute(pServiceServer, 'putWithBodyParser', `/Upserts`, this._Endpoints.Upserts, `the internal behavior _Endpoints.Upserts`);
|
|
207
|
+
}
|
|
208
|
+
if (this._EnabledBehaviorSets.Delete)
|
|
209
|
+
{
|
|
210
|
+
this.connectRoute(pServiceServer, 'del', ``, this._Endpoints.Delete, `the internal behavior _Endpoints.Delete`);
|
|
211
|
+
this.connectRoute(pServiceServer, 'del', `/:IDRecord`, this._Endpoints.Delete, `the internal behavior _Endpoints.Delete`);
|
|
212
|
+
this.connectRoute(pServiceServer, 'get', `/Undelete/:IDRecord`, this._Endpoints.Undelete, `the internal behavior _Endpoints.Undelete`);
|
|
213
|
+
}
|
|
214
|
+
if (this._EnabledBehaviorSets.Count)
|
|
215
|
+
{
|
|
216
|
+
this.connectRoute(pServiceServer, 'get', `s/Count`, this._Endpoints.Count, `the internal behavior _Endpoints.Count`);
|
|
217
|
+
this.connectRoute(pServiceServer, 'get', `s/Count/By/:ByField/:ByValue`, this._Endpoints.CountBy, `the internal behavior _Endpoints.CountBy`);
|
|
218
|
+
this.connectRoute(pServiceServer, 'get', `s/Count/FilteredTo/:Filter`, this._Endpoints.Count, `the internal behavior _Endpoints.Count`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
601
222
|
|
|
602
|
-
/**
|
|
603
|
-
* Behavior Modifications
|
|
604
|
-
*
|
|
605
|
-
* @property behaviorModifications
|
|
606
|
-
* @type object
|
|
607
|
-
*/
|
|
608
|
-
Object.defineProperty(tmpNewMeadowEndpointObject, 'behaviorModifications',
|
|
609
|
-
{
|
|
610
|
-
get: function() { return _BehaviorModifications; },
|
|
611
|
-
enumerable: true
|
|
612
|
-
});
|
|
613
223
|
|
|
614
|
-
|
|
615
|
-
|
|
224
|
+
// This is for backwards compatibility
|
|
225
|
+
function autoConstruct(pMeadow, pControllerOptions)
|
|
226
|
+
{
|
|
227
|
+
return new MeadowEndpoints(pMeadow, pControllerOptions);
|
|
228
|
+
}
|
|
616
229
|
|
|
617
|
-
|
|
618
|
-
|
|
230
|
+
module.exports = MeadowEndpoints;
|
|
231
|
+
module.exports.new = autoConstruct;
|
|
619
232
|
|
|
620
|
-
module.exports =
|
|
233
|
+
module.exports.Meadow = libMeadow;
|
|
234
|
+
module.exports.BaseController = libMeadowEndpointsControllerBase;
|