namirasoft-node 1.4.59 → 1.4.60
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/BaseController.d.ts +1 -0
- package/dist/BaseController.js +5 -0
- package/dist/BaseController.js.map +1 -1
- package/package.json +43 -43
- package/src/AnomalyDetector.ts +84 -84
- package/src/BaseApplication.ts +432 -432
- package/src/BaseApplicationLink.ts +6 -6
- package/src/BaseController.ts +205 -199
- package/src/BaseCron.ts +54 -54
- package/src/BaseDatabase.ts +45 -45
- package/src/BaseEmailService.ts +38 -38
- package/src/BaseFilterItemBuilder.ts +152 -152
- package/src/BaseFilterItemBuilderDatabase.ts +20 -20
- package/src/BaseFilterItemBuilderObject.ts +78 -78
- package/src/BaseTable.ts +125 -125
- package/src/CommandOperation.ts +32 -32
- package/src/EmptyDatabase.ts +11 -11
- package/src/GmailService.ts +22 -22
- package/src/IPOperation.ts +38 -38
- package/src/Meta.ts +41 -41
- package/src/OTPOperation.ts +84 -84
- package/src/RequestHeaderService.ts +27 -27
- package/src/SMTPService.ts +26 -26
- package/src/ServerToServerOperation.ts +23 -23
- package/src/index.ts +19 -19
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,153 +1,153 @@
|
|
|
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 (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>;
|
|
153
153
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
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
|
+
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
|
+
}
|
|
21
21
|
}
|
|
@@ -1,79 +1,79 @@
|
|
|
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 { 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
|
+
}
|
|
79
79
|
}
|