instant-local-throwaway
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -136,1 +136,30 @@ import zenecaTriples from "../data/zenecaTriples.json"; | ||
}); | ||
test("Nested Where", () => { | ||
expect( | ||
query( | ||
{ | ||
user: { | ||
$: { where: { handle: "nicolegf" } }, | ||
bookshelf: { | ||
$: { where: { name: "Poetry" } }, | ||
}, | ||
}, | ||
}, | ||
db | ||
) | ||
).toEqual({ | ||
user: [ | ||
{ | ||
bookshelf: [ | ||
{ desc: "", id: "622-7", name: "Poetry", order: 7 }, | ||
], | ||
createdAt: "2021-02-05 22:35:23.754264", | ||
email: "nicolegrf9@gmail.com", | ||
fullName: "Nicole Garcia Fischer", | ||
handle: "nicolegf", | ||
id: "622", | ||
}, | ||
], | ||
}); | ||
}); |
{ | ||
"name": "instant-local-throwaway", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "This is an experiment for instant", | ||
"main": "index.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.es.js", | ||
"unpkg": "dist/index.js", | ||
"scripts": { | ||
"test": "jest", | ||
"build": "rollup -c", | ||
"script:generateTriples": "node scripts/generateTriples/generateTriples.js" | ||
@@ -13,2 +16,5 @@ }, | ||
"@babel/preset-env": "^7.16.11", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^22.0.0", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"babel-jest": "^27.5.1", | ||
@@ -18,7 +24,8 @@ "camelcase": "^5.3.1", | ||
"jest": "^28.0.3", | ||
"lodash": "^4.17.21" | ||
"lodash": "^4.17.21", | ||
"rollup": "^2.72.1" | ||
}, | ||
"dependencies": { | ||
"react": "^18.1.0" | ||
"peerDependencies": { | ||
"react": ">=16" | ||
} | ||
} |
@@ -77,2 +77,2 @@ // 1. patternMatch | ||
return Object.values(db.entityIndex); | ||
} | ||
} |
import * as datalog from "./datalog"; | ||
import * as tripleDB from "./db"; | ||
@@ -4,0 +3,0 @@ import { isAttrJoinFor, makeJoinAttr } from "./instaql"; |
@@ -1,2 +0,4 @@ | ||
import * as datalogDB from "./db"; | ||
import { useState, useEffect } from "react"; | ||
import * as tripleDB from "./db"; | ||
import * as instaql from "./instaql"; | ||
@@ -8,3 +10,3 @@ import * as instaml from "./instaml"; | ||
_token: null, | ||
_current: datalogDB.createDB([]), | ||
_current: tripleDB.createDB([]), | ||
_subs: {}, | ||
@@ -24,3 +26,3 @@ subscribe(f) { | ||
export function useInit(useState, useEffect, { token }) { | ||
export function useInit({ token }) { | ||
const [isLoading, setIsLoading] = useState(true); | ||
@@ -31,3 +33,3 @@ useEffect(() => { | ||
ws.onmessage = function (event) { | ||
db.change(datalogDB.createDB(JSON.parse(event.data))); | ||
db.change(tripleDB.createDB(JSON.parse(event.data))); | ||
setIsLoading(false); | ||
@@ -42,3 +44,3 @@ }; | ||
export function useQuery(useState, useEffect, q) { | ||
export function useQuery(q) { | ||
const [state, setState] = useState(instaql.query(q, db._current)); | ||
@@ -59,3 +61,3 @@ useEffect(() => { | ||
const ts = instaml.transform(mutations, newDb); | ||
datalogDB.save(ts, newDb); | ||
tripleDB.save(ts, newDb); | ||
fetch("https://instant-server.herokuapp.com/api/transact", { | ||
@@ -62,0 +64,0 @@ method: "POST", |
import * as datalog from "./datalog"; | ||
import intersection from "lodash/intersection"; | ||
@@ -104,2 +105,17 @@ function makeVar(k) { | ||
function getRefEids(top, eid, refNamespace, query, db) { | ||
const eids = datalog.query(makeFindRefQuery(top, eid, refNamespace), db) | ||
/** | ||
* For a nested where, we naively search like it's a top-level query | ||
* A simple optimization, would be to contraint this query, by the `eids` | ||
* above. I am intentionally avoiding it, to keep the code simple | ||
* | ||
* We would do something different for a production version. | ||
*/ | ||
const where = datalog.query(buildWhereQuery(refNamespace, query.$?.where), db); | ||
return new Set(intersection(eids, where)); | ||
} | ||
function expandSelect(top, query, db, eid) { | ||
@@ -112,5 +128,3 @@ const attrTups = hackFilterForJustAttribute( | ||
refNamespaces.forEach((refNamespace) => { | ||
const refEids = new Set( | ||
datalog.query(makeFindRefQuery(top, eid, refNamespace), db) | ||
); | ||
const refEids = getRefEids(top, eid, refNamespace, query[refNamespace], db); | ||
m[refNamespace] = [...refEids].map((refEid) => | ||
@@ -117,0 +131,0 @@ expandSelect(refNamespace, query[refNamespace], db, refEid) |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
1792156
27
27529
11
5
+ Addedreact@19.0.0(transitive)
- Removedreact@^18.1.0
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedreact@18.3.1(transitive)