meadow-endpoints 2.0.12 → 3.0.0
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 +32 -0
- package/README.md +30 -1
- package/{DebugHarness.js → debug/Harness.js} +0 -0
- package/package.json +27 -7
- package/source/Meadow-Authenticator.js +21 -11
- package/source/Meadow-Authorizers.js +23 -7
- package/source/Meadow-CommonServices.js +20 -15
- package/source/Meadow-Endpoints.js +58 -45
- package/source/Meadow-MarshallSessionData.js +64 -0
- package/source/crud/Meadow-Endpoint-Count.js +1 -1
- package/source/crud/Meadow-Endpoint-ReadDistinctList.js +146 -0
- package/source/crud/Meadow-Endpoint-ReadLiteList.js +8 -2
- package/source/crud/Meadow-Endpoint-ReadSelectList.js +6 -1
- package/source/crud/Meadow-Endpoint-Reads.js +6 -1
- package/source/crud/Meadow-Endpoint-ReadsBy.js +5 -0
- package/source/crud/Meadow-Marshal-DistinctList.js +55 -0
- package/test/MeadowEndpoints_basic_tests.js +80 -4
- package/test/MeadowEndpoints_disabledAuth_tests.js +1325 -0
- package/test/MeadowEndpoints_trustedSession_tests.js +1731 -0
- package/.travis.yml +0 -21
- package/0001-Don-t-call-response.send-on-huge-record-sets.-Use-JS.patch +0 -209
- package/0001-Register-wildcard-matches-that-have-parameter-count-.patch +0 -38
- package/0002-Bump-package-version.patch +0 -24
- package/0002-Fix-indent.patch +0 -47
- package/0003-Bump-package-version-for-publication.patch +0 -24
- package/cloud9setup.sh +0 -25
- package/source/crud/Meadow-Filter-Parse.js +0 -206
package/.travis.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
node_js:
|
|
3
|
-
- "8"
|
|
4
|
-
- "10"
|
|
5
|
-
- "12"
|
|
6
|
-
- "14"
|
|
7
|
-
- "15"
|
|
8
|
-
services:
|
|
9
|
-
- mysql
|
|
10
|
-
before_install:
|
|
11
|
-
- mysql -e 'CREATE DATABASE FableTest;'
|
|
12
|
-
addons:
|
|
13
|
-
code_climate:
|
|
14
|
-
repo_token: b0b7492746ebd2075419cab324ea69ab4f444baeb687a1e4cad47e04216af7f6
|
|
15
|
-
after_success:
|
|
16
|
-
- npm run coverage
|
|
17
|
-
after_script:
|
|
18
|
-
- cat coverage/lcov.info | ./node_modules/codeclimate-test-reporter/bin/codeclimate.js
|
|
19
|
-
- cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
|
|
20
|
-
notifications:
|
|
21
|
-
slack: paviateam:C1q99hL9XXpiPpau2PUrVZPC
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
From 6a29bd206ef3b9dd8957c532dd8bc10b2c1789ac Mon Sep 17 00:00:00 2001
|
|
2
|
-
From: Alex Decker <alex.decker@headlight.com>
|
|
3
|
-
Date: Fri, 12 Nov 2021 23:31:24 -0800
|
|
4
|
-
Subject: [PATCH 1/2] Don't call response.send on huge record sets. Use
|
|
5
|
-
JSONStream instead, to avoid blocking the main thread.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
package.json | 1 +
|
|
9
|
-
source/crud/Meadow-Endpoint-BulkCreate.js | 4 ++--
|
|
10
|
-
source/crud/Meadow-Endpoint-BulkUpdate.js | 4 ++--
|
|
11
|
-
source/crud/Meadow-Endpoint-BulkUpsert.js | 4 ++--
|
|
12
|
-
source/crud/Meadow-Endpoint-ReadLiteList.js | 5 +++--
|
|
13
|
-
source/crud/Meadow-Endpoint-ReadSelectList.js | 5 +++--
|
|
14
|
-
source/crud/Meadow-Endpoint-Reads.js | 6 ++++--
|
|
15
|
-
source/crud/Meadow-Endpoint-ReadsBy.js | 5 +++--
|
|
16
|
-
test/MeadowEndpoints_basic_tests.js | 5 ++---
|
|
17
|
-
9 files changed, 22 insertions(+), 17 deletions(-)
|
|
18
|
-
|
|
19
|
-
diff --git a/package.json b/package.json
|
|
20
|
-
index b893e0c..b5bf05f 100644
|
|
21
|
-
--- a/package.json
|
|
22
|
-
+++ b/package.json
|
|
23
|
-
@@ -33,6 +33,7 @@
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"async": "2.6.1",
|
|
27
|
-
+ "JSONStream": "^1.3.5",
|
|
28
|
-
"meadow": "~1.0.30",
|
|
29
|
-
"mysql2": "1.6.1",
|
|
30
|
-
"orator": "~2.0.2",
|
|
31
|
-
diff --git a/source/crud/Meadow-Endpoint-BulkCreate.js b/source/crud/Meadow-Endpoint-BulkCreate.js
|
|
32
|
-
index 2858990..eb53ec6 100644
|
|
33
|
-
--- a/source/crud/Meadow-Endpoint-BulkCreate.js
|
|
34
|
-
+++ b/source/crud/Meadow-Endpoint-BulkCreate.js
|
|
35
|
-
@@ -13,6 +13,7 @@
|
|
36
|
-
var libAsync = require('async');
|
|
37
|
-
|
|
38
|
-
var doCreate = require('./Meadow-Operation-Create.js');
|
|
39
|
-
+const streamRecordsToResponse = require('./Meadow-StreamRecordArray');
|
|
40
|
-
|
|
41
|
-
var doAPIBulkCreateEndpoint = function(pRequest, pResponse, fNext)
|
|
42
|
-
{
|
|
43
|
-
@@ -50,8 +51,7 @@ var doAPIBulkCreateEndpoint = function(pRequest, pResponse, fNext)
|
|
44
|
-
function(fStageComplete)
|
|
45
|
-
{
|
|
46
|
-
//5. Respond with the new records
|
|
47
|
-
- pResponse.send(pRequest.CreatedRecords);
|
|
48
|
-
- return fStageComplete(null);
|
|
49
|
-
+ return streamRecordsToResponse(pResponse, pRequest.CreatedRecords, fStageComplete);
|
|
50
|
-
}
|
|
51
|
-
], function(pError)
|
|
52
|
-
{
|
|
53
|
-
diff --git a/source/crud/Meadow-Endpoint-BulkUpdate.js b/source/crud/Meadow-Endpoint-BulkUpdate.js
|
|
54
|
-
index 95b5a71..cf33e2e 100644
|
|
55
|
-
--- a/source/crud/Meadow-Endpoint-BulkUpdate.js
|
|
56
|
-
+++ b/source/crud/Meadow-Endpoint-BulkUpdate.js
|
|
57
|
-
@@ -13,6 +13,7 @@
|
|
58
|
-
var libAsync = require('async');
|
|
59
|
-
|
|
60
|
-
var doUpdate = require('./Meadow-Operation-Update.js');
|
|
61
|
-
+const streamRecordsToResponse = require('./Meadow-StreamRecordArray');
|
|
62
|
-
|
|
63
|
-
var doAPIUpdateEndpoint = function(pRequest, pResponse, fNext)
|
|
64
|
-
{
|
|
65
|
-
@@ -57,8 +58,7 @@ var doAPIUpdateEndpoint = function(pRequest, pResponse, fNext)
|
|
66
|
-
function(fStageComplete)
|
|
67
|
-
{
|
|
68
|
-
//5. Respond with the new record
|
|
69
|
-
- pResponse.send(pRequest.UpdatedRecords);
|
|
70
|
-
- return fStageComplete(null);
|
|
71
|
-
+ return streamRecordsToResponse(pResponse, pRequest.UpdatedRecords, fStageComplete);
|
|
72
|
-
}
|
|
73
|
-
], function(pError)
|
|
74
|
-
{
|
|
75
|
-
diff --git a/source/crud/Meadow-Endpoint-BulkUpsert.js b/source/crud/Meadow-Endpoint-BulkUpsert.js
|
|
76
|
-
index e1f7b67..3f8881b 100644
|
|
77
|
-
--- a/source/crud/Meadow-Endpoint-BulkUpsert.js
|
|
78
|
-
+++ b/source/crud/Meadow-Endpoint-BulkUpsert.js
|
|
79
|
-
@@ -14,6 +14,7 @@ var libAsync = require('async');
|
|
80
|
-
|
|
81
|
-
var doUpsert = require('./Meadow-Operation-Upsert.js');
|
|
82
|
-
var marshalLiteList = require('./Meadow-Marshal-LiteList.js');
|
|
83
|
-
+const streamRecordsToResponse = require('./Meadow-StreamRecordArray');
|
|
84
|
-
|
|
85
|
-
var doAPIUpsertEndpoint = function(pRequest, pResponse, fNext)
|
|
86
|
-
{
|
|
87
|
-
@@ -59,8 +60,7 @@ var doAPIUpsertEndpoint = function(pRequest, pResponse, fNext)
|
|
88
|
-
function(fStageComplete)
|
|
89
|
-
{
|
|
90
|
-
//5. Respond with the new records
|
|
91
|
-
- pResponse.send(marshalLiteList(pRequest.UpsertedRecords, pRequest));
|
|
92
|
-
- return fStageComplete(null);
|
|
93
|
-
+ return streamRecordsToResponse(pResponse, marshalLiteList(pRequest.UpsertedRecords, pRequest), fStageComplete);
|
|
94
|
-
}
|
|
95
|
-
], function(pError)
|
|
96
|
-
{
|
|
97
|
-
diff --git a/source/crud/Meadow-Endpoint-ReadLiteList.js b/source/crud/Meadow-Endpoint-ReadLiteList.js
|
|
98
|
-
index e1113b0..f6837be 100644
|
|
99
|
-
--- a/source/crud/Meadow-Endpoint-ReadLiteList.js
|
|
100
|
-
+++ b/source/crud/Meadow-Endpoint-ReadLiteList.js
|
|
101
|
-
@@ -9,6 +9,8 @@
|
|
102
|
-
var libAsync = require('async');
|
|
103
|
-
var meadowFilterParser = require('./Meadow-Filter-Parse.js');
|
|
104
|
-
var marshalLiteList = require('./Meadow-Marshal-LiteList.js');
|
|
105
|
-
+const streamRecordsToResponse = require('./Meadow-StreamRecordArray');
|
|
106
|
-
+
|
|
107
|
-
/**
|
|
108
|
-
* Get a set of records from a DAL.
|
|
109
|
-
*/
|
|
110
|
-
@@ -123,8 +125,7 @@ var doAPIReadLiteEndpoint = function(pRequest, pResponse, fNext)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
pRequest.CommonServices.log.info('Read a recordset lite list with '+pResultRecords.length+' results.', {SessionID:pRequest.UserSession.SessionID, RequestID:pRequest.RequestUUID, RequestURL:pRequest.url, Action:pRequest.DAL.scope+'-ReadLite'}, pRequest);
|
|
114
|
-
- pResponse.send(pResultRecords);
|
|
115
|
-
- return fNext();
|
|
116
|
-
+ return streamRecordsToResponse(pResponse, pResultRecords, fNext);
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
};
|
|
120
|
-
diff --git a/source/crud/Meadow-Endpoint-ReadSelectList.js b/source/crud/Meadow-Endpoint-ReadSelectList.js
|
|
121
|
-
index d41580d..5402a35 100644
|
|
122
|
-
--- a/source/crud/Meadow-Endpoint-ReadSelectList.js
|
|
123
|
-
+++ b/source/crud/Meadow-Endpoint-ReadSelectList.js
|
|
124
|
-
@@ -8,6 +8,8 @@
|
|
125
|
-
*/
|
|
126
|
-
var libAsync = require('async');
|
|
127
|
-
var meadowFilterParser = require('./Meadow-Filter-Parse.js');
|
|
128
|
-
+const streamRecordsToResponse = require('./Meadow-StreamRecordArray');
|
|
129
|
-
+
|
|
130
|
-
/**
|
|
131
|
-
* Get a set of records from a DAL.
|
|
132
|
-
*/
|
|
133
|
-
@@ -130,8 +132,7 @@ var doAPIReadSelectListEndpoint = function(pRequest, pResponse, fNext)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
pRequest.CommonServices.log.info('Read a recordset select list with '+pResultRecords.length+' results.', {SessionID:pRequest.UserSession.SessionID, RequestID:pRequest.RequestUUID, RequestURL:pRequest.url, Action:pRequest.DAL.scope+'-ReadSelectList'}, pRequest);
|
|
137
|
-
- pResponse.send(pResultRecords);
|
|
138
|
-
- return fNext();
|
|
139
|
-
+ return streamRecordsToResponse(pResponse, pResultRecords, fNext);
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
};
|
|
143
|
-
diff --git a/source/crud/Meadow-Endpoint-Reads.js b/source/crud/Meadow-Endpoint-Reads.js
|
|
144
|
-
index 49cc779..669441f 100644
|
|
145
|
-
--- a/source/crud/Meadow-Endpoint-Reads.js
|
|
146
|
-
+++ b/source/crud/Meadow-Endpoint-Reads.js
|
|
147
|
-
@@ -8,6 +8,8 @@
|
|
148
|
-
*/
|
|
149
|
-
var libAsync = require('async');
|
|
150
|
-
var meadowFilterParser = require('./Meadow-Filter-Parse.js');
|
|
151
|
-
+const streamRecordsToResponse = require('./Meadow-StreamRecordArray');
|
|
152
|
-
+
|
|
153
|
-
/**
|
|
154
|
-
* Get a set of records from a DAL.
|
|
155
|
-
*/
|
|
156
|
-
@@ -113,8 +115,8 @@ var doAPIReadsEndpoint = function(pRequest, pResponse, fNext)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
pRequest.CommonServices.log.info('Read a list of records.', {SessionID:pRequest.UserSession.SessionID, RequestID:pRequest.RequestUUID, RequestURL:pRequest.url, Action:pRequest.DAL.scope+'-Reads'}, pRequest);
|
|
160
|
-
- pResponse.send(pRequest.Records);
|
|
161
|
-
- return fNext();
|
|
162
|
-
+
|
|
163
|
-
+ streamRecordsToResponse(pResponse, pRequest.Records, fNext);
|
|
164
|
-
}
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
diff --git a/source/crud/Meadow-Endpoint-ReadsBy.js b/source/crud/Meadow-Endpoint-ReadsBy.js
|
|
168
|
-
index 36a5397..b7c5deb 100644
|
|
169
|
-
--- a/source/crud/Meadow-Endpoint-ReadsBy.js
|
|
170
|
-
+++ b/source/crud/Meadow-Endpoint-ReadsBy.js
|
|
171
|
-
@@ -7,6 +7,8 @@
|
|
172
|
-
* @module Meadow
|
|
173
|
-
*/
|
|
174
|
-
var libAsync = require('async');
|
|
175
|
-
+const streamRecordsToResponse = require('./Meadow-StreamRecordArray');
|
|
176
|
-
+
|
|
177
|
-
/**
|
|
178
|
-
* Get a specific record from a DAL.
|
|
179
|
-
*/
|
|
180
|
-
@@ -140,8 +142,7 @@ var doAPIReadsByEndpoint = function(pRequest, pResponse, fNext)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
pRequest.CommonServices.log.info('Read a list of records by '+pRequest.params.ByField+' = '+pRequest.params.ByValue+'.', {SessionID:pRequest.UserSession.SessionID, RequestID:pRequest.RequestUUID, RequestURL:pRequest.url, Action:pRequest.DAL.scope+'-ReadsBy'}, pRequest);
|
|
184
|
-
- pResponse.send(pRequest.Records);
|
|
185
|
-
- return fNext();
|
|
186
|
-
+ return streamRecordsToResponse(pResponse, pRequest.Records, fNext);
|
|
187
|
-
}
|
|
188
|
-
);
|
|
189
|
-
};
|
|
190
|
-
diff --git a/test/MeadowEndpoints_basic_tests.js b/test/MeadowEndpoints_basic_tests.js
|
|
191
|
-
index ac40dcc..02944db 100644
|
|
192
|
-
--- a/test/MeadowEndpoints_basic_tests.js
|
|
193
|
-
+++ b/test/MeadowEndpoints_basic_tests.js
|
|
194
|
-
@@ -736,10 +736,9 @@ suite
|
|
195
|
-
.end(
|
|
196
|
-
function (pError, pResponse)
|
|
197
|
-
{
|
|
198
|
-
- console.log('FUCK'+pResponse.text)
|
|
199
|
-
var tmpResults = JSON.parse(pResponse.text);
|
|
200
|
-
- Expect(tmpResults.length).to.equal(6);
|
|
201
|
-
- Expect(tmpResults[0].Value).to.equal('FableTest #1');
|
|
202
|
-
+ Expect(tmpResults.length).to.equal(2);
|
|
203
|
-
+ Expect(tmpResults[0].Value).to.equal('FableTest #3');
|
|
204
|
-
fDone();
|
|
205
|
-
}
|
|
206
|
-
);
|
|
207
|
-
--
|
|
208
|
-
2.25.1
|
|
209
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
From 6e13b744340cf152a393614188673e65f45d963b Mon Sep 17 00:00:00 2001
|
|
2
|
-
From: Alex Decker <alex.decker@headlight.com>
|
|
3
|
-
Date: Fri, 24 Sep 2021 17:16:18 -0700
|
|
4
|
-
Subject: [PATCH 1/3] Register wildcard matches that have parameter-count
|
|
5
|
-
matches afterward, so the exact match is used.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
source/Meadow-Endpoints.js | 6 +++---
|
|
9
|
-
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
10
|
-
|
|
11
|
-
diff --git a/source/Meadow-Endpoints.js b/source/Meadow-Endpoints.js
|
|
12
|
-
index ec6c5df..288cda9 100644
|
|
13
|
-
--- a/source/Meadow-Endpoints.js
|
|
14
|
-
+++ b/source/Meadow-Endpoints.js
|
|
15
|
-
@@ -342,17 +342,17 @@ var MeadowEndpoints = function()
|
|
16
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/FilteredTo/:Filter', _EndpointAuthenticators.Reads, wireState, _Endpoints.Reads);
|
|
17
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/FilteredTo/:Filter/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.Reads);
|
|
18
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'Select', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
19
|
-
- pRestServer.get('/1.0/'+tmpEndpointName+'Select/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
20
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'Select/FilteredTo/:Filter', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
21
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'Select/FilteredTo/:Filter/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
22
|
-
+ pRestServer.get('/1.0/'+tmpEndpointName+'Select/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadSelectList);
|
|
23
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/Lite', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
24
|
-
- pRestServer.get('/1.0/'+tmpEndpointName+'s/Lite/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
25
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/Lite/FilteredTo/:Filter', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
26
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/Lite/FilteredTo/:Filter/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
27
|
-
+ pRestServer.get('/1.0/'+tmpEndpointName+'s/Lite/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
28
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/LiteExtended/:ExtraColumns', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
29
|
-
- pRestServer.get('/1.0/'+tmpEndpointName+'s/LiteExtended/:ExtraColumns/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
30
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/LiteExtended/:ExtraColumns/FilteredTo/:Filter', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
31
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/LiteExtended/:ExtraColumns/FilteredTo/:Filter/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
32
|
-
+ pRestServer.get('/1.0/'+tmpEndpointName+'s/LiteExtended/:ExtraColumns/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.ReadLiteList);
|
|
33
|
-
pRestServer.get('/1.0/'+tmpEndpointName+'s/:Begin/:Cap', _EndpointAuthenticators.Reads, wireState, _Endpoints.Reads);
|
|
34
|
-
}
|
|
35
|
-
if (_EnabledBehaviors.Update)
|
|
36
|
-
--
|
|
37
|
-
2.25.1
|
|
38
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
From 80e05ff43891942bfdcebe03a3680402bfc627a4 Mon Sep 17 00:00:00 2001
|
|
2
|
-
From: Alex Decker <alex.decker@headlight.com>
|
|
3
|
-
Date: Fri, 12 Nov 2021 23:31:42 -0800
|
|
4
|
-
Subject: [PATCH 2/2] Bump package version.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
package.json | 2 +-
|
|
8
|
-
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
9
|
-
|
|
10
|
-
diff --git a/package.json b/package.json
|
|
11
|
-
index b5bf05f..c55df53 100644
|
|
12
|
-
--- a/package.json
|
|
13
|
-
+++ b/package.json
|
|
14
|
-
@@ -1,6 +1,6 @@
|
|
15
|
-
{
|
|
16
|
-
"name": "meadow-endpoints",
|
|
17
|
-
- "version": "2.0.11",
|
|
18
|
-
+ "version": "2.0.12",
|
|
19
|
-
"description": "Automatic API endpoints for Meadow data.",
|
|
20
|
-
"main": "source/Meadow-Endpoints.js",
|
|
21
|
-
"scripts": {
|
|
22
|
-
--
|
|
23
|
-
2.25.1
|
|
24
|
-
|
package/0002-Fix-indent.patch
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
From f45d012b61f34ba52756cfb52ab0b66158493973 Mon Sep 17 00:00:00 2001
|
|
2
|
-
From: Alex Decker <alex.decker@headlight.com>
|
|
3
|
-
Date: Fri, 24 Sep 2021 17:17:19 -0700
|
|
4
|
-
Subject: [PATCH 2/3] Fix indent.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
source/Meadow-Endpoints.js | 18 +++++++++---------
|
|
8
|
-
1 file changed, 9 insertions(+), 9 deletions(-)
|
|
9
|
-
|
|
10
|
-
diff --git a/source/Meadow-Endpoints.js b/source/Meadow-Endpoints.js
|
|
11
|
-
index 288cda9..2d1204e 100644
|
|
12
|
-
--- a/source/Meadow-Endpoints.js
|
|
13
|
-
+++ b/source/Meadow-Endpoints.js
|
|
14
|
-
@@ -357,21 +357,21 @@ var MeadowEndpoints = function()
|
|
15
|
-
}
|
|
16
|
-
if (_EnabledBehaviors.Update)
|
|
17
|
-
{
|
|
18
|
-
- pRestServer.put('/1.0/'+tmpEndpointName, _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Update);
|
|
19
|
-
- pRestServer.put('/1.0/'+tmpEndpointName+'s', _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Updates);
|
|
20
|
-
- pRestServer.put('/1.0/'+tmpEndpointName+'/Upsert', _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Upsert);
|
|
21
|
-
- pRestServer.put('/1.0/'+tmpEndpointName+'/Upserts', _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Upserts);
|
|
22
|
-
+ pRestServer.put('/1.0/'+tmpEndpointName, _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Update);
|
|
23
|
-
+ pRestServer.put('/1.0/'+tmpEndpointName+'s', _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Updates);
|
|
24
|
-
+ pRestServer.put('/1.0/'+tmpEndpointName+'/Upsert', _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Upsert);
|
|
25
|
-
+ pRestServer.put('/1.0/'+tmpEndpointName+'/Upserts', _CommonServices.bodyParser(), _EndpointAuthenticators.Update, wireState, _Endpoints.Upserts);
|
|
26
|
-
}
|
|
27
|
-
if (_EnabledBehaviors.Delete)
|
|
28
|
-
{
|
|
29
|
-
- pRestServer.del('/1.0/'+tmpEndpointName, _CommonServices.bodyParser(), _EndpointAuthenticators.Delete, wireState, _Endpoints.Delete);
|
|
30
|
-
- pRestServer.del('/1.0/'+tmpEndpointName+'/:IDRecord', _EndpointAuthenticators.Delete, wireState, _Endpoints.Delete);
|
|
31
|
-
+ pRestServer.del('/1.0/'+tmpEndpointName, _CommonServices.bodyParser(), _EndpointAuthenticators.Delete, wireState, _Endpoints.Delete);
|
|
32
|
-
+ pRestServer.del('/1.0/'+tmpEndpointName+'/:IDRecord', _EndpointAuthenticators.Delete, wireState, _Endpoints.Delete);
|
|
33
|
-
}
|
|
34
|
-
if (_EnabledBehaviors.Count)
|
|
35
|
-
{
|
|
36
|
-
- pRestServer.get('/1.0/'+tmpEndpointName+'s/Count', _EndpointAuthenticators.Count, wireState, _Endpoints.Count);
|
|
37
|
-
- pRestServer.get('/1.0/'+tmpEndpointName+'s/Count/By/:ByField/:ByValue', _EndpointAuthenticators.Count, wireState, _Endpoints.CountBy);
|
|
38
|
-
- pRestServer.get('/1.0/'+tmpEndpointName+'s/Count/FilteredTo/:Filter', _EndpointAuthenticators.Count, wireState, _Endpoints.Count);
|
|
39
|
-
+ pRestServer.get('/1.0/'+tmpEndpointName+'s/Count', _EndpointAuthenticators.Count, wireState, _Endpoints.Count);
|
|
40
|
-
+ pRestServer.get('/1.0/'+tmpEndpointName+'s/Count/By/:ByField/:ByValue', _EndpointAuthenticators.Count, wireState, _Endpoints.CountBy);
|
|
41
|
-
+ pRestServer.get('/1.0/'+tmpEndpointName+'s/Count/FilteredTo/:Filter', _EndpointAuthenticators.Count, wireState, _Endpoints.Count);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
--
|
|
46
|
-
2.25.1
|
|
47
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
From f15fe4fa2611ca3cbec3c78ba819bca746b1d917 Mon Sep 17 00:00:00 2001
|
|
2
|
-
From: Alex Decker <alex.decker@headlight.com>
|
|
3
|
-
Date: Fri, 24 Sep 2021 17:18:12 -0700
|
|
4
|
-
Subject: [PATCH 3/3] Bump package version for publication.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
package.json | 2 +-
|
|
8
|
-
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
9
|
-
|
|
10
|
-
diff --git a/package.json b/package.json
|
|
11
|
-
index 84dace7..b893e0c 100644
|
|
12
|
-
--- a/package.json
|
|
13
|
-
+++ b/package.json
|
|
14
|
-
@@ -1,6 +1,6 @@
|
|
15
|
-
{
|
|
16
|
-
"name": "meadow-endpoints",
|
|
17
|
-
- "version": "2.0.10",
|
|
18
|
-
+ "version": "2.0.11",
|
|
19
|
-
"description": "Automatic API endpoints for Meadow data.",
|
|
20
|
-
"main": "source/Meadow-Endpoints.js",
|
|
21
|
-
"scripts": {
|
|
22
|
-
--
|
|
23
|
-
2.25.1
|
|
24
|
-
|
package/cloud9setup.sh
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#! /bin/bash
|
|
2
|
-
echo "Setup a Cloud9 environment for Meadow Endpoints"
|
|
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/scripts/InitializeDatabase-C9.sql
|
|
20
|
-
echo ""
|
|
21
|
-
echo "## Remember to Switch to node 8.x by running these commands..."
|
|
22
|
-
echo "nvm use 8"
|
|
23
|
-
echo "nvm alias default 8"
|
|
24
|
-
echo ""
|
|
25
|
-
echo "## And we're done! Have a great day."
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Meadow Endpoint Utility Function - Parse a Filter String and put it into a Query.
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
*
|
|
6
|
-
* @author Steven Velozo <steven@velozo.com>
|
|
7
|
-
* @module Meadow
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Parse GET-passed Filter Strings, turn the results into proper Meadow query stanzas
|
|
11
|
-
|
|
12
|
-
Take the filter and return an array of filter instructions
|
|
13
|
-
Basic instruction anatomy:
|
|
14
|
-
INSTRUCTION~FIELD~OPERATOR~VALUE
|
|
15
|
-
FOP - Filter Open Paren
|
|
16
|
-
FOP~0~(~0
|
|
17
|
-
FCP - Filter Close Paren
|
|
18
|
-
FCP~0~)~0
|
|
19
|
-
FBV - Filter By Value (left-side AND connected)
|
|
20
|
-
FBV~Category~EQ~Books
|
|
21
|
-
Possible comparisons:
|
|
22
|
-
* EQ - Equals To (=)
|
|
23
|
-
* NE - Not Equals To (!=)
|
|
24
|
-
* GT - Greater Than (>)
|
|
25
|
-
* GE - Greater Than or Equals To (>=)
|
|
26
|
-
* LT - Less Than (<)
|
|
27
|
-
* LE - Less Than or Equals To (<=)
|
|
28
|
-
* LK - Like (Like)
|
|
29
|
-
* IN - Is NULL
|
|
30
|
-
* NN - Is NOT NULL
|
|
31
|
-
* INN - IN list
|
|
32
|
-
FBVOR - Filter By Value (left-side OR connected)
|
|
33
|
-
FBL - Filter By List (value list, separated by commas)
|
|
34
|
-
FBL~Category~EQ~Books,Movies
|
|
35
|
-
FBD - Filter by Date (exclude time)
|
|
36
|
-
FBD~UpdateDate~EQ~2015-10-01
|
|
37
|
-
FSF - Filter Sort Field
|
|
38
|
-
FSF~Category~ASC~0
|
|
39
|
-
FSF~Category~DESC~0
|
|
40
|
-
|
|
41
|
-
This means: FBV~Category~EQ~Books~FBV~PublishedYear~GT~2000~FSF~PublishedYear~DESC~0
|
|
42
|
-
Filters down to ALL BOOKS PUBLUSHED AFTER 200 IN DESCENDING ORDER
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
// Get the comparison operator for use in a query stanza
|
|
46
|
-
var getFilterComparisonOperator = function(pFilterOperator)
|
|
47
|
-
{
|
|
48
|
-
var tmpOperator = '=';
|
|
49
|
-
switch(pFilterOperator)
|
|
50
|
-
{
|
|
51
|
-
case 'EQ':
|
|
52
|
-
tmpOperator = '=';
|
|
53
|
-
break;
|
|
54
|
-
case 'NE':
|
|
55
|
-
tmpOperator = '!=';
|
|
56
|
-
break;
|
|
57
|
-
case 'GT':
|
|
58
|
-
tmpOperator = '>';
|
|
59
|
-
break;
|
|
60
|
-
case 'GE':
|
|
61
|
-
tmpOperator = '>=';
|
|
62
|
-
break;
|
|
63
|
-
case 'LT':
|
|
64
|
-
tmpOperator = '<';
|
|
65
|
-
break;
|
|
66
|
-
case 'LE':
|
|
67
|
-
tmpOperator = '<=';
|
|
68
|
-
break;
|
|
69
|
-
case 'LK':
|
|
70
|
-
tmpOperator = 'LIKE';
|
|
71
|
-
break;
|
|
72
|
-
case 'NLK':
|
|
73
|
-
tmpOperator = 'NOT LIKE';
|
|
74
|
-
break;
|
|
75
|
-
case 'IN':
|
|
76
|
-
tmpOperator = 'IS NULL';
|
|
77
|
-
break;
|
|
78
|
-
case 'NN':
|
|
79
|
-
tmpOperator = 'IS NOT NULL';
|
|
80
|
-
break;
|
|
81
|
-
case 'INN':
|
|
82
|
-
tmpOperator = 'IN';
|
|
83
|
-
break;
|
|
84
|
-
case 'FOP':
|
|
85
|
-
tmpOperator = '(';
|
|
86
|
-
break;
|
|
87
|
-
case 'FCP':
|
|
88
|
-
tmpOperator = ')';
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
return tmpOperator;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
var addFilterStanzaToQuery = function(pFilterStanza, pQuery)
|
|
95
|
-
{
|
|
96
|
-
if (!pFilterStanza.Instruction)
|
|
97
|
-
{
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
switch(pFilterStanza.Instruction)
|
|
102
|
-
{
|
|
103
|
-
case 'FBV': // Filter by Value (left-side AND)
|
|
104
|
-
pQuery.addFilter(pFilterStanza.Field, pFilterStanza.Value, getFilterComparisonOperator(pFilterStanza.Operator), 'AND');
|
|
105
|
-
break;
|
|
106
|
-
|
|
107
|
-
case 'FBVOR': // Filter by Value (left-side OR)
|
|
108
|
-
pQuery.addFilter(pFilterStanza.Field, pFilterStanza.Value, getFilterComparisonOperator(pFilterStanza.Operator), 'OR');
|
|
109
|
-
break;
|
|
110
|
-
|
|
111
|
-
case 'FBL': // Filter by List (left-side AND)
|
|
112
|
-
// Just split the value by comma for now. May want to revisit better characters or techniques later.
|
|
113
|
-
pQuery.addFilter(pFilterStanza.Field, pFilterStanza.Value.split(','), getFilterComparisonOperator(pFilterStanza.Operator), 'AND');
|
|
114
|
-
break;
|
|
115
|
-
|
|
116
|
-
case 'FBLOR': // Filter by List (left-side OR)
|
|
117
|
-
// Just split the value by comma for now. May want to revisit better characters or techniques later.
|
|
118
|
-
pQuery.addFilter(pFilterStanza.Field, pFilterStanza.Value.split(','), getFilterComparisonOperator(pFilterStanza.Operator, 'OR'));
|
|
119
|
-
break;
|
|
120
|
-
|
|
121
|
-
case 'FBD': // Filter by Date (exclude time)
|
|
122
|
-
pQuery.addFilter(`DATE(${pFilterStanza.Field})`, pFilterStanza.Value.split(','), getFilterComparisonOperator(pFilterStanza.Operator), 'AND', pFilterStanza.Field);
|
|
123
|
-
break;
|
|
124
|
-
|
|
125
|
-
case 'FBDOR': // Filter by Date (exclude time)
|
|
126
|
-
pQuery.addFilter(`DATE(${pFilterStanza.Field})`, pFilterStanza.Value.split(','), getFilterComparisonOperator(pFilterStanza.Operator), 'OR', pFilterStanza.Field);
|
|
127
|
-
break;
|
|
128
|
-
|
|
129
|
-
case 'FSF': // Filter Sort Field
|
|
130
|
-
var tmpSortDirection = (pFilterStanza.Operator === 'DESC') ? 'Descending' : 'Ascending';
|
|
131
|
-
pQuery.addSort({Column:pFilterStanza.Field, Direction:tmpSortDirection});
|
|
132
|
-
break;
|
|
133
|
-
|
|
134
|
-
case 'FOP': // Filter Open Paren
|
|
135
|
-
pQuery.addFilter('', '', '(');
|
|
136
|
-
break;
|
|
137
|
-
|
|
138
|
-
case 'FCP': // Filter Close Paren
|
|
139
|
-
pQuery.addFilter('', '', ')');
|
|
140
|
-
break;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
default:
|
|
144
|
-
//console.log('Unparsable filter stanza.');
|
|
145
|
-
return false;
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Be paranoid about the instruction
|
|
150
|
-
pFilterStanza.Instruction = false;
|
|
151
|
-
return true;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
var doParseFilter = function(pFilterString, pQuery)
|
|
155
|
-
{
|
|
156
|
-
if (typeof(pFilterString) !== 'string')
|
|
157
|
-
{
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
var tmpFilterTerms = pFilterString.split('~');
|
|
162
|
-
|
|
163
|
-
if (tmpFilterTerms.length < 4)
|
|
164
|
-
return true;
|
|
165
|
-
|
|
166
|
-
var tmpFilterStanza = { Instruction:false };
|
|
167
|
-
|
|
168
|
-
for (var i = 0; i < tmpFilterTerms.length; i++)
|
|
169
|
-
{
|
|
170
|
-
switch(i % 4)
|
|
171
|
-
{
|
|
172
|
-
case 0: // INSTRUCTION
|
|
173
|
-
addFilterStanzaToQuery(tmpFilterStanza, pQuery);
|
|
174
|
-
//console.log(i+' Instruction: '+tmpFilterTerms[i]);
|
|
175
|
-
tmpFilterStanza = (
|
|
176
|
-
{
|
|
177
|
-
Instruction: tmpFilterTerms[i],
|
|
178
|
-
Field: '',
|
|
179
|
-
Operator: '',
|
|
180
|
-
Value: ''
|
|
181
|
-
});
|
|
182
|
-
break;
|
|
183
|
-
|
|
184
|
-
case 1: // FIELD
|
|
185
|
-
//console.log(i+' Field: '+tmpFilterTerms[i]);
|
|
186
|
-
tmpFilterStanza.Field = tmpFilterTerms[i];
|
|
187
|
-
break;
|
|
188
|
-
|
|
189
|
-
case 2: // OPERATOR
|
|
190
|
-
//console.log(i+' Operator: '+tmpFilterTerms[i]);
|
|
191
|
-
tmpFilterStanza.Operator = tmpFilterTerms[i];
|
|
192
|
-
break;
|
|
193
|
-
|
|
194
|
-
case 3: // VALUE
|
|
195
|
-
//console.log(i+' Value: '+tmpFilterTerms[i]);
|
|
196
|
-
tmpFilterStanza.Value = tmpFilterTerms[i];
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
addFilterStanzaToQuery(tmpFilterStanza, pQuery);
|
|
202
|
-
|
|
203
|
-
return true;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
module.exports = doParseFilter;
|