namirasoft-node 1.4.60 → 1.4.62

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.
@@ -1,39 +1,39 @@
1
- import nodemailer from 'nodemailer';
2
- import Mail, { AttachmentLike } from "nodemailer/lib/mailer";
3
- import { Readable } from "stream";
4
-
5
- export abstract class BaseEmailService
6
- {
7
- username: string;
8
- constructor(username: string)
9
- {
10
- this.username = username;
11
- }
12
- protected abstract getTransform(): any;
13
- send(from: string | null, to: string, subject: string, text: string, html?: string | Buffer | Readable | AttachmentLike | undefined, callback?: (err: Error | null, info: any) => void)
14
- {
15
- let transform = this.getTransform();
16
- let transporter = nodemailer.createTransport(transform);
17
-
18
- let mailOptions: Mail.Options = {
19
- from: from ?? this.username,
20
- to,
21
- subject,
22
- text,
23
- html
24
- };
25
- if (html)
26
- mailOptions.html = html;
27
-
28
- transporter.sendMail(mailOptions, function (error, info)
29
- {
30
- if (callback)
31
- callback(error, info);
32
- else
33
- {
34
- if (error)
35
- console.log(error);
36
- }
37
- });
38
- }
1
+ import nodemailer from 'nodemailer';
2
+ import Mail, { AttachmentLike } from "nodemailer/lib/mailer";
3
+ import { Readable } from "stream";
4
+
5
+ export abstract class BaseEmailService
6
+ {
7
+ username: string;
8
+ constructor(username: string)
9
+ {
10
+ this.username = username;
11
+ }
12
+ protected abstract getTransform(): any;
13
+ send(from: string | null, to: string, subject: string, text: string, html?: string | Buffer | Readable | AttachmentLike | undefined, callback?: (err: Error | null, info: any) => void)
14
+ {
15
+ let transform = this.getTransform();
16
+ let transporter = nodemailer.createTransport(transform);
17
+
18
+ let mailOptions: Mail.Options = {
19
+ from: from ?? this.username,
20
+ to,
21
+ subject,
22
+ text,
23
+ html
24
+ };
25
+ if (html)
26
+ mailOptions.html = html;
27
+
28
+ transporter.sendMail(mailOptions, function (error, info)
29
+ {
30
+ if (callback)
31
+ callback(error, info);
32
+ else
33
+ {
34
+ if (error)
35
+ console.log(error);
36
+ }
37
+ });
38
+ }
39
39
  }
@@ -1,153 +1,170 @@
1
- import { ErrorOperation, FilterItem, FilterItemOperator } from "namirasoft-core";
2
-
3
- export interface BaseFilterItemBuilder_JoinTable<WhereOptions>
4
- {
5
- main: {
6
- column: string;
7
- };
8
- secondary: {
9
- column: string;
10
- };
11
- getExtraConditions?: (column: string) => WhereOptions[];
12
- }
13
-
14
- export type BaseFilterItemBuilder_Condition<WhereOptions> = {
15
- condition: WhereOptions;
16
- independant?: { not: boolean };
17
- };
18
-
19
- export abstract class BaseFilterItemBuilder<Table extends { getName: () => string; }, WhereOptions>
20
- {
21
- public async build(table_main: Table, table_joins: { [table: string]: BaseFilterItemBuilder_JoinTable<WhereOptions> }, filters?: FilterItem[] | undefined): Promise<WhereOptions[]>
22
- {
23
- let ans: WhereOptions[] = [];
24
- if (filters)
25
- {
26
- let conditions_in_select_main: { [table: string]: WhereOptions[] } = {};
27
- Object.keys(table_joins).forEach(table => { conditions_in_select_main[table] = []; });
28
- let processed: { [index: number]: boolean } = {};
29
-
30
- let getCondition_IDInSelect = async (table: string, not: boolean, conditions: WhereOptions[]): Promise<WhereOptions> =>
31
- {
32
- let join = table_joins[table];
33
- return this.getInSelect(table, not, join, conditions);
34
- }
35
-
36
- for (let i = 0; i < filters.length; i++)
37
- if (!processed[i])
38
- {
39
- const filter = filters[i];
40
- this.checkColumn(filter.table.name, filter.column.name);
41
- let join = table_joins[filter.table.name];
42
- let is_table_main = table_main.getName() === filter.table.name;
43
- let column_name = this.getRealColumnName(filter.table.name, filter.column.name) ?? filter.column.name;
44
-
45
- let values = filter.values;
46
- if (filter.operator.count > 0)
47
- for (let j = i + 1; j < filters.length; j++)
48
- {
49
- const f = filters[j];
50
- if (filter.table.name == f.table.name)
51
- if (filter.column.name == f.column.name)
52
- if (filter.not == f.not)
53
- if (filter.operator.sign == f.operator.sign)
54
- {
55
- processed[j] = true;
56
- values.push(...f.values);
57
- }
58
- }
59
-
60
- let getNumbers = () =>
61
- {
62
- let nums: number[] = values.map(x => parseFloat(x));
63
- if (nums.filter(x => isNaN(x)).length > 0)
64
- ErrorOperation.throwHTTP(400, `Invalid number values for: '${values.join(",")}'`);
65
- return nums;
66
- };
67
- let addCondition = async (res: BaseFilterItemBuilder_Condition<WhereOptions>) =>
68
- {
69
- let condition: WhereOptions = res.condition;
70
- if (is_table_main)
71
- ans.push(condition);
72
- else
73
- {
74
- if (res.independant || join.getExtraConditions)
75
- ans.push(await getCondition_IDInSelect(filter.table.name, res.independant?.not ?? false, [condition, ...(join.getExtraConditions?.(filter.column.name) ?? [])]));
76
- else
77
- conditions_in_select_main[filter.table.name].push(condition);
78
- }
79
- };
80
- if (filter.operator == FilterItemOperator.all.equals)
81
- await addCondition(this.getIn(column_name, filter.not, values));
82
- else if (filter.operator == FilterItemOperator.all.contains)
83
- for (const value of values)
84
- await addCondition(this.getLike(column_name, filter.not, value));
85
- else if (filter.operator == FilterItemOperator.all.regex)
86
- for (const value of values)
87
- await addCondition(this.getRegex(column_name, filter.not, value));
88
- else if (filter.operator == FilterItemOperator.all.empty)
89
- await addCondition(this.getEmpty(column_name, filter.not));
90
- else if (filter.operator == FilterItemOperator.all.exists)
91
- await addCondition(this.getExists(column_name, filter.not));
92
- else if (filter.operator == FilterItemOperator.all.includes)
93
- await addCondition(this.getIncludes(column_name, filter.not, values));
94
- else if (filter.operator == FilterItemOperator.all.startswith)
95
- for (const value of values)
96
- await addCondition(this.getStartsWith(column_name, filter.not, value));
97
- else if (filter.operator == FilterItemOperator.all.endswith)
98
- for (const value of values)
99
- await addCondition(this.getEndsWith(column_name, filter.not, value));
100
- else if (filter.operator == FilterItemOperator.all.lessthan)
101
- {
102
- if (filter.not)
103
- await addCondition(this.getGTE(column_name, Math.max(...getNumbers())));
104
- else
105
- await addCondition(this.getLT(column_name, Math.max(...getNumbers())));
106
- }
107
- else if (filter.operator == FilterItemOperator.all.lessthanequal)
108
- {
109
- if (filter.not)
110
- await addCondition(this.getGT(column_name, Math.max(...getNumbers())));
111
- else
112
- await addCondition(this.getLTE(column_name, Math.max(...getNumbers())));
113
- }
114
- else if (filter.operator == FilterItemOperator.all.morethan)
115
- {
116
- if (filter.not)
117
- await addCondition(this.getLTE(column_name, Math.max(...getNumbers())));
118
- else
119
- await addCondition(this.getGT(column_name, Math.max(...getNumbers())));
120
- }
121
- else if (filter.operator == FilterItemOperator.all.morethanequal)
122
- {
123
- if (filter.not)
124
- await addCondition(this.getLT(column_name, Math.max(...getNumbers())));
125
- else
126
- await addCondition(this.getGTE(column_name, Math.max(...getNumbers())));
127
- }
128
- }
129
- for (let table of Object.keys(conditions_in_select_main))
130
- {
131
- let conditions = conditions_in_select_main[table];
132
- if (conditions.length > 0)
133
- ans.push(await getCondition_IDInSelect(table, false, conditions));
134
- }
135
- }
136
- return ans;
137
- }
138
- public abstract checkColumn(table_name: string, column_name: string): void;
139
- public abstract getRealColumnName(table_name: string, column_name: string): string;
140
- public abstract getIn(column_name: string, not: boolean, values: string[]): BaseFilterItemBuilder_Condition<WhereOptions>;
141
- public abstract getLike(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
142
- public abstract getRegex(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
143
- public abstract getEmpty(column_name: string, not: boolean): BaseFilterItemBuilder_Condition<WhereOptions>;
144
- public abstract getExists(column_name: string, not: boolean): BaseFilterItemBuilder_Condition<WhereOptions>;
145
- public abstract getIncludes(column_name: string, not: boolean, value: string[]): BaseFilterItemBuilder_Condition<WhereOptions>;
146
- public abstract getStartsWith(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
147
- public abstract getEndsWith(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
148
- public abstract getLT(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
149
- public abstract getLTE(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
150
- public abstract getGT(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
151
- public abstract getGTE(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
152
- public abstract getInSelect(table_name: string, not: boolean, join: BaseFilterItemBuilder_JoinTable<WhereOptions>, conditions: WhereOptions[]): Promise<WhereOptions>;
1
+ import { ErrorOperation, FilterItem, FilterItemOperator } from "namirasoft-core";
2
+
3
+ export interface BaseFilterItemBuilder_JoinTable<WhereOptions>
4
+ {
5
+ main: {
6
+ column: string;
7
+ };
8
+ secondary: {
9
+ column: string;
10
+ };
11
+ getExtraConditions?: (column: string) => WhereOptions[];
12
+ }
13
+
14
+ export type BaseFilterItemBuilder_Condition<WhereOptions> = {
15
+ condition: WhereOptions;
16
+ independant?: { not: boolean };
17
+ };
18
+
19
+ export abstract class BaseFilterItemBuilder<Table extends { getName: () => string; }, WhereOptions>
20
+ {
21
+ public async build(table_main: Table, table_joins: { [table: string]: BaseFilterItemBuilder_JoinTable<WhereOptions> }, filters?: FilterItem[] | undefined): Promise<WhereOptions[]>
22
+ {
23
+ let ans: WhereOptions[] = [];
24
+ if (filters)
25
+ {
26
+ let conditions_in_select_main: { [table: string]: WhereOptions[] } = {};
27
+ Object.keys(table_joins).forEach(table => { conditions_in_select_main[table] = []; });
28
+ let processed: { [index: number]: boolean } = {};
29
+
30
+ let getCondition_IDInSelect = async (table: string, not: boolean, conditions: WhereOptions[]): Promise<WhereOptions> =>
31
+ {
32
+ let join = table_joins[table];
33
+ return this.getInSelect(table, not, join, conditions);
34
+ }
35
+
36
+ for (let i = 0; i < filters.length; i++)
37
+ if (!processed[i])
38
+ {
39
+ const filter = filters[i];
40
+ this.checkColumn(filter.table.name, filter.column.name);
41
+ let join = table_joins[filter.table.name];
42
+ let is_table_main = table_main.getName() === filter.table.name;
43
+ let column_name = this.getRealColumnName(filter.table.name, filter.column.name) ?? filter.column.name;
44
+
45
+ let values = filter.values;
46
+ if (filter.operator.count > 0)
47
+ for (let j = i + 1; j < filters.length; j++)
48
+ {
49
+ const f = filters[j];
50
+ if (filter.table.name == f.table.name)
51
+ if (filter.column.name == f.column.name)
52
+ if (filter.not == f.not)
53
+ if (filter.operator.sign == f.operator.sign)
54
+ {
55
+ processed[j] = true;
56
+ values.push(...f.values);
57
+ }
58
+ }
59
+
60
+ let getNumbers = () =>
61
+ {
62
+ let nums: number[] = values.map(x => parseFloat(x));
63
+ if (nums.filter(x => isNaN(x)).length > 0)
64
+ ErrorOperation.throwHTTP(400, `Invalid number values for: '${values.join(",")}'`);
65
+ return nums;
66
+ };
67
+ let addCondition = async (res: BaseFilterItemBuilder_Condition<WhereOptions>) =>
68
+ {
69
+ let condition: WhereOptions = res.condition;
70
+ if (is_table_main)
71
+ ans.push(condition);
72
+ else
73
+ {
74
+ if (res.independant || join.getExtraConditions)
75
+ ans.push(await getCondition_IDInSelect(filter.table.name, res.independant?.not ?? false, [condition, ...(join.getExtraConditions?.(filter.column.name) ?? [])]));
76
+ else
77
+ conditions_in_select_main[filter.table.name].push(condition);
78
+ }
79
+ };
80
+ if (column_name === "*")
81
+ {
82
+ if (filter.operator !== FilterItemOperator.all.equals)
83
+ ErrorOperation.throwHTTP(400, `Invalid operator for all columns (*).`);
84
+ else
85
+ {
86
+ let columns = this.getAdvancedSearchColumns(filter.table.name);
87
+ for (let i = 0; i < values.length; i++)
88
+ {
89
+ const value = values[i];
90
+ let conditions = await this.getAdvancedSearchConditions(columns, value);
91
+ ans.push(...conditions);
92
+ }
93
+ }
94
+ }
95
+ else if (filter.operator == FilterItemOperator.all.equals)
96
+ await addCondition(this.getIn(column_name, filter.not, values));
97
+ else if (filter.operator == FilterItemOperator.all.contains)
98
+ for (const value of values)
99
+ await addCondition(this.getLike(column_name, filter.not, value));
100
+ else if (filter.operator == FilterItemOperator.all.regex)
101
+ for (const value of values)
102
+ await addCondition(this.getRegex(column_name, filter.not, value));
103
+ else if (filter.operator == FilterItemOperator.all.empty)
104
+ await addCondition(this.getEmpty(column_name, filter.not));
105
+ else if (filter.operator == FilterItemOperator.all.exists)
106
+ await addCondition(this.getExists(column_name, filter.not));
107
+ else if (filter.operator == FilterItemOperator.all.includes)
108
+ await addCondition(this.getIncludes(column_name, filter.not, values));
109
+ else if (filter.operator == FilterItemOperator.all.startswith)
110
+ for (const value of values)
111
+ await addCondition(this.getStartsWith(column_name, filter.not, value));
112
+ else if (filter.operator == FilterItemOperator.all.endswith)
113
+ for (const value of values)
114
+ await addCondition(this.getEndsWith(column_name, filter.not, value));
115
+ else if (filter.operator == FilterItemOperator.all.lessthan)
116
+ {
117
+ if (filter.not)
118
+ await addCondition(this.getGTE(column_name, Math.max(...getNumbers())));
119
+ else
120
+ await addCondition(this.getLT(column_name, Math.max(...getNumbers())));
121
+ }
122
+ else if (filter.operator == FilterItemOperator.all.lessthanequal)
123
+ {
124
+ if (filter.not)
125
+ await addCondition(this.getGT(column_name, Math.max(...getNumbers())));
126
+ else
127
+ await addCondition(this.getLTE(column_name, Math.max(...getNumbers())));
128
+ }
129
+ else if (filter.operator == FilterItemOperator.all.morethan)
130
+ {
131
+ if (filter.not)
132
+ await addCondition(this.getLTE(column_name, Math.max(...getNumbers())));
133
+ else
134
+ await addCondition(this.getGT(column_name, Math.max(...getNumbers())));
135
+ }
136
+ else if (filter.operator == FilterItemOperator.all.morethanequal)
137
+ {
138
+ if (filter.not)
139
+ await addCondition(this.getLT(column_name, Math.max(...getNumbers())));
140
+ else
141
+ await addCondition(this.getGTE(column_name, Math.max(...getNumbers())));
142
+ }
143
+ }
144
+ for (let table of Object.keys(conditions_in_select_main))
145
+ {
146
+ let conditions = conditions_in_select_main[table];
147
+ if (conditions.length > 0)
148
+ ans.push(await getCondition_IDInSelect(table, false, conditions));
149
+ }
150
+ }
151
+ return ans;
152
+ }
153
+ public abstract checkColumn(table_name: string, column_name: string): void;
154
+ public abstract getRealColumnName(table_name: string, column_name: string): string;
155
+ public abstract getAdvancedSearchColumns(table_name: string): string[];
156
+ public abstract getAdvancedSearchConditions(columns: string[], search: string): Promise<WhereOptions[]>;
157
+ public abstract getIn(column_name: string, not: boolean, values: string[]): BaseFilterItemBuilder_Condition<WhereOptions>;
158
+ public abstract getLike(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
159
+ public abstract getRegex(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
160
+ public abstract getEmpty(column_name: string, not: boolean): BaseFilterItemBuilder_Condition<WhereOptions>;
161
+ public abstract getExists(column_name: string, not: boolean): BaseFilterItemBuilder_Condition<WhereOptions>;
162
+ public abstract getIncludes(column_name: string, not: boolean, value: string[]): BaseFilterItemBuilder_Condition<WhereOptions>;
163
+ public abstract getStartsWith(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
164
+ public abstract getEndsWith(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
165
+ public abstract getLT(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
166
+ public abstract getLTE(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
167
+ public abstract getGT(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
168
+ public abstract getGTE(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
169
+ public abstract getInSelect(table_name: string, not: boolean, join: BaseFilterItemBuilder_JoinTable<WhereOptions>, conditions: WhereOptions[]): Promise<WhereOptions>;
153
170
  }
@@ -1,21 +1,22 @@
1
- import { BaseTable } from "./BaseTable";
2
- import { BaseDatabase } from "./BaseDatabase";
3
- import { BaseFilterItemBuilder } from "./BaseFilterItemBuilder";
4
-
5
- export abstract class BaseFilterItemBuilderDatabase<WhereOptions> extends BaseFilterItemBuilder<BaseTable<BaseDatabase, any>, WhereOptions>
6
- {
7
- constructor(public database: BaseDatabase)
8
- {
9
- super();
10
- }
11
- public checkColumn(table_name: string, column_name: string): void
12
- {
13
- let t = this.database.getTable<BaseTable<BaseDatabase, any>>(table_name);
14
- t.checkColumn(column_name, false, null);
15
- }
16
- public getRealColumnName(table_name: string, column_name: string): string
17
- {
18
- let t = this.database.getTable<BaseTable<BaseDatabase, any>>(table_name);
19
- return t.getRealColumnName(column_name);
20
- }
1
+ import { BaseTable } from "./BaseTable";
2
+ import { BaseDatabase } from "./BaseDatabase";
3
+ import { BaseFilterItemBuilder } from "./BaseFilterItemBuilder";
4
+
5
+ export abstract class BaseFilterItemBuilderDatabase<WhereOptions> extends BaseFilterItemBuilder<BaseTable<BaseDatabase, any>, WhereOptions>
6
+ {
7
+ constructor(public database: BaseDatabase)
8
+ {
9
+ super();
10
+ }
11
+ public checkColumn(table_name: string, column_name: string): void
12
+ {
13
+ let t = this.database.getTable<BaseTable<BaseDatabase, any>>(table_name);
14
+ if (column_name != "*")
15
+ t.checkColumn(column_name, false, null);
16
+ }
17
+ public getRealColumnName(table_name: string, column_name: string): string
18
+ {
19
+ let t = this.database.getTable<BaseTable<BaseDatabase, any>>(table_name);
20
+ return t.getRealColumnName(column_name);
21
+ }
21
22
  }
@@ -1,79 +1,89 @@
1
- import { BaseFilterItemBuilder } from "./BaseFilterItemBuilder";
2
-
3
- export class BaseFilterItemBuilderObject extends BaseFilterItemBuilder<{ getName: () => string }, boolean>
4
- {
5
- constructor(public object: any)
6
- {
7
- super();
8
- }
9
- public checkColumn(): void
10
- {
11
- }
12
- public getRealColumnName(_: string, column_name: string): string
13
- {
14
- return column_name;
15
- }
16
- override getIn(column_name: string, not: boolean, values: string[])
17
- {
18
- let condition = values.includes(this.object[column_name] ?? null) !== not;
19
- return { condition };
20
- }
21
- override getLike(column_name: string, not: boolean, value: string)
22
- {
23
- let condition = new RegExp(`.*${value}.*`).test(this.object[column_name] ?? "") !== not;
24
- return { condition };
25
- }
26
- override getRegex(column_name: string, not: boolean, value: string)
27
- {
28
- let condition = new RegExp(value).test(this.object[column_name] ?? "") !== not;
29
- return { condition };
30
- }
31
- override getEmpty(column_name: string, not: boolean)
32
- {
33
- let condition = ((this.object[column_name] ?? "") == "") !== not;
34
- return { condition };
35
- }
36
- override getExists(column_name: string, not: boolean)
37
- {
38
- let condition = ((this.object[column_name]) != null) !== not;
39
- return { condition };
40
- }
41
- override getIncludes(column_name: string, not: boolean, values: string[])
42
- {
43
- return this.getExists(column_name, not) && this.getIn(column_name, not, values);
44
- }
45
- override getStartsWith(column_name: string, not: boolean, value: string)
46
- {
47
- let condition = new RegExp(`${value}.*`).test(this.object[column_name] ?? "") !== not;
48
- return { condition };
49
- }
50
- override getEndsWith(column_name: string, not: boolean, value: string)
51
- {
52
- let condition = new RegExp(`.*${value}`).test(this.object[column_name] ?? "") !== not;
53
- return { condition };
54
- }
55
- override getLT(column_name: string, value: any)
56
- {
57
- let condition = (parseFloat(this.object[column_name] ?? "") < parseFloat(value));
58
- return { condition };
59
- }
60
- override getLTE(column_name: string, value: any)
61
- {
62
- let condition = (parseFloat(this.object[column_name] ?? "") <= parseFloat(value));
63
- return { condition };
64
- }
65
- override getGT(column_name: string, value: any)
66
- {
67
- let condition = (parseFloat(this.object[column_name] ?? "") > parseFloat(value));
68
- return { condition };
69
- }
70
- override getGTE(column_name: string, value: any)
71
- {
72
- let condition = (parseFloat(this.object[column_name] ?? "") >= parseFloat(value));
73
- return { condition };
74
- }
75
- override async getInSelect(): Promise<boolean>
76
- {
77
- throw new Error('Not implemented');
78
- }
1
+ import { SearchOperation } from "namirasoft-core";
2
+ import { BaseFilterItemBuilder } from "./BaseFilterItemBuilder";
3
+
4
+ export class BaseFilterItemBuilderObject extends BaseFilterItemBuilder<{ getName: () => string }, boolean>
5
+ {
6
+ constructor(public object: any)
7
+ {
8
+ super();
9
+ }
10
+ public checkColumn(): void
11
+ {
12
+ }
13
+ public getRealColumnName(_: string, column_name: string): string
14
+ {
15
+ return column_name;
16
+ }
17
+ override getAdvancedSearchColumns(): string[]
18
+ {
19
+ return Object.keys(this.object);
20
+ }
21
+ override async getAdvancedSearchConditions(columns: string[], search: string): Promise<boolean[]>
22
+ {
23
+ let text = columns.map(c => this.object[c]).filter(v => v).join(" ");
24
+ return [SearchOperation.match(text, search)];
25
+ }
26
+ override getIn(column_name: string, not: boolean, values: string[])
27
+ {
28
+ let condition = values.includes(this.object[column_name] ?? null) !== not;
29
+ return { condition };
30
+ }
31
+ override getLike(column_name: string, not: boolean, value: string)
32
+ {
33
+ let condition = new RegExp(`.*${value}.*`).test(this.object[column_name] ?? "") !== not;
34
+ return { condition };
35
+ }
36
+ override getRegex(column_name: string, not: boolean, value: string)
37
+ {
38
+ let condition = new RegExp(value).test(this.object[column_name] ?? "") !== not;
39
+ return { condition };
40
+ }
41
+ override getEmpty(column_name: string, not: boolean)
42
+ {
43
+ let condition = ((this.object[column_name] ?? "") == "") !== not;
44
+ return { condition };
45
+ }
46
+ override getExists(column_name: string, not: boolean)
47
+ {
48
+ let condition = ((this.object[column_name]) != null) !== not;
49
+ return { condition };
50
+ }
51
+ override getIncludes(column_name: string, not: boolean, values: string[])
52
+ {
53
+ return this.getExists(column_name, not) && this.getIn(column_name, not, values);
54
+ }
55
+ override getStartsWith(column_name: string, not: boolean, value: string)
56
+ {
57
+ let condition = new RegExp(`${value}.*`).test(this.object[column_name] ?? "") !== not;
58
+ return { condition };
59
+ }
60
+ override getEndsWith(column_name: string, not: boolean, value: string)
61
+ {
62
+ let condition = new RegExp(`.*${value}`).test(this.object[column_name] ?? "") !== not;
63
+ return { condition };
64
+ }
65
+ override getLT(column_name: string, value: any)
66
+ {
67
+ let condition = (parseFloat(this.object[column_name] ?? "") < parseFloat(value));
68
+ return { condition };
69
+ }
70
+ override getLTE(column_name: string, value: any)
71
+ {
72
+ let condition = (parseFloat(this.object[column_name] ?? "") <= parseFloat(value));
73
+ return { condition };
74
+ }
75
+ override getGT(column_name: string, value: any)
76
+ {
77
+ let condition = (parseFloat(this.object[column_name] ?? "") > parseFloat(value));
78
+ return { condition };
79
+ }
80
+ override getGTE(column_name: string, value: any)
81
+ {
82
+ let condition = (parseFloat(this.object[column_name] ?? "") >= parseFloat(value));
83
+ return { condition };
84
+ }
85
+ override async getInSelect(): Promise<boolean>
86
+ {
87
+ throw new Error('Not implemented');
88
+ }
79
89
  }