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
206
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.17.0-experimental.5 to 0.17.0

23

__tests__/src/instaql.test.js

@@ -194,2 +194,25 @@ import { test, expect } from "vitest";

test("like case sensitivity", () => {
function runQuery(where) {
return query(
{ store },
{
users: {
$: {
where: {
fullName: where,
},
},
},
},
)
.data.users.map((x) => x.fullName)
.sort();
}
expect(runQuery({ $like: "%O%" })).toEqual([]);
expect(runQuery({ $ilike: "%O%" })).toEqual(["Joe Averbukh", "Nicole"]);
expect(runQuery({ $like: "%j%" })).toEqual([]);
expect(runQuery({ $ilike: "%j%" })).toEqual(["Joe Averbukh"]);
});
test("Where and", () => {

@@ -196,0 +219,0 @@ expect(

30

dist/instaql.js

@@ -98,8 +98,16 @@ "use strict";

}
function matchesLikePattern(value, pattern) {
if (typeof value !== "string" || typeof pattern !== "string")
return false;
function makeLikeMatcher(caseSensitive, pattern) {
if (typeof pattern !== "string") {
return function likeMatcher(_value) {
return false;
};
}
const regexPattern = pattern.replace(/%/g, ".*").replace(/_/g, ".");
const regex = new RegExp(`^${regexPattern}$`);
return regex.test(value);
const regex = new RegExp(`^${regexPattern}$`, caseSensitive ? undefined : "i");
return function likeMatcher(value) {
if (typeof value !== "string") {
return false;
}
return regex.test(value);
};
}

@@ -162,9 +170,19 @@ function parseValue(attr, v) {

if (v.hasOwnProperty("$like")) {
const matcher = makeLikeMatcher(true, v.$like);
return {
$comparator: true,
$op: function like(triple) {
return matchesLikePattern(triple[2], v.$like);
return matcher(triple[2]);
},
};
}
if (v.hasOwnProperty("$ilike")) {
const matcher = makeLikeMatcher(false, v.$ilike);
return {
$comparator: true,
$op: function ilike(triple) {
return matcher(triple[2]);
},
};
}
return v;

@@ -171,0 +189,0 @@ }

@@ -72,8 +72,16 @@ import { query as datalogQuery } from "./datalog";

}
function matchesLikePattern(value, pattern) {
if (typeof value !== "string" || typeof pattern !== "string")
return false;
function makeLikeMatcher(caseSensitive, pattern) {
if (typeof pattern !== "string") {
return function likeMatcher(_value) {
return false;
};
}
const regexPattern = pattern.replace(/%/g, ".*").replace(/_/g, ".");
const regex = new RegExp(`^${regexPattern}$`);
return regex.test(value);
const regex = new RegExp(`^${regexPattern}$`, caseSensitive ? undefined : "i");
return function likeMatcher(value) {
if (typeof value !== "string") {
return false;
}
return regex.test(value);
};
}

@@ -136,9 +144,19 @@ function parseValue(attr, v) {

if (v.hasOwnProperty("$like")) {
const matcher = makeLikeMatcher(true, v.$like);
return {
$comparator: true,
$op: function like(triple) {
return matchesLikePattern(triple[2], v.$like);
return matcher(triple[2]);
},
};
}
if (v.hasOwnProperty("$ilike")) {
const matcher = makeLikeMatcher(false, v.$ilike);
return {
$comparator: true,
$op: function ilike(triple) {
return matcher(triple[2]);
},
};
}
return v;

@@ -145,0 +163,0 @@ }

1

dist/module/queryTypes.d.ts

@@ -19,2 +19,3 @@ import type { EntitiesDef, IContainEntitiesAndLinks, InstantGraph, LinkAttrDef, ResolveAttrs, ResolveEntityAttrs } from "./schemaTypes";

$like?: string;
$ilike?: string;
};

@@ -21,0 +22,0 @@ type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;

export default version;
declare const version: "0.17.0-experimental.5";
declare const version: "v0.17.0";
//# sourceMappingURL=version.d.ts.map
// Autogenerated by publish_packages.clj
const version = "0.17.0-experimental.5";
const version = "v0.17.0";
export default version;
//# sourceMappingURL=version.js.map

@@ -19,2 +19,3 @@ import type { EntitiesDef, IContainEntitiesAndLinks, InstantGraph, LinkAttrDef, ResolveAttrs, ResolveEntityAttrs } from "./schemaTypes";

$like?: string;
$ilike?: string;
};

@@ -21,0 +22,0 @@ type WhereClauseValue = string | number | boolean | NonEmpty<WhereArgs>;

export default version;
declare const version: "0.17.0-experimental.5";
declare const version: "v0.17.0";
//# sourceMappingURL=version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Autogenerated by publish_packages.clj
const version = "0.17.0-experimental.5";
const version = "v0.17.0";
exports.default = version;
//# sourceMappingURL=version.js.map
{
"name": "@instantdb/core",
"version": "0.17.0-experimental.5",
"version": "v0.17.0",
"description": "Instant's core local abstraction",

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

@@ -91,7 +91,19 @@ import { query as datalogQuery } from "./datalog";

function matchesLikePattern(value, pattern) {
if (typeof value !== "string" || typeof pattern !== "string") return false;
function makeLikeMatcher(caseSensitive, pattern) {
if (typeof pattern !== "string") {
return function likeMatcher(_value) {
return false;
};
}
const regexPattern = pattern.replace(/%/g, ".*").replace(/_/g, ".");
const regex = new RegExp(`^${regexPattern}$`);
return regex.test(value);
const regex = new RegExp(
`^${regexPattern}$`,
caseSensitive ? undefined : "i",
);
return function likeMatcher(value) {
if (typeof value !== "string") {
return false;
}
return regex.test(value);
};
}

@@ -161,6 +173,7 @@

if (v.hasOwnProperty("$like")) {
const matcher = makeLikeMatcher(true, v.$like);
return {
$comparator: true,
$op: function like(triple) {
return matchesLikePattern(triple[2], v.$like);
return matcher(triple[2]);
},

@@ -170,2 +183,12 @@ };

if (v.hasOwnProperty("$ilike")) {
const matcher = makeLikeMatcher(false, v.$ilike);
return {
$comparator: true,
$op: function ilike(triple) {
return matcher(triple[2]);
},
};
}
return v;

@@ -172,0 +195,0 @@ }

@@ -35,2 +35,3 @@ // Query

$like?: string;
$ilike?: string;
};

@@ -37,0 +38,0 @@

// Autogenerated by publish_packages.clj
const version = "0.17.0-experimental.5";
const version = "v0.17.0";
export default version;

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 too big to display

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