namirasoft-node 1.4.101 → 1.4.103
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/BaseFilterItemBuilder.d.ts +1 -0
- package/dist/BaseFilterItemBuilder.js +9 -8
- package/dist/BaseFilterItemBuilder.js.map +1 -1
- package/dist/BaseFilterItemBuilderObject.d.ts +1 -0
- package/dist/BaseFilterItemBuilderObject.js +3 -0
- package/dist/BaseFilterItemBuilderObject.js.map +1 -1
- package/dist/OTPOperation.js +3 -3
- package/dist/OTPOperation.js.map +1 -1
- package/package.json +43 -43
- package/src/AnomalyDetector.ts +84 -84
- package/src/BaseApplication.ts +440 -440
- package/src/BaseApplicationLink.ts +6 -6
- package/src/BaseController.ts +225 -225
- package/src/BaseCron.ts +104 -104
- package/src/BaseDatabase.ts +45 -45
- package/src/BaseEmailService.ts +38 -38
- package/src/BaseFilterItemBuilder.ts +191 -189
- package/src/BaseFilterItemBuilderDatabase.ts +45 -45
- package/src/BaseFilterItemBuilderObject.ts +95 -91
- package/src/BaseTable.ts +137 -137
- package/src/BaseTableColumnOptions.ts +8 -8
- package/src/CommandOperation.ts +32 -32
- package/src/GmailService.ts +22 -22
- package/src/IPOperation.ts +38 -38
- package/src/Meta.ts +36 -36
- package/src/OTPOperation.ts +94 -94
- package/src/RequestHeaderService.ts +27 -27
- package/src/SMTPService.ts +26 -26
- package/src/ServerToServerOperation.ts +23 -23
- package/src/Timer.ts +17 -17
- package/src/Validator.ts +15 -15
- package/src/index.ts +21 -21
package/src/BaseDatabase.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import * as express from "express";
|
|
2
|
-
import { ErrorOperation, SortItem } from "namirasoft-core";
|
|
3
|
-
|
|
4
|
-
export abstract class BaseDatabase
|
|
5
|
-
{
|
|
6
|
-
private tables: { [name: string]: any } = {};
|
|
7
|
-
public req?: express.Request;
|
|
8
|
-
public res?: express.Response;
|
|
9
|
-
abstract init(): Promise<void>;
|
|
10
|
-
abstract connect(): Promise<void>;
|
|
11
|
-
abstract sync(force: boolean): Promise<void>;
|
|
12
|
-
async seedBefore(): Promise<void>
|
|
13
|
-
{
|
|
14
|
-
}
|
|
15
|
-
async seedAfter(): Promise<void>
|
|
16
|
-
{
|
|
17
|
-
}
|
|
18
|
-
addTable(name: string, table: any)
|
|
19
|
-
{
|
|
20
|
-
this.tables[name] = table;
|
|
21
|
-
}
|
|
22
|
-
getTable<T>(name: string): T
|
|
23
|
-
{
|
|
24
|
-
let ans = this.tables[name] as T;
|
|
25
|
-
if (!ans)
|
|
26
|
-
ErrorOperation.throwHTTP(404, `Table '${name}' not found`);
|
|
27
|
-
return ans;
|
|
28
|
-
}
|
|
29
|
-
paginate(page_number: number, page_size: number, page_size_default?: number): { offset: number, limit: number }
|
|
30
|
-
{
|
|
31
|
-
// page_number
|
|
32
|
-
if (isNaN(page_number))
|
|
33
|
-
page_number = 1;
|
|
34
|
-
// page_size
|
|
35
|
-
if (isNaN(page_size))
|
|
36
|
-
if (page_size_default)
|
|
37
|
-
page_size = page_size_default;
|
|
38
|
-
if (isNaN(page_size))
|
|
39
|
-
page_size = 25;
|
|
40
|
-
//
|
|
41
|
-
let offset = (page_number - 1) * page_size;
|
|
42
|
-
let limit = page_size;
|
|
43
|
-
return { offset, limit };
|
|
44
|
-
}
|
|
45
|
-
public abstract getSortOptions(sorts?: SortItem[] | undefined): any;
|
|
1
|
+
import * as express from "express";
|
|
2
|
+
import { ErrorOperation, SortItem } from "namirasoft-core";
|
|
3
|
+
|
|
4
|
+
export abstract class BaseDatabase
|
|
5
|
+
{
|
|
6
|
+
private tables: { [name: string]: any } = {};
|
|
7
|
+
public req?: express.Request;
|
|
8
|
+
public res?: express.Response;
|
|
9
|
+
abstract init(): Promise<void>;
|
|
10
|
+
abstract connect(): Promise<void>;
|
|
11
|
+
abstract sync(force: boolean): Promise<void>;
|
|
12
|
+
async seedBefore(): Promise<void>
|
|
13
|
+
{
|
|
14
|
+
}
|
|
15
|
+
async seedAfter(): Promise<void>
|
|
16
|
+
{
|
|
17
|
+
}
|
|
18
|
+
addTable(name: string, table: any)
|
|
19
|
+
{
|
|
20
|
+
this.tables[name] = table;
|
|
21
|
+
}
|
|
22
|
+
getTable<T>(name: string): T
|
|
23
|
+
{
|
|
24
|
+
let ans = this.tables[name] as T;
|
|
25
|
+
if (!ans)
|
|
26
|
+
ErrorOperation.throwHTTP(404, `Table '${name}' not found`);
|
|
27
|
+
return ans;
|
|
28
|
+
}
|
|
29
|
+
paginate(page_number: number, page_size: number, page_size_default?: number): { offset: number, limit: number }
|
|
30
|
+
{
|
|
31
|
+
// page_number
|
|
32
|
+
if (isNaN(page_number))
|
|
33
|
+
page_number = 1;
|
|
34
|
+
// page_size
|
|
35
|
+
if (isNaN(page_size))
|
|
36
|
+
if (page_size_default)
|
|
37
|
+
page_size = page_size_default;
|
|
38
|
+
if (isNaN(page_size))
|
|
39
|
+
page_size = 25;
|
|
40
|
+
//
|
|
41
|
+
let offset = (page_number - 1) * page_size;
|
|
42
|
+
let limit = page_size;
|
|
43
|
+
return { offset, limit };
|
|
44
|
+
}
|
|
45
|
+
public abstract getSortOptions(sorts?: SortItem[] | undefined): any;
|
|
46
46
|
}
|
package/src/BaseEmailService.ts
CHANGED
|
@@ -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,190 +1,192 @@
|
|
|
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
|
-
function get_conditions_in_select_main(name: string)
|
|
28
|
-
{
|
|
29
|
-
if (!conditions_in_select_main[name])
|
|
30
|
-
conditions_in_select_main[name] = [];
|
|
31
|
-
return conditions_in_select_main[name];
|
|
32
|
-
}
|
|
33
|
-
let processed: { [index: number]: boolean } = {};
|
|
34
|
-
|
|
35
|
-
let getCondition_IDInSelect = async (table: string, not: boolean, conditions: WhereOptions[]): Promise<WhereOptions> =>
|
|
36
|
-
{
|
|
37
|
-
let join = table_joins[table];
|
|
38
|
-
return this.getInSelect(table, not, join, conditions);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
for (let i = 0; i < filters.length; i++)
|
|
42
|
-
if (!processed[i])
|
|
43
|
-
{
|
|
44
|
-
const filter = filters[i];
|
|
45
|
-
this.checkColumn(filter.table.name, filter.column.name);
|
|
46
|
-
let is_table_main = table_main.getName() === filter.table.name;
|
|
47
|
-
let column_name = this.getRealColumnName(filter.table.name, filter.column.name) ?? filter.column.name;
|
|
48
|
-
|
|
49
|
-
let values = filter.values;
|
|
50
|
-
|
|
51
|
-
if ([
|
|
52
|
-
FilterItemOperator.all.equals.sign,
|
|
53
|
-
FilterItemOperator.all.lessthan.sign,
|
|
54
|
-
FilterItemOperator.all.lessthanequal.sign,
|
|
55
|
-
FilterItemOperator.all.morethan.sign,
|
|
56
|
-
FilterItemOperator.all.morethanequal.sign
|
|
57
|
-
].includes(filter.operator.sign))
|
|
58
|
-
for (let v = 0; v < values.length; v++)
|
|
59
|
-
this.checkValue(filter.table.name, filter.column.name, values[i]);
|
|
60
|
-
|
|
61
|
-
if (filter.operator.count > 0)
|
|
62
|
-
for (let j = i + 1; j < filters.length; j++)
|
|
63
|
-
{
|
|
64
|
-
const f = filters[j];
|
|
65
|
-
if (filter.table.name == f.table.name)
|
|
66
|
-
if (filter.column.name == f.column.name)
|
|
67
|
-
if (filter.not == f.not)
|
|
68
|
-
if (filter.operator.sign == f.operator.sign)
|
|
69
|
-
{
|
|
70
|
-
processed[j] = true;
|
|
71
|
-
values.push(...f.values);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
public abstract
|
|
171
|
-
public abstract
|
|
172
|
-
public abstract
|
|
173
|
-
public abstract
|
|
174
|
-
public abstract
|
|
175
|
-
public abstract
|
|
176
|
-
public abstract
|
|
177
|
-
|
|
178
|
-
public abstract
|
|
179
|
-
//
|
|
180
|
-
public abstract
|
|
181
|
-
//
|
|
182
|
-
public abstract
|
|
183
|
-
|
|
184
|
-
public abstract
|
|
185
|
-
public abstract
|
|
186
|
-
public abstract
|
|
187
|
-
public abstract
|
|
188
|
-
public abstract
|
|
189
|
-
public abstract
|
|
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
|
+
function get_conditions_in_select_main(name: string)
|
|
28
|
+
{
|
|
29
|
+
if (!conditions_in_select_main[name])
|
|
30
|
+
conditions_in_select_main[name] = [];
|
|
31
|
+
return conditions_in_select_main[name];
|
|
32
|
+
}
|
|
33
|
+
let processed: { [index: number]: boolean } = {};
|
|
34
|
+
|
|
35
|
+
let getCondition_IDInSelect = async (table: string, not: boolean, conditions: WhereOptions[]): Promise<WhereOptions> =>
|
|
36
|
+
{
|
|
37
|
+
let join = table_joins[table];
|
|
38
|
+
return this.getInSelect(table, not, join, conditions);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < filters.length; i++)
|
|
42
|
+
if (!processed[i])
|
|
43
|
+
{
|
|
44
|
+
const filter = filters[i];
|
|
45
|
+
this.checkColumn(filter.table.name, filter.column.name);
|
|
46
|
+
let is_table_main = table_main.getName() === filter.table.name;
|
|
47
|
+
let column_name = this.getRealColumnName(filter.table.name, filter.column.name) ?? filter.column.name;
|
|
48
|
+
|
|
49
|
+
let values = filter.values;
|
|
50
|
+
|
|
51
|
+
if ([
|
|
52
|
+
FilterItemOperator.all.equals.sign,
|
|
53
|
+
FilterItemOperator.all.lessthan.sign,
|
|
54
|
+
FilterItemOperator.all.lessthanequal.sign,
|
|
55
|
+
FilterItemOperator.all.morethan.sign,
|
|
56
|
+
FilterItemOperator.all.morethanequal.sign
|
|
57
|
+
].includes(filter.operator.sign))
|
|
58
|
+
for (let v = 0; v < values.length; v++)
|
|
59
|
+
this.checkValue(filter.table.name, filter.column.name, values[i]);
|
|
60
|
+
|
|
61
|
+
if (filter.operator.count > 0)
|
|
62
|
+
for (let j = i + 1; j < filters.length; j++)
|
|
63
|
+
{
|
|
64
|
+
const f = filters[j];
|
|
65
|
+
if (filter.table.name == f.table.name)
|
|
66
|
+
if (filter.column.name == f.column.name)
|
|
67
|
+
if (filter.not == f.not)
|
|
68
|
+
if (filter.operator.sign == f.operator.sign)
|
|
69
|
+
{
|
|
70
|
+
processed[j] = true;
|
|
71
|
+
values.push(...f.values);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let escapedValues = values.map(v => this.escapeValue(v));
|
|
76
|
+
let getNumbers = () =>
|
|
77
|
+
{
|
|
78
|
+
let nums: number[] = values.map(x => parseFloat(x));
|
|
79
|
+
if (nums.filter(x => isNaN(x)).length > 0)
|
|
80
|
+
ErrorOperation.throwHTTP(400, `Invalid number values for: '${values.join(",")}'`);
|
|
81
|
+
return nums;
|
|
82
|
+
};
|
|
83
|
+
let addCondition = async (res: BaseFilterItemBuilder_Condition<WhereOptions>) =>
|
|
84
|
+
{
|
|
85
|
+
let condition: WhereOptions = res.condition;
|
|
86
|
+
if (is_table_main)
|
|
87
|
+
ans.push(condition);
|
|
88
|
+
else
|
|
89
|
+
{
|
|
90
|
+
let join = table_joins[filter.table.name];
|
|
91
|
+
if (res.independant || join?.getExtraConditions)
|
|
92
|
+
ans.push(await getCondition_IDInSelect(filter.table.name, res.independant?.not ?? false, [condition, ...(join?.getExtraConditions?.(filter.column.name) ?? [])]));
|
|
93
|
+
else
|
|
94
|
+
get_conditions_in_select_main(filter.table.name).push(condition);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
if (column_name === "*")
|
|
98
|
+
{
|
|
99
|
+
if (filter.operator !== FilterItemOperator.all.equals)
|
|
100
|
+
ErrorOperation.throwHTTP(400, `Invalid operator for all columns (*).`);
|
|
101
|
+
else
|
|
102
|
+
{
|
|
103
|
+
let columns = this.getAdvancedSearchColumns(filter.table.name);
|
|
104
|
+
for (let i = 0; i < escapedValues.length; i++)
|
|
105
|
+
{
|
|
106
|
+
const value = escapedValues[i];
|
|
107
|
+
let conditions = await this.getAdvancedSearchConditions(columns, value);
|
|
108
|
+
ans.push(...conditions);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (filter.operator == FilterItemOperator.all.equals)
|
|
113
|
+
await addCondition(this.getIn(column_name, filter.not, escapedValues));
|
|
114
|
+
else if (filter.operator == FilterItemOperator.all.contains)
|
|
115
|
+
for (const value of escapedValues)
|
|
116
|
+
await addCondition(this.getLike(column_name, filter.not, value));
|
|
117
|
+
else if (filter.operator == FilterItemOperator.all.regex)
|
|
118
|
+
for (const value of escapedValues)
|
|
119
|
+
await addCondition(this.getRegex(column_name, filter.not, value));
|
|
120
|
+
else if (filter.operator == FilterItemOperator.all.empty)
|
|
121
|
+
await addCondition(this.getEmpty(column_name, filter.not));
|
|
122
|
+
else if (filter.operator == FilterItemOperator.all.exists)
|
|
123
|
+
await addCondition(this.getExists(column_name, filter.not));
|
|
124
|
+
else if (filter.operator == FilterItemOperator.all.includes)
|
|
125
|
+
await addCondition(this.getIncludes(column_name, filter.not, escapedValues));
|
|
126
|
+
else if (filter.operator == FilterItemOperator.all.startswith)
|
|
127
|
+
for (const value of escapedValues)
|
|
128
|
+
await addCondition(this.getStartsWith(column_name, filter.not, value));
|
|
129
|
+
else if (filter.operator == FilterItemOperator.all.endswith)
|
|
130
|
+
for (const value of escapedValues)
|
|
131
|
+
await addCondition(this.getEndsWith(column_name, filter.not, value));
|
|
132
|
+
else if (filter.operator == FilterItemOperator.all.lessthan)
|
|
133
|
+
{
|
|
134
|
+
if (filter.not)
|
|
135
|
+
await addCondition(this.getGTE(column_name, Math.max(...getNumbers())));
|
|
136
|
+
else
|
|
137
|
+
await addCondition(this.getLT(column_name, Math.max(...getNumbers())));
|
|
138
|
+
}
|
|
139
|
+
else if (filter.operator == FilterItemOperator.all.lessthanequal)
|
|
140
|
+
{
|
|
141
|
+
if (filter.not)
|
|
142
|
+
await addCondition(this.getGT(column_name, Math.max(...getNumbers())));
|
|
143
|
+
else
|
|
144
|
+
await addCondition(this.getLTE(column_name, Math.max(...getNumbers())));
|
|
145
|
+
}
|
|
146
|
+
else if (filter.operator == FilterItemOperator.all.morethan)
|
|
147
|
+
{
|
|
148
|
+
if (filter.not)
|
|
149
|
+
await addCondition(this.getLTE(column_name, Math.max(...getNumbers())));
|
|
150
|
+
else
|
|
151
|
+
await addCondition(this.getGT(column_name, Math.max(...getNumbers())));
|
|
152
|
+
}
|
|
153
|
+
else if (filter.operator == FilterItemOperator.all.morethanequal)
|
|
154
|
+
{
|
|
155
|
+
if (filter.not)
|
|
156
|
+
await addCondition(this.getLT(column_name, Math.max(...getNumbers())));
|
|
157
|
+
else
|
|
158
|
+
await addCondition(this.getGTE(column_name, Math.max(...getNumbers())));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (let table of Object.keys(conditions_in_select_main))
|
|
162
|
+
{
|
|
163
|
+
let conditions = conditions_in_select_main[table];
|
|
164
|
+
if (conditions.length > 0)
|
|
165
|
+
ans.push(await getCondition_IDInSelect(table, false, conditions));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return ans;
|
|
169
|
+
}
|
|
170
|
+
public abstract checkColumn(table_name: string, column_name: string): void;
|
|
171
|
+
public abstract checkValue(table_name: string, column_name: string, value: string): void;
|
|
172
|
+
public abstract escapeValue(value: string): string;
|
|
173
|
+
public abstract getRealColumnName(table_name: string, column_name: string): string;
|
|
174
|
+
public abstract getAdvancedSearchColumns(table_name: string): string[];
|
|
175
|
+
public abstract getAdvancedSearchConditions(columns: string[], search: string): Promise<WhereOptions[]>;
|
|
176
|
+
public abstract getIn(column_name: string, not: boolean, values: string[]): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
177
|
+
public abstract getLike(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
178
|
+
public abstract getRegex(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
179
|
+
// Empty means the column exists but the value is undefined, null or ''
|
|
180
|
+
public abstract getEmpty(column_name: string, not: boolean): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
181
|
+
// Exist means the column does not exist or the value is undefined, null or ''
|
|
182
|
+
public abstract getExists(column_name: string, not: boolean): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
183
|
+
// Include is only used when there is a join and it means the column has one of the value
|
|
184
|
+
public abstract getIncludes(column_name: string, not: boolean, values: string[]): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
185
|
+
public abstract getStartsWith(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
186
|
+
public abstract getEndsWith(column_name: string, not: boolean, value: string): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
187
|
+
public abstract getLT(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
188
|
+
public abstract getLTE(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
189
|
+
public abstract getGT(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
190
|
+
public abstract getGTE(column_name: string, value: any): BaseFilterItemBuilder_Condition<WhereOptions>;
|
|
191
|
+
public abstract getInSelect(table_name: string, not: boolean, join: BaseFilterItemBuilder_JoinTable<WhereOptions>, conditions: WhereOptions[]): Promise<WhereOptions>;
|
|
190
192
|
}
|