@muze-nl/simplystore 0.6.22 → 0.6.24

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.22",
3
+ "version": "0.6.24",
4
4
  "main": "src/server.mjs",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  "@muze-nl/od-jsontag": "^0.2.9",
21
21
  "codemirror": "^6.0.1",
22
22
  "express": "^4.18.1",
23
- "@muze-nl/jaqt": "^0.9.6",
23
+ "@muze-nl/jaqt": "^0.9.7",
24
24
  "json-pointer": "^0.6.2",
25
25
  "jsonpath-plus": "^7.2.0",
26
26
  "vm2": "^3.9.13",
@@ -160,6 +160,11 @@ export function runQuery(pointer, request, query) {
160
160
  if (!response.code) {
161
161
  if (response.jsontag) {
162
162
  try {
163
+ // JSONTag.stringify doesn't handle tagName/attributes well
164
+ // with od-jsontag, since some entries in result haven't been parsed yet
165
+ // only after parsing will these be available
166
+ // so force parsing of all result - od-jsontag should have its own stringify
167
+ parseAllObjects(result)
163
168
  response.body = JSONTag.stringify(result)
164
169
  } catch(err) {
165
170
  console.log(err)
@@ -174,6 +179,33 @@ export function runQuery(pointer, request, query) {
174
179
  return response
175
180
  }
176
181
 
182
+ let seen = new WeakMap()
183
+ function parseAllObjects(o, reset=true) {
184
+ if (reset) {
185
+ seen = new WeakMap()
186
+ }
187
+ if (seen.has(o)) {
188
+ return
189
+ }
190
+ if (o && typeof o == 'object') {
191
+ let temp = o[source]
192
+ seen.set(o, true)
193
+ if (Array.isArray(o)) {
194
+ for (let v of o) {
195
+ if (v && typeof v == 'object') {
196
+ parseAllObjects(v, false)
197
+ }
198
+ }
199
+ } else if (o && typeof o == 'object') {
200
+ for (let k of Object.keys(o)) {
201
+ if (o[k] && typeof o[k]=='object') {
202
+ parseAllObjects(o[k], false)
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+
177
209
  export function getDataSpace(path, dataspace) {
178
210
  if (path.substring(path.length-1)==='/') {
179
211
  //jsonpointer doesn't allow a trailing '/'