@instantdb/core
Advanced tools
Comparing version 0.14.20 to 0.14.21
@@ -29,2 +29,18 @@ import { test, expect } from "vitest"; | ||
test("ignores id attrs", () => { | ||
const testId = uuid(); | ||
const ops = instatx.tx.books[testId].update({ title: "New Title", id: 'ploop' }); | ||
const result = instaml.transform(zenecaAttrs, ops); | ||
const expected = [ | ||
["add-triple", testId, zenecaAttrToId["books/title"], "New Title"], | ||
["add-triple", testId, zenecaAttrToId["books/id"], testId], | ||
]; | ||
expect(result).toHaveLength(expected.length); | ||
for (const item of expected) { | ||
expect(result).toContainEqual(item); | ||
} | ||
}); | ||
test("optimistically adds attrs if they don't exist", () => { | ||
@@ -681,1 +697,2 @@ const testId = uuid(); | ||
}); | ||
@@ -193,3 +193,13 @@ "use strict"; | ||
} | ||
function toTxSteps(attrs, [action, ...args]) { | ||
function removeIdFromArgs(step) { | ||
const [op, etype, eid, obj] = step; | ||
if (!obj) { | ||
return step; | ||
} | ||
const newObj = Object.assign({}, obj); | ||
delete newObj.id; | ||
return [op, etype, eid, newObj]; | ||
} | ||
function toTxSteps(attrs, step) { | ||
const [action, ...args] = removeIdFromArgs(step); | ||
switch (action) { | ||
@@ -196,0 +206,0 @@ case "merge": |
@@ -184,3 +184,13 @@ import { getOps, isLookup, parseLookup } from "./instatx"; | ||
} | ||
function toTxSteps(attrs, [action, ...args]) { | ||
function removeIdFromArgs(step) { | ||
const [op, etype, eid, obj] = step; | ||
if (!obj) { | ||
return step; | ||
} | ||
const newObj = Object.assign({}, obj); | ||
delete newObj.id; | ||
return [op, etype, eid, newObj]; | ||
} | ||
function toTxSteps(attrs, step) { | ||
const [action, ...args] = removeIdFromArgs(step); | ||
switch (action) { | ||
@@ -187,0 +197,0 @@ case "merge": |
{ | ||
"name": "@instantdb/core", | ||
"version": "v0.14.20", | ||
"version": "v0.14.21", | ||
"description": "Instant's core local abstraction", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -210,4 +210,14 @@ import { getOps, isLookup, parseLookup } from "./instatx"; | ||
} | ||
function removeIdFromArgs(step) { | ||
const [op, etype, eid, obj] = step; | ||
if (!obj) { | ||
return step; | ||
} | ||
const newObj = {...obj}; | ||
delete newObj.id | ||
return [op, etype, eid, newObj] | ||
} | ||
function toTxSteps(attrs, [action, ...args]) { | ||
function toTxSteps(attrs, step) { | ||
const [action, ...args] = removeIdFromArgs(step); | ||
switch (action) { | ||
@@ -214,0 +224,0 @@ case "merge": |
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 too big to display
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
2362571
42019