@ruiapp/rapid-core 0.8.16 → 0.8.18
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/dist/dataAccess/dataAccessTypes.d.ts +1 -1
- package/dist/index.js +61 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/dataAccess/dataAccessTypes.ts +2 -0
- package/src/plugins/auth/actionHandlers/createSession.ts +1 -1
- package/src/queryBuilder/queryBuilder.ts +78 -1
- package/src/types.ts +2 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type DataAccessPgColumnTypes = "int4" | "int8" | "float4" | "float8" | "decimal" | "text" | "text[]" | "bool" | "date" | "time" | "timestamptz" | "jsonb";
|
|
2
|
-
export type RowFilterRelationalOperators = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | "notContains" | "containsCS" | "notContainsCS" | "startsWith" | "notStartsWith" | "endsWith" | "notEndsWith";
|
|
2
|
+
export type RowFilterRelationalOperators = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "matches" | "matchesCS" | "contains" | "notContains" | "containsCS" | "notContainsCS" | "startsWith" | "notStartsWith" | "endsWith" | "notEndsWith";
|
|
3
3
|
export type RowFilterArrayOperators = "arrayContains" | "arrayOverlap";
|
|
4
4
|
export type RowFilterSetOperators = "in" | "notIn";
|
|
5
5
|
export type RowFilterRangeOperators = "between";
|
package/dist/index.js
CHANGED
|
@@ -522,12 +522,24 @@ function buildFilterQuery(level, ctx, filter) {
|
|
|
522
522
|
else if (operator === "between") {
|
|
523
523
|
return buildRangeFilterQuery(ctx, filter);
|
|
524
524
|
}
|
|
525
|
+
else if (operator === "matches") {
|
|
526
|
+
return buildMatchesFilterQuery(ctx, filter);
|
|
527
|
+
}
|
|
528
|
+
else if (operator === "matchesCS") {
|
|
529
|
+
return buildMatchesCSFilterQuery(ctx, filter);
|
|
530
|
+
}
|
|
525
531
|
else if (operator === "contains") {
|
|
526
532
|
return buildContainsFilterQuery(ctx, filter);
|
|
527
533
|
}
|
|
534
|
+
else if (operator === "containsCS") {
|
|
535
|
+
return buildContainsCSFilterQuery(ctx, filter);
|
|
536
|
+
}
|
|
528
537
|
else if (operator === "notContains") {
|
|
529
538
|
return buildNotContainsFilterQuery(ctx, filter);
|
|
530
539
|
}
|
|
540
|
+
else if (operator === "notContainsCS") {
|
|
541
|
+
return buildNotContainsCSFilterQuery(ctx, filter);
|
|
542
|
+
}
|
|
531
543
|
else if (operator === "startsWith") {
|
|
532
544
|
return buildStartsWithFilterQuery(ctx, filter);
|
|
533
545
|
}
|
|
@@ -612,6 +624,34 @@ function buildRangeFilterQuery(ctx, filter) {
|
|
|
612
624
|
}
|
|
613
625
|
return command;
|
|
614
626
|
}
|
|
627
|
+
function convertSearchTextToLikeParamValue(searchText) {
|
|
628
|
+
if (lodash.isNil(searchText)) {
|
|
629
|
+
return searchText;
|
|
630
|
+
}
|
|
631
|
+
let result = searchText.replace(/\*/g, "%");
|
|
632
|
+
result = result.replace(/\?/g, "_");
|
|
633
|
+
return result;
|
|
634
|
+
}
|
|
635
|
+
function buildMatchesFilterQuery(ctx, filter) {
|
|
636
|
+
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
637
|
+
command += " ILIKE ";
|
|
638
|
+
if (ctx.paramToLiteral) ;
|
|
639
|
+
else {
|
|
640
|
+
ctx.params.push(`%${convertSearchTextToLikeParamValue(filter.value)}%`);
|
|
641
|
+
command += "$" + ctx.params.length;
|
|
642
|
+
}
|
|
643
|
+
return command;
|
|
644
|
+
}
|
|
645
|
+
function buildMatchesCSFilterQuery(ctx, filter) {
|
|
646
|
+
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
647
|
+
command += " LIKE ";
|
|
648
|
+
if (ctx.paramToLiteral) ;
|
|
649
|
+
else {
|
|
650
|
+
ctx.params.push(`%${convertSearchTextToLikeParamValue(filter.value)}%`);
|
|
651
|
+
command += "$" + ctx.params.length;
|
|
652
|
+
}
|
|
653
|
+
return command;
|
|
654
|
+
}
|
|
615
655
|
function buildContainsFilterQuery(ctx, filter) {
|
|
616
656
|
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
617
657
|
command += " ILIKE ";
|
|
@@ -622,6 +662,16 @@ function buildContainsFilterQuery(ctx, filter) {
|
|
|
622
662
|
}
|
|
623
663
|
return command;
|
|
624
664
|
}
|
|
665
|
+
function buildContainsCSFilterQuery(ctx, filter) {
|
|
666
|
+
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
667
|
+
command += " LIKE ";
|
|
668
|
+
if (ctx.paramToLiteral) ;
|
|
669
|
+
else {
|
|
670
|
+
ctx.params.push(`%${filter.value}%`);
|
|
671
|
+
command += "$" + ctx.params.length;
|
|
672
|
+
}
|
|
673
|
+
return command;
|
|
674
|
+
}
|
|
625
675
|
function buildNotContainsFilterQuery(ctx, filter) {
|
|
626
676
|
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
627
677
|
command += " NOT ILIKE ";
|
|
@@ -632,6 +682,16 @@ function buildNotContainsFilterQuery(ctx, filter) {
|
|
|
632
682
|
}
|
|
633
683
|
return command;
|
|
634
684
|
}
|
|
685
|
+
function buildNotContainsCSFilterQuery(ctx, filter) {
|
|
686
|
+
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
687
|
+
command += " NOT LIKE ";
|
|
688
|
+
if (ctx.paramToLiteral) ;
|
|
689
|
+
else {
|
|
690
|
+
ctx.params.push(`%${filter.value}%`);
|
|
691
|
+
command += "$" + ctx.params.length;
|
|
692
|
+
}
|
|
693
|
+
return command;
|
|
694
|
+
}
|
|
635
695
|
function buildStartsWithFilterQuery(ctx, filter) {
|
|
636
696
|
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
637
697
|
command += " ILIKE ";
|
|
@@ -6829,7 +6889,7 @@ async function handler$d(plugin, ctx, options) {
|
|
|
6829
6889
|
},
|
|
6830
6890
|
{
|
|
6831
6891
|
operator: "null",
|
|
6832
|
-
field: "
|
|
6892
|
+
field: "deleted_at",
|
|
6833
6893
|
},
|
|
6834
6894
|
],
|
|
6835
6895
|
}, routeContext?.getDbTransactionClient());
|
package/dist/types.d.ts
CHANGED
|
@@ -481,7 +481,7 @@ export interface IRpdDataAccessor<T = any> {
|
|
|
481
481
|
count(options: CountRowOptions, databaseClient: IDatabaseClient | null): Promise<number>;
|
|
482
482
|
deleteById(id: any, databaseClient: IDatabaseClient | null): Promise<void>;
|
|
483
483
|
}
|
|
484
|
-
export type EntityFilterRelationalOperators = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | "notContains" | "containsCS" | "notContainsCS" | "startsWith" | "notStartsWith" | "endsWith" | "notEndsWith";
|
|
484
|
+
export type EntityFilterRelationalOperators = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "matches" | "matchesCS" | "contains" | "notContains" | "containsCS" | "notContainsCS" | "startsWith" | "notStartsWith" | "endsWith" | "notEndsWith";
|
|
485
485
|
export type EntityFilterArrayOperators = "arrayContains" | "arrayOverlap";
|
|
486
486
|
export type EntityFilterSetOperators = "in" | "notIn";
|
|
487
487
|
export type EntityFilterLogicalOperators = "or" | "and";
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { find, isBoolean, isNull, isNumber, isString, isUndefined } from "lodash";
|
|
1
|
+
import { find, isBoolean, isNil, isNull, isNumber, isString, isUndefined } from "lodash";
|
|
2
2
|
import { RpdDataModel, RpdDataModelProperty, CreateEntityOptions, QuoteTableOptions, DatabaseQuery, IQueryBuilder } from "../types";
|
|
3
3
|
import {
|
|
4
4
|
CountRowOptions,
|
|
@@ -420,10 +420,18 @@ function buildFilterQuery(level: number, ctx: BuildQueryContext, filter: RowFilt
|
|
|
420
420
|
return buildInFilterQuery(ctx, filter);
|
|
421
421
|
} else if (operator === "between") {
|
|
422
422
|
return buildRangeFilterQuery(ctx, filter);
|
|
423
|
+
} else if (operator === "matches") {
|
|
424
|
+
return buildMatchesFilterQuery(ctx, filter);
|
|
425
|
+
} else if (operator === "matchesCS") {
|
|
426
|
+
return buildMatchesCSFilterQuery(ctx, filter);
|
|
423
427
|
} else if (operator === "contains") {
|
|
424
428
|
return buildContainsFilterQuery(ctx, filter);
|
|
429
|
+
} else if (operator === "containsCS") {
|
|
430
|
+
return buildContainsCSFilterQuery(ctx, filter);
|
|
425
431
|
} else if (operator === "notContains") {
|
|
426
432
|
return buildNotContainsFilterQuery(ctx, filter);
|
|
433
|
+
} else if (operator === "notContainsCS") {
|
|
434
|
+
return buildNotContainsCSFilterQuery(ctx, filter);
|
|
427
435
|
} else if (operator === "startsWith") {
|
|
428
436
|
return buildStartsWithFilterQuery(ctx, filter);
|
|
429
437
|
} else if (operator === "notStartsWith") {
|
|
@@ -513,6 +521,46 @@ function buildRangeFilterQuery(ctx: BuildQueryContext, filter: FindRowRangeFilte
|
|
|
513
521
|
return command;
|
|
514
522
|
}
|
|
515
523
|
|
|
524
|
+
function convertSearchTextToLikeParamValue(searchText: string) {
|
|
525
|
+
if (isNil(searchText)) {
|
|
526
|
+
return searchText;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
let result = searchText.replace(/\*/g, "%");
|
|
530
|
+
result = result.replace(/\?/g, "_");
|
|
531
|
+
return result;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function buildMatchesFilterQuery(ctx: BuildQueryContext, filter: FindRowRelationalFilterOptions) {
|
|
535
|
+
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
536
|
+
|
|
537
|
+
command += " ILIKE ";
|
|
538
|
+
|
|
539
|
+
if (ctx.paramToLiteral) {
|
|
540
|
+
// TODO: implement it
|
|
541
|
+
} else {
|
|
542
|
+
ctx.params.push(`%${convertSearchTextToLikeParamValue(filter.value)}%`);
|
|
543
|
+
command += "$" + ctx.params.length;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return command;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function buildMatchesCSFilterQuery(ctx: BuildQueryContext, filter: FindRowRelationalFilterOptions) {
|
|
550
|
+
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
551
|
+
|
|
552
|
+
command += " LIKE ";
|
|
553
|
+
|
|
554
|
+
if (ctx.paramToLiteral) {
|
|
555
|
+
// TODO: implement it
|
|
556
|
+
} else {
|
|
557
|
+
ctx.params.push(`%${convertSearchTextToLikeParamValue(filter.value)}%`);
|
|
558
|
+
command += "$" + ctx.params.length;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return command;
|
|
562
|
+
}
|
|
563
|
+
|
|
516
564
|
function buildContainsFilterQuery(ctx: BuildQueryContext, filter: FindRowRelationalFilterOptions) {
|
|
517
565
|
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
518
566
|
|
|
@@ -528,6 +576,21 @@ function buildContainsFilterQuery(ctx: BuildQueryContext, filter: FindRowRelatio
|
|
|
528
576
|
return command;
|
|
529
577
|
}
|
|
530
578
|
|
|
579
|
+
function buildContainsCSFilterQuery(ctx: BuildQueryContext, filter: FindRowRelationalFilterOptions) {
|
|
580
|
+
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
581
|
+
|
|
582
|
+
command += " LIKE ";
|
|
583
|
+
|
|
584
|
+
if (ctx.paramToLiteral) {
|
|
585
|
+
// TODO: implement it
|
|
586
|
+
} else {
|
|
587
|
+
ctx.params.push(`%${filter.value}%`);
|
|
588
|
+
command += "$" + ctx.params.length;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return command;
|
|
592
|
+
}
|
|
593
|
+
|
|
531
594
|
function buildNotContainsFilterQuery(ctx: BuildQueryContext, filter: FindRowRelationalFilterOptions) {
|
|
532
595
|
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
533
596
|
|
|
@@ -542,6 +605,20 @@ function buildNotContainsFilterQuery(ctx: BuildQueryContext, filter: FindRowRela
|
|
|
542
605
|
return command;
|
|
543
606
|
}
|
|
544
607
|
|
|
608
|
+
function buildNotContainsCSFilterQuery(ctx: BuildQueryContext, filter: FindRowRelationalFilterOptions) {
|
|
609
|
+
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
610
|
+
|
|
611
|
+
command += " NOT LIKE ";
|
|
612
|
+
if (ctx.paramToLiteral) {
|
|
613
|
+
// TODO: implement it
|
|
614
|
+
} else {
|
|
615
|
+
ctx.params.push(`%${filter.value}%`);
|
|
616
|
+
command += "$" + ctx.params.length;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return command;
|
|
620
|
+
}
|
|
621
|
+
|
|
545
622
|
function buildStartsWithFilterQuery(ctx: BuildQueryContext, filter: FindRowRelationalFilterOptions) {
|
|
546
623
|
let command = ctx.builder.quoteColumn(ctx.model, filter.field, ctx.emitTableAlias);
|
|
547
624
|
|