Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

18 changes: 18 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @ts-check

import { configs } from "@js-soft/eslint-config-ts";
import { globalIgnores } from "eslint/config";
import tseslint from "typescript-eslint";

export default tseslint.config(globalIgnores(["**/dist", "**/node_modules"]), {
extends: [configs.base, configs.jest],
languageOptions: {
parserOptions: {
project: ["./tsconfig.eslint.json", "./packages/*/tsconfig.json", "./packages/*/test/tsconfig.json"]
}
},
files: ["**/*.ts"],
rules: {
"jest/max-nested-describe": ["error", { max: 3 }]
}
});
1,068 changes: 579 additions & 489 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"build": "npm run build --workspaces",
"build:watch": "tsc -b -w packages/*",
"lint": "npm run lint:prettier && npm run lint:eslint && npm run lint:tsc",
"lint:eslint": "eslint --ext .ts ./packages/*/src ./packages/*/test",
"lint:eslint": "eslint",
"lint:prettier": "prettier --check .",
"lint:tsc": "npm run build --workspaces",
"test:local": "npm run test:local --workspaces --if-present"
},
"devDependencies": {
"@js-soft/eslint-config-ts": "1.6.14",
"@js-soft/eslint-config-ts": "2.0.1",
"@js-soft/license-check": "1.0.9",
"@types/jest": "^30.0.0",
"@types/node": "^24.0.10",
"eslint": "^8.57.1",
"@types/node": "^24.0.14",
"eslint": "^9.31.0",
"jest": "^30.0.4",
"prettier": "^3.6.2",
"ts-jest": "^29.4.0",
Expand Down
18 changes: 2 additions & 16 deletions packages/abstractions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"lib": ["esnext", "dom"]
"outDir": "dist"
},
"include": ["src/**/*.ts"]
}
55 changes: 27 additions & 28 deletions packages/loki/test/DatabaseCollection.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { afterAll, beforeAll, describe, expect, test } from "@jest/globals";
import { LokiJsCollectionProvider, LokiJsConnection } from "../src";

const connection = LokiJsConnection.inMemory();
Expand All @@ -22,8 +21,8 @@ describe("DatabaseCollection", () => {
const entry = { id: "test", name: "testtest" };

const createdEntry = await db.create(entry);
expect(createdEntry.id).toEqual(entry.id);
expect(createdEntry.name).toEqual(entry.name);
expect(createdEntry.id).toBe(entry.id);
expect(createdEntry.name).toBe(entry.name);

await db.create({ id: "test2", name: "asd" });

Expand All @@ -32,10 +31,10 @@ describe("DatabaseCollection", () => {

const queriedEntries = await db.find({ id: { $eq: "test" } });
expect(queriedEntries).toHaveLength(1);
expect(queriedEntries[0].name).toEqual(entry.name);
expect(queriedEntries[0].name).toBe(entry.name);

const queriedEntry = await db.findOne({ id: { $eq: "test" } });
expect(queriedEntry.name).toEqual(entry.name);
expect(queriedEntry.name).toBe(entry.name);
});

test("should query elements", async function () {
Expand Down Expand Up @@ -92,9 +91,9 @@ describe("DatabaseCollection", () => {
await db.create({ id: "test2", value: "test2" });

const value = await db.findOne({ id: "test" });
expect(value).not.toBeUndefined();
expect(value.value).not.toBeUndefined();
expect(value.value).toEqual("test");
expect(value).toBeDefined();
expect(value.value).toBeDefined();
expect(value.value).toBe("test");
});

test("should update a value", async function () {
Expand All @@ -105,45 +104,45 @@ describe("DatabaseCollection", () => {
await db.update(value, { id: "test", value: "test" });

const queriedValue = await db.findOne({ id: "test" });
expect(queriedValue).not.toBeUndefined();
expect(queriedValue.value).not.toBeUndefined();
expect(queriedValue.value).toEqual("test");
expect(queriedValue).toBeDefined();
expect(queriedValue.value).toBeDefined();
expect(queriedValue.value).toBe("test");
});

test("should get the count of objects", async function () {
const db = await getRandomCollection();

let count = await db.count();
expect(count).toStrictEqual(0);
expect(count).toBe(0);

await db.create({ id: "test", value: "a-string" });
await db.create({ id: "test", value: "a-string" });
await db.create({ id: "test", value: "another-string" });

count = await db.count();
expect(count).toStrictEqual(3);
expect(count).toBe(3);

count = await db.count({ value: "a-string" });
expect(count).toStrictEqual(2);
expect(count).toBe(2);
});

test("should check if objects exist", async function () {
const db = await getRandomCollection();

let exists = await db.exists({});
expect(exists).toStrictEqual(false);
expect(exists).toBe(false);

await db.create({ id: "test", value: "a-string" });
await db.create({ id: "test", value: "a-string" });

exists = await db.exists();
expect(exists).toStrictEqual(true);
expect(exists).toBe(true);

exists = await db.exists({ value: "a-string" });
expect(exists).toStrictEqual(true);
expect(exists).toBe(true);

exists = await db.exists({ value: "another-string" });
expect(exists).toStrictEqual(false);
expect(exists).toBe(false);
});

test("should query with paging", async () => {
Expand All @@ -158,8 +157,8 @@ describe("DatabaseCollection", () => {
const find2 = await db.find(undefined, { skip: 1, limit: 1 });
expect(find2).toHaveLength(1);

expect(find1[0].id).not.toEqual(find2[0].id);
expect(find1[0].value).not.toEqual(find2[0].value);
expect(find1[0].id).not.toBe(find2[0].id);
expect(find1[0].value).not.toBe(find2[0].value);
});

test("should sort ascending", async () => {
Expand All @@ -171,8 +170,8 @@ describe("DatabaseCollection", () => {
const find = await db.find(undefined, undefined, { sortBy: "value", sortOrder: "asc" });
expect(find).toHaveLength(2);

expect(find[0].id).toEqual("id1");
expect(find[1].id).toEqual("id2");
expect(find[0].id).toBe("id1");
expect(find[1].id).toBe("id2");
});

test("should sort descending", async () => {
Expand All @@ -184,8 +183,8 @@ describe("DatabaseCollection", () => {
const find = await db.find(undefined, undefined, { sortBy: "value", sortOrder: "desc" });
expect(find).toHaveLength(2);

expect(find[0].id).toEqual("id2");
expect(find[1].id).toEqual("id1");
expect(find[0].id).toBe("id2");
expect(find[1].id).toBe("id1");
});

test("should query with paging and sorting ascending", async () => {
Expand All @@ -196,11 +195,11 @@ describe("DatabaseCollection", () => {

const find1 = await db.find(undefined, { skip: 0, limit: 1 }, { sortBy: "value", sortOrder: "asc" });
expect(find1).toHaveLength(1);
expect(find1[0].id).toEqual("id1");
expect(find1[0].id).toBe("id1");

const find2 = await db.find(undefined, { skip: 1, limit: 1 }, { sortBy: "value", sortOrder: "asc" });
expect(find2).toHaveLength(1);
expect(find2[0].id).toEqual("id2");
expect(find2[0].id).toBe("id2");
});

test("should query with paging and sorting descending", async () => {
Expand All @@ -211,11 +210,11 @@ describe("DatabaseCollection", () => {

const find1 = await db.find(undefined, { skip: 0, limit: 1 }, { sortBy: "value", sortOrder: "desc" });
expect(find1).toHaveLength(1);
expect(find1[0].id).toEqual("id2");
expect(find1[0].id).toBe("id2");

const find2 = await db.find(undefined, { skip: 1, limit: 1 }, { sortBy: "value", sortOrder: "desc" });
expect(find2).toHaveLength(1);
expect(find2[0].id).toEqual("id1");
expect(find2[0].id).toBe("id1");
});

test("should not allow to create duplicate entries for unique index", async function () {
Expand Down
15 changes: 7 additions & 8 deletions packages/loki/test/DatabaseMap.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { afterAll, beforeAll, describe, expect, test } from "@jest/globals";
import { LokiJsCollectionProvider, LokiJsConnection } from "../src";

const connection = LokiJsConnection.inMemory();
Expand All @@ -23,7 +22,7 @@ describe("DatabaseMap", () => {
await db.set("test", value);

const queried = await db.get("test");
expect(queried).not.toBeUndefined();
expect(queried).toBeDefined();
expect(queried).toStrictEqual(value);
});

Expand All @@ -35,13 +34,13 @@ describe("DatabaseMap", () => {
await db.set("ttest2", { size: 3, name: "test" });

const queriedList = await db.list();
expect(queriedList).not.toBeUndefined();
expect(queriedList).toBeDefined();
expect(queriedList).toHaveLength(3);

const filteredList = await db.find("ttest");
expect(filteredList).not.toBeUndefined();
expect(filteredList).toBeDefined();
expect(filteredList).toHaveLength(1);
expect(filteredList[0].value.size).toEqual(3);
expect(filteredList[0].value.size).toBe(3);
});

test("should find a value by regex", async function () {
Expand All @@ -54,7 +53,7 @@ describe("DatabaseMap", () => {
await db.set("key", value);

const filteredList = await db.find("^k.*");
expect(filteredList).not.toBeUndefined();
expect(filteredList).toBeDefined();
expect(filteredList).toHaveLength(1);
expect(filteredList[0].value).toStrictEqual(value);
});
Expand Down Expand Up @@ -86,9 +85,9 @@ describe("DatabaseMap", () => {
const db = await getRandomMap();

await db.set("test", "test");
expect(await db.get("test")).toEqual("test");
expect(await db.get("test")).toBe("test");

await db.set("test", "test2");
expect(await db.get("test")).toEqual("test2");
expect(await db.get("test")).toBe("test2");
});
});
23 changes: 3 additions & 20 deletions packages/loki/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"lib": ["esnext", "dom"],
"baseUrl": "../",
"paths": {
"chaimodule": ["./test/types/globalsals"]
}
"noEmit": true,
"baseUrl": "../"
},
"include": ["**/*.ts"]
}
18 changes: 2 additions & 16 deletions packages/loki/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"lib": ["esnext", "dom"]
"outDir": "dist"
},
"include": ["src/**/*.ts"]
}
Loading