@electrolux-oss/plugin-infrawallet-backend 0.2.0 → 0.2.1
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/config.d.ts +114 -131
- package/dist/index.cjs.js +12 -9
- package/dist/index.cjs.js.map +1 -1
- package/mock/mock_response.json +935 -9664
- package/package.json +1 -1
package/config.d.ts
CHANGED
|
@@ -2,139 +2,122 @@ export interface Config {
|
|
|
2
2
|
backend: {
|
|
3
3
|
infraWallet: {
|
|
4
4
|
integrations: {
|
|
5
|
-
azure?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
attribute: string;
|
|
96
|
-
pattern: string;
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
},
|
|
100
|
-
];
|
|
101
|
-
mock?: [
|
|
102
|
-
{
|
|
103
|
-
name: string;
|
|
104
|
-
},
|
|
105
|
-
];
|
|
5
|
+
azure?: {
|
|
6
|
+
name: string;
|
|
7
|
+
subscriptionId: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
tenantId: string;
|
|
10
|
+
/**
|
|
11
|
+
* @visibility secret
|
|
12
|
+
*/
|
|
13
|
+
clientSecret: string;
|
|
14
|
+
tags?: string[];
|
|
15
|
+
}[];
|
|
16
|
+
aws?: {
|
|
17
|
+
name: string;
|
|
18
|
+
accountId: string;
|
|
19
|
+
assumedRoleName?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @visibility secret
|
|
22
|
+
*/
|
|
23
|
+
accessKeyId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @visibility secret
|
|
26
|
+
*/
|
|
27
|
+
accessKeySecret?: string;
|
|
28
|
+
tags?: string[];
|
|
29
|
+
filters?: [
|
|
30
|
+
{
|
|
31
|
+
type: string;
|
|
32
|
+
attribute: string;
|
|
33
|
+
pattern: string;
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}[];
|
|
37
|
+
gcp?: {
|
|
38
|
+
name: string;
|
|
39
|
+
/**
|
|
40
|
+
* @visibility secret
|
|
41
|
+
*/
|
|
42
|
+
keyFilePath: string;
|
|
43
|
+
projectId: string;
|
|
44
|
+
datasetId: string;
|
|
45
|
+
tableId: string;
|
|
46
|
+
tags?: string[];
|
|
47
|
+
}[];
|
|
48
|
+
confluent?: {
|
|
49
|
+
name: string;
|
|
50
|
+
/**
|
|
51
|
+
* @visibility secret
|
|
52
|
+
*/
|
|
53
|
+
apiKey: string;
|
|
54
|
+
/**
|
|
55
|
+
* @visibility secret
|
|
56
|
+
*/
|
|
57
|
+
apiSecret: string;
|
|
58
|
+
tags?: string[];
|
|
59
|
+
}[];
|
|
60
|
+
mongoatlas?: {
|
|
61
|
+
name: string;
|
|
62
|
+
orgId: string;
|
|
63
|
+
/**
|
|
64
|
+
* @visibility secret
|
|
65
|
+
*/
|
|
66
|
+
publicKey: string;
|
|
67
|
+
/**
|
|
68
|
+
* @visibility secret
|
|
69
|
+
*/
|
|
70
|
+
privateKey: string;
|
|
71
|
+
tags?: string[];
|
|
72
|
+
}[];
|
|
73
|
+
datadog?: {
|
|
74
|
+
name: string;
|
|
75
|
+
/**
|
|
76
|
+
* @visibility secret
|
|
77
|
+
*/
|
|
78
|
+
apiKey: string;
|
|
79
|
+
/**
|
|
80
|
+
* @visibility secret
|
|
81
|
+
*/
|
|
82
|
+
applicationKey: string;
|
|
83
|
+
ddSite: string;
|
|
84
|
+
filters?: [
|
|
85
|
+
{
|
|
86
|
+
type: string;
|
|
87
|
+
attribute: string;
|
|
88
|
+
pattern: string;
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
}[];
|
|
92
|
+
mock?: {
|
|
93
|
+
name: string;
|
|
94
|
+
}[];
|
|
106
95
|
};
|
|
107
96
|
metricProviders?: {
|
|
108
|
-
datadog?:
|
|
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
|
-
mock?: [
|
|
134
|
-
{
|
|
135
|
-
name: string;
|
|
136
|
-
},
|
|
137
|
-
];
|
|
97
|
+
datadog?: {
|
|
98
|
+
name: string;
|
|
99
|
+
/**
|
|
100
|
+
* @visibility secret
|
|
101
|
+
*/
|
|
102
|
+
apiKey: string;
|
|
103
|
+
/**
|
|
104
|
+
* @visibility secret
|
|
105
|
+
*/
|
|
106
|
+
applicationKey: string;
|
|
107
|
+
ddSite: string;
|
|
108
|
+
}[];
|
|
109
|
+
grafanaCloud?: {
|
|
110
|
+
name: string;
|
|
111
|
+
url: string;
|
|
112
|
+
datasourceUid: string;
|
|
113
|
+
/**
|
|
114
|
+
* @visibility secret
|
|
115
|
+
*/
|
|
116
|
+
token: string;
|
|
117
|
+
}[];
|
|
118
|
+
mock?: {
|
|
119
|
+
name: string;
|
|
120
|
+
}[];
|
|
138
121
|
};
|
|
139
122
|
};
|
|
140
123
|
};
|
package/dist/index.cjs.js
CHANGED
|
@@ -1474,36 +1474,39 @@ class MockClient extends InfraWalletClient {
|
|
|
1474
1474
|
}
|
|
1475
1475
|
async transformCostsData(_subAccountConfig, query, _costResponse) {
|
|
1476
1476
|
try {
|
|
1477
|
-
const
|
|
1478
|
-
let
|
|
1477
|
+
const startDate = moment__default.default.unix(Number(query.startTime) / 1e3);
|
|
1478
|
+
let endDate = moment__default.default.unix(Number(query.endTime) / 1e3);
|
|
1479
1479
|
const mockDir = backendPluginApi.resolvePackagePath("@electrolux-oss/plugin-infrawallet-backend", "mock");
|
|
1480
1480
|
const mockFilePath = upath__namespace.join(mockDir, "mock_response.json");
|
|
1481
1481
|
const data = await fs.promises.readFile(mockFilePath, "utf8");
|
|
1482
1482
|
const jsonData = JSON.parse(data);
|
|
1483
1483
|
const currentDate = moment__default.default();
|
|
1484
|
-
if (
|
|
1485
|
-
|
|
1486
|
-
|
|
1484
|
+
if (endDate.isAfter(currentDate)) {
|
|
1485
|
+
endDate = currentDate.clone();
|
|
1486
|
+
endDate.add(1, "day");
|
|
1487
1487
|
}
|
|
1488
1488
|
const processedData = await Promise.all(
|
|
1489
1489
|
jsonData.map(async (item) => {
|
|
1490
1490
|
item.providerType = PROVIDER_TYPE.INTEGRATION;
|
|
1491
1491
|
item.reports = {};
|
|
1492
|
-
|
|
1492
|
+
let tempDate = moment__default.default(startDate);
|
|
1493
|
+
if (item.provider === "GCP") {
|
|
1494
|
+
tempDate = tempDate.add(1, "month");
|
|
1495
|
+
}
|
|
1493
1496
|
let step = "months";
|
|
1494
1497
|
let dateFormat = "YYYY-MM";
|
|
1495
1498
|
if (query.granularity.toLowerCase() === "daily") {
|
|
1496
1499
|
step = "days";
|
|
1497
1500
|
dateFormat = "YYYY-MM-DD";
|
|
1498
1501
|
}
|
|
1499
|
-
while (
|
|
1500
|
-
const dateString =
|
|
1502
|
+
while (tempDate.isBefore(endDate)) {
|
|
1503
|
+
const dateString = tempDate.format(dateFormat);
|
|
1501
1504
|
if (query.granularity.toLowerCase() === "monthly") {
|
|
1502
1505
|
item.reports[dateString] = this.getRandomValue(0.4 * 30, 33.3 * 30);
|
|
1503
1506
|
} else {
|
|
1504
1507
|
item.reports[dateString] = this.getRandomValue(0.4, 33.3);
|
|
1505
1508
|
}
|
|
1506
|
-
|
|
1509
|
+
tempDate.add(1, step);
|
|
1507
1510
|
}
|
|
1508
1511
|
return item;
|
|
1509
1512
|
})
|