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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"prepare": "tsc"
},
"dependencies": {
"tsx": "^4.19.2",
"typescript": "^5.7.3"
},
"devDependencies": {
Expand All @@ -21,6 +20,7 @@
"jest": "^29.7.0",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.7",
"ts-jest": "^29.2.5"
"ts-jest": "^29.2.5",
"tsx": "^4.19.2"
}
}
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions test/advanced-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ let postLoadCalled = false;
lastUpdated: { encoder: dateEncoder }
},
{
preSave: async (context, model) => {
preSave: async (_context, model) => {
preSaveCalled = true;
return model;
},
postSave: async (context, model) => {
postSave: async (_context, model) => {
postSaveCalled = true;
return model;
},
postLoad: async (context, model) => {
postLoad: async (_context, model) => {
postLoadCalled = true;
return model;
}
Expand Down Expand Up @@ -180,8 +180,8 @@ describe('Advanced Model Features', () => {

const allModels = await ComplexModel.all();
expect(allModels.length).toBeGreaterThanOrEqual(2);
expect(allModels[0].get("metadata")).toBeInstanceOf(Object);
expect(allModels[0].get("lastUpdated")).toBeInstanceOf(Date);
expect(allModels[0]?.get("metadata")).toBeInstanceOf(Object);
expect(allModels[0]?.get("lastUpdated")).toBeInstanceOf(Date);
expect(postLoadCalled).toBe(true);
});

Expand All @@ -196,7 +196,7 @@ describe('Advanced Model Features', () => {

const foundModel = await ComplexModel.getBy({ name: "Search Test" });
expect(foundModel).not.toBeNull();
expect(foundModel?.get("metadata").searchKey).toBe("findMe");
expect(foundModel?.get("metadata")?.searchKey).toBe("findMe");
expect(foundModel?.get("lastUpdated").getTime()).toBe(date.getTime());
expect(postLoadCalled).toBe(true);
});
Expand Down
2 changes: 1 addition & 1 deletion test/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('Model', () => {

const peopleAge45 = await Person.all({ age: 45 });
expect(peopleAge45.length).toBeGreaterThan(0);
expect(peopleAge45[0].get("age")).toBe(45);
expect(peopleAge45[0]?.get("age")).toBe(45);

const personByName = await Person.getBy({ firstName: "David" });
expect(personByName).not.toBeNull();
Expand Down
4 changes: 2 additions & 2 deletions test/sqlite-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AdapterConfig, Model, ModelAttributes, WithId } from "../src";
import { AdapterConfig, Model, ModelAttributes, WithId } from "../src/index";
import * as sqlite3 from "sqlite3";
import { Database, open } from "sqlite";

Expand Down Expand Up @@ -55,7 +55,7 @@ export function createSqliteAdapter<T extends ModelAttributes>(dbName: string, t
bindValues = Object.values(matchOrQuery);
}
let res = await context.db.all<WithId<T>[]>(`SELECT * FROM ${tableName} ${whereClause}`, bindValues);
return res.map(row => convertRowToCamelCase<WithId<T>>(row));
return res.map((row: WithId<T>) => convertRowToCamelCase<WithId<T>>(row));
}

async function get(context: Context, id: any) {
Expand Down
30 changes: 3 additions & 27 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,16 @@
],
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016",
"lib": [
"ES2015"
],
// "jsx": "preserve", /* Specify what JSX code is generated. */
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "ESNext",
"module": "ES6",
"moduleResolution": "node",
"rootDir": "./src",
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "moduleResolution": "nodenext",
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
Expand Down Expand Up @@ -87,22 +71,14 @@
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"strictBuiltinIteratorReturn": true,
"noImplicitThis": true,
"useUnknownInCatchVariables": true,
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
"noUnusedLocals": true,
"noUnusedParameters": true,
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
// "allowUnusedLabels": true,
// "allowUnreachableCode": true,
/* Completeness */
// "skipDefaultLibCheck": true,
"skipLibCheck": true
}
}
Loading