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

@instantdb/core

Package Overview
Dependencies
Maintainers
5
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@instantdb/core - npm Package Compare versions

Comparing version 0.12.12 to 0.12.13

.turbo/turbo-test$colon$ci.log

77

__tests__/src/instaml.test.js

@@ -92,1 +92,78 @@ import { test, expect } from "vitest";

});
test("it doesn't create duplicate ref attrs", () => {
const aid = uuid();
const bid = uuid();
const ops = [
instatx.tx.nsA[aid].update({}).link({ nsB: bid }),
instatx.tx.nsB[bid].update({}).link({ nsA: aid }),
];
expect(instaml.transform({}, ops)).toEqual([
[
"add-attr",
{
cardinality: "one",
"forward-identity": [expect.any(String), "nsA", "id"],
id: expect.any(String),
"index?": false,
isUnsynced: true,
"unique?": false,
"value-type": "blob",
},
],
[
"add-attr",
{
cardinality: "one",
"forward-identity": [expect.any(String), "nsB", "id"],
id: expect.any(String),
"index?": false,
isUnsynced: true,
"unique?": false,
"value-type": "blob",
},
],
[
"add-attr",
{
cardinality: "many",
"forward-identity": [expect.any(String), "nsA", "nsB"],
id: expect.any(String),
"index?": false,
isUnsynced: true,
"reverse-identity": [expect.any(String), "nsB", "nsA"],
"unique?": false,
"value-type": "ref",
},
],
[
"add-attr",
{
cardinality: "one",
"forward-identity": [expect.any(String), "nsA", "id"],
id: expect.any(String),
"index?": false,
isUnsynced: true,
"unique?": false,
"value-type": "blob",
},
],
[
"add-attr",
{
cardinality: "one",
"forward-identity": [expect.any(String), "nsB", "id"],
id: expect.any(String),
"index?": false,
isUnsynced: true,
"unique?": false,
"value-type": "blob",
},
],
["add-triple", aid, expect.any(String), aid],
["add-triple", aid, expect.any(String), bid],
["add-triple", bid, expect.any(String), bid],
["add-triple", aid, expect.any(String), bid],
]);
});

20

dist/instaml.js

@@ -224,9 +224,15 @@ "use strict";

const objectIdents = uniqueIdents(objectOps.flatMap(extractIdents));
const missingIdents = objectIdents.filter(([etype, label]) => !getAttrByFwdIdentName(attrs, etype, label) &&
!getAttrByReverseIdentName(attrs, etype, label));
const refAttrs = missingIdents.map(createRefAttr);
const newAttrs = refAttrs.reduce((acc, attr) => {
acc[attr.id] = attr;
return acc;
}, Object.assign({}, attrs));
const { refAttrs, newAttrs } = objectIdents.reduce(({ newAttrs, refAttrs }, missingIdent) => {
const [etype, label] = missingIdent;
if (!getAttrByFwdIdentName(newAttrs, etype, label) &&
!getAttrByReverseIdentName(newAttrs, etype, label)) {
const attr = createRefAttr(missingIdent);
newAttrs[attr.id] = attr;
refAttrs.push(attr);
}
return { newAttrs, refAttrs };
}, {
newAttrs: Object.assign({}, attrs),
refAttrs: [],
});
const attrTxSteps = refAttrs.map((attr) => ["add-attr", attr]);

@@ -233,0 +239,0 @@ const localAttrs = objectIdents.flatMap(([etype, label]) => {

@@ -216,9 +216,15 @@ import { getOps, isLookup, parseLookup } from "./instatx";

const objectIdents = uniqueIdents(objectOps.flatMap(extractIdents));
const missingIdents = objectIdents.filter(([etype, label]) => !getAttrByFwdIdentName(attrs, etype, label) &&
!getAttrByReverseIdentName(attrs, etype, label));
const refAttrs = missingIdents.map(createRefAttr);
const newAttrs = refAttrs.reduce((acc, attr) => {
acc[attr.id] = attr;
return acc;
}, Object.assign({}, attrs));
const { refAttrs, newAttrs } = objectIdents.reduce(({ newAttrs, refAttrs }, missingIdent) => {
const [etype, label] = missingIdent;
if (!getAttrByFwdIdentName(newAttrs, etype, label) &&
!getAttrByReverseIdentName(newAttrs, etype, label)) {
const attr = createRefAttr(missingIdent);
newAttrs[attr.id] = attr;
refAttrs.push(attr);
}
return { newAttrs, refAttrs };
}, {
newAttrs: Object.assign({}, attrs),
refAttrs: [],
});
const attrTxSteps = refAttrs.map((attr) => ["add-attr", attr]);

@@ -225,0 +231,0 @@ const localAttrs = objectIdents.flatMap(([etype, label]) => {

@@ -287,2 +287,5 @@ // @ts-check

var _a, _b, _c, _d;
if (msg.op !== "ping") {
console.log("receive", msg);
}
switch (msg.op) {

@@ -673,2 +676,3 @@ case "init-ok":

_trySend(eventId, msg) {
console.log("send", this._ws.readyState !== WS_OPEN_STATUS, msg);
if (this._ws.readyState !== WS_OPEN_STATUS) {

@@ -675,0 +679,0 @@ return;

@@ -315,2 +315,5 @@ "use strict";

var _a, _b, _c, _d;
if (msg.op !== "ping") {
console.log("receive", msg);
}
switch (msg.op) {

@@ -701,2 +704,3 @@ case "init-ok":

_trySend(eventId, msg) {
console.log("send", this._ws.readyState !== WS_OPEN_STATUS, msg);
if (this._ws.readyState !== WS_OPEN_STATUS) {

@@ -703,0 +707,0 @@ return;

{
"name": "@instantdb/core",
"version": "0.12.12",
"version": "0.12.13",
"description": "Instant's core local abstraction",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -259,15 +259,24 @@ import { getOps, isLookup, parseLookup } from "./instatx";

const objectIdents = uniqueIdents(objectOps.flatMap(extractIdents));
const missingIdents = objectIdents.filter(
([etype, label]) =>
!getAttrByFwdIdentName(attrs, etype, label) &&
!getAttrByReverseIdentName(attrs, etype, label),
);
const refAttrs = missingIdents.map(createRefAttr);
const newAttrs = refAttrs.reduce(
(acc, attr) => {
acc[attr.id] = attr;
return acc;
const { refAttrs, newAttrs } = objectIdents.reduce(
({ newAttrs, refAttrs }, missingIdent) => {
const [etype, label] = missingIdent;
if (
!getAttrByFwdIdentName(newAttrs, etype, label) &&
!getAttrByReverseIdentName(newAttrs, etype, label)
) {
const attr = createRefAttr(missingIdent);
newAttrs[attr.id] = attr;
refAttrs.push(attr);
}
return { newAttrs, refAttrs };
},
{ ...attrs },
{
newAttrs: {
...attrs,
},
refAttrs: [],
},
);
const attrTxSteps = refAttrs.map((attr) => ["add-attr", attr]);

@@ -274,0 +283,0 @@

@@ -247,2 +247,5 @@ // @ts-check

_handleReceive(msg) {
if (msg.op !== "ping") {
console.log("receive", msg);
}
switch (msg.op) {

@@ -745,2 +748,3 @@ case "init-ok":

_trySend(eventId, msg) {
console.log("send", this._ws.readyState !== WS_OPEN_STATUS, msg);
if (this._ws.readyState !== WS_OPEN_STATUS) {

@@ -747,0 +751,0 @@ return;

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