@simitgroup/simpleapp-generator 2.0.1-w-alpha → 2.0.1-x-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ReleaseNote.md CHANGED
@@ -1,4 +1,10 @@
1
+ [2.0.1x-alpha]
2
+
3
+ 1. disable system cron auto run
4
+ 2. fix search text syntax mess up
5
+
1
6
  [2.0.1w-alpha]
7
+
2
8
  1. touch up abit debugger in simple-app.service
3
9
  2. add default queue job option code
4
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "2.0.1w-alpha",
3
+ "version": "2.0.1x-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -15,25 +15,25 @@ export class CronSystemService extends SimpleAppCronBaseClass {
15
15
  super(robotUserService);
16
16
  }
17
17
 
18
- @Cron('0 1 * * *')
18
+ //@Cron('0 1 * * *')
19
19
  async deleteApiLog() {
20
- if (process.env.ON_CRONTAB == 'true') {
21
- this.logger.debug('run CronSystemService.deleteApiLog 0 1 * * *')
20
+ //if (process.env.ON_CRONTAB == 'true') {
21
+ this.logger.debug('run CronSystemService.deleteApiLog')
22
22
  const today = new Date();
23
23
  const newDate = new Date(today.getTime());
24
24
  const cutoffdate = new Date(newDate.setDate(newDate.getDate() - 90)).toISOString();
25
25
  await this.apiEventModel.deleteMany({ created: { $lte: cutoffdate } });
26
- }
26
+ //}
27
27
  }
28
28
 
29
- @Cron('30 0 * * *')
29
+ //@Cron('30 0 * * *')
30
30
  async deleteQueueJob() {
31
- if (process.env.ON_CRONTAB == 'true') {
32
- this.logger.debug('run deleteQueueJob.deleteApiLog 30 0 * * *')
31
+ //if (process.env.ON_CRONTAB == 'true') {
32
+ this.logger.debug('run deleteQueueJob.deleteApiLog')
33
33
  const today = new Date();
34
34
  const newDate = new Date(today.getTime());
35
35
  const cutoffdate = new Date(newDate.setDate(newDate.getDate() - 90)).toISOString();
36
36
  await this.queueJobModel.deleteMany({ created: { $lte: cutoffdate } });
37
- }
37
+ //}
38
38
  }
39
39
  }
@@ -286,27 +286,24 @@ export class SimpleAppService<T extends SchemaFields> {
286
286
 
287
287
  async fullTextSearch(appuser: UserContext, body: TextSearchBody) {
288
288
  try {
289
+ //{filters:string[],fields:string[]}
289
290
  const isolationFilter = { ...this.getIsolationFilter(appuser) };
290
291
  this.polishIsolationFilter(isolationFilter);
291
292
  const keyword = body.keyword;
292
-
293
+ // console.log("bodybody",body)
293
294
  // Prepare regex filter
294
295
  const orConditions: any[] = [];
295
- if (body.fields && body.fields.length > 0) {
296
- body.fields.forEach((field: string) => {
297
- if (field != 'defaultPrice' && field != 'amount' && field != 'active' && field != 'updated') {
296
+ const regex = new RegExp(keyword, 'i')
297
+
298
+ if (body.filters && body.filters.length > 0) {
299
+ body.filters.forEach((field: string) => {
298
300
  orConditions.push({
299
- [field]: { $regex: keyword, $options: 'i' },
300
- });
301
- } else {
302
- if (!isNaN(Number(keyword)) && (field == 'defaultPrice' || field == 'amount')) {
303
- orConditions.push({
304
- [field]: { $gte: keyword },
305
- });
306
- }
307
- }
301
+ [field]: { $regex: regex },
302
+ });
308
303
  });
309
304
  }
305
+
306
+
310
307
  const filter = {
311
308
  $or: orConditions,
312
309
  };
@@ -318,7 +315,7 @@ export class SimpleAppService<T extends SchemaFields> {
318
315
 
319
316
  const fields = body.fields || {};
320
317
  const sorts = body.sorts || {};
321
-
318
+ // console.log("newfilters",JSON.stringify(newfilters),fields)
322
319
  // Ensure `this.doc` is a Mongoose model or similar
323
320
  const results = await this.doc.find(newfilters, fields).sort(sorts).exec();
324
321
 
@@ -499,7 +496,7 @@ export class SimpleAppService<T extends SchemaFields> {
499
496
  errormsg.push(this.errorlist[i].message);
500
497
  }
501
498
 
502
- throw new BadRequestException(errormsg as HttpExceptionOptions,'Before validation hook failed');
499
+ throw new BadRequestException(errormsg as HttpExceptionOptions, 'Before validation hook failed');
503
500
  }
504
501
 
505
502
  let validate;
@@ -513,7 +510,7 @@ export class SimpleAppService<T extends SchemaFields> {
513
510
  if (!valid) {
514
511
  this.logger.error(JSON.stringify(data));
515
512
  this.logger.error(JSON.stringify(validate.errors), 'validate errors:');
516
- throw new BadRequestException(validate.errors as HttpExceptionOptions,'Data validation failed');
513
+ throw new BadRequestException(validate.errors as HttpExceptionOptions, 'Data validation failed');
517
514
  }
518
515
  }
519
516
 
@@ -1089,7 +1086,7 @@ export class SimpleAppService<T extends SchemaFields> {
1089
1086
 
1090
1087
  if (!unionresult) {
1091
1088
  this.logger.error('foreign key control failed ', 'identifyForeignKeys');
1092
- throw new InternalServerErrorException(pipelines as HttpExceptionOptions,'Foreignkey check execution error');
1089
+ throw new InternalServerErrorException(pipelines as HttpExceptionOptions, 'Foreignkey check execution error');
1093
1090
  } else {
1094
1091
  const searchresult: any = {};
1095
1092
  unionresult.forEach((item) => {
@@ -1099,7 +1096,7 @@ export class SimpleAppService<T extends SchemaFields> {
1099
1096
  searchresult[item.collection] = [item._id];
1100
1097
  }
1101
1098
  });
1102
- this.logger.debug( this.documentType + ' search Result',unionresult);
1099
+ this.logger.debug(this.documentType + ' search Result', unionresult);
1103
1100
 
1104
1101
  //search is it all foreign key exists in db
1105
1102
  for (let i = 0; i < collections.length; i++) {
@@ -143,6 +143,7 @@ export class DynamicParam {
143
143
  export class TextSearchBody {
144
144
  keyword: string;
145
145
  fields?: string[];
146
+ filters?: string[];
146
147
  sorts?: string[][];
147
148
  lookup?: Record<string, string>;
148
149
  }