@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 CHANGED
@@ -2,139 +2,122 @@ export interface Config {
2
2
  backend: {
3
3
  infraWallet: {
4
4
  integrations: {
5
- azure?: [
6
- {
7
- name: string;
8
- subscriptionId: string;
9
- clientId: string;
10
- tenantId: string;
11
- /**
12
- * @visibility secret
13
- */
14
- clientSecret: string;
15
- tags?: string[];
16
- },
17
- ];
18
- aws?: [
19
- {
20
- name: string;
21
- accountId: string;
22
- assumedRoleName?: string;
23
- /**
24
- * @visibility secret
25
- */
26
- accessKeyId?: string;
27
- /**
28
- * @visibility secret
29
- */
30
- accessKeySecret?: string;
31
- tags?: string[];
32
- filters?: [
33
- {
34
- type: string;
35
- attribute: string;
36
- pattern: string;
37
- },
38
- ];
39
- },
40
- ];
41
- gcp?: [
42
- {
43
- name: string;
44
- keyFilePath: string;
45
- projectId: string;
46
- datasetId: string;
47
- tableId: string;
48
- tags?: string[];
49
- },
50
- ];
51
- confluent?: [
52
- {
53
- name: string;
54
- /**
55
- * @visibility secret
56
- */
57
- apiKey: string;
58
- /**
59
- * @visibility secret
60
- */
61
- apiSecret: string;
62
- tags?: string[];
63
- },
64
- ];
65
- mongoatlas?: [
66
- {
67
- name: string;
68
- orgId: string;
69
- /**
70
- * @visibility secret
71
- */
72
- publicKey: string;
73
- /**
74
- * @visibility secret
75
- */
76
- privateKey: string;
77
- tags?: string[];
78
- },
79
- ];
80
- datadog?: [
81
- {
82
- name: string;
83
- /**
84
- * @visibility secret
85
- */
86
- apiKey: string;
87
- /**
88
- * @visibility secret
89
- */
90
- applicationKey: string;
91
- ddSite: string;
92
- filters?: [
93
- {
94
- type: string;
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
- name: string;
111
- /**
112
- * @visibility secret
113
- */
114
- apiKey: string;
115
- /**
116
- * @visibility secret
117
- */
118
- applicationKey: string;
119
- ddSite: string;
120
- },
121
- ];
122
- grafanaCloud?: [
123
- {
124
- name: string;
125
- url: string;
126
- datasourceUid: string;
127
- /**
128
- * @visibility secret
129
- */
130
- token: string;
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 startD = moment__default.default.unix(Number(query.startTime) / 1e3);
1478
- let endD = moment__default.default.unix(Number(query.endTime) / 1e3);
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 (endD.isAfter(currentDate)) {
1485
- endD = currentDate.clone();
1486
- endD.add(1, "day");
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
- const StartDate = moment__default.default(startD);
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 (StartDate.isBefore(endD)) {
1500
- const dateString = StartDate.format(dateFormat);
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
- StartDate.add(1, step);
1509
+ tempDate.add(1, step);
1507
1510
  }
1508
1511
  return item;
1509
1512
  })