@muze-nl/simplystore 0.6.3 → 0.6.5

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.3",
3
+ "version": "0.6.5",
4
4
  "main": "src/server.mjs",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -17,9 +17,10 @@
17
17
  "homepage": "https://github.com/simplyedit/simplystore#readme",
18
18
  "dependencies": {
19
19
  "@muze-nl/jsontag": "^0.9.1",
20
- "jaqt": "^0.6.1",
20
+ "@muze-nl/od-jsontag": "^0.1.1",
21
21
  "codemirror": "^6.0.1",
22
22
  "express": "^4.18.1",
23
+ "jaqt": "^0.6.2",
23
24
  "json-pointer": "^0.6.2",
24
25
  "jsonpath-plus": "^7.2.0",
25
26
  "vm2": "^3.9.13",
@@ -37,4 +38,4 @@
37
38
  "www/",
38
39
  "scripts/"
39
40
  ]
40
- }
41
+ }
@@ -1,12 +1,13 @@
1
1
  import JSONTag from '@muze-nl/jsontag'
2
- import {source, isChanged, getIndex} from './symbols.mjs'
3
- import fastParse from './fastParse.mjs'
4
- import {stringToSAB,resultSetStringify} from './fastStringify.mjs'
2
+ import {source, isChanged, getIndex, resultSet} from '@muze-nl/od-jsontag/src/symbols.mjs'
3
+ import parse from '@muze-nl/od-jsontag/src/parse.mjs'
4
+ import serialize, {stringify} from '@muze-nl/od-jsontag/src/serialize.mjs'
5
+ import * as FastJSONTag from '@muze-nl/od-jsontag/src/jsontag.mjs'
5
6
  import writeFileAtomic from 'write-file-atomic'
6
7
  import {_,from,not,anyOf,allOf,asc,desc,sum,count,avg,max,min} from 'jaqt'
7
8
 
8
9
  let commands = {}
9
- let resultSet = []
10
+ let resultArr = []
10
11
  let dataspace
11
12
  let datafile
12
13
  let meta = {}
@@ -20,7 +21,7 @@ export const metaIdProxy = {
20
21
  meta.index.id.forEach((ref,id) => {
21
22
  callback({
22
23
  deref: () => {
23
- return resultSet[ref]
24
+ return resultArr[ref]
24
25
  }
25
26
  },id)
26
27
  })
@@ -34,7 +35,7 @@ export const metaIdProxy = {
34
35
  }
35
36
  } else {
36
37
  let line = meta.index.id.get(id)
37
- resultSet[line] = ref
38
+ resultArr[line] = ref
38
39
  }
39
40
  },
40
41
  get: (id) => {
@@ -42,7 +43,7 @@ export const metaIdProxy = {
42
43
  if (index || index===0) {
43
44
  return {
44
45
  deref: () => {
45
- return resultSet[index]
46
+ return resultArr[index]
46
47
  }
47
48
  }
48
49
  }
@@ -52,22 +53,9 @@ export const metaIdProxy = {
52
53
  }
53
54
  }
54
55
 
55
- export const FastJSONTag = {
56
- getType: (obj) => JSONTag.getType(obj?.[source]),
57
- getAttribute: (obj, attr) => JSONTag.getAttribute(obj?.[source],attr),
58
- setAttribute: (obj, attr, value) => {
59
- if (!obj) return
60
- obj[isChanged] = true
61
- return JSONTag.setAttribute(obj[source], attr, value)
62
- },
63
- getAttributes: (obj) => JSONTag.getAttributes(obj?.[source]),
64
- getAttributeString: (obj) => JSONTag.getAttributesString(obj?.[source]),
65
- getTypeString: (obj) => JSONTag.getTypeString(obj?.[source])
66
- }
67
-
68
56
  export async function initialize(task) {
69
- resultSet = fastParse(task.data, task.meta, false) // false means mutable
70
- dataspace = resultSet[0]
57
+ dataspace = parse(task.data, task.meta, false) // false means mutable
58
+ resultArr = dataspace[resultSet]
71
59
  meta = task.meta
72
60
  metaProxy.index.id = metaIdProxy
73
61
  datafile = task.datafile
@@ -90,8 +78,7 @@ export default async function runCommand(commandStr, request) {
90
78
  //TODO: if command/task makes no changes, skip updating data.jsontag and writing it, skip response.data
91
79
  FastJSONTag.setAttribute(dataspace, 'command', task.id)
92
80
 
93
- const strData = resultSetStringify(resultSet)
94
- const uint8sab = stringToSAB(strData)
81
+ const uint8sab = serialize(dataspace)
95
82
  response.data = uint8sab
96
83
  response.meta = {
97
84
  index: {
@@ -1,12 +1,13 @@
1
- import JSONTag from '@muze-nl/jsontag'
2
- import fastParse from './fastParse.mjs'
3
- import {source, isProxy} from './symbols.mjs'
4
- import {_,from,not,anyOf,allOf,asc,desc,sum,count,avg,max,min} from 'jaqt'
5
1
  import pointer from 'json-pointer'
6
2
  import {VM} from 'vm2'
7
3
  import { memoryUsage } from 'node:process'
4
+ import JSONTag from '@muze-nl/jsontag'
5
+ import {source, isProxy, resultSet} from '@muze-nl/od-jsontag/src/symbols.mjs'
6
+ import parse from '@muze-nl/od-jsontag/src/parse.mjs'
7
+ import * as FastJSONTag from '@muze-nl/od-jsontag/src/jsontag.mjs'
8
+ import {_,from,not,anyOf,allOf,asc,desc,sum,count,avg,max,min} from 'jaqt'
8
9
 
9
- let resultSet = []
10
+ let resultArr = []
10
11
  let dataspace
11
12
  let meta = {}
12
13
  let metaProxy = {
@@ -18,7 +19,7 @@ const metaIdProxy = {
18
19
  get: (id) => {
19
20
  let index = meta.index.id.get(id)
20
21
  if (index || index===0) {
21
- return resultSet[index]
22
+ return resultArr[index]
22
23
  }
23
24
  },
24
25
  has: (id) => {
@@ -26,18 +27,10 @@ const metaIdProxy = {
26
27
  }
27
28
  }
28
29
 
29
- const FastJSONTag = {
30
- getType: (obj) => JSONTag.getType(obj?.[source]),
31
- getAttribute: (obj, attr) => JSONTag.getAttribute(obj?.[source],attr),
32
- getAttributes: (obj) => JSONTag.getAttributes(obj?.[source]),
33
- getAttributeString: (obj) => JSONTag.getAttributesString(obj?.[source]),
34
- getTypeString: (obj) => JSONTag.getTypeString(obj?.[source])
35
- }
36
-
37
30
  const tasks = {
38
31
  init: async (task) => {
39
- resultSet = fastParse(task.req.body)
40
- dataspace = resultSet[0]
32
+ dataspace = parse(task.req.body)
33
+ resultArr = dataspace[resultSet]
41
34
  meta = task.req.meta
42
35
  metaProxy.index.id = metaIdProxy
43
36
  //@TODO: add references and baseURL