Skip to content

Commit c81f52f

Browse files
committed
fixes search by strings containing "+"
1 parent ecae115 commit c81f52f

File tree

9 files changed

+42
-27
lines changed

9 files changed

+42
-27
lines changed

adminforth/dataConnectors/mongo.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import AdminForthBaseConnector from './baseConnector.js';
55

66
import { AdminForthDataTypes, AdminForthFilterOperators, AdminForthSortDirections, } from '../types/Common.js';
77

8+
const escapeRegex = (value) => {
9+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // Escapes special characters
10+
};
11+
812
class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataSourceConnector {
913
db: MongoClient
1014

@@ -31,8 +35,8 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
3135
[AdminForthFilterOperators.LT]: (value) => ({ $lt: value }),
3236
[AdminForthFilterOperators.GTE]: (value) => ({ $gte: value }),
3337
[AdminForthFilterOperators.LTE]: (value) => ({ $lte: value }),
34-
[AdminForthFilterOperators.LIKE]: (value) => ({ $regex: value }),
35-
[AdminForthFilterOperators.ILIKE]: (value) => ({ $regex: value, $options: 'i' }),
38+
[AdminForthFilterOperators.LIKE]: (value) => ({ $regex: escapeRegex(value) }),
39+
[AdminForthFilterOperators.ILIKE]: (value) => ({ $regex: escapeRegex(value), $options: 'i' }),
3640
[AdminForthFilterOperators.IN]: (value) => ({ $in: value }),
3741
[AdminForthFilterOperators.NIN]: (value) => ({ $nin: value }),
3842
};

adminforth/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adminforth",
3-
"version": "1.5.8-next.25",
3+
"version": "1.5.8-next.27",
44
"description": "OpenSource Vue3 powered forth-generation admin panel",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

adminforth/plugins/upload/index.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ export default class UploadPlugin extends AdminForthPlugin {
2525
async setupLifecycleRule() {
2626
// check that lifecyle rule "adminforth-unused-cleaner" exists
2727
const CLEANUP_RULE_ID = 'adminforth-unused-cleaner';
28-
const s3 = new S3({
29-
credentials: {
30-
accessKeyId: this.options.s3AccessKeyId,
31-
secretAccessKey: this.options.s3SecretAccessKey,
32-
},
3328

34-
region: this.options.s3Region,
35-
});
29+
const s3 = new S3({
30+
credentials: {
31+
accessKeyId: this.options.s3AccessKeyId,
32+
secretAccessKey: this.options.s3SecretAccessKey,
33+
},
34+
region: this.options.s3Region,
35+
});
36+
3637
// check bucket exists
3738
const bucketExists = s3.headBucket({ Bucket: this.options.s3Bucket })
3839
if (!bucketExists) {
@@ -47,6 +48,8 @@ export default class UploadPlugin extends AdminForthPlugin {
4748
ruleExists = lifecycleConfig.Rules.some((rule: any) => rule.ID === CLEANUP_RULE_ID);
4849
} catch (e: any) {
4950
if (e.name !== 'NoSuchLifecycleConfiguration') {
51+
console.error(`⛔ Error checking lifecycle configuration, please check keys have permissions to
52+
getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${this.options.s3Region}. Exception:`, e);
5053
throw e;
5154
} else {
5255
ruleExists = false;

adminforth/plugins/upload/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/plugins/upload/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "@adminforth/upload",
3-
"version": "1.0.30",
3+
"version": "1.0.31-next.1",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"scripts": {
88
"rollout": "tsc && rsync -av --exclude 'node_modules' custom dist/ && npm version patch && npm publish --access public",
99
"prepare": "npm link adminforth",
10+
"rollout-next": "npm run build && npm version prerelease --preid=next && npm publish --tag next",
1011
"build": "tsc"
1112
},
1213
"type": "module",

dev-demo/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import gamesUsersResource from './resources/games_users.js';
1313
import gamesResource from './resources/games.js';
1414
import translationsResource from './resources/translation.js';
1515

16+
// const ADMIN_BASE_URL = '/portal';
1617
const ADMIN_BASE_URL = '';
1718

1819
// create test1.db
@@ -177,7 +178,7 @@ export const admin = new AdminForth({
177178
},
178179
{
179180
id: 'db3',
180-
url: 'mongodb://127.0.0.1:27017/betbolt?retryWrites=true&w=majority&authSource=admin',
181+
url: 'mongodb://127.0.0.1:27028/demo?retryWrites=true&w=majority&authSource=admin',
181182
},
182183
{
183184
id: 'ch',
@@ -228,11 +229,11 @@ export const admin = new AdminForth({
228229

229230
},
230231

231-
// {
232-
// label: 'Games',
233-
// icon: 'flowbite:caret-right-solid',
234-
// resourceId: 'games',
235-
// },
232+
{
233+
label: 'Games',
234+
icon: 'flowbite:caret-right-solid',
235+
resourceId: 'game',
236+
},
236237
// {
237238
// label: 'Games Users',
238239
// icon: 'flowbite:user-solid',
@@ -288,7 +289,7 @@ export const admin = new AdminForth({
288289

289290
const app = express()
290291
app.use(express.json());
291-
const port = 3000;
292+
const port = 30000;
292293

293294
(async () => {
294295
console.log('🅿️🅿️🅿️ 🅿️Bundling AdminForth...');

dev-demo/inventory.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ services:
3333
- pg-data:/var/lib/postgresql/data
3434

3535
mongo:
36-
image: mongo:4.4
36+
image: mongo:6.0.5
3737
restart: always
38+
environment:
39+
MONGO_INITDB_DATABASE: demo
3840
ports:
39-
- "27017:27017"
41+
- "27028:27017"
4042
volumes:
41-
- mongo-data:/data/db
43+
- mongo-data1:/data/db
4244

4345
volumes:
4446
clickhouse-data:
4547
pg-data:
46-
mongo-data:
48+
mongo-data1:

dev-demo/resources/game.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export default {
1515
name: "bb_enabled",
1616
type: AdminForthDataTypes.BOOLEAN,
1717
required: false,
18-
backendOnly: true,
18+
},
19+
{
20+
name: "email",
21+
type: AdminForthDataTypes.STRING,
22+
required: false,
1923
},
2024
{ name: "bb_rank", type: AdminForthDataTypes.INTEGER, required: false },
2125
{

0 commit comments

Comments
 (0)