@oneuptime/common 7.0.2976 → 7.0.2986
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/Models/AnalyticsModels/AnalyticsBaseModel/CommonModel.ts +8 -7
- package/Models/DatabaseModels/Monitor.ts +36 -0
- package/Server/API/BaseAnalyticsAPI.ts +2 -6
- package/Server/Infrastructure/Postgres/SchemaMigrations/1724078044172-MigrationName.ts +23 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Services/AnalyticsDatabaseService.ts +2 -2
- package/Server/Services/DatabaseService.ts +2 -2
- package/Server/Services/MonitorService.ts +9 -0
- package/Server/Services/ProjectService.ts +16 -2
- package/Server/Services/StatusPageHeaderLinkService.ts +1 -1
- package/Server/Types/AnalyticsDatabase/QueryHelper.ts +8 -7
- package/Server/Types/Database/Query.ts +6 -20
- package/Server/Types/Database/QueryHelper.ts +59 -42
- package/Server/Types/Database/QueryUtil.ts +8 -7
- package/Server/Types/Workflow/Components/Conditions/IfElse.ts +17 -5
- package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +1 -1
- package/Tests/Types/Database/CompareBase.test.ts +6 -6
- package/Tests/Types/Database/Date.test.ts +1 -1
- package/Tests/Types/Database/EqualToOrNull.test.ts +14 -8
- package/Tests/Types/Database/InBetween.test.ts +8 -8
- package/Tests/Types/Database/NotEqual.test.ts +2 -2
- package/Types/BaseDatabase/AggregateBy.ts +1 -1
- package/Types/BaseDatabase/EqualToOrNull.ts +12 -16
- package/Types/BaseDatabase/GreaterThan.ts +8 -6
- package/Types/BaseDatabase/GreaterThanOrEqual.ts +10 -6
- package/Types/BaseDatabase/InBetween.ts +21 -23
- package/Types/BaseDatabase/Includes.ts +2 -2
- package/Types/BaseDatabase/IsNull.ts +3 -2
- package/Types/BaseDatabase/LessThan.ts +8 -6
- package/Types/BaseDatabase/LessThanOrEqual.ts +10 -6
- package/Types/BaseDatabase/NotEqual.ts +10 -17
- package/Types/BaseDatabase/NotNull.ts +3 -2
- package/Types/BaseDatabase/Query.ts +17 -6
- package/Types/BaseDatabase/QueryOperator.ts +11 -0
- package/Types/BaseDatabase/Search.ts +12 -10
- package/Types/BrandColors.ts +8 -0
- package/Types/Database/CompareBase.ts +10 -6
- package/Types/Database/Date.ts +1 -1
- package/Types/Date.ts +3 -1
- package/Types/Domain.ts +1 -1
- package/Types/JSON.ts +17 -16
- package/Types/JSONFunctions.ts +3 -2
- package/Types/Workflow/Components/Condition.ts +15 -1
- package/UI/Components/Charts/Line/LineChart.tsx +2 -2
- package/UI/Components/Date/StartAndEndDate.tsx +6 -8
- package/UI/Components/Filters/DateFilter.tsx +6 -3
- package/UI/Components/Filters/FilterViewer.tsx +3 -1
- package/UI/Components/Filters/JSONFilter.tsx +4 -1
- package/UI/Components/Filters/Types/FilterData.ts +1 -1
- package/UI/Components/HeaderAlert/HeaderModelAlert.tsx +1 -1
- package/UI/Components/ModelFilter/Filter.ts +1 -1
- package/UI/Components/ModelList/ModelList.tsx +1 -1
- package/UI/Components/ModelListModal/ModelListModal.tsx +1 -1
- package/UI/Components/ModelProgress/ModelProgress.tsx +1 -1
- package/UI/Components/ModelTable/AnalyticsModelTable.tsx +1 -1
- package/UI/Components/ModelTable/BaseModelTable.tsx +1 -1
- package/UI/Components/ModelTable/ModelTable.tsx +1 -1
- package/UI/Components/SideMenu/CountModelSideMenuItem.tsx +1 -1
- package/UI/Components/Workflow/Utils.ts +23 -6
- package/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts +1 -1
- package/UI/Utils/ModelAPI/ModelAPI.ts +1 -1
- package/UI/Utils/Realtime.ts +1 -1
- package/Utils/CronTime.ts +1 -0
- package/build/dist/Models/AnalyticsModels/AnalyticsBaseModel/CommonModel.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Monitor.js +36 -0
- package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
- package/build/dist/Server/API/BaseAnalyticsAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724078044172-MigrationName.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724078044172-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +2 -2
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +7 -0
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +15 -2
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageHeaderLinkService.js.map +1 -1
- package/build/dist/Server/Types/AnalyticsDatabase/QueryHelper.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryUtil.js.map +1 -1
- package/build/dist/Server/Types/Workflow/Components/Conditions/IfElse.js +18 -3
- package/build/dist/Server/Types/Workflow/Components/Conditions/IfElse.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
- package/build/dist/Tests/Types/Database/CompareBase.test.js.map +1 -1
- package/build/dist/Tests/Types/Database/EqualToOrNull.test.js.map +1 -1
- package/build/dist/Tests/Types/Database/InBetween.test.js.map +1 -1
- package/build/dist/Tests/Types/Database/NotEqual.test.js.map +1 -1
- package/build/dist/Types/BaseDatabase/EqualToOrNull.js +4 -10
- package/build/dist/Types/BaseDatabase/EqualToOrNull.js.map +1 -1
- package/build/dist/Types/BaseDatabase/GreaterThan.js.map +1 -1
- package/build/dist/Types/BaseDatabase/GreaterThanOrEqual.js.map +1 -1
- package/build/dist/Types/BaseDatabase/InBetween.js +2 -2
- package/build/dist/Types/BaseDatabase/InBetween.js.map +1 -1
- package/build/dist/Types/BaseDatabase/Includes.js +2 -2
- package/build/dist/Types/BaseDatabase/Includes.js.map +1 -1
- package/build/dist/Types/BaseDatabase/IsNull.js +2 -2
- package/build/dist/Types/BaseDatabase/IsNull.js.map +1 -1
- package/build/dist/Types/BaseDatabase/LessThan.js.map +1 -1
- package/build/dist/Types/BaseDatabase/LessThanOrEqual.js.map +1 -1
- package/build/dist/Types/BaseDatabase/NotEqual.js +4 -11
- package/build/dist/Types/BaseDatabase/NotEqual.js.map +1 -1
- package/build/dist/Types/BaseDatabase/NotNull.js +2 -2
- package/build/dist/Types/BaseDatabase/NotNull.js.map +1 -1
- package/build/dist/Types/BaseDatabase/QueryOperator.js +7 -0
- package/build/dist/Types/BaseDatabase/QueryOperator.js.map +1 -0
- package/build/dist/Types/BaseDatabase/Search.js +2 -2
- package/build/dist/Types/BaseDatabase/Search.js.map +1 -1
- package/build/dist/Types/BrandColors.js +7 -0
- package/build/dist/Types/BrandColors.js.map +1 -1
- package/build/dist/Types/Database/CompareBase.js +2 -2
- package/build/dist/Types/Database/CompareBase.js.map +1 -1
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/Domain.js +1 -1
- package/build/dist/Types/Domain.js.map +1 -1
- package/build/dist/Types/JSON.js.map +1 -1
- package/build/dist/Types/JSONFunctions.js.map +1 -1
- package/build/dist/Types/Workflow/Components/Condition.js +14 -1
- package/build/dist/Types/Workflow/Components/Condition.js.map +1 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js +2 -2
- package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Date/StartAndEndDate.js.map +1 -1
- package/build/dist/UI/Components/Filters/DateFilter.js.map +1 -1
- package/build/dist/UI/Components/Filters/FilterViewer.js.map +1 -1
- package/build/dist/UI/Components/Filters/JSONFilter.js.map +1 -1
- package/build/dist/UI/Components/Workflow/Utils.js +23 -6
- package/build/dist/UI/Components/Workflow/Utils.js.map +1 -1
- package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
- package/build/dist/UI/Utils/Realtime.js.map +1 -1
- package/build/dist/Utils/CronTime.js +1 -0
- package/build/dist/Utils/CronTime.js.map +1 -1
- package/package.json +2 -2
- package/UI/Utils/BaseDatabase/Query.ts +0 -25
- package/build/dist/UI/Utils/BaseDatabase/Query.js +0 -2
- package/build/dist/UI/Utils/BaseDatabase/Query.js.map +0 -1
|
@@ -5,7 +5,9 @@ import ReturnResult from "Common/Types/IsolatedVM/ReturnResult";
|
|
|
5
5
|
import { JSONObject, JSONValue } from "Common/Types/JSON";
|
|
6
6
|
import ComponentMetadata, { Port } from "Common/Types/Workflow/Component";
|
|
7
7
|
import ComponentID from "Common/Types/Workflow/ComponentID";
|
|
8
|
-
import Components
|
|
8
|
+
import Components, {
|
|
9
|
+
ConditionOperator,
|
|
10
|
+
} from "Common/Types/Workflow/Components/Condition";
|
|
9
11
|
|
|
10
12
|
export default class IfElse extends ComponentCode {
|
|
11
13
|
public constructor() {
|
|
@@ -87,7 +89,7 @@ export default class IfElse extends ComponentCode {
|
|
|
87
89
|
return arg;
|
|
88
90
|
};
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
let code: string = `
|
|
91
93
|
const input1 = ${
|
|
92
94
|
serialize(args["input-1"] as string) || ""
|
|
93
95
|
};
|
|
@@ -96,9 +98,19 @@ export default class IfElse extends ComponentCode {
|
|
|
96
98
|
serialize(args["input-2"] as string) || ""
|
|
97
99
|
};
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
if (args["operator"] === ConditionOperator.Contains) {
|
|
104
|
+
code += `return input1.includes(input2);`;
|
|
105
|
+
} else if (args["operator"] === ConditionOperator.DoesNotContain) {
|
|
106
|
+
code += `return !input1.includes(input2);`;
|
|
107
|
+
} else if (args["operator"] === ConditionOperator.StartsWith) {
|
|
108
|
+
code += `return input1.startsWith(input2);`;
|
|
109
|
+
} else if (args["operator"] === ConditionOperator.EndsWith) {
|
|
110
|
+
code += `return input1.endsWith(input2);`;
|
|
111
|
+
} else {
|
|
112
|
+
code += `return input1 ${(args["operator"] as string) || "=="} input2;`;
|
|
113
|
+
}
|
|
102
114
|
|
|
103
115
|
const returnResult: ReturnResult = await VMUtil.runCodeInSandbox({
|
|
104
116
|
code,
|
|
@@ -538,7 +538,7 @@ export default class StatementGenerator<TBaseModel extends AnalyticsBaseModel> {
|
|
|
538
538
|
const selectStatement: Statement = new Statement();
|
|
539
539
|
|
|
540
540
|
const aggregationMethod: string =
|
|
541
|
-
aggregateBy.
|
|
541
|
+
aggregateBy.aggregationType.toLocaleLowerCase();
|
|
542
542
|
const aggregationInterval: string = AggregateUtil.getAggregationInterval({
|
|
543
543
|
startDate: aggregateBy.startTimestamp!,
|
|
544
544
|
endDate: aggregateBy.endTimestamp!,
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import CompareBase from "../../../Types/Database/CompareBase";
|
|
1
|
+
import CompareBase, { CompareType } from "../../../Types/Database/CompareBase";
|
|
2
2
|
import BadDataException from "../../../Types/Exception/BadDataException";
|
|
3
3
|
import { describe, expect, it } from "@jest/globals";
|
|
4
4
|
|
|
5
5
|
describe("CompareBase", () => {
|
|
6
6
|
describe("toString", () => {
|
|
7
7
|
it("should return string representation of value", () => {
|
|
8
|
-
const compareBase: CompareBase = new CompareBase(10);
|
|
8
|
+
const compareBase: CompareBase<CompareType> = new CompareBase(10);
|
|
9
9
|
expect(compareBase.toString()).toBe("10");
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
describe("toNumber", () => {
|
|
14
14
|
it("should return value as number if it is a number", () => {
|
|
15
|
-
const compareBase: CompareBase = new CompareBase(10);
|
|
15
|
+
const compareBase: CompareBase<CompareType> = new CompareBase(10);
|
|
16
16
|
expect(compareBase.toNumber()).toBe(10);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should throw BadDataException if value is not a number", () => {
|
|
20
|
-
const compareBase: CompareBase = new CompareBase(new Date());
|
|
20
|
+
const compareBase: CompareBase<CompareType> = new CompareBase(new Date());
|
|
21
21
|
expect(() => {
|
|
22
22
|
return compareBase.toNumber();
|
|
23
23
|
}).toThrow(BadDataException);
|
|
@@ -27,12 +27,12 @@ describe("CompareBase", () => {
|
|
|
27
27
|
describe("toDate", () => {
|
|
28
28
|
it("should return value as date object if it is a date object", () => {
|
|
29
29
|
const date: Date = new Date();
|
|
30
|
-
const compareBase: CompareBase = new CompareBase(date);
|
|
30
|
+
const compareBase: CompareBase<CompareType> = new CompareBase(date);
|
|
31
31
|
expect(compareBase.toDate()).toBe(date);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it("should throw BadDataException if value is not a date object", () => {
|
|
35
|
-
const compareBase: CompareBase = new CompareBase(10);
|
|
35
|
+
const compareBase: CompareBase<CompareType> = new CompareBase(10);
|
|
36
36
|
expect(() => {
|
|
37
37
|
return compareBase.toDate();
|
|
38
38
|
}).toThrow(BadDataException);
|
|
@@ -73,7 +73,7 @@ describe("DatabaseDate", () => {
|
|
|
73
73
|
|
|
74
74
|
it("should be a type of InBetween", () => {
|
|
75
75
|
const inputDate: string = "2023-10-24T12:00:00Z";
|
|
76
|
-
const result: InBetween =
|
|
76
|
+
const result: InBetween<string> =
|
|
77
77
|
DatabaseDate.asDateStartOfTheDayEndOfTheDayForDatabaseQuery(inputDate);
|
|
78
78
|
expect(result).toBeInstanceOf(InBetween);
|
|
79
79
|
});
|
|
@@ -6,29 +6,35 @@ import { describe, expect, it } from "@jest/globals";
|
|
|
6
6
|
describe("EqualToOrNull", () => {
|
|
7
7
|
it("should create an EqualToOrNull object with a valid value", () => {
|
|
8
8
|
const value: string = "oneuptime";
|
|
9
|
-
const equalObj: EqualToOrNull = new EqualToOrNull(value);
|
|
9
|
+
const equalObj: EqualToOrNull<string> = new EqualToOrNull<string>(value);
|
|
10
10
|
expect(equalObj.value).toBe(value);
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it("should get the value property of an EqualToOrNull object", () => {
|
|
14
14
|
const value: string = "oneuptime";
|
|
15
|
-
const equalObj: EqualToOrNull = new EqualToOrNull(value);
|
|
15
|
+
const equalObj: EqualToOrNull<string> = new EqualToOrNull<string>(value);
|
|
16
16
|
expect(equalObj.value).toBe(value);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("should set the value property of an EqualToOrNull object", () => {
|
|
20
|
-
const equalObj: EqualToOrNull = new EqualToOrNull(
|
|
20
|
+
const equalObj: EqualToOrNull<string> = new EqualToOrNull<string>(
|
|
21
|
+
"oldValue",
|
|
22
|
+
);
|
|
21
23
|
equalObj.value = "newValue";
|
|
22
24
|
expect(equalObj.value).toBe("newValue");
|
|
23
25
|
});
|
|
24
26
|
|
|
25
27
|
it("should return the correct string representation using toString method", () => {
|
|
26
|
-
const equalObj: EqualToOrNull = new EqualToOrNull(
|
|
28
|
+
const equalObj: EqualToOrNull<string> = new EqualToOrNull<string>(
|
|
29
|
+
"oneuptime",
|
|
30
|
+
);
|
|
27
31
|
expect(equalObj.toString()).toBe("oneuptime");
|
|
28
32
|
});
|
|
29
33
|
|
|
30
34
|
it("should generate the correct JSON representation using toJSON method", () => {
|
|
31
|
-
const equalObj: EqualToOrNull = new EqualToOrNull(
|
|
35
|
+
const equalObj: EqualToOrNull<string> = new EqualToOrNull<string>(
|
|
36
|
+
"oneuptime",
|
|
37
|
+
);
|
|
32
38
|
const expectedJSON: JSONObject = {
|
|
33
39
|
_type: "EqualToOrNull",
|
|
34
40
|
value: "oneuptime",
|
|
@@ -41,7 +47,7 @@ describe("EqualToOrNull", () => {
|
|
|
41
47
|
_type: "EqualToOrNull",
|
|
42
48
|
value: "oneuptime",
|
|
43
49
|
};
|
|
44
|
-
const equalObj: EqualToOrNull = EqualToOrNull.fromJSON(jsonInput);
|
|
50
|
+
const equalObj: EqualToOrNull<string> = EqualToOrNull.fromJSON(jsonInput);
|
|
45
51
|
expect(equalObj.value).toBe("oneuptime");
|
|
46
52
|
});
|
|
47
53
|
|
|
@@ -56,7 +62,7 @@ describe("EqualToOrNull", () => {
|
|
|
56
62
|
});
|
|
57
63
|
|
|
58
64
|
it("should be a type of EqualToOrNull", () => {
|
|
59
|
-
const equalObj: EqualToOrNull = new EqualToOrNull("oneuptime");
|
|
65
|
+
const equalObj: EqualToOrNull<string> = new EqualToOrNull("oneuptime");
|
|
60
66
|
expect(equalObj).toBeInstanceOf(EqualToOrNull);
|
|
61
67
|
});
|
|
62
68
|
|
|
@@ -65,7 +71,7 @@ describe("EqualToOrNull", () => {
|
|
|
65
71
|
_type: "EqualToOrNull",
|
|
66
72
|
value: null,
|
|
67
73
|
};
|
|
68
|
-
const equalObj: EqualToOrNull = EqualToOrNull.fromJSON(jsonInput);
|
|
74
|
+
const equalObj: EqualToOrNull<string> = EqualToOrNull.fromJSON(jsonInput);
|
|
69
75
|
expect(equalObj.value).toBeNull();
|
|
70
76
|
});
|
|
71
77
|
});
|
|
@@ -7,7 +7,7 @@ describe("InBetween", () => {
|
|
|
7
7
|
it("should create an InBetween object with valid start and end values", () => {
|
|
8
8
|
const startValue: number = 10;
|
|
9
9
|
const endValue: number = 20;
|
|
10
|
-
const betweenObj: InBetween = new InBetween(startValue, endValue);
|
|
10
|
+
const betweenObj: InBetween<number> = new InBetween(startValue, endValue);
|
|
11
11
|
expect(betweenObj.startValue).toBe(10);
|
|
12
12
|
expect(betweenObj.endValue).toBe(20);
|
|
13
13
|
});
|
|
@@ -15,7 +15,7 @@ describe("InBetween", () => {
|
|
|
15
15
|
it("should generate the correct JSON representation using toJSON method", () => {
|
|
16
16
|
const startValue: number = 10;
|
|
17
17
|
const endValue: number = 20;
|
|
18
|
-
const betweenObj: InBetween = new InBetween(startValue, endValue);
|
|
18
|
+
const betweenObj: InBetween<number> = new InBetween(startValue, endValue);
|
|
19
19
|
const expectedJSON: JSONObject = {
|
|
20
20
|
_type: "InBetween",
|
|
21
21
|
startValue: 10,
|
|
@@ -30,7 +30,7 @@ describe("InBetween", () => {
|
|
|
30
30
|
startValue: 10,
|
|
31
31
|
endValue: 20,
|
|
32
32
|
};
|
|
33
|
-
const betweenObj: InBetween = InBetween.fromJSON(jsonInput);
|
|
33
|
+
const betweenObj: InBetween<number> = InBetween.fromJSON(jsonInput);
|
|
34
34
|
expect(betweenObj.startValue).toBe(10);
|
|
35
35
|
expect(betweenObj.endValue).toBe(20);
|
|
36
36
|
});
|
|
@@ -49,33 +49,33 @@ describe("InBetween", () => {
|
|
|
49
49
|
it("should return a string with start and end values matching", () => {
|
|
50
50
|
const startValue: number = 15;
|
|
51
51
|
const endValue: number = 15;
|
|
52
|
-
const betweenObj: InBetween = new InBetween(startValue, endValue);
|
|
52
|
+
const betweenObj: InBetween<number> = new InBetween(startValue, endValue);
|
|
53
53
|
expect(betweenObj.toString()).toBe("15");
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
it("should return a string with start and end values different", () => {
|
|
57
57
|
const startValue: number = 10;
|
|
58
58
|
const endValue: number = 20;
|
|
59
|
-
const betweenObj: InBetween = new InBetween(startValue, endValue);
|
|
59
|
+
const betweenObj: InBetween<number> = new InBetween(startValue, endValue);
|
|
60
60
|
expect(betweenObj.toString()).toBe("10 - 20");
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it("should return the start value as a string", () => {
|
|
64
64
|
const startValue: number = 10;
|
|
65
65
|
const endValue: number = 20;
|
|
66
|
-
const betweenObj: InBetween = new InBetween(startValue, endValue);
|
|
66
|
+
const betweenObj: InBetween<number> = new InBetween(startValue, endValue);
|
|
67
67
|
expect(betweenObj.toStartValueString()).toBe("10");
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
it("should return the end value as a string", () => {
|
|
71
71
|
const startValue: number = 10;
|
|
72
72
|
const endValue: number = 20;
|
|
73
|
-
const betweenObj: InBetween = new InBetween(startValue, endValue);
|
|
73
|
+
const betweenObj: InBetween<number> = new InBetween(startValue, endValue);
|
|
74
74
|
expect(betweenObj.toEndValueString()).toBe("20");
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it("should be a type of InBetween", () => {
|
|
78
|
-
const inBetweenObj: InBetween = new InBetween(10, 15);
|
|
78
|
+
const inBetweenObj: InBetween<number> = new InBetween(10, 15);
|
|
79
79
|
expect(inBetweenObj).toBeInstanceOf(InBetween);
|
|
80
80
|
});
|
|
81
81
|
});
|
|
@@ -5,14 +5,14 @@ describe("NotEqual", () => {
|
|
|
5
5
|
describe("constructor", () => {
|
|
6
6
|
it("should set the value property", () => {
|
|
7
7
|
const value: string = "test";
|
|
8
|
-
const notEqual: NotEqual = new NotEqual(value);
|
|
8
|
+
const notEqual: NotEqual<string> = new NotEqual(value);
|
|
9
9
|
expect(notEqual.value).toBe(value);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
describe("toString", () => {
|
|
13
13
|
it("should return the string value", () => {
|
|
14
14
|
const value: string = "test";
|
|
15
|
-
const notEqual: NotEqual = new NotEqual(value);
|
|
15
|
+
const notEqual: NotEqual<string> = new NotEqual(value);
|
|
16
16
|
expect(notEqual.toString()).toBe(value);
|
|
17
17
|
});
|
|
18
18
|
});
|
|
@@ -5,7 +5,7 @@ import Sort from "./Sort";
|
|
|
5
5
|
|
|
6
6
|
export default interface AggregateBy<TBaseModel extends GenericObject> {
|
|
7
7
|
aggregateColumnName: keyof TBaseModel;
|
|
8
|
-
|
|
8
|
+
aggregationType: AggregationType;
|
|
9
9
|
// aggregationInterval?: AggregationInterval;
|
|
10
10
|
aggregationTimestampColumnName: keyof TBaseModel;
|
|
11
11
|
startTimestamp: Date;
|
|
@@ -1,35 +1,31 @@
|
|
|
1
|
+
import CompareBase, { CompareType } from "../Database/CompareBase";
|
|
1
2
|
import BadDataException from "../Exception/BadDataException";
|
|
2
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
3
|
-
import SerializableObject from "../SerializableObject";
|
|
4
4
|
|
|
5
|
-
export default class EqualToOrNull
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
public set value(v: string) {
|
|
11
|
-
this._value = v;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public constructor(value: string) {
|
|
15
|
-
super();
|
|
5
|
+
export default class EqualToOrNull<
|
|
6
|
+
T extends CompareType,
|
|
7
|
+
> extends CompareBase<T> {
|
|
8
|
+
public constructor(value: T) {
|
|
9
|
+
super(value);
|
|
16
10
|
this.value = value;
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
public override toString(): string {
|
|
20
|
-
return this.value;
|
|
14
|
+
return this.value.toString();
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
public override toJSON(): JSONObject {
|
|
24
18
|
return {
|
|
25
19
|
_type: ObjectType.EqualToOrNull,
|
|
26
|
-
value: (this as EqualToOrNull).toString(),
|
|
20
|
+
value: (this as EqualToOrNull<T>).toString(),
|
|
27
21
|
};
|
|
28
22
|
}
|
|
29
23
|
|
|
30
|
-
public static override fromJSON
|
|
24
|
+
public static override fromJSON<T extends CompareType>(
|
|
25
|
+
json: JSONObject,
|
|
26
|
+
): EqualToOrNull<T> {
|
|
31
27
|
if (json["_type"] === ObjectType.EqualToOrNull) {
|
|
32
|
-
return new EqualToOrNull(json["value"] as
|
|
28
|
+
return new EqualToOrNull(json["value"] as T);
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import CompareBase from "../Database/CompareBase";
|
|
1
|
+
import CompareBase, { CompareType } from "../Database/CompareBase";
|
|
2
2
|
import BadDataException from "../Exception/BadDataException";
|
|
3
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
4
4
|
|
|
5
|
-
export default class GreaterThan extends CompareBase {
|
|
6
|
-
public constructor(value:
|
|
5
|
+
export default class GreaterThan<T extends CompareType> extends CompareBase<T> {
|
|
6
|
+
public constructor(value: T) {
|
|
7
7
|
super(value);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
public override toJSON(): JSONObject {
|
|
11
11
|
return {
|
|
12
12
|
_type: ObjectType.GreaterThan,
|
|
13
|
-
value: (this as GreaterThan).toString(),
|
|
13
|
+
value: (this as GreaterThan<T>).toString(),
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
public static override fromJSON
|
|
17
|
+
public static override fromJSON<T extends CompareType>(
|
|
18
|
+
json: JSONObject,
|
|
19
|
+
): GreaterThan<T> {
|
|
18
20
|
if (json["_type"] === ObjectType.GreaterThan) {
|
|
19
|
-
return new GreaterThan(json["value"] as
|
|
21
|
+
return new GreaterThan(json["value"] as T);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import CompareBase from "../Database/CompareBase";
|
|
1
|
+
import CompareBase, { CompareType } from "../Database/CompareBase";
|
|
2
2
|
import BadDataException from "../Exception/BadDataException";
|
|
3
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
4
4
|
|
|
5
|
-
export default class GreaterThanOrEqual
|
|
6
|
-
|
|
5
|
+
export default class GreaterThanOrEqual<
|
|
6
|
+
T extends CompareType,
|
|
7
|
+
> extends CompareBase<T> {
|
|
8
|
+
public constructor(value: T) {
|
|
7
9
|
super(value);
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
public override toJSON(): JSONObject {
|
|
11
13
|
return {
|
|
12
14
|
_type: ObjectType.GreaterThanOrEqual,
|
|
13
|
-
value: (this as GreaterThanOrEqual).toString(),
|
|
15
|
+
value: (this as GreaterThanOrEqual<T>).toString(),
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
public static override fromJSON
|
|
19
|
+
public static override fromJSON<T extends CompareType>(
|
|
20
|
+
json: JSONObject,
|
|
21
|
+
): GreaterThanOrEqual<T> {
|
|
18
22
|
if (json["_type"] === ObjectType.GreaterThanOrEqual) {
|
|
19
|
-
return new GreaterThanOrEqual(json["value"] as
|
|
23
|
+
return new GreaterThanOrEqual<T>(json["value"] as T);
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import OneUptimeDate from "../Date";
|
|
2
2
|
import BadDataException from "../Exception/BadDataException";
|
|
3
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
4
|
-
import
|
|
4
|
+
import QueryOperator from "./QueryOperator";
|
|
5
5
|
|
|
6
|
-
export default class InBetween
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export default class InBetween<
|
|
7
|
+
T extends number | Date | string,
|
|
8
|
+
> extends QueryOperator<T> {
|
|
9
|
+
private _startValue!: T;
|
|
10
|
+
public get startValue(): T {
|
|
9
11
|
return this._startValue;
|
|
10
12
|
}
|
|
11
|
-
public set startValue(v:
|
|
13
|
+
public set startValue(v: T) {
|
|
12
14
|
this._startValue = v;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
private _endValue!:
|
|
16
|
-
public get endValue():
|
|
17
|
+
private _endValue!: T;
|
|
18
|
+
public get endValue(): T {
|
|
17
19
|
return this._endValue;
|
|
18
20
|
}
|
|
19
|
-
public set endValue(v:
|
|
21
|
+
public set endValue(v: T) {
|
|
20
22
|
this._endValue = v;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
public constructor(
|
|
24
|
-
startValue: number | Date | string,
|
|
25
|
-
endValue: number | Date | string,
|
|
26
|
-
) {
|
|
25
|
+
public constructor(startValue: T, endValue: T) {
|
|
27
26
|
super();
|
|
28
27
|
this.startValue = startValue;
|
|
29
28
|
this.endValue = endValue;
|
|
@@ -32,32 +31,31 @@ export default class InBetween extends SerializableObject {
|
|
|
32
31
|
public override toJSON(): JSONObject {
|
|
33
32
|
return {
|
|
34
33
|
_type: ObjectType.InBetween,
|
|
35
|
-
startValue: (this as InBetween).startValue,
|
|
36
|
-
endValue: (this as InBetween).endValue,
|
|
34
|
+
startValue: (this as InBetween<T>).startValue,
|
|
35
|
+
endValue: (this as InBetween<T>).endValue,
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
public static override fromJSON
|
|
39
|
+
public static override fromJSON<T extends number | Date | string>(
|
|
40
|
+
json: JSONObject,
|
|
41
|
+
): InBetween<T> {
|
|
41
42
|
if (json["_type"] === ObjectType.InBetween) {
|
|
42
|
-
return new InBetween(
|
|
43
|
-
json["startValue"] as number | Date | string,
|
|
44
|
-
json["endValue"] as number | Date | string,
|
|
45
|
-
);
|
|
43
|
+
return new InBetween(json["startValue"] as T, json["endValue"] as T);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
public override toString(): string {
|
|
52
|
-
let startValue:
|
|
53
|
-
let endValue:
|
|
50
|
+
let startValue: T = this.startValue;
|
|
51
|
+
let endValue: T = this.endValue;
|
|
54
52
|
|
|
55
53
|
if (startValue instanceof Date) {
|
|
56
|
-
startValue = OneUptimeDate.asDateForDatabaseQuery(startValue);
|
|
54
|
+
startValue = OneUptimeDate.asDateForDatabaseQuery(startValue) as T;
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
if (endValue instanceof Date) {
|
|
60
|
-
endValue = OneUptimeDate.asDateForDatabaseQuery(endValue);
|
|
58
|
+
endValue = OneUptimeDate.asDateForDatabaseQuery(endValue) as T;
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
if (startValue.toString() === endValue.toString()) {
|
|
@@ -2,11 +2,11 @@ import BadDataException from "../Exception/BadDataException";
|
|
|
2
2
|
import { JSONObject, ObjectType } from "../JSON";
|
|
3
3
|
import JSONFunctions from "../JSONFunctions";
|
|
4
4
|
import ObjectID from "../ObjectID";
|
|
5
|
-
import
|
|
5
|
+
import QueryOperator from "./QueryOperator";
|
|
6
6
|
|
|
7
7
|
export type IncludesType = Array<string> | Array<ObjectID> | Array<number>;
|
|
8
8
|
|
|
9
|
-
export default class Includes extends
|
|
9
|
+
export default class Includes extends QueryOperator<IncludesType> {
|
|
10
10
|
private _values: IncludesType = [];
|
|
11
11
|
|
|
12
12
|
public get values(): IncludesType {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import BadDataException from "../Exception/BadDataException";
|
|
2
|
+
import GenericObject from "../GenericObject";
|
|
2
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
3
|
-
import
|
|
4
|
+
import QueryOperator from "./QueryOperator";
|
|
4
5
|
|
|
5
|
-
export default class IsNull extends
|
|
6
|
+
export default class IsNull extends QueryOperator<GenericObject> {
|
|
6
7
|
public constructor() {
|
|
7
8
|
super();
|
|
8
9
|
}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import CompareBase from "../Database/CompareBase";
|
|
1
|
+
import CompareBase, { CompareType } from "../Database/CompareBase";
|
|
2
2
|
import BadDataException from "../Exception/BadDataException";
|
|
3
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
4
4
|
|
|
5
|
-
export default class LessThan extends CompareBase {
|
|
6
|
-
public constructor(value:
|
|
5
|
+
export default class LessThan<T extends CompareType> extends CompareBase<T> {
|
|
6
|
+
public constructor(value: T) {
|
|
7
7
|
super(value);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
public override toJSON(): JSONObject {
|
|
11
11
|
return {
|
|
12
12
|
_type: ObjectType.LessThan,
|
|
13
|
-
value: (this as LessThan).toString(),
|
|
13
|
+
value: (this as LessThan<T>).toString(),
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
public static override fromJSON
|
|
17
|
+
public static override fromJSON<T extends CompareType>(
|
|
18
|
+
json: JSONObject,
|
|
19
|
+
): LessThan<T> {
|
|
18
20
|
if (json["_type"] === ObjectType.LessThan) {
|
|
19
|
-
return new LessThan(json["value"] as
|
|
21
|
+
return new LessThan(json["value"] as T);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import CompareBase from "../Database/CompareBase";
|
|
1
|
+
import CompareBase, { CompareType } from "../Database/CompareBase";
|
|
2
2
|
import BadDataException from "../Exception/BadDataException";
|
|
3
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
4
4
|
|
|
5
|
-
export default class LessThanOrEqual
|
|
6
|
-
|
|
5
|
+
export default class LessThanOrEqual<
|
|
6
|
+
T extends CompareType,
|
|
7
|
+
> extends CompareBase<T> {
|
|
8
|
+
public constructor(value: T) {
|
|
7
9
|
super(value);
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
public override toJSON(): JSONObject {
|
|
11
13
|
return {
|
|
12
14
|
_type: ObjectType.LessThanOrEqual,
|
|
13
|
-
value: (this as LessThanOrEqual).toString(),
|
|
15
|
+
value: (this as LessThanOrEqual<T>).toString(),
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
public static override fromJSON
|
|
19
|
+
public static override fromJSON<T extends CompareType>(
|
|
20
|
+
json: JSONObject,
|
|
21
|
+
): LessThanOrEqual<T> {
|
|
18
22
|
if (json["_type"] === ObjectType.LessThanOrEqual) {
|
|
19
|
-
return new LessThanOrEqual(json["value"] as
|
|
23
|
+
return new LessThanOrEqual<T>(json["value"] as T);
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
|
|
@@ -1,35 +1,28 @@
|
|
|
1
|
+
import CompareBase, { CompareType } from "../Database/CompareBase";
|
|
1
2
|
import BadDataException from "../Exception/BadDataException";
|
|
2
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
3
|
-
import SerializableObject from "../SerializableObject";
|
|
4
4
|
|
|
5
|
-
export default class NotEqual extends
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return this._value;
|
|
9
|
-
}
|
|
10
|
-
public set value(v: string) {
|
|
11
|
-
this._value = v;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public constructor(value: string) {
|
|
15
|
-
super();
|
|
16
|
-
this.value = value;
|
|
5
|
+
export default class NotEqual<T extends CompareType> extends CompareBase<T> {
|
|
6
|
+
public constructor(value: T) {
|
|
7
|
+
super(value);
|
|
17
8
|
}
|
|
18
9
|
|
|
19
10
|
public override toString(): string {
|
|
20
|
-
return this.value;
|
|
11
|
+
return this.value.toString();
|
|
21
12
|
}
|
|
22
13
|
|
|
23
14
|
public override toJSON(): JSONObject {
|
|
24
15
|
return {
|
|
25
16
|
_type: ObjectType.NotEqual,
|
|
26
|
-
value: (this as NotEqual).toString(),
|
|
17
|
+
value: (this as NotEqual<T>).toString(),
|
|
27
18
|
};
|
|
28
19
|
}
|
|
29
20
|
|
|
30
|
-
public static override fromJSON
|
|
21
|
+
public static override fromJSON<T extends CompareType>(
|
|
22
|
+
json: JSONObject,
|
|
23
|
+
): NotEqual<T> {
|
|
31
24
|
if (json["_type"] === ObjectType.NotEqual) {
|
|
32
|
-
return new NotEqual(json["value"] as
|
|
25
|
+
return new NotEqual(json["value"] as T);
|
|
33
26
|
}
|
|
34
27
|
|
|
35
28
|
throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import BadDataException from "../Exception/BadDataException";
|
|
2
|
+
import GenericObject from "../GenericObject";
|
|
2
3
|
import { JSONObject, ObjectType } from "../JSON";
|
|
3
|
-
import
|
|
4
|
+
import QueryOperator from "./QueryOperator";
|
|
4
5
|
|
|
5
|
-
export default class NotNull extends
|
|
6
|
+
export default class NotNull extends QueryOperator<GenericObject> {
|
|
6
7
|
public constructor() {
|
|
7
8
|
super();
|
|
8
9
|
}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import GenericObject from "../GenericObject";
|
|
2
|
-
import
|
|
2
|
+
import QueryOperator from "./QueryOperator";
|
|
3
3
|
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare type FindWhereProperty<Property extends GenericObject> =
|
|
5
|
+
| Property
|
|
6
|
+
| FindWhere<Property>
|
|
7
|
+
| QueryOperator<Property>
|
|
8
|
+
| undefined;
|
|
9
|
+
/**
|
|
10
|
+
* :
|
|
11
|
+
* Used for find operations.
|
|
12
|
+
*/
|
|
13
|
+
export declare type FindWhere<Entity> = {
|
|
14
|
+
[P in keyof Entity]?: FindWhereProperty<NonNullable<Entity[P]>>;
|
|
8
15
|
};
|
|
9
16
|
|
|
10
|
-
type Query<TBaseModel extends GenericObject> =
|
|
17
|
+
declare type Query<TBaseModel extends GenericObject> = FindWhere<TBaseModel>;
|
|
18
|
+
|
|
19
|
+
export declare type OrQuery<TBaseModel extends GenericObject> = Array<
|
|
20
|
+
Query<TBaseModel>
|
|
21
|
+
>;
|
|
11
22
|
|
|
12
23
|
export default Query;
|