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
11 changes: 0 additions & 11 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
"private": true,
"license": "UNLICENSED",
"type": "module",
"packageExtensions": {
"ibm_db": {
"dependencies": {
"node-gyp": "^11.5.0"
}
}
},
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
Expand Down Expand Up @@ -80,7 +73,6 @@
"knex": "3.1.0",
"lru-cache": "^11.2.2",
"nanoid": "5.1.6",
"node-gyp": "^11.5.0",
"nodemailer": "^7.0.10",
"nunjucks": "^3.2.4",
"openai": "^6.7.0",
Expand All @@ -100,9 +92,6 @@
"validator": "^13.15.20",
"winston": "3.18.3"
},
"optionalDependencies": {
"ibm_db": "3.3.0"
},
"devDependencies": {
"@ava/typescript": "6.0.0",
"@nestjs/cli": "^11.0.10",
Expand Down
132 changes: 0 additions & 132 deletions backend/src/helpers/cache/cacher.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import { ForeignKeyDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/foreign-key.ds.js';
import { PrimaryKeyDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/primary-key.ds.js';
import { TableStructureDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/table-structure.ds.js';
import { Knex } from 'knex';
import { LRUCache } from 'lru-cache';
import { ConnectionEntity } from '../../entities/connection/connection.entity.js';
import { isSaaS } from '../app/is-saas.js';
import { Constants } from '../constants/constants.js';

const knexCache = new LRUCache(Constants.DEFAULT_CONNECTION_CACHE_OPTIONS);
const tunnelCache = new LRUCache(Constants.DEFAULT_TUNNEL_CACHE_OPTIONS);
const driverCache = new LRUCache(Constants.DEFAULT_DRIVER_CACHE_OPTIONS);
const invitationCache = new LRUCache(Constants.DEFAULT_INVITATION_CACHE_OPTIONS);
const tableStructureCache = new LRUCache(Constants.DEFAULT_TABLE_STRUCTURE_ELEMENTS_CACHE_OPTIONS);
const tableForeignKeysCache = new LRUCache(Constants.DEFAULT_TABLE_STRUCTURE_ELEMENTS_CACHE_OPTIONS);
const tablePrimaryKeysCache = new LRUCache(Constants.DEFAULT_TABLE_STRUCTURE_ELEMENTS_CACHE_OPTIONS);
const tableReadPermissionCache = new LRUCache(Constants.DEFAULT_TABLE_PERMISSIONS_CACHE_OPTIONS);

export class Cacher {
Expand Down Expand Up @@ -76,129 +65,8 @@ export class Cacher {
return userInvitations <= 10 && groupInvitations <= 10;
}

public static getCachedKnex(connectionConfig): Knex {
const cachedKnex = knexCache.get(JSON.stringify(connectionConfig)) as Knex;
return cachedKnex ? cachedKnex : null;
}

public static setKnexCache(connectionConfig, newKnex: Knex): void {
knexCache.set(JSON.stringify(connectionConfig), newKnex);
}

public static getTunnelCache(connection: ConnectionEntity): any {
const cachedTnl = tunnelCache.get(JSON.stringify(connection));
return cachedTnl ? cachedTnl : null;
}

public static setTunnelCache(connection: ConnectionEntity, tnlObj): void {
tunnelCache.set(JSON.stringify(connection), tnlObj);
}

public static delTunnelCache(connection: ConnectionEntity): void {
tunnelCache.delete(JSON.stringify(connection));
}

public static getDriverCache(connection: ConnectionEntity): any {
const cachedDriver = driverCache.get(JSON.stringify(connection));
return cachedDriver ? cachedDriver : null;
}

public static setDriverCache(connection: ConnectionEntity, newDriver): void {
driverCache.set(JSON.stringify(connection), newDriver);
}

public static delDriverCache(connection: ConnectionEntity): void {
driverCache.delete(JSON.stringify(connection));
}

public static setTableStructureCache(
connection: ConnectionEntity,
tableName: string,
structure: Array<TableStructureDS>,
): void {
const connectionCopy = {
...connection,
};
const cacheObj = JSON.stringify({ connectionCopy, tableName });
tableStructureCache.set(cacheObj, structure);
}

public static getTableStructureCache(connection: ConnectionEntity, tableName: string): Array<TableStructureDS> {
const connectionCopy = {
...connection,
};
const cacheObj = JSON.stringify({ connectionCopy, tableName });
const foundStructure = tableStructureCache.get(cacheObj) as Array<TableStructureDS>;
return foundStructure ? foundStructure : null;
}

public static setTablePrimaryKeysCache(
connection: ConnectionEntity,
tableName: string,
primaryKeys: Array<PrimaryKeyDS>,
): void {
const connectionCopy = {
...connection,
};
const cacheObj = JSON.stringify({ connectionCopy, tableName });
tablePrimaryKeysCache.set(cacheObj, primaryKeys);
}

public static getTablePrimaryKeysCache(connection: ConnectionEntity, tableName: string): Array<PrimaryKeyDS> {
const connectionCopy = {
...connection,
};
const cacheObj = JSON.stringify({ connectionCopy, tableName });
const foundKeys = tablePrimaryKeysCache.get(cacheObj) as Array<PrimaryKeyDS>;
return foundKeys ? foundKeys : null;
}

public static setTableForeignKeysCache(
connection: ConnectionEntity,
tableName: string,
foreignKeys: Array<ForeignKeyDS>,
): void {
const connectionCopy = {
...connection,
};
const cacheObj = JSON.stringify({ connectionCopy, tableName });
tableForeignKeysCache.set(cacheObj, foreignKeys);
}

public static getTableForeignKeysCache(connection: ConnectionEntity, tableName: string): Array<ForeignKeyDS> {
const connectionCopy = {
...connection,
};
const cacheObj = JSON.stringify({ connectionCopy, tableName });
const foundKeys = tableForeignKeysCache.get(cacheObj) as Array<ForeignKeyDS>;
return foundKeys ? foundKeys : null;
}

public static async clearAllCache(): Promise<void> {
const elements = [];
knexCache.forEach((value, key) => {
elements.push({ key, value });
});
for (const element of elements) {
await element.value.destroy();
knexCache.delete(element.key);
}
knexCache.clear();

const tunnelElements = [];
tunnelCache.forEach((value, key) => {
tunnelElements.push({ key, value });
});
for (const element of tunnelElements) {
await element.value.close();
tunnelCache.delete(element.key);
}
tunnelCache.clear();
await driverCache.clear();
await invitationCache.clear();
await tableStructureCache.clear();
await tableForeignKeysCache.clear();
await tablePrimaryKeysCache.clear();
await tableReadPermissionCache.clear();
}
}
22 changes: 0 additions & 22 deletions backend/src/helpers/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,11 @@ export const Constants = {
},
},

DEFAULT_TUNNEL_CACHE_OPTIONS: {
max: 100,
ttl: 1000 * 60 * 60,
dispose: async (tnl: any) => {
try {
await tnl.close();
} catch (e) {
console.error('Tunnel closing error: ' + e);
}
},
},

DEFAULT_DRIVER_CACHE_OPTIONS: {
max: 50,
ttl: 1000 * 60 * 60,
},

DEFAULT_INVITATION_CACHE_OPTIONS: {
max: 200,
ttl: 1000 * 60 * 60,
},

DEFAULT_TABLE_STRUCTURE_ELEMENTS_CACHE_OPTIONS: {
max: 1000,
ttl: 1000 * 60,
},

DEFAULT_TABLE_PERMISSIONS_CACHE_OPTIONS: {
max: 1000,
ttl: 1000 * 10,
Expand Down
3 changes: 2 additions & 1 deletion shared-code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"packageExtensions": {
"ibm_db": {
"dependencies": {
"node-gyp": "^10.2.0"
"node-gyp": "^11.5.0"
}
}
},
Expand All @@ -29,6 +29,7 @@
"mongodb": "^6.20.0",
"mysql2": "^3.15.3",
"nanoid": "^5.1.6",
"node-gyp": "^11.5.0",
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding node-gyp as a direct dependency is redundant and may cause version conflicts. The node-gyp dependency is already managed through packageExtensions for ibm_db (lines 6-11), which is the package that actually needs it. Since ibm_db is listed as an optional dependency (line 44), adding node-gyp as a direct dependency creates unnecessary coupling and potential version management issues.

Consider removing this line and relying solely on the packageExtensions configuration to provide node-gyp to ibm_db.

Suggested change
"node-gyp": "^11.5.0",

Copilot uses AI. Check for mistakes.
"oracledb": "^6.10.0",
"p-queue": "^9.0.0",
"pg": "^8.16.3",
Expand Down
6 changes: 1 addition & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3068,6 +3068,7 @@ __metadata:
mongodb: ^6.20.0
mysql2: ^3.15.3
nanoid: ^5.1.6
node-gyp: ^11.5.0
oracledb: ^6.10.0
p-queue: ^9.0.0
pg: ^8.16.3
Expand Down Expand Up @@ -5226,7 +5227,6 @@ __metadata:
fetch-blob: ^4.0.0
helmet: 8.1.0
i18n-iso-countries: ^7.14.0
ibm_db: 3.3.0
ip-range-check: 0.2.0
json2csv: ^5.0.7
jsonwebtoken: ^9.0.2
Expand All @@ -5235,7 +5235,6 @@ __metadata:
lru-cache: ^11.2.2
nanoid: 5.1.6
nock: ^14.0.10
node-gyp: ^11.5.0
nodemailer: ^7.0.10
nunjucks: ^3.2.4
openai: ^6.7.0
Expand All @@ -5260,9 +5259,6 @@ __metadata:
uuid: ^13.0.0
validator: ^13.15.20
winston: 3.18.3
dependenciesMeta:
ibm_db:
optional: true
languageName: unknown
linkType: soft

Expand Down
Loading