meadow-endpoints 3.0.7 → 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 (127) hide show
  1. package/Dockerfile_LUXURYCode +1 -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 +27 -15
  12. package/source/Meadow-Endpoints-Browser-Shim.js +14 -0
  13. package/source/Meadow-Endpoints.js +176 -565
  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 -2408
  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-Undelete.js +0 -161
  99. package/source/crud/Meadow-Endpoint-Update.js +0 -80
  100. package/source/crud/Meadow-Endpoint-Upsert.js +0 -78
  101. package/source/crud/Meadow-Operation-Create.js +0 -105
  102. package/source/crud/Meadow-Operation-Update.js +0 -145
  103. package/source/crud/Meadow-Operation-Upsert.js +0 -106
  104. package/source/crud/Meadow-StreamRecordArray.js +0 -45
  105. package/source/schema/Meadow-Endpoint-New.js +0 -37
  106. package/source/schema/Meadow-Endpoint-Schema.js +0 -37
  107. package/source/schema/Meadow-Endpoint-Validate.js +0 -43
  108. package/test/Animal.json +0 -140
  109. package/test/MeadowEndpoints_disabledAuth_tests.js +0 -1325
  110. package/test/MeadowEndpoints_trustedSession_tests.js +0 -1731
  111. package/test/load/artillery-low.yml +0 -10
  112. package/test/load/cloud9setup.sh +0 -25
  113. package/test/load/package.json +0 -19
  114. package/test/load/test-schema-initializedatabase.sql +0 -29
  115. package/test/load/test-schema.json +0 -119
  116. package/test/load/test-server.js +0 -157
  117. package/test/scripts/InitializeDatabase-C9.sql +0 -7
  118. /package/{test/schemas → test_support/model}/json_schema/BookStore-Extended.json +0 -0
  119. /package/{test/schemas → test_support/model}/json_schema/BookStore-PICT.json +0 -0
  120. /package/{test/schemas → test_support/model}/json_schema/BookStore.json +0 -0
  121. /package/{test/schemas → test_support/model}/json_schema/README.md +0 -0
  122. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Author.json +0 -0
  123. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Book.json +0 -0
  124. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-BookAuthorJoin.json +0 -0
  125. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-BookPrice.json +0 -0
  126. /package/{test/schemas → test_support/model}/meadow_schema/BookStore-MeadowSchema-Review.json +0 -0
  127. /package/{test/schemas → test_support/model}/meadow_schema/README.md +0 -0
@@ -1,45 +0,0 @@
1
- /**
2
- * Meadow Endpoint Marshaller - Stream an array of recods as JSON to an output stream.
3
- *
4
- * If the array is small enough, we just call send() for simplicity.
5
- *
6
- * @license MIT
7
- *
8
- * @author Alex Decker <alex.decker@headlight.com>
9
- * @module Meadow
10
- */
11
-
12
- const libAsync = require('async');
13
- const JSONStream = require('JSONStream');
14
- const libUnderscore = require('underscore');
15
-
16
- module.exports = (pResponse, pRecords, fCallback) =>
17
- {
18
- // for meadow invoke, writeHead isn't provided, so just call send(), which is the shim it uses...
19
- // also, for small arrays, don't bother with the async serialization; this threshold could use tuning
20
- if (!pResponse.writeHead || !Array.isArray(pRecords) || pRecords.length < 2500)
21
- {
22
- pResponse.send(pRecords);
23
- return fCallback();
24
- }
25
-
26
- pResponse.writeHead(200,
27
- {
28
- 'content-type': 'application/json',
29
- });
30
-
31
- const recordJsonMarshaller = JSONStream.stringify();
32
- recordJsonMarshaller.pipe(pResponse);
33
-
34
- // we write the records in chunks; doing one per loop is very inefficient, doing all is the same as not doing this at all
35
- libAsync.eachSeries(libUnderscore.chunk(pRecords, 1000), (pRecordChunk, fNext) =>
36
- {
37
- pRecordChunk.forEach(recordJsonMarshaller.write);
38
- setImmediate(fNext);
39
- },
40
- (error) =>
41
- {
42
- recordJsonMarshaller.end();
43
- fCallback(error);
44
- });
45
- };
@@ -1,37 +0,0 @@
1
- /**
2
- * Meadow Endpoint - New Record
3
- *
4
- * @license MIT
5
- *
6
- * @author Steven Velozo <steven@velozo.com>
7
- * @module Meadow
8
- */
9
- /**
10
- * Create a new record using the Meadow DAL object
11
- */
12
- var doAPINewEndpoint = function(pRequest, pResponse, fNext)
13
- {
14
- // This state is the requirement for the UserRoleIndex value in the UserSession object... processed by default as >=
15
- // The default here is that any authenticated user can use this endpoint.
16
- pRequest.EndpointAuthorizationRequirement = pRequest.EndpointAuthorizationLevels.New;
17
-
18
- // INJECT: Pre authorization (for instance to change the authorization level)
19
-
20
- if (pRequest.CommonServices.authorizeEndpoint(pRequest, pResponse, fNext) === false)
21
- {
22
- // If this endpoint fails, it's sent an error automatically.
23
- return;
24
- }
25
-
26
- // INJECT: Pre endpoint operation
27
-
28
- var tmpEmptyObject = pRequest.DAL.schemaFull.defaultObject;
29
-
30
- // INJECT: After the empty object is grabbed, let the user alter it
31
-
32
- pRequest.CommonServices.log.info('Delivered new '+pRequest.DAL.scope, {SessionID:pRequest.UserSession.SessionID, RequestID:pRequest.RequestUUID, RequestURL:pRequest.url, Action:pRequest.DAL.scope+'-New'}, pRequest);
33
- pResponse.send(tmpEmptyObject);
34
- return fNext();
35
- };
36
-
37
- module.exports = doAPINewEndpoint;
@@ -1,37 +0,0 @@
1
- /**
2
- * Meadow Endpoint - Get the Record Schema
3
- *
4
- * @license MIT
5
- *
6
- * @author Steven Velozo <steven@velozo.com>
7
- * @module Meadow
8
- */
9
- /**
10
- * Get the JSONSchema for a particular scope
11
- */
12
- var doAPISchemaEndpoint = function(pRequest, pResponse, fNext)
13
- {
14
- // This state is the requirement for the UserRoleIndex value in the UserSession object... processed by default as >=
15
- // The default here is that any authenticated user can use this endpoint.
16
- pRequest.EndpointAuthorizationRequirement = pRequest.EndpointAuthorizationLevels.Schema;
17
-
18
- // INJECT: Pre authorization (for instance to change the authorization level)
19
-
20
- if (pRequest.CommonServices.authorizeEndpoint(pRequest, pResponse, fNext) === false)
21
- {
22
- // If this endpoint fails, it's sent an error automatically.
23
- return;
24
- }
25
-
26
- // INJECT: Pre endpoint operation
27
-
28
- var tmpSchema = pRequest.DAL.jsonSchema;
29
-
30
- // INJECT: After the schema is grabbed, let the user alter it
31
-
32
- pRequest.CommonServices.log.info('Delivered a JSON schema for '+pRequest.DAL.scope, {SessionID:pRequest.UserSession.SessionID, RequestID:pRequest.RequestUUID, RequestURL:pRequest.url, Action:pRequest.DAL.scope+'-Schema'}, pRequest);
33
- pResponse.send(tmpSchema);
34
- return fNext();
35
- };
36
-
37
- module.exports = doAPISchemaEndpoint;
@@ -1,43 +0,0 @@
1
- /**
2
- * Meadow Endpoint - Validate a Record
3
- *
4
- * @license MIT
5
- *
6
- * @author Steven Velozo <steven@velozo.com>
7
- * @module Meadow
8
- */
9
- /**
10
- * Validate a record using the Meadow DAL object
11
- */
12
- var doAPIValidateEndpoint = function(pRequest, pResponse, fNext)
13
- {
14
- // This state is the requirement for the UserRoleIndex value in the UserSession object... processed by default as >=
15
- // The default here is that any authenticated user can use this endpoint.
16
- pRequest.EndpointAuthorizationRequirement = pRequest.EndpointAuthorizationLevels.New;
17
-
18
- // INJECT: Pre authorization (for instance to change the authorization level)
19
-
20
- if (pRequest.CommonServices.authorizeEndpoint(pRequest, pResponse, fNext) === false)
21
- {
22
- // If this endpoint fails, it's sent an error automatically.
23
- return;
24
- }
25
-
26
- if (typeof(pRequest.body) !== 'object')
27
- {
28
- return pRequest.CommonServices.sendError('Record validate failure - a valid JSON object is required.', pRequest, pResponse, fNext);
29
- }
30
- var tmpRecord = pRequest.body;
31
-
32
- // INJECT: Pre endpoint operation
33
-
34
- var tmpValid = pRequest.DAL.schemaFull.validateObject(tmpRecord);
35
-
36
- // INJECT: After the record is validated, let the API user alter the resultant
37
-
38
- pRequest.CommonServices.log.info('Delivered validation for '+pRequest.DAL.scope+': '+tmpValid, {SessionID:pRequest.UserSession.SessionID, RequestID:pRequest.RequestUUID, RequestURL:pRequest.url, Action:pRequest.DAL.scope+'-Validate'}, pRequest);
39
- pResponse.send(tmpValid);
40
- return fNext();
41
- };
42
-
43
- module.exports = doAPIValidateEndpoint;
package/test/Animal.json DELETED
@@ -1,140 +0,0 @@
1
- {
2
- "Scope": "FableTest",
3
-
4
- "DefaultIdentifier": "IDAnimal",
5
-
6
- "Schema": [
7
- { "Column": "IDAnimal", "Type":"AutoIdentity" },
8
- { "Column": "GUIDAnimal", "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": "Type", "Type":"String" },
18
- { "Column": "IDCustomer", "Type":"Number" }
19
- ],
20
-
21
- "DefaultObject": {
22
- "IDAnimal": null,
23
- "GUIDAnimal": "",
24
-
25
- "CreateDate": false,
26
- "CreatingIDUser": 0,
27
- "UpdateDate": false,
28
- "UpdatingIDUser": 0,
29
- "Deleted": 0,
30
- "DeleteDate": false,
31
- "DeletingIDUser": 0,
32
-
33
- "Name": "Unknown",
34
- "Type": "Unclassified",
35
- "IDCustomer": 0
36
- },
37
-
38
- "JsonSchema": {
39
- "title": "Animal",
40
- "description": "A creature that lives in a meadow.",
41
- "type": "object",
42
- "properties": {
43
- "IDAnimal": {
44
- "description": "The unique identifier for an animal",
45
- "type": "integer"
46
- },
47
- "Name": {
48
- "description": "The animal's name",
49
- "type": "string"
50
- },
51
- "Type": {
52
- "description": "The type of the animal",
53
- "type": "string"
54
- },
55
- "IDCustomer": {
56
- "description": "The customer ID of the record",
57
- "type": "number"
58
- }
59
- },
60
- "required": ["IDAnimal", "Name", "CreatingIDUser"]
61
- },
62
-
63
- "Authorization": {
64
- "__DefaultAPISecurity": {
65
- "Create": "Deny",
66
- "Read": "Deny",
67
- "Reads": "Deny",
68
- "ReadsBy": "Deny",
69
- "ReadMax": "Deny",
70
- "ReadSelectList": "Deny",
71
- "Update": "Deny",
72
- "Delete": "Deny",
73
- "Count": "Deny",
74
- "CountBy": "Deny",
75
- "Schema": "Deny",
76
- "Validate": "Deny",
77
- "New": "Deny"
78
- },
79
- "Unauthenticated": {
80
- "Create": "Deny",
81
- "Read": "Allow",
82
- "Reads": "Allow",
83
- "ReadsBy": "Allow",
84
- "ReadMax": "Allow",
85
- "ReadSelectList": "Allow",
86
- "Update": "Allow",
87
- "Delete": "Allow",
88
- "Count": "Allow",
89
- "CountBy": "Allow",
90
- "Schema": "Allow",
91
- "Validate": "Allow",
92
- "New": "Allow"
93
- },
94
- "Readonly": {
95
- "Create": "Deny",
96
- "Read": "Allow",
97
- "Reads": "Allow",
98
- "ReadsBy": "Allow",
99
- "ReadMax": "Allow",
100
- "ReadSelectList": "Allow",
101
- "Update": "Deny",
102
- "Delete": "Deny",
103
- "Count": "Allow",
104
- "CountBy": "Allow",
105
- "Schema": "Allow",
106
- "Validate": "Allow",
107
- "New": "Deny"
108
- },
109
- "User": {
110
- "Create": "Allow",
111
- "Read": "Allow",
112
- "Reads": "Allow",
113
- "ReadsBy": "Allow",
114
- "ReadMax": "Allow",
115
- "ReadSelectList": "Allow",
116
- "Update": "Allow",
117
- "Delete": "Allow",
118
- "Count": "Allow",
119
- "CountBy": "Allow",
120
- "Schema": "Allow",
121
- "Validate": "Allow",
122
- "New": "Allow"
123
- },
124
- "Manager": {
125
- "Create": "Allow",
126
- "Read": "Allow",
127
- "Reads": "Allow",
128
- "ReadsBy": "Allow",
129
- "ReadMax": "Allow",
130
- "ReadSelectList": "Allow",
131
- "Update": "Allow",
132
- "Delete": "Allow",
133
- "Count": "Allow",
134
- "CountBy": "Allow",
135
- "Schema": "Allow",
136
- "Validate": "Allow",
137
- "New": "Allow"
138
- }
139
- }
140
- }