namirasoft-cost 1.4.34 → 1.4.35
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/.ns-sdkg-dir-deep +3 -3
- package/.ns-sdkg-file-keep +27 -27
- package/dist/NamirasoftCostServer.js +1 -1
- package/package.json +28 -28
- package/src/NamirasoftCostServer.ts +59 -59
- package/src/NamirasoftCostServerBase.ts +29 -29
- package/src/NamirasoftCostServerBillWatchAWS.ts +47 -47
- package/src/NamirasoftCostServerBillWatchAzure.ts +47 -47
- package/src/NamirasoftCostServerBillWatchGCP.ts +47 -47
- package/src/NamirasoftCostServerCost.ts +41 -41
- package/src/NamirasoftCostServerFieldCategory.ts +47 -47
- package/src/NamirasoftCostServerFieldField.ts +47 -47
- package/src/NamirasoftCostServerHealthz.ts +35 -35
- package/src/NamirasoftCostServerMetrics.ts +35 -35
- package/src/NamirasoftCostServerSecretSecret.ts +61 -61
- package/src/NamirasoftCostServerValue.ts +36 -36
- package/src/bonus/BaseBonus.ts +13 -13
- package/src/bonus/DeactiveBonus.ts +14 -14
- package/src/bonus/FreeCountBonus.ts +14 -14
- package/src/bonus/FreeTotalValueBonus.ts +28 -28
- package/src/bonus/FreeValueBonus.ts +24 -24
- package/src/bonus/LowAmountBonus.ts +14 -14
- package/src/bonus/LowSecondsBonus.ts +14 -14
- package/src/bonus/LowTotalValueBonus.ts +14 -14
- package/src/bonus/LowValueBonus.ts +14 -14
- package/src/bonus/TrialBonus.ts +18 -18
- package/src/command/BillWatchAWSCommand.ts +33 -33
- package/src/command/BillWatchAWSEstimateRecordCommand.ts +109 -109
- package/src/command/BillWatchAWS_CreateForRecordCommand.ts +118 -118
- package/src/command/BillWatchAzureCommand.ts +33 -33
- package/src/command/BillWatchAzureEstimateRecordCommand.ts +109 -109
- package/src/command/BillWatchAzure_CreateForRecordCommand.ts +118 -118
- package/src/command/BillWatchGCPCommand.ts +33 -33
- package/src/command/BillWatchGCPEstimateRecordCommand.ts +109 -109
- package/src/command/BillWatchGCP_CreateForRecordCommand.ts +118 -118
- package/src/command/CostCommand.ts +31 -31
- package/src/command/CostListCommand.ts +44 -44
- package/src/command/FieldCategoryCommand.ts +33 -33
- package/src/command/FieldCategoryEstimateRecordCommand.ts +109 -109
- package/src/command/FieldCategory_CreateForRecordCommand.ts +118 -118
- package/src/command/FieldFieldCommand.ts +33 -33
- package/src/command/FieldFieldEstimateRecordCommand.ts +109 -109
- package/src/command/FieldField_CreateForRecordCommand.ts +118 -118
- package/src/command/HealthzCommand.ts +31 -31
- package/src/command/HealthzGetCommand.ts +44 -44
- package/src/command/MetricsCommand.ts +31 -31
- package/src/command/MetricsGetCommand.ts +44 -44
- package/src/command/SecretSecretCommand.ts +37 -37
- package/src/command/SecretSecretEstimateReadCommand.ts +109 -109
- package/src/command/SecretSecretEstimateRecordCommand.ts +109 -109
- package/src/command/SecretSecret_CreateForReadCommand.ts +118 -118
- package/src/command/SecretSecret_CreateForRecordCommand.ts +118 -118
- package/src/command/ValueCommand.ts +31 -31
- package/src/command/ValueListCommand.ts +44 -44
- package/src/command/cli.ts +50 -50
- package/src/index.ts +90 -90
- package/src/meta/CostMetaTable.ts +81 -81
- package/src/meta/NamirasoftCostMetaDatabase.ts +50 -50
- package/src/row/CostRow.ts +40 -40
- package/src/type/Bonus.ts +20 -20
- package/src/type/CalculationOption.ts +33 -33
- package/src/type/Estimation.ts +34 -34
- package/src/type/EstimationOption.ts +31 -31
- package/src/type/EstimationUsage.ts +22 -22
- package/src/type/Period.ts +101 -101
- package/src/type/SimulationOption.ts +29 -29
- package/src/type/Usage.ts +24 -24
@@ -1,34 +1,34 @@
|
|
1
|
-
import { BaseVariableSchema, BoolSchema, IntegerSchema, ObjectSchema, StringSchema } from "namirasoft-schema";
|
2
|
-
import { Period, PeriodSchema } from "./Period";
|
3
|
-
|
4
|
-
export interface CalculationOption
|
5
|
-
{
|
6
|
-
period: Period;
|
7
|
-
total_count: number;
|
8
|
-
number: number;
|
9
|
-
total_value: number;
|
10
|
-
value: number;
|
11
|
-
active: boolean;
|
12
|
-
workspace_id: string;
|
13
|
-
resource_id: string;
|
14
|
-
};
|
15
|
-
|
16
|
-
export class CalculationOptionSchema extends ObjectSchema
|
17
|
-
{
|
18
|
-
constructor(required: boolean)
|
19
|
-
{
|
20
|
-
super("CalculationOption", required, [
|
21
|
-
new BaseVariableSchema("period", new PeriodSchema(true)),
|
22
|
-
new BaseVariableSchema("total_count", new IntegerSchema(true, 0)),
|
23
|
-
new BaseVariableSchema("number", new IntegerSchema(true, 1)),
|
24
|
-
new BaseVariableSchema("total_value", new IntegerSchema(true, 0)),
|
25
|
-
new BaseVariableSchema("value", new IntegerSchema(true, 1)),
|
26
|
-
new BaseVariableSchema("active", new BoolSchema(true)),
|
27
|
-
new BaseVariableSchema("workspace_id", new StringSchema(false, 20, 20)),
|
28
|
-
new BaseVariableSchema("resource_id", new StringSchema(false, 20, 20)),
|
29
|
-
]);
|
30
|
-
this.external = {
|
31
|
-
package: "./type/CalculationOption"
|
32
|
-
};
|
33
|
-
}
|
1
|
+
import { BaseVariableSchema, BoolSchema, IntegerSchema, ObjectSchema, StringSchema } from "namirasoft-schema";
|
2
|
+
import { Period, PeriodSchema } from "./Period";
|
3
|
+
|
4
|
+
export interface CalculationOption
|
5
|
+
{
|
6
|
+
period: Period;
|
7
|
+
total_count: number;
|
8
|
+
number: number;
|
9
|
+
total_value: number;
|
10
|
+
value: number;
|
11
|
+
active: boolean;
|
12
|
+
workspace_id: string;
|
13
|
+
resource_id: string;
|
14
|
+
};
|
15
|
+
|
16
|
+
export class CalculationOptionSchema extends ObjectSchema
|
17
|
+
{
|
18
|
+
constructor(required: boolean)
|
19
|
+
{
|
20
|
+
super("CalculationOption", required, [
|
21
|
+
new BaseVariableSchema("period", new PeriodSchema(true)),
|
22
|
+
new BaseVariableSchema("total_count", new IntegerSchema(true, 0)),
|
23
|
+
new BaseVariableSchema("number", new IntegerSchema(true, 1)),
|
24
|
+
new BaseVariableSchema("total_value", new IntegerSchema(true, 0)),
|
25
|
+
new BaseVariableSchema("value", new IntegerSchema(true, 1)),
|
26
|
+
new BaseVariableSchema("active", new BoolSchema(true)),
|
27
|
+
new BaseVariableSchema("workspace_id", new StringSchema(false, 20, 20)),
|
28
|
+
new BaseVariableSchema("resource_id", new StringSchema(false, 20, 20)),
|
29
|
+
]);
|
30
|
+
this.external = {
|
31
|
+
package: "./type/CalculationOption"
|
32
|
+
};
|
33
|
+
}
|
34
34
|
}
|
package/src/type/Estimation.ts
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
import { BaseVariableSchema, IntegerSchema, MoneySchema, ObjectSchema, StringSchema } from "namirasoft-schema";
|
2
|
-
import { BaseBonus } from "../bonus/BaseBonus";
|
3
|
-
import { EstimationOption, EstimationOptionSchema } from "./EstimationOption";
|
4
|
-
import { EstimationUsage, EstimationUsageSchema } from "./EstimationUsage";
|
5
|
-
import { BonusSchema } from "./Bonus";
|
6
|
-
|
7
|
-
export type Estimation =
|
8
|
-
{
|
9
|
-
option: EstimationOption;
|
10
|
-
seconds: number;
|
11
|
-
usage: EstimationUsage;
|
12
|
-
fee: number;
|
13
|
-
amount: number;
|
14
|
-
currency: string;
|
15
|
-
free?: BaseBonus;
|
16
|
-
};
|
17
|
-
|
18
|
-
export class EstimationSchema extends ObjectSchema
|
19
|
-
{
|
20
|
-
constructor(required: boolean)
|
21
|
-
{
|
22
|
-
super("Estimation", required, [
|
23
|
-
new BaseVariableSchema("option", new EstimationOptionSchema(true)),
|
24
|
-
new BaseVariableSchema("seconds", new IntegerSchema(true, 1, 3600)),
|
25
|
-
new BaseVariableSchema("usage", new EstimationUsageSchema(true)),
|
26
|
-
new BaseVariableSchema("fee", new MoneySchema(true)),
|
27
|
-
new BaseVariableSchema("amount", new MoneySchema(true, 1)),
|
28
|
-
new BaseVariableSchema("currency", new StringSchema(true)),
|
29
|
-
new BaseVariableSchema("free", new BonusSchema(false)),
|
30
|
-
]);
|
31
|
-
this.external = {
|
32
|
-
package: "./type/Estimation"
|
33
|
-
};
|
34
|
-
}
|
1
|
+
import { BaseVariableSchema, IntegerSchema, MoneySchema, ObjectSchema, StringSchema } from "namirasoft-schema";
|
2
|
+
import { BaseBonus } from "../bonus/BaseBonus";
|
3
|
+
import { EstimationOption, EstimationOptionSchema } from "./EstimationOption";
|
4
|
+
import { EstimationUsage, EstimationUsageSchema } from "./EstimationUsage";
|
5
|
+
import { BonusSchema } from "./Bonus";
|
6
|
+
|
7
|
+
export type Estimation =
|
8
|
+
{
|
9
|
+
option: EstimationOption;
|
10
|
+
seconds: number;
|
11
|
+
usage: EstimationUsage;
|
12
|
+
fee: number;
|
13
|
+
amount: number;
|
14
|
+
currency: string;
|
15
|
+
free?: BaseBonus;
|
16
|
+
};
|
17
|
+
|
18
|
+
export class EstimationSchema extends ObjectSchema
|
19
|
+
{
|
20
|
+
constructor(required: boolean)
|
21
|
+
{
|
22
|
+
super("Estimation", required, [
|
23
|
+
new BaseVariableSchema("option", new EstimationOptionSchema(true)),
|
24
|
+
new BaseVariableSchema("seconds", new IntegerSchema(true, 1, 3600)),
|
25
|
+
new BaseVariableSchema("usage", new EstimationUsageSchema(true)),
|
26
|
+
new BaseVariableSchema("fee", new MoneySchema(true)),
|
27
|
+
new BaseVariableSchema("amount", new MoneySchema(true, 1)),
|
28
|
+
new BaseVariableSchema("currency", new StringSchema(true)),
|
29
|
+
new BaseVariableSchema("free", new BonusSchema(false)),
|
30
|
+
]);
|
31
|
+
this.external = {
|
32
|
+
package: "./type/Estimation"
|
33
|
+
};
|
34
|
+
}
|
35
35
|
}
|
@@ -1,32 +1,32 @@
|
|
1
|
-
import { BaseVariableSchema, BoolSchema, DateTimeSchema, IntegerSchema, ObjectSchema } from "namirasoft-schema";
|
2
|
-
import { Period, PeriodSchema } from "./Period";
|
3
|
-
|
4
|
-
export interface EstimationOption
|
5
|
-
{
|
6
|
-
period: Period;
|
7
|
-
total_count: number;
|
8
|
-
number: number;
|
9
|
-
total_value: number;
|
10
|
-
value: number;
|
11
|
-
active: boolean;
|
12
|
-
trial_started_at: Date | null;
|
13
|
-
};
|
14
|
-
|
15
|
-
export class EstimationOptionSchema extends ObjectSchema
|
16
|
-
{
|
17
|
-
constructor(required: boolean)
|
18
|
-
{
|
19
|
-
super("EstimationOption", required, [
|
20
|
-
new BaseVariableSchema("period", new PeriodSchema(true)),
|
21
|
-
new BaseVariableSchema("total_count", new IntegerSchema(true, 0)),
|
22
|
-
new BaseVariableSchema("number", new IntegerSchema(true, 1)),
|
23
|
-
new BaseVariableSchema("total_value", new IntegerSchema(true, 0)),
|
24
|
-
new BaseVariableSchema("value", new IntegerSchema(true, 1)),
|
25
|
-
new BaseVariableSchema("active", new BoolSchema(true)),
|
26
|
-
new BaseVariableSchema("trial_started_at", new DateTimeSchema(false)),
|
27
|
-
]);
|
28
|
-
this.external = {
|
29
|
-
package: "./type/EstimationOption"
|
30
|
-
};
|
31
|
-
}
|
1
|
+
import { BaseVariableSchema, BoolSchema, DateTimeSchema, IntegerSchema, ObjectSchema } from "namirasoft-schema";
|
2
|
+
import { Period, PeriodSchema } from "./Period";
|
3
|
+
|
4
|
+
export interface EstimationOption
|
5
|
+
{
|
6
|
+
period: Period;
|
7
|
+
total_count: number;
|
8
|
+
number: number;
|
9
|
+
total_value: number;
|
10
|
+
value: number;
|
11
|
+
active: boolean;
|
12
|
+
trial_started_at: Date | null;
|
13
|
+
};
|
14
|
+
|
15
|
+
export class EstimationOptionSchema extends ObjectSchema
|
16
|
+
{
|
17
|
+
constructor(required: boolean)
|
18
|
+
{
|
19
|
+
super("EstimationOption", required, [
|
20
|
+
new BaseVariableSchema("period", new PeriodSchema(true)),
|
21
|
+
new BaseVariableSchema("total_count", new IntegerSchema(true, 0)),
|
22
|
+
new BaseVariableSchema("number", new IntegerSchema(true, 1)),
|
23
|
+
new BaseVariableSchema("total_value", new IntegerSchema(true, 0)),
|
24
|
+
new BaseVariableSchema("value", new IntegerSchema(true, 1)),
|
25
|
+
new BaseVariableSchema("active", new BoolSchema(true)),
|
26
|
+
new BaseVariableSchema("trial_started_at", new DateTimeSchema(false)),
|
27
|
+
]);
|
28
|
+
this.external = {
|
29
|
+
package: "./type/EstimationOption"
|
30
|
+
};
|
31
|
+
}
|
32
32
|
}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
import { BaseVariableSchema, IntegerSchema, ObjectSchema, StringSchema } from "namirasoft-schema";
|
2
|
-
|
3
|
-
export type EstimationUsage =
|
4
|
-
{
|
5
|
-
name: string;
|
6
|
-
value: number;
|
7
|
-
unit: string;
|
8
|
-
};
|
9
|
-
|
10
|
-
export class EstimationUsageSchema extends ObjectSchema
|
11
|
-
{
|
12
|
-
constructor(required: boolean)
|
13
|
-
{
|
14
|
-
super("EstimationUsage", required, [
|
15
|
-
new BaseVariableSchema("name", new StringSchema(true)),
|
16
|
-
new BaseVariableSchema("value", new IntegerSchema(true)),
|
17
|
-
new BaseVariableSchema("unit", new StringSchema(true)),
|
18
|
-
]);
|
19
|
-
this.external = {
|
20
|
-
package: "./type/EstimationUsage"
|
21
|
-
};
|
22
|
-
}
|
1
|
+
import { BaseVariableSchema, IntegerSchema, ObjectSchema, StringSchema } from "namirasoft-schema";
|
2
|
+
|
3
|
+
export type EstimationUsage =
|
4
|
+
{
|
5
|
+
name: string;
|
6
|
+
value: number;
|
7
|
+
unit: string;
|
8
|
+
};
|
9
|
+
|
10
|
+
export class EstimationUsageSchema extends ObjectSchema
|
11
|
+
{
|
12
|
+
constructor(required: boolean)
|
13
|
+
{
|
14
|
+
super("EstimationUsage", required, [
|
15
|
+
new BaseVariableSchema("name", new StringSchema(true)),
|
16
|
+
new BaseVariableSchema("value", new IntegerSchema(true)),
|
17
|
+
new BaseVariableSchema("unit", new StringSchema(true)),
|
18
|
+
]);
|
19
|
+
this.external = {
|
20
|
+
package: "./type/EstimationUsage"
|
21
|
+
};
|
22
|
+
}
|
23
23
|
}
|
package/src/type/Period.ts
CHANGED
@@ -1,102 +1,102 @@
|
|
1
|
-
import { TimeOperation } from "namirasoft-core";
|
2
|
-
import { BaseVariableSchema, IntegerSchema, ObjectSchema } from "namirasoft-schema";
|
3
|
-
|
4
|
-
export type Period =
|
5
|
-
{
|
6
|
-
year: number;
|
7
|
-
month: number;
|
8
|
-
day: number;
|
9
|
-
hour: number;
|
10
|
-
start: {
|
11
|
-
minute: number;
|
12
|
-
second: number;
|
13
|
-
};
|
14
|
-
end: {
|
15
|
-
minute: number;
|
16
|
-
second: number;
|
17
|
-
};
|
18
|
-
};
|
19
|
-
|
20
|
-
export class PeriodSchema extends ObjectSchema
|
21
|
-
{
|
22
|
-
constructor(required: boolean)
|
23
|
-
{
|
24
|
-
super("Period", required, [
|
25
|
-
new BaseVariableSchema("year", new IntegerSchema(true, 0, 9999)),
|
26
|
-
new BaseVariableSchema("month", new IntegerSchema(true, 1, 12)),
|
27
|
-
new BaseVariableSchema("day", new IntegerSchema(true, 1, 31)),
|
28
|
-
new BaseVariableSchema("hour", new IntegerSchema(true, 0, 23)),
|
29
|
-
new BaseVariableSchema("start", new ObjectSchema("", true, [
|
30
|
-
new BaseVariableSchema("minute", new IntegerSchema(true, 0, 59)),
|
31
|
-
new BaseVariableSchema("second", new IntegerSchema(true, 0, 59))
|
32
|
-
])),
|
33
|
-
new BaseVariableSchema("end", new ObjectSchema("", true, [
|
34
|
-
new BaseVariableSchema("minute", new IntegerSchema(true, 0, 59)),
|
35
|
-
new BaseVariableSchema("second", new IntegerSchema(true, 0, 59))
|
36
|
-
])),
|
37
|
-
]);
|
38
|
-
this.external = {
|
39
|
-
package: "./type/Period"
|
40
|
-
};
|
41
|
-
}
|
42
|
-
}
|
43
|
-
export class PeriodUtil
|
44
|
-
{
|
45
|
-
static toSeconds(period: Period)
|
46
|
-
{
|
47
|
-
return (period.end.minute * 60 + period.end.second) - (period.start.minute * 60 + period.start.second) + 1
|
48
|
-
}
|
49
|
-
static toDates(period: Period)
|
50
|
-
{
|
51
|
-
let start = new Date(period.year, period.month - 1, period.day, period.hour, period.start.minute, period.start.second);
|
52
|
-
let end = new Date(period.year, period.month - 1, period.day, period.hour, period.end.minute, period.end.second);
|
53
|
-
return { start, end };
|
54
|
-
}
|
55
|
-
static byDates(start: Date, end: Date)
|
56
|
-
{
|
57
|
-
return {
|
58
|
-
year: start.getFullYear(),
|
59
|
-
month: start.getMonth() + 1,
|
60
|
-
day: start.getDate(),
|
61
|
-
hour: start.getHours(),
|
62
|
-
start: {
|
63
|
-
minute: start.getMinutes(),
|
64
|
-
second: start.getSeconds(),
|
65
|
-
},
|
66
|
-
end: {
|
67
|
-
minute: end.getMinutes(),
|
68
|
-
second: end.getSeconds(),
|
69
|
-
}
|
70
|
-
};
|
71
|
-
}
|
72
|
-
static async loop(start: Date, end: Date, estimate_hour: (period: Period) => Promise<void>): Promise<void>
|
73
|
-
{
|
74
|
-
let pre_estimate_hour = async (start: Date, end: Date) =>
|
75
|
-
{
|
76
|
-
if (end <= start)
|
77
|
-
return;
|
78
|
-
return await estimate_hour(PeriodUtil.byDates(start, end));
|
79
|
-
}
|
80
|
-
|
81
|
-
let s = start;
|
82
|
-
let e = null;
|
83
|
-
|
84
|
-
do
|
85
|
-
{
|
86
|
-
let next_start = TimeOperation.hoursLater(1, s);
|
87
|
-
next_start.setMilliseconds(0);
|
88
|
-
next_start.setSeconds(0);
|
89
|
-
next_start.setMinutes(0);
|
90
|
-
if (end < next_start)
|
91
|
-
{
|
92
|
-
next_start = end;
|
93
|
-
e = end;
|
94
|
-
}
|
95
|
-
else
|
96
|
-
e = TimeOperation.secondsAgo(1, next_start);
|
97
|
-
await pre_estimate_hour(s, e);
|
98
|
-
s = next_start;
|
99
|
-
}
|
100
|
-
while (e < end)
|
101
|
-
}
|
1
|
+
import { TimeOperation } from "namirasoft-core";
|
2
|
+
import { BaseVariableSchema, IntegerSchema, ObjectSchema } from "namirasoft-schema";
|
3
|
+
|
4
|
+
export type Period =
|
5
|
+
{
|
6
|
+
year: number;
|
7
|
+
month: number;
|
8
|
+
day: number;
|
9
|
+
hour: number;
|
10
|
+
start: {
|
11
|
+
minute: number;
|
12
|
+
second: number;
|
13
|
+
};
|
14
|
+
end: {
|
15
|
+
minute: number;
|
16
|
+
second: number;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
|
20
|
+
export class PeriodSchema extends ObjectSchema
|
21
|
+
{
|
22
|
+
constructor(required: boolean)
|
23
|
+
{
|
24
|
+
super("Period", required, [
|
25
|
+
new BaseVariableSchema("year", new IntegerSchema(true, 0, 9999)),
|
26
|
+
new BaseVariableSchema("month", new IntegerSchema(true, 1, 12)),
|
27
|
+
new BaseVariableSchema("day", new IntegerSchema(true, 1, 31)),
|
28
|
+
new BaseVariableSchema("hour", new IntegerSchema(true, 0, 23)),
|
29
|
+
new BaseVariableSchema("start", new ObjectSchema("", true, [
|
30
|
+
new BaseVariableSchema("minute", new IntegerSchema(true, 0, 59)),
|
31
|
+
new BaseVariableSchema("second", new IntegerSchema(true, 0, 59))
|
32
|
+
])),
|
33
|
+
new BaseVariableSchema("end", new ObjectSchema("", true, [
|
34
|
+
new BaseVariableSchema("minute", new IntegerSchema(true, 0, 59)),
|
35
|
+
new BaseVariableSchema("second", new IntegerSchema(true, 0, 59))
|
36
|
+
])),
|
37
|
+
]);
|
38
|
+
this.external = {
|
39
|
+
package: "./type/Period"
|
40
|
+
};
|
41
|
+
}
|
42
|
+
}
|
43
|
+
export class PeriodUtil
|
44
|
+
{
|
45
|
+
static toSeconds(period: Period)
|
46
|
+
{
|
47
|
+
return (period.end.minute * 60 + period.end.second) - (period.start.minute * 60 + period.start.second) + 1
|
48
|
+
}
|
49
|
+
static toDates(period: Period)
|
50
|
+
{
|
51
|
+
let start = new Date(period.year, period.month - 1, period.day, period.hour, period.start.minute, period.start.second);
|
52
|
+
let end = new Date(period.year, period.month - 1, period.day, period.hour, period.end.minute, period.end.second);
|
53
|
+
return { start, end };
|
54
|
+
}
|
55
|
+
static byDates(start: Date, end: Date)
|
56
|
+
{
|
57
|
+
return {
|
58
|
+
year: start.getFullYear(),
|
59
|
+
month: start.getMonth() + 1,
|
60
|
+
day: start.getDate(),
|
61
|
+
hour: start.getHours(),
|
62
|
+
start: {
|
63
|
+
minute: start.getMinutes(),
|
64
|
+
second: start.getSeconds(),
|
65
|
+
},
|
66
|
+
end: {
|
67
|
+
minute: end.getMinutes(),
|
68
|
+
second: end.getSeconds(),
|
69
|
+
}
|
70
|
+
};
|
71
|
+
}
|
72
|
+
static async loop(start: Date, end: Date, estimate_hour: (period: Period) => Promise<void>): Promise<void>
|
73
|
+
{
|
74
|
+
let pre_estimate_hour = async (start: Date, end: Date) =>
|
75
|
+
{
|
76
|
+
if (end <= start)
|
77
|
+
return;
|
78
|
+
return await estimate_hour(PeriodUtil.byDates(start, end));
|
79
|
+
}
|
80
|
+
|
81
|
+
let s = start;
|
82
|
+
let e = null;
|
83
|
+
|
84
|
+
do
|
85
|
+
{
|
86
|
+
let next_start = TimeOperation.hoursLater(1, s);
|
87
|
+
next_start.setMilliseconds(0);
|
88
|
+
next_start.setSeconds(0);
|
89
|
+
next_start.setMinutes(0);
|
90
|
+
if (end < next_start)
|
91
|
+
{
|
92
|
+
next_start = end;
|
93
|
+
e = end;
|
94
|
+
}
|
95
|
+
else
|
96
|
+
e = TimeOperation.secondsAgo(1, next_start);
|
97
|
+
await pre_estimate_hour(s, e);
|
98
|
+
s = next_start;
|
99
|
+
}
|
100
|
+
while (e < end)
|
101
|
+
}
|
102
102
|
};
|
@@ -1,30 +1,30 @@
|
|
1
|
-
import { BaseVariableSchema, BoolSchema, IntegerSchema, ObjectSchema } from "namirasoft-schema";
|
2
|
-
import { Period, PeriodSchema } from "./Period";
|
3
|
-
|
4
|
-
export interface SimulationOption
|
5
|
-
{
|
6
|
-
period: Period;
|
7
|
-
total_count: number;
|
8
|
-
number: number;
|
9
|
-
total_value: number;
|
10
|
-
value: number;
|
11
|
-
active: boolean;
|
12
|
-
};
|
13
|
-
|
14
|
-
export class SimulationOptionSchema extends ObjectSchema
|
15
|
-
{
|
16
|
-
constructor(required: boolean)
|
17
|
-
{
|
18
|
-
super("SimulationOption", required, [
|
19
|
-
new BaseVariableSchema("period", new PeriodSchema(true)),
|
20
|
-
new BaseVariableSchema("total_count", new IntegerSchema(true, 0)),
|
21
|
-
new BaseVariableSchema("number", new IntegerSchema(true, 1)),
|
22
|
-
new BaseVariableSchema("total_value", new IntegerSchema(true, 0)),
|
23
|
-
new BaseVariableSchema("value", new IntegerSchema(true, 1)),
|
24
|
-
new BaseVariableSchema("active", new BoolSchema(true)),
|
25
|
-
]);
|
26
|
-
this.external = {
|
27
|
-
package: "./type/SimulationOption"
|
28
|
-
};
|
29
|
-
}
|
1
|
+
import { BaseVariableSchema, BoolSchema, IntegerSchema, ObjectSchema } from "namirasoft-schema";
|
2
|
+
import { Period, PeriodSchema } from "./Period";
|
3
|
+
|
4
|
+
export interface SimulationOption
|
5
|
+
{
|
6
|
+
period: Period;
|
7
|
+
total_count: number;
|
8
|
+
number: number;
|
9
|
+
total_value: number;
|
10
|
+
value: number;
|
11
|
+
active: boolean;
|
12
|
+
};
|
13
|
+
|
14
|
+
export class SimulationOptionSchema extends ObjectSchema
|
15
|
+
{
|
16
|
+
constructor(required: boolean)
|
17
|
+
{
|
18
|
+
super("SimulationOption", required, [
|
19
|
+
new BaseVariableSchema("period", new PeriodSchema(true)),
|
20
|
+
new BaseVariableSchema("total_count", new IntegerSchema(true, 0)),
|
21
|
+
new BaseVariableSchema("number", new IntegerSchema(true, 1)),
|
22
|
+
new BaseVariableSchema("total_value", new IntegerSchema(true, 0)),
|
23
|
+
new BaseVariableSchema("value", new IntegerSchema(true, 1)),
|
24
|
+
new BaseVariableSchema("active", new BoolSchema(true)),
|
25
|
+
]);
|
26
|
+
this.external = {
|
27
|
+
package: "./type/SimulationOption"
|
28
|
+
};
|
29
|
+
}
|
30
30
|
}
|
package/src/type/Usage.ts
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
export class Usage
|
2
|
-
{
|
3
|
-
static Time = {
|
4
|
-
name: "Time",
|
5
|
-
units: {
|
6
|
-
Second: {
|
7
|
-
name: "Second"
|
8
|
-
},
|
9
|
-
Minute: {
|
10
|
-
name: "Minute"
|
11
|
-
},
|
12
|
-
Hour: {
|
13
|
-
name: "Hour"
|
14
|
-
}
|
15
|
-
}
|
16
|
-
};
|
17
|
-
static APICALL = {
|
18
|
-
name: "API Call",
|
19
|
-
units: {
|
20
|
-
REQUEST: {
|
21
|
-
name: "Request"
|
22
|
-
}
|
23
|
-
}
|
24
|
-
};
|
1
|
+
export class Usage
|
2
|
+
{
|
3
|
+
static Time = {
|
4
|
+
name: "Time",
|
5
|
+
units: {
|
6
|
+
Second: {
|
7
|
+
name: "Second"
|
8
|
+
},
|
9
|
+
Minute: {
|
10
|
+
name: "Minute"
|
11
|
+
},
|
12
|
+
Hour: {
|
13
|
+
name: "Hour"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
};
|
17
|
+
static APICALL = {
|
18
|
+
name: "API Call",
|
19
|
+
units: {
|
20
|
+
REQUEST: {
|
21
|
+
name: "Request"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
};
|
25
25
|
};
|