Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

instant-local-throwaway

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instant-local-throwaway - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

__tests__/instant-local/data/movieTriples.json

8

dist/instant.d.ts

@@ -1,3 +0,5 @@

declare type Config = {
declare type UserConfig = {
token: string;
websocketURI?: string;
httpURI?: string;
defaults?: {

@@ -9,5 +11,5 @@ [connectionA: string]: {

};
export declare function useInit(config: Config): boolean;
export declare function useInit(_config: UserConfig): boolean;
export declare function useQuery(_q: Object): {
[k: string]: any[];
[k: string]: any;
};

@@ -14,0 +16,0 @@ export declare const tx: any;

@@ -38,3 +38,3 @@ "use strict";

const db = {
_config: null,
_config: undefined,
_current: tripleDB.createDB([]),

@@ -55,7 +55,11 @@ _subs: {},

};
function useInit(config) {
function configWithDefaults(c) {
return Object.assign({ websocketURI: "wss://instant-server.herokuapp.com", httpURI: "https://instant-server.herokuapp.com/api" }, c);
}
function useInit(_config) {
const config = configWithDefaults(_config);
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
(0, react_1.useEffect)(() => {
db._config = config;
const ws = new WebSocket("wss://instant-server.herokuapp.com", null);
const ws = new WebSocket(config.websocketURI);
ws.onmessage = function (event) {

@@ -108,11 +112,11 @@ db.change(tripleDB.createDB(JSON.parse(event.data)));

function transact(ts) {
var _a;
var _a, _b;
const newDb = Object.assign({}, db._current);
const datalogTs = instaml.transform(instaml.isOp(ts) ? [ts] : ts, newDb);
tripleDB.save(datalogTs, newDb);
fetch("https://instant-server.herokuapp.com/api/transact", {
fetch(`${(_a = db._config) === null || _a === void 0 ? void 0 : _a.httpURI}/transact`, {
method: "POST",
headers: {
"content-type": "application/json",
authorization: `Bearer ${(_a = db._config) === null || _a === void 0 ? void 0 : _a.token}`,
authorization: `Bearer ${(_b = db._config) === null || _b === void 0 ? void 0 : _b.token}`,
},

@@ -119,0 +123,0 @@ body: JSON.stringify({ transactions: datalogTs }),

@@ -12,4 +12,4 @@ export function isAttrJoinFor(attr: any, namespaceB: any): any;

export function query(form: any, db: any): {
[k: string]: any[];
[k: string]: any;
};
//# sourceMappingURL=instaql.d.ts.map

@@ -208,8 +208,14 @@ "use strict";

function query(form, db) {
return Object.fromEntries(Object.keys(form).map((top) => [
top,
queryPart({ namespace: top, query: form[top], db: db }),
]));
return Object.fromEntries(Object.keys(form).map((top) => {
var _a;
// TODO: right now there are two functions: `queryPart`, which handles the top level,
// and `expandSelect`, which recursively handles children.
// Perhaps there's some nicer recursion that can move them together?
const q = form[top];
const namespace = ((_a = q.$) === null || _a === void 0 ? void 0 : _a.as) || top;
const objs = queryPart({ namespace, query: q, db: db });
return [top, modifyWithCardinality(objs, q)];
}));
}
exports.query = query;
//# sourceMappingURL=instaql.js.map

@@ -1,3 +0,5 @@

declare type Config = {
declare type UserConfig = {
token: string;
websocketURI?: string;
httpURI?: string;
defaults?: {

@@ -9,5 +11,5 @@ [connectionA: string]: {

};
export declare function useInit(config: Config): boolean;
export declare function useInit(_config: UserConfig): boolean;
export declare function useQuery(_q: Object): {
[k: string]: any[];
[k: string]: any;
};

@@ -14,0 +16,0 @@ export declare const tx: any;

@@ -9,3 +9,3 @@ import { useState, useEffect } from "react";

const db = {
_config: null,
_config: undefined,
_current: tripleDB.createDB([]),

@@ -26,7 +26,11 @@ _subs: {},

};
export function useInit(config) {
function configWithDefaults(c) {
return Object.assign({ websocketURI: "wss://instant-server.herokuapp.com", httpURI: "https://instant-server.herokuapp.com/api" }, c);
}
export function useInit(_config) {
const config = configWithDefaults(_config);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
db._config = config;
const ws = new WebSocket("wss://instant-server.herokuapp.com", null);
const ws = new WebSocket(config.websocketURI);
ws.onmessage = function (event) {

@@ -77,11 +81,11 @@ db.change(tripleDB.createDB(JSON.parse(event.data)));

export function transact(ts) {
var _a;
var _a, _b;
const newDb = Object.assign({}, db._current);
const datalogTs = instaml.transform(instaml.isOp(ts) ? [ts] : ts, newDb);
tripleDB.save(datalogTs, newDb);
fetch("https://instant-server.herokuapp.com/api/transact", {
fetch(`${(_a = db._config) === null || _a === void 0 ? void 0 : _a.httpURI}/transact`, {
method: "POST",
headers: {
"content-type": "application/json",
authorization: `Bearer ${(_a = db._config) === null || _a === void 0 ? void 0 : _a.token}`,
authorization: `Bearer ${(_b = db._config) === null || _b === void 0 ? void 0 : _b.token}`,
},

@@ -88,0 +92,0 @@ body: JSON.stringify({ transactions: datalogTs }),

@@ -12,4 +12,4 @@ export function isAttrJoinFor(attr: any, namespaceB: any): any;

export function query(form: any, db: any): {
[k: string]: any[];
[k: string]: any;
};
//# sourceMappingURL=instaql.d.ts.map

@@ -175,7 +175,13 @@ import * as datalog from "./datalog";

export function query(form, db) {
return Object.fromEntries(Object.keys(form).map((top) => [
top,
queryPart({ namespace: top, query: form[top], db: db }),
]));
return Object.fromEntries(Object.keys(form).map((top) => {
var _a;
// TODO: right now there are two functions: `queryPart`, which handles the top level,
// and `expandSelect`, which recursively handles children.
// Perhaps there's some nicer recursion that can move them together?
const q = form[top];
const namespace = ((_a = q.$) === null || _a === void 0 ? void 0 : _a.as) || top;
const objs = queryPart({ namespace, query: q, db: db });
return [top, modifyWithCardinality(objs, q)];
}));
}
//# sourceMappingURL=instaql.js.map
{
"name": "instant-local-throwaway",
"version": "1.0.8",
"version": "1.0.9",
"description": "This is an experiment for instant",

@@ -10,6 +10,6 @@ "main": "dist/index.js",

"test": "jest",
"sync": "./sync.sh",
"build": "rm -rf dist; npm run build:main && npm run build:module",
"build:main": "tsc -p tsconfig.json",
"build:module": "tsc -p tsconfig.module.json",
"script:generateTriples": "node scripts/generateTriples/generateTriples.js"
"build:module": "tsc -p tsconfig.module.json"
},

@@ -19,5 +19,2 @@ "devDependencies": {

"@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",
"@types/lodash": "^4.14.182",

@@ -24,0 +21,0 @@ "@types/react": "^18.0.9",

@@ -5,7 +5,14 @@ # instant-local

Note: We regularly _sync_ code from `www` into here.
```
npm i
npm i
npm run sync
npm run test
```
Want to play with this E2E? Go on over to `../ex/web-app`.
Want to play with this E2E? Just run www!
Helpful links:
- [InstaQL + InstaML documentation](https://paper.dropbox.com/doc/InstaQL-Private--BiM7OMI01x66UWjRaRyCbIk2Ag-yVxntbv98aeAovazd9TNL)
{
"include": ["src"],
"include": ["instant-local"],
"exclude": ["node_modules/**/*.ts"],

@@ -9,3 +9,3 @@ "compilerOptions": {

"outDir": "dist",
"rootDir": "src",
"rootDir": "instant-local",
"sourceMap": true,

@@ -12,0 +12,0 @@ "target": "es2015",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc