@muze-nl/simplystore 0.6.18 → 0.6.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muze-nl/simplystore",
3
- "version": "0.6.18",
3
+ "version": "0.6.20",
4
4
  "main": "src/server.mjs",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -17,10 +17,10 @@
17
17
  "homepage": "https://github.com/simplyedit/simplystore#readme",
18
18
  "dependencies": {
19
19
  "@muze-nl/jsontag": "^0.9.1",
20
- "@muze-nl/od-jsontag": "^0.2.7",
20
+ "@muze-nl/od-jsontag": "^0.2.9",
21
21
  "codemirror": "^6.0.1",
22
22
  "express": "^4.18.1",
23
- "jaqt": "^0.9.0",
23
+ "@muze-nl/jaqt": "^0.9.5",
24
24
  "json-pointer": "^0.6.2",
25
25
  "jsonpath-plus": "^7.2.0",
26
26
  "vm2": "^3.9.13",
@@ -1,9 +1,10 @@
1
1
  import { parentPort } from 'node:worker_threads'
2
+ import JSONTag from '@muze-nl/jsontag'
2
3
  import parse from '@muze-nl/od-jsontag/src/parse.mjs'
3
4
  import fs from 'fs'
4
5
  import serialize from '@muze-nl/od-jsontag/src/serialize.mjs'
5
6
 
6
- parentPort.on('message', datafile => {
7
+ parentPort.on('message', (files) => {
7
8
  let meta = {
8
9
  index: {
9
10
  id: new Map()
@@ -11,11 +12,11 @@ parentPort.on('message', datafile => {
11
12
  }
12
13
 
13
14
  let count = 0
14
- let basefile = datafile
15
- let data
15
+ let basefile = files.dataFile
16
+ let data
16
17
  let jsontag
17
18
  let tempMeta = {}
18
-
19
+ let datafile = files.dataFile
19
20
  do {
20
21
  jsontag = fs.readFileSync(datafile)
21
22
  data = parse(jsontag, tempMeta) // tempMeta is needed to combine the resultArray, using meta conflicts with meta.index.id
@@ -23,6 +24,10 @@ parentPort.on('message', datafile => {
23
24
  datafile = basefile + '.' + count
24
25
  } while(fs.existsSync(datafile))
25
26
  meta.parts = count
27
+ if (files.schemaFile) {
28
+ jsontag = fs.readFileSync(files.schemaFile, 'utf-8')
29
+ meta.schema = JSONTag.parse(jsontag, null, tempMeta)
30
+ }
26
31
 
27
32
  const sab = serialize(data, {meta})
28
33
 
@@ -5,7 +5,7 @@ import JSONTag from '@muze-nl/jsontag'
5
5
  import * as odJSONTag from '@muze-nl/od-jsontag/src/jsontag.mjs'
6
6
  import {source, isProxy, resultSet} from '@muze-nl/od-jsontag/src/symbols.mjs'
7
7
  import parse from '@muze-nl/od-jsontag/src/parse.mjs'
8
- import {_,from,not,anyOf,allOf,asc,desc,sum,count,avg,max,min} from 'jaqt'
8
+ import {_,from,not,anyOf,allOf,asc,desc,sum,count,avg,max,min,distinct} from '@muze-nl/jaqt'
9
9
 
10
10
  let dataspace
11
11
  let meta = {}
@@ -74,10 +74,14 @@ const tasks = {
74
74
  if (task.req.meta.index) {
75
75
  meta.index = task.req.meta.index
76
76
  }
77
+ if (task.req.meta.schema) {
78
+ meta.schema = task.req.meta.schema
79
+ }
77
80
  for (let sab of task.req.body) { //body contains an array of sharedArrayBuffers with initial data and changes
78
81
  dataspace = parse(sab, meta)
79
82
  }
80
83
  metaProxy.index.id = metaIdProxy
84
+ metaProxy.schema = meta.schema
81
85
  //@TODO: add meta.index.references? and baseURL
82
86
  return true
83
87
  },
@@ -129,7 +133,8 @@ export function runQuery(pointer, request, query) {
129
133
  count,
130
134
  avg,
131
135
  max,
132
- min,
136
+ min,
137
+ distinct,
133
138
  // console: connectConsole(res),
134
139
  JSONTag: myJSONTag,
135
140
  request
package/src/server.mjs CHANGED
@@ -20,6 +20,7 @@ async function main(options) {
20
20
  }
21
21
  const port = options.port || 3000
22
22
  const datafile = options.datafile || './data.od-jsontag'
23
+ const schemaFile = options.schemaFile || null
23
24
  const wwwroot = options.wwwroot || __dirname+'/www'
24
25
  const maxWorkers = options.maxWorkers || 8
25
26
  const queryWorker = options.queryWorker || __dirname+'/src/query-worker.mjs'
@@ -49,7 +50,7 @@ async function main(options) {
49
50
  reject(error)
50
51
  worker.terminate()
51
52
  })
52
- worker.postMessage(datafile)
53
+ worker.postMessage({dataFile:datafile,schemaFile})
53
54
  })
54
55
  }
55
56
  try {