Skip to content

Commit

Permalink
0.32.1 Upgrade package deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Elschnagoo committed May 28, 2024
1 parent 1ac779c commit 97d08df
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 48 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"class-methods-use-this": "warn",
"linebreak-style": "off",
"no-restricted-properties": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"import/extensions": [
"warn",
"ignorePackages",
Expand Down
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@grandlinex/bundle-sqlight",
"version": "0.32.0",
"version": "0.32.1",
"description": "",
"type": "module",
"exports": {
Expand Down Expand Up @@ -46,31 +46,31 @@
"license": "BSD-3-Clause",
"dependencies": {
"@grandlinex/core": "0.32.0",
"better-sqlite3": "8.2.0",
"@types/better-sqlite3": "7.6.3"
"better-sqlite3": "10.0.0",
"@types/better-sqlite3": "7.6.10"
},
"devDependencies": {
"@types/jest": "29.5.0",
"@types/node": "18.15.11",
"@typescript-eslint/eslint-plugin": "5.57.1",
"@typescript-eslint/parser": "5.57.1",
"@types/jest": "29.5.12",
"@types/node": "20.12.12",
"@typescript-eslint/eslint-plugin": "7.11.0",
"@typescript-eslint/parser": "7.11.0",
"cross-env": "7.0.3",
"eslint": "8.37.0",
"eslint": "8.57.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "27.2.1",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "4.2.1",
"jest": "29.5.0",
"jest-junit": "15.0.0",
"prettier": "2.8.7",
"ts-jest": "29.1.0",
"ts-loader": "9.4.2",
"ts-node": "10.9.1",
"typedoc": "0.23.28",
"typescript": "5.0.3"
"eslint-config-airbnb-typescript": "18.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jest": "28.5.0",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-prettier": "5.1.3",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"prettier": "3.2.5",
"ts-jest": "29.1.4",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
"typedoc": "0.25.13",
"typescript": "5.4.5"
},
"repository": {
"type": "git",
Expand Down
41 changes: 21 additions & 20 deletions src/class/SQLCon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class SQLCon<
T extends IDataBase<any, any> | null = any,
P extends ICoreClient | null = any,
C extends ICoreCache | null = any,
X extends ICorePresenter<any> | null = any
X extends ICorePresenter<any> | null = any,
>
extends CoreDBCon<DbType, RunResult, K, T, P, C, X>
implements IDataBase<DbType, RunResult, K, T, P, C, X>
Expand All @@ -43,7 +43,7 @@ export default class SQLCon<

constructor(
module: ICoreKernelModule<any, any, any, any, any>,
dbversion: string
dbversion: string,
) {
super(dbversion, 'main', module);
const store = module.getKernel().getConfigStore();
Expand All @@ -58,12 +58,12 @@ export default class SQLCon<

async createEntity<E extends CoreEntity>(
config: EntityConfig<E>,
entity: EProperties<E>
entity: EProperties<E>,
): Promise<E> {
const [keys, values, params] = objToTable(entity, config);
const query: RawQuery = {
exec: `INSERT INTO ${this.schemaName}.${config.className}(${keys.join(
', '
', ',
)})
VALUES (${values.join(', ')})`,
param: params,
Expand All @@ -78,7 +78,7 @@ export default class SQLCon<
async updateEntity<E extends CoreEntity>(
config: EntityConfig<E>,
e_id: string,
entity: EUpDateProperties<E>
entity: EUpDateProperties<E>,
): Promise<boolean> {
const [, values, params] = objToTable(entity, config, true);
const result = await this.execScripts([
Expand All @@ -95,12 +95,12 @@ export default class SQLCon<

async getEntityById<E extends CoreEntity>(
config: EntityConfig<E>,
id: string
id: string,
): Promise<E | null> {
const query = this.db?.prepare(
`SELECT *
FROM ${this.schemaName}.${config.className}
WHERE e_id = ?;`
WHERE e_id = ?;`,
);

const res = query?.get([id]);
Expand All @@ -112,7 +112,7 @@ export default class SQLCon<

async findEntity<E extends CoreEntity>(
config: EntityConfig<E>,
search: { [D in keyof E]?: E[D] | undefined }
search: { [D in keyof E]?: E[D] | undefined },
): Promise<E | null> {
let searchQ = '';
const param: any[] = [];
Expand All @@ -121,7 +121,7 @@ export default class SQLCon<

const query = this.db?.prepare(
`SELECT *
FROM ${this.schemaName}.${config.className} ${searchQ};`
FROM ${this.schemaName}.${config.className} ${searchQ};`,
);

const res = query?.get(param);
Expand All @@ -135,13 +135,13 @@ export default class SQLCon<
const query = this.db?.prepare(
`DELETE
FROM ${this.schemaName}.${className}
WHERE e_id = ?;`
WHERE e_id = ?;`,
);
return query?.run([id]).changes === 1;
}

async getEntityList<E extends CoreEntity>(
q: QueryInterface<E>
q: QueryInterface<E>,
): Promise<E[]> {
const { limit, search, config, order, offset } = q;
if (limit === 0) {
Expand All @@ -167,7 +167,7 @@ export default class SQLCon<
FROM ${this.schemaName}.${config.className}
${searchQ}
${orderByQ}
${range};`
${range};`,
);

const res = query?.all(param);
Expand All @@ -179,7 +179,7 @@ export default class SQLCon<

async initEntity<E extends CoreEntity>(
className: string,
entity: E
entity: E,
): Promise<boolean> {
await this.execScripts([
{
Expand Down Expand Up @@ -257,9 +257,9 @@ export default class SQLCon<
try {
const query = this.db.prepare(
`SELECT *
FROM ${this.schemaName}.config;`
FROM ${this.schemaName}.config;`,
);
const result = query.all();
const result = query.all() as any[];
const version = result.find((el) => {
return el.c_key === 'dbversion';
});
Expand Down Expand Up @@ -297,9 +297,9 @@ export default class SQLCon<
const query = this.db?.prepare(
`SELECT *
FROM ${this.schemaName}.config
WHERE c_key = '${key}'`
WHERE c_key = '${key}'`,
);
const exist = query?.get();
const exist = query?.get() as any;
return !!exist && exist.c_key !== undefined && exist.c_value !== undefined;
}

Expand All @@ -313,7 +313,7 @@ export default class SQLCon<
c_key,
c_value
)
VALUES ('${key}', '${value}');`
VALUES ('${key}', '${value}');`,
);
if (query === undefined) {
return false;
Expand All @@ -326,9 +326,9 @@ export default class SQLCon<
const query = this.db?.prepare(
`SELECT *
FROM ${this.schemaName}.config
WHERE c_key = '${key}'`
WHERE c_key = '${key}'`,
);
return query?.get();
return query?.get() as any;
}

async execScripts(list: RawQuery[]): Promise<RunResult[]> {
Expand All @@ -345,6 +345,7 @@ export default class SQLCon<
}

async disconnect(): Promise<boolean> {
this.db?.close();
return true;
}
}
2 changes: 1 addition & 1 deletion src/util/buildSearchQ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function buildSearchQ<E>(
config: EntityConfig<E>,
search: { [P in keyof E]?: E[P] },
param: any[],
searchQ: string
searchQ: string,
) {
let temp = searchQ;
const keys: (keyof E)[] = Object.keys(search) as (keyof E)[];
Expand Down
8 changes: 4 additions & 4 deletions src/util/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function convertSpecialFields<E>(
meta: ColumnProps,
clone: any,
key: keyof E,
params: any[]
params: any[],
) {
switch (meta.dataType) {
case 'date':
Expand All @@ -34,7 +34,7 @@ export function convertSpecialFields<E>(
export function objToTable<E extends CoreEntity>(
entity: E | EUpDateProperties<E>,
config: EntityConfig<E>,
update?: boolean
update?: boolean,
): [(keyof E)[], string[], unknown[]] {
const clone: any = entity;
const keysOriginal = Object.keys(entity) as (keyof E)[];
Expand Down Expand Up @@ -68,7 +68,7 @@ export function objToTable<E extends CoreEntity>(

export function rowToObj<E extends CoreEntity>(
config: EntityConfig<E>,
row: any
row: any,
): E {
const clone: any = row;
config.meta.forEach((value, key) => {
Expand All @@ -88,7 +88,7 @@ export function rowToObj<E extends CoreEntity>(

export function tableToObj<E extends CoreEntity>(
config: EntityConfig<E>,
table: any[]
table: any[],
): E[] {
return table.map((row) => {
return rowToObj(config, row);
Expand Down
2 changes: 1 addition & 1 deletion src/util/mappingWithDataType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import resolveDBType from './resolveDBType.js';
export default function mappingWithDataType<E extends CoreEntity>(
meta: ColumnProps,
out: string[],
key: keyof E
key: keyof E,
): void {
if (!meta.dataType) {
throw new Error('DataType not set');
Expand Down

0 comments on commit 97d08df

Please sign in to comment.