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.
Files changed (126) hide show
  1. package/{Dockerfile → Dockerfile_LUXURYCode} +43 -1
  2. package/README.md +48 -14
  3. package/debug/Animal.json +62 -0
  4. package/debug/Harness-Configuration.json +31 -0
  5. package/debug/Harness.js +7 -108
  6. package/debug/KillHarness.sh +10 -0
  7. package/dist/meadowendpoints.js +4402 -0
  8. package/dist/meadowendpoints.min.js +92 -0
  9. package/dist/meadowendpoints.min.js.map +1 -0
  10. package/gulpfile.js +83 -0
  11. package/package.json +29 -16
  12. package/source/Meadow-Endpoints-Browser-Shim.js +14 -0
  13. package/source/Meadow-Endpoints.js +176 -562
  14. package/source/controller/Meadow-Endpoints-Controller-Base.js +161 -0
  15. package/source/controller/components/Meadow-Endpoints-Controller-BehaviorInjection.js +125 -0
  16. package/source/controller/components/Meadow-Endpoints-Controller-Error-StatusCodes.txt +189 -0
  17. package/source/controller/components/Meadow-Endpoints-Controller-Error.js +118 -0
  18. package/source/controller/components/Meadow-Endpoints-Controller-Log.js +103 -0
  19. package/source/controller/utility/Meadow-Endpoints-Filter-Parser.js +225 -0
  20. package/source/controller/utility/Meadow-Endpoints-Session-Marshaler.js +48 -0
  21. package/source/controller/utility/Meadow-Endpoints-Stream-RecordArray.js +66 -0
  22. package/source/endpoints/count/Meadow-Endpoint-Count.js +49 -0
  23. package/source/endpoints/count/Meadow-Endpoint-CountBy.js +40 -0
  24. package/source/endpoints/create/Meadow-Endpoint-BulkCreate.js +53 -0
  25. package/source/endpoints/create/Meadow-Endpoint-Create.js +58 -0
  26. package/source/endpoints/create/Meadow-Operation-Create.js +83 -0
  27. package/source/endpoints/delete/Meadow-Endpoint-Delete.js +93 -0
  28. package/source/endpoints/delete/Meadow-Endpoint-Undelete.js +108 -0
  29. package/source/endpoints/read/Meadow-Endpoint-Read.js +72 -0
  30. package/source/endpoints/read/Meadow-Endpoint-ReadDistinctList.js +92 -0
  31. package/source/endpoints/read/Meadow-Endpoint-ReadLiteList.js +85 -0
  32. package/source/endpoints/read/Meadow-Endpoint-ReadMax.js +55 -0
  33. package/source/endpoints/read/Meadow-Endpoint-ReadSelectList.js +89 -0
  34. package/source/endpoints/read/Meadow-Endpoint-Reads.js +75 -0
  35. package/source/endpoints/read/Meadow-Endpoint-ReadsBy.js +100 -0
  36. package/source/{crud → endpoints/read}/Meadow-Marshal-DistinctList.js +4 -13
  37. package/source/{crud → endpoints/read}/Meadow-Marshal-LiteList.js +5 -14
  38. package/source/endpoints/schema/Meadow-Endpoint-New.js +36 -0
  39. package/source/endpoints/schema/Meadow-Endpoint-Schema.js +36 -0
  40. package/source/endpoints/schema/Meadow-Endpoint-Validate.js +41 -0
  41. package/source/endpoints/update/Meadow-Endpoint-BulkUpdate.js +50 -0
  42. package/source/endpoints/update/Meadow-Endpoint-Update.js +58 -0
  43. package/source/endpoints/update/Meadow-Operation-Update.js +115 -0
  44. package/source/endpoints/upsert/Meadow-Endpoint-BulkUpsert.js +52 -0
  45. package/source/endpoints/upsert/Meadow-Endpoint-Upsert.js +57 -0
  46. package/source/endpoints/upsert/Meadow-Operation-Upsert.js +137 -0
  47. package/test/MeadowEndpoints_basic_tests.js +50 -2375
  48. package/test_support/bookstore-api-endpoint-exercises.paw +0 -0
  49. package/test_support/bookstore-configuration.json +28 -0
  50. package/test_support/bookstore-import-books-run.js +1 -0
  51. package/test_support/bookstore-import-books.js +215 -0
  52. package/test_support/bookstore-serve-meadow-endpoint-apis-IPC.js +138 -0
  53. package/test_support/bookstore-serve-meadow-endpoint-apis-run.js +6 -0
  54. package/test_support/bookstore-serve-meadow-endpoint-apis.js +129 -0
  55. package/test_support/data/books.csv +10001 -0
  56. package/test_support/model/ddl/BookStore.ddl +66 -0
  57. package/test_support/model/generated_diagram/README.md +1 -0
  58. package/test_support/model/generated_diagram/Stricture_Output.dot +13 -0
  59. package/test_support/model/generated_diagram/Stricture_Output.png +0 -0
  60. package/test_support/model/generated_documentation/Dictionary.md +18 -0
  61. package/test_support/model/generated_documentation/Model-Author.md +20 -0
  62. package/test_support/model/generated_documentation/Model-Book.md +26 -0
  63. package/test_support/model/generated_documentation/Model-BookAuthorJoin.md +14 -0
  64. package/test_support/model/generated_documentation/Model-BookPrice.md +25 -0
  65. package/test_support/model/generated_documentation/Model-Review.md +22 -0
  66. package/test_support/model/generated_documentation/ModelChangeTracking.md +17 -0
  67. package/test_support/model/generated_documentation/README.md +1 -0
  68. package/test_support/model/manual_scripts/DropTables.sql +5 -0
  69. package/test_support/model/manual_scripts/README.md +2 -0
  70. package/test_support/model/sql_create/BookStore-CreateDatabase.mysql.sql +116 -0
  71. package/test_support/model/sql_create/README.md +1 -0
  72. package/test_support/test_old/Tests.js +3243 -0
  73. package/test_support/test_old/untitled.js +88 -0
  74. package/source/Meadow-Authenticator.js +0 -31
  75. package/source/Meadow-Authorizers.js +0 -214
  76. package/source/Meadow-BehaviorModifications.js +0 -170
  77. package/source/Meadow-CommonServices.js +0 -206
  78. package/source/Meadow-MarshallSessionData.js +0 -64
  79. package/source/Restify-RouteParser.js +0 -114
  80. package/source/authorizers/Meadow-Authorizer-Allow.js +0 -17
  81. package/source/authorizers/Meadow-Authorizer-Deny.js +0 -17
  82. package/source/authorizers/Meadow-Authorizer-Mine.js +0 -47
  83. package/source/authorizers/Meadow-Authorizer-MyCustomer.js +0 -48
  84. package/source/crud/Meadow-Endpoint-BulkCreate.js +0 -67
  85. package/source/crud/Meadow-Endpoint-BulkUpdate.js +0 -74
  86. package/source/crud/Meadow-Endpoint-BulkUpsert.js +0 -76
  87. package/source/crud/Meadow-Endpoint-Count.js +0 -93
  88. package/source/crud/Meadow-Endpoint-CountBy.js +0 -101
  89. package/source/crud/Meadow-Endpoint-Create.js +0 -77
  90. package/source/crud/Meadow-Endpoint-Delete.js +0 -139
  91. package/source/crud/Meadow-Endpoint-Read.js +0 -109
  92. package/source/crud/Meadow-Endpoint-ReadDistinctList.js +0 -146
  93. package/source/crud/Meadow-Endpoint-ReadLiteList.js +0 -139
  94. package/source/crud/Meadow-Endpoint-ReadMax.js +0 -86
  95. package/source/crud/Meadow-Endpoint-ReadSelectList.js +0 -145
  96. package/source/crud/Meadow-Endpoint-Reads.js +0 -129
  97. package/source/crud/Meadow-Endpoint-ReadsBy.js +0 -155
  98. package/source/crud/Meadow-Endpoint-Update.js +0 -80
  99. package/source/crud/Meadow-Endpoint-Upsert.js +0 -78
  100. package/source/crud/Meadow-Operation-Create.js +0 -105
  101. package/source/crud/Meadow-Operation-Update.js +0 -145
  102. package/source/crud/Meadow-Operation-Upsert.js +0 -106
  103. package/source/crud/Meadow-StreamRecordArray.js +0 -45
  104. package/source/schema/Meadow-Endpoint-New.js +0 -37
  105. package/source/schema/Meadow-Endpoint-Schema.js +0 -37
  106. package/source/schema/Meadow-Endpoint-Validate.js +0 -43
  107. package/test/Animal.json +0 -140
  108. package/test/MeadowEndpoints_disabledAuth_tests.js +0 -1325
  109. package/test/MeadowEndpoints_trustedSession_tests.js +0 -1731
  110. package/test/load/artillery-low.yml +0 -10
  111. package/test/load/cloud9setup.sh +0 -25
  112. package/test/load/package.json +0 -19
  113. package/test/load/test-schema-initializedatabase.sql +0 -29
  114. package/test/load/test-schema.json +0 -119
  115. package/test/load/test-server.js +0 -157
  116. package/test/scripts/InitializeDatabase-C9.sql +0 -7
  117. /package/{test/schemas → test_support/model}/json_schema/BookStore-Extended.json +0 -0
  118. /package/{test/schemas → test_support/model}/json_schema/BookStore-PICT.json +0 -0
  119. /package/{test/schemas → test_support/model}/json_schema/BookStore.json +0 -0
  120. /package/{test/schemas → test_support/model}/json_schema/README.md +0 -0
  121. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Author.json +0 -0
  122. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Book.json +0 -0
  123. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-BookAuthorJoin.json +0 -0
  124. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-BookPrice.json +0 -0
  125. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Review.json +0 -0
  126. /package/{test/schemas → test_support/model}/meadow_schema/README.md +0 -0
@@ -1,10 +0,0 @@
1
- config:
2
- target: 'http://localhost:8080'
3
- phases:
4
- - duration: 60
5
- arrivalRate: 50
6
-
7
- scenarios:
8
- - flow:
9
- - get:
10
- url: "/Magic/1"
@@ -1,25 +0,0 @@
1
- #! /bin/bash
2
- echo "Setup a Cloud9 environment for Meadow Endpoint Load Tests"
3
- echo "MIT License."
4
- echo "steven velozo <steven@velozo.com>"
5
- echo ""
6
- echo "---"
7
- echo ""
8
- echo "## MySQL Parameters exist. Script running!"
9
- echo "##"
10
- echo ""
11
- echo "!! This may be bad to run on anything but a Cloud9 virtual machine !!"
12
- echo ""
13
- read -p "Press [Enter] key to configure the environment..."
14
- echo ""
15
- echo "## Initializing the Cloud9 database environment..."
16
- time mysql-ctl start
17
- echo ""
18
- echo "## Creating Fable and Meadow databases and users..."
19
- time mysql-ctl cli < test-schema-initializedatabase.sql
20
- echo ""
21
- echo "## Remember to Switch to node 5.x by running these commands..."
22
- echo "nvm use 5"
23
- echo "nvm alias default 5"
24
- echo ""
25
- echo "## And we're done! Have a great day."
@@ -1,19 +0,0 @@
1
- {
2
- "name": "meadow-endpoints-load-test",
3
- "version": "1.0.0",
4
- "description": "Load Test Harness for Meadow Endpoints",
5
- "main": "test-server.js",
6
- "scripts": {
7
- "start": "node test-server.js",
8
- "test": "node_modules/artillery/bin/artillery run artillery-low.yml"
9
- },
10
- "author": "steven velozo <steven@velozo.com>",
11
- "license": "ISC",
12
- "dependencies": {
13
- "chance": "^1.0.4",
14
- "meadow-endpoints": "^1.0.29"
15
- },
16
- "devDependencies": {
17
- "artillery": "^1.5.0-10"
18
- }
19
- }
@@ -1,29 +0,0 @@
1
- -- Meadow Endpoints Test Database Initialization for Cloud9
2
- -- steven velozo <steven@velozo.com>
3
- -- MIT License
4
-
5
- CREATE DATABASE IF NOT EXISTS FableTest;
6
-
7
- -- Use the database for fable tests
8
- USE FableTest;
9
-
10
- -- Create the table if it isn't there
11
- CREATE TABLE IF NOT EXISTS TestRequest
12
- (
13
- IDTestRequest INT UNSIGNED NOT NULL AUTO_INCREMENT,
14
- GUIDTestRequest CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
15
- CreateDate DATETIME,
16
- CreatingIDUser INT NOT NULL DEFAULT '0',
17
- UpdateDate DATETIME,
18
- UpdatingIDUser INT NOT NULL DEFAULT '0',
19
- Deleted TINYINT NOT NULL DEFAULT '0',
20
- DeleteDate DATETIME,
21
- DeletingIDUser INT NOT NULL DEFAULT '0',
22
- Name CHAR(128) NOT NULL DEFAULT '',
23
- UserID CHAR(128) NOT NULL DEFAULT '',
24
-
25
- PRIMARY KEY (IDTestRequest)
26
- );
27
-
28
- -- Clear out results from a previous test
29
- TRUNCATE TABLE TestRequest;
@@ -1,119 +0,0 @@
1
- {
2
- "Scope": "TestRequest",
3
-
4
- "DefaultIdentifier": "IDTestRequest",
5
-
6
- "Schema": [
7
- { "Column": "IDTestRequest", "Type":"AutoIdentity" },
8
- { "Column": "GUIDTestRequest", "Type":"AutoGUID" },
9
- { "Column": "CreateDate", "Type":"CreateDate" },
10
- { "Column": "CreatingIDUser", "Type":"CreateIDUser" },
11
- { "Column": "UpdateDate", "Type":"UpdateDate" },
12
- { "Column": "UpdatingIDUser", "Type":"UpdateIDUser" },
13
- { "Column": "Deleted", "Type":"Deleted" },
14
- { "Column": "DeletingIDUser", "Type":"DeleteIDUser" },
15
- { "Column": "DeleteDate", "Type":"DeleteDate" },
16
- { "Column": "Name", "Type":"String" },
17
- { "Column": "UserID", "Type":"String" }
18
- ],
19
-
20
- "DefaultObject": {
21
- "IDTestRequest": null,
22
- "GUIDTestRequest": "",
23
-
24
- "CreateDate": false,
25
- "CreatingIDUser": 0,
26
- "UpdateDate": false,
27
- "UpdatingIDUser": 0,
28
- "Deleted": 0,
29
- "DeleteDate": false,
30
- "DeletingIDUser": 0,
31
-
32
- "Name": "Unknown",
33
- "UserID": "Unclassified"
34
- },
35
-
36
- "JsonSchema": {
37
- "title": "TestRequest",
38
- "description": "A row created by a meadow-endpoints request",
39
- "type": "object",
40
- "properties": {
41
- "IDTestRequest": {
42
- "description": "The unique identifier for a request",
43
- "type": "integer"
44
- },
45
- "Name": {
46
- "description": "Some content",
47
- "type": "string"
48
- },
49
- "UserID": {
50
- "description": "The User ID (provided as part of the data, not auto interleaved)",
51
- "type": "string"
52
- }
53
- },
54
- "required": ["IDTestRequest"]
55
- },
56
-
57
- "Authorization": {
58
- "__DefaultAPISecurity": {
59
- "Create": "Deny",
60
- "Read": "Deny",
61
- "Reads": "Deny",
62
- "ReadsBy": "Deny",
63
- "ReadMax": "Deny",
64
- "ReadSelectList": "Deny",
65
- "Update": "Deny",
66
- "Delete": "Deny",
67
- "Count": "Deny",
68
- "CountBy": "Deny",
69
- "Schema": "Deny",
70
- "Validate": "Deny",
71
- "New": "Deny"
72
- },
73
- "Unauthenticated": {
74
- "Create": "Allow",
75
- "Read": "Allow",
76
- "Reads": "Allow",
77
- "ReadsBy": "Allow",
78
- "ReadMax": "Allow",
79
- "ReadSelectList": "Allow",
80
- "Update": "Allow",
81
- "Delete": "Allow",
82
- "Count": "Allow",
83
- "CountBy": "Allow",
84
- "Schema": "Allow",
85
- "Validate": "Allow",
86
- "New": "Allow"
87
- },
88
- "User": {
89
- "Create": "Allow",
90
- "Read": "Allow",
91
- "Reads": "Allow",
92
- "ReadsBy": "Allow",
93
- "ReadMax": "Allow",
94
- "ReadSelectList": "Allow",
95
- "Update": "Allow",
96
- "Delete": "Allow",
97
- "Count": "Allow",
98
- "CountBy": "Allow",
99
- "Schema": "Allow",
100
- "Validate": "Allow",
101
- "New": "Allow"
102
- },
103
- "Manager": {
104
- "Create": "Allow",
105
- "Read": "Allow",
106
- "Reads": "Allow",
107
- "ReadsBy": "Allow",
108
- "ReadMax": "Allow",
109
- "ReadSelectList": "Allow",
110
- "Update": "Allow",
111
- "Delete": "Allow",
112
- "Count": "Allow",
113
- "CountBy": "Allow",
114
- "Schema": "Allow",
115
- "Validate": "Allow",
116
- "New": "Allow"
117
- }
118
- }
119
- }
@@ -1,157 +0,0 @@
1
- /**
2
- * Test Server for Meadow Load Tests
3
- *
4
- * @license MIT
5
- *
6
- * @author Steven Velozo <steven@velozo.com>
7
- */
8
-
9
- var libFable = require('fable').new(
10
- {
11
- Product: 'Meadow-Load-Test',
12
- ProductVersion: '1.0.0',
13
-
14
- UserIDMinimum: 1,
15
- UserIDMaximum: 1000,
16
-
17
- APIServerPort: 8080,
18
-
19
- LogStreams:
20
- [
21
- {
22
- level: 'trace',
23
- path: './server_test.log'
24
- }
25
- ],
26
-
27
- MySQL:
28
- {
29
- // This is queued up for Travis/cloud9 defaults.
30
- Server: "localhost",
31
- Port: 3306,
32
- User: "root",
33
- Password: "",
34
- Database: "FableTest",
35
- ConnectionPoolLimit: 20
36
- },
37
-
38
- ConfigFile: __dirname + "/MeadowLoadTest-Settings.json"
39
- });
40
-
41
- // Jimmy up an authorizer that creates sessions:
42
- // * Random user IDs between UserIDMinimum and UserIDMaximum
43
- // * Session IDs sequentially growing; wrapping at 4 bajillion or something silly
44
- var _SessionIndex = 0;
45
- var getSession = function()
46
- {
47
- var tmpUserID = Math.floor(Math.random() * (libFable.settings.UserIDMaximum - libFable.settings.UserIDMinimum)) + libFable.settings.UserIDMinimum;
48
- return (
49
- {
50
- SessionID: '0000-VALID-'+tmpUserID+'-'+_SessionIndex++,
51
- UserID: tmpUserID,
52
- UserRole: 'User',
53
- UserRoleIndex: 1,
54
- LoggedIn: true,
55
- DeviceID: 'TEST-HARNESS'
56
- });
57
- };
58
- var mockAuthentication = function(pRequest, pResponse, fNext)
59
- {
60
- pRequest.UserSession = getSession();
61
- fNext();
62
- };
63
-
64
- // Load the schema for our test
65
- var _TestSchema = require('./test-schema.json');
66
-
67
- // Load up a Meadow (pointing at the Animal database)
68
- var _Meadow = require('meadow')
69
- .new(libFable, 'TestRequest')
70
- .setProvider('MySQL')
71
- .setSchema(_TestSchema.Schema)
72
- .setJsonSchema(_TestSchema.JsonSchema)
73
- .setDefaultIdentifier(_TestSchema.DefaultIdentifier)
74
- .setDefault(_TestSchema.DefaultObject)
75
- .setAuthorizer(_TestSchema.Authorization);
76
-
77
- // Instantiate the endpoints
78
- var _MeadowEndpoints = require('../../source/Meadow-Endpoints.js').new(_Meadow);
79
-
80
-
81
- // Setup the web server
82
- var _Orator = require('orator').new(libFable.settings);
83
- _Orator.enabledModules.CORS = true;
84
- _Orator.enabledModules.FullResponse = true;
85
- _Orator.enabledModules.Body = false;
86
- // Map in the custom authorizer
87
- _Orator.webServer.use(mockAuthentication);
88
-
89
- // Wire the endpoints up
90
- _MeadowEndpoints.connectRoutes(_Orator.webServer);
91
-
92
- var libChancePrototype = require('chance');
93
- var libChance = new libChancePrototype();
94
-
95
- var _IDTestRequest_Max = 0;
96
- // Magically create a record, and stuff the user ID in (to track the magic Meadow does)
97
- _Orator.webServer.get
98
- (
99
- '/Magic/:Index',
100
- function(pRequest, pResponse, fNext)
101
- {
102
- _MeadowEndpoints.invokeEndpoint('Create',
103
- { // This is the constructed record for our load test
104
- Name: libChance.sentence({words: 4})+' ['+pRequest.params.Index+']',
105
- UserID: pRequest.UserSession.UserID
106
- },
107
- pRequest,
108
- function(pError, pEndpointResponse)
109
- {
110
- // Expect response to be the record we just created.
111
- // Set the testrequest max to be this, which isn't always accurate but is safe.
112
- _IDTestRequest_Max = pEndpointResponse.body.IDTestRequest;
113
- pResponse.send(pEndpointResponse.body);
114
- return fNext();
115
- }
116
- );
117
- }
118
- );
119
-
120
- // Magically return a record, based on the current max id. If the max ID is 0, return an empty javascript object.
121
- _Orator.webServer.get
122
- (
123
- '/Magic',
124
- function(pRequest, pResponse, fNext)
125
- {
126
- if (_IDTestRequest_Max < 0)
127
- {
128
- // If there have been no records created return an empty object
129
- pResponse.send({});
130
- return fNext();
131
- }
132
- else
133
- {
134
- // IDRequestMax is not set
135
- var tmpIDTestRequest = libChance.integer({min: 0, max: _IDTestRequest_Max});
136
- _MeadowEndpoints.invokeEndpoint('Read',
137
- {
138
- IDTestRequest: tmpIDTestRequest
139
- },
140
- pRequest,
141
- function(pError, pEndpointResponse)
142
- {
143
- // Expect response to be the record we just created.
144
- pResponse.send(pEndpointResponse.body);
145
- return fNext();
146
- }
147
- );
148
- }
149
- }
150
- );
151
-
152
- // Start the Web Server
153
- _Orator.startWebServer (
154
- function()
155
- {
156
- libFable.log.trace('--> Test server is up and running');
157
- });
@@ -1,7 +0,0 @@
1
- -- Meadow Endpoints Test Database Initialization for Cloud9
2
- -- steven velozo <steven@velozo.com>
3
- -- MIT License
4
-
5
- CREATE DATABASE IF NOT EXISTS FableTest;
6
-
7
- DELETE FROM FableTest WHERE 1=1;