@muze-nl/simplystore 0.4.4 → 0.4.6

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/README.md CHANGED
@@ -3,9 +3,11 @@
3
3
  SimplyStore is a radically simpler backend storage server. It does not have a database, certainly no SQL or GraphQL, it is not REST. In return it has a well defined API that is automatically derived from your dataset. It supports JSONTag to allow for semantically meaningful data, without having to do the full switch to Linked Data and triple stores. The query format is javascript, you can post javascript queries that will run on the server. All data is read into memory and is available to these javascript queries without needing (or allowing) disk access or indexes.
4
4
 
5
5
  [JSONTag](https://github.com/poef/jsontag) is an enhancement over JSON that allows you to tag JSON data with metadata using HTML-like tags.
6
- Javascript queries are run in a [VM2](https://www.npmjs.com/package/vm2) sandbox.
6
+ Javascript queries are run in a [VM2](https://www.npmjs.com/package/vm2) sandbox.
7
7
  You can query data using the [array-where-select](https://www.npmjs.com/package/array-where-select) extension.
8
8
 
9
+ Note: _There are known security issues in VM2, so the project will switch to V8-isolate. For now don't use SimplyStore in production_
10
+
9
11
  ## Table of Contents
10
12
 
11
13
  - [Background](#background)
@@ -103,12 +105,28 @@ from(data.persons)
103
105
  })
104
106
  ```
105
107
 
106
- See the [array-where-select](https://www.npmjs.com/package/array-where-select) package for more information about the query possibilities.
108
+ See the [query documentation](docs/queries.md) for more information about the query possibilities.
107
109
 
108
110
  Remember: it is just javascript, so you can also use filter(), map() and reduce() on arrays. You can use all the default javascript API's, like Math, Array, Object, etc. You can not use any webbrowser API's, and you can't access any NodeJS API's. You do not have network access in your query.
109
111
 
110
112
  Most important: queries cannot change the dataset, it is immutable.
111
113
 
114
+ ## Example SimplyStore server
115
+
116
+ The example directory contains a server that uses SimplyStore to serve a
117
+ Star Wars API.
118
+
119
+ To start it:
120
+
121
+ ```shell
122
+ cd example/
123
+ npm install
124
+ npm start
125
+ ```
126
+
127
+ Now go to http://localhost:3000/query/ and you can run all the example
128
+ queries from the [query documentation](docs/queries.md)
129
+
112
130
  <a name="goals"></a>
113
131
  ## Goals of this project
114
132
 
@@ -144,6 +162,8 @@ In addition, SimplyStore is meant to be a real-world testcase for JSONTag.
144
162
  - add support for metadata on each JSON pointer path (or better: each object)
145
163
  - allow custom templates, instead of the default index.html
146
164
  - add support for access control, based on webid / openid connect
165
+ - switch from VM2 to V8-isolate, which is more secure
166
+ - switch the server runtime to Rust, so SimplyStore can share immutable data between threads
147
167
 
148
168
  <a name="license"></a>
149
169
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muze-nl/simplystore",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "main": "src/server.mjs",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "homepage": "https://github.com/simplyedit/simplystore#readme",
18
18
  "dependencies": {
19
19
  "@muze-nl/jsontag": "^0.8.6",
20
- "array-where-select": "^0.4.2",
20
+ "array-where-select": "^0.4.4",
21
21
  "codemirror": "^6.0.1",
22
22
  "express": "^4.18.1",
23
23
  "json-pointer": "^0.6.2",
@@ -1,6 +1,6 @@
1
1
  import JSONTag from "@muze-nl/jsontag"
2
2
  import pointer from 'json-pointer'
3
- import {_,from,not,anyOf,allOf,asc,desc} from 'array-where-select'
3
+ import {_,from,not,anyOf,allOf,asc,desc,sum,count,avg,max,min} from 'array-where-select'
4
4
  import {deepFreeze} from './util.mjs'
5
5
  import {VM} from 'vm2'
6
6
 
@@ -115,6 +115,11 @@ export function runQuery({pointer, request, query}) {
115
115
  allOf,
116
116
  asc,
117
117
  desc,
118
+ sum,
119
+ count,
120
+ avg,
121
+ max,
122
+ min,
118
123
  // console: connectConsole(res),
119
124
  JSONTag,
120
125
  request