emissions-api-sdk 1.0.5 → 1.0.7
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/.secrets.baseline +314 -0
- package/README.md +20 -27
- package/dist/Constants.js +5 -29
- package/dist/api/Calculation.js +0 -63
- package/dist/api/EconomicActivity.js +0 -60
- package/dist/api/Factor.js +0 -82
- package/dist/api/Fugitive.js +0 -63
- package/dist/api/Location.js +0 -61
- package/dist/api/Metadata.js +155 -0
- package/dist/api/Mobile.js +0 -64
- package/dist/api/RealEstate.js +0 -61
- package/dist/api/Stationary.js +0 -63
- package/dist/api/TransportationAndDistribution.js +0 -63
- package/dist/api/TypeRecommender.js +62 -0
- package/dist/coverage/clover.xml +142 -238
- package/dist/coverage/coverage-final.json +15 -13
- package/dist/coverage/lcov-report/index.html +20 -20
- package/dist/coverage/lcov-report/src/Client.ts.html +28 -28
- package/dist/coverage/lcov-report/src/Constants.ts.html +31 -106
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +7 -217
- package/dist/coverage/lcov-report/src/api/EconomicActivity.ts.html +7 -214
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +6 -285
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +7 -223
- package/dist/coverage/lcov-report/src/api/Location.ts.html +6 -222
- package/dist/coverage/lcov-report/src/api/Metadata.ts.html +604 -0
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +6 -231
- package/dist/coverage/lcov-report/src/api/RealEstate.ts.html +6 -219
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +6 -225
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +7 -223
- package/dist/coverage/lcov-report/src/api/TypeRecommender.ts.html +277 -0
- package/dist/coverage/lcov-report/src/api/Usage.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/index.html +63 -33
- package/dist/coverage/lcov-report/src/index.html +7 -7
- package/dist/coverage/lcov-report/src/request.ts.html +5 -5
- package/dist/coverage/lcov-report/src/utils.ts.html +6 -6
- package/dist/coverage/lcov-report/test/index.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +1 -1
- package/dist/coverage/lcov-report/test/mocks/index.html +1 -1
- package/dist/coverage/lcov-report/test/testUtils.ts.html +1 -1
- package/dist/coverage/lcov.info +239 -353
- package/dist/index.js +3 -1
- package/dist/interfaces/response/TypeRecommenderResponse.js +2 -0
- package/dist/types/Constants.d.ts +4 -28
- package/dist/types/api/Calculation.d.ts +0 -41
- package/dist/types/api/EconomicActivity.d.ts +0 -38
- package/dist/types/api/Factor.d.ts +0 -52
- package/dist/types/api/Fugitive.d.ts +0 -41
- package/dist/types/api/Location.d.ts +0 -39
- package/dist/types/api/Metadata.d.ts +99 -0
- package/dist/types/api/Mobile.d.ts +0 -42
- package/dist/types/api/RealEstate.d.ts +0 -39
- package/dist/types/api/Stationary.d.ts +0 -41
- package/dist/types/api/TransportationAndDistribution.d.ts +0 -41
- package/dist/types/api/TypeRecommender.d.ts +50 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interfaces/response/TypeRecommenderResponse.d.ts +14 -0
- package/docs/_sources/reference.rst.txt +14 -50
- package/docs/_static/basic.css +8 -0
- package/docs/_static/pygments.css +146 -164
- package/docs/_static/searchtools.js +5 -8
- package/docs/_static/styles/furo.css +1 -1
- package/docs/_static/styles/furo.css.map +1 -1
- package/docs/authentication.html +28 -19
- package/docs/client.html +28 -19
- package/docs/genindex.html +41 -84
- package/docs/getting_started.html +28 -19
- package/docs/index.html +29 -20
- package/docs/objects.inv +0 -0
- package/docs/reference.html +102 -502
- package/docs/sdk.html +28 -19
- package/docs/search.html +28 -19
- package/docs/searchindex.js +1 -1
- package/docs/troubleshooting.html +28 -19
- package/package.json +10 -7
- package/sphinx-build/requirements.txt +1 -0
- package/sphinx-build/source/reference.rst +14 -50
- package/src/Constants.ts +5 -30
- package/src/api/Calculation.ts +1 -72
- package/src/api/EconomicActivity.ts +1 -71
- package/src/api/Factor.ts +1 -94
- package/src/api/Fugitive.ts +1 -74
- package/src/api/Location.ts +1 -73
- package/src/api/Metadata.ts +174 -0
- package/src/api/Mobile.ts +1 -76
- package/src/api/RealEstate.ts +1 -72
- package/src/api/Stationary.ts +1 -74
- package/src/api/TransportationAndDistribution.ts +1 -74
- package/src/api/TypeRecommender.ts +65 -0
- package/src/index.ts +4 -1
- package/src/interfaces/response/TypeRecommenderResponse.ts +18 -0
- package/test/apiTest.test.ts +9 -205
- package/test/metadata.test.ts +224 -0
- package/test/request.test.ts +0 -1
- package/sphinx-build/.secrets.baseline +0 -150
package/test/apiTest.test.ts
CHANGED
|
@@ -10,6 +10,7 @@ import * as realEstateApi from "../src/api/RealEstate";
|
|
|
10
10
|
import * as UsageApi from "../src/api/Usage";
|
|
11
11
|
import * as Factors from "../src/api/Factor";
|
|
12
12
|
import * as FactorSets from "../src/api/FactorSets";
|
|
13
|
+
import * as VectorTypeSearch from "../src/api/TypeRecommender";
|
|
13
14
|
|
|
14
15
|
import {
|
|
15
16
|
LOCATION_API_PATH,
|
|
@@ -21,37 +22,10 @@ import {
|
|
|
21
22
|
FACTOR_API_PATH,
|
|
22
23
|
FACTOR_SET_API_PATH,
|
|
23
24
|
SEARCH_API_PATH,
|
|
24
|
-
LOCATION_TYPES,
|
|
25
|
-
FUGITIVE_API_TYPES,
|
|
26
|
-
MOBILE_API_TYPES,
|
|
27
|
-
STATIONARY_API_TYPES,
|
|
28
|
-
CALCULATION_TYPES,
|
|
29
|
-
FACTOR_API_TYPES,
|
|
30
|
-
TRANSPORTATION_AND_DISTRIBUTION_API_TYPES,
|
|
31
|
-
LOCATION_API_AREA,
|
|
32
|
-
FUGITIVE_API_AREA,
|
|
33
|
-
MOBILE_API_AREA,
|
|
34
|
-
STATIONARY_API_AREA,
|
|
35
|
-
GENERAL_API_AREA,
|
|
36
|
-
FACTOR_API_AREA,
|
|
37
|
-
TRANSPORTATION_AND_DISTRIBUTION_API_AREA,
|
|
38
|
-
LOCATION_API_UNITS,
|
|
39
|
-
SEARCH_API_AREA,
|
|
40
|
-
FUGITIVE_API_UNITS,
|
|
41
|
-
MOBILE_API_UNITS,
|
|
42
|
-
STATIONARY_API_UNITS,
|
|
43
|
-
GENERAL_API_UNITS,
|
|
44
|
-
FACTOR_API_UNITS,
|
|
45
|
-
TRANSPORTATION_AND_DISTRIBUTION_API_UNITS,
|
|
46
25
|
USAGE_API,
|
|
47
26
|
ECONOMIC_ACTIVITY_API_PATH,
|
|
48
|
-
ECONOMIC_ACTIVITY_API_TYPES,
|
|
49
27
|
REAL_ESTATE_API_PATH,
|
|
50
|
-
|
|
51
|
-
ECONOMIC_ACTIVITY_API_AREA,
|
|
52
|
-
REAL_ESTATE_API_AREA,
|
|
53
|
-
ECONOMIC_ACTIVITY_API_UNITS,
|
|
54
|
-
REAL_ESTATE_API_UNITS
|
|
28
|
+
TYPE_RECOMMENDER_API_PATH,
|
|
55
29
|
} from "../src/Constants";
|
|
56
30
|
import locationPayload from "./mocks/LocationRequest";
|
|
57
31
|
import commonpayload from "./mocks/CommonRequest";
|
|
@@ -149,183 +123,6 @@ const testCases: ApiTestCase[] = [
|
|
|
149
123
|
payload: SearchPayload,
|
|
150
124
|
method: "POST",
|
|
151
125
|
},
|
|
152
|
-
{
|
|
153
|
-
name: "Location API - getTypes",
|
|
154
|
-
func: locationApi.getTypes,
|
|
155
|
-
path: LOCATION_TYPES,
|
|
156
|
-
method: "GET",
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
name: "Fugitive API - getTypes",
|
|
160
|
-
func: fugitiveApi.getTypes,
|
|
161
|
-
path: FUGITIVE_API_TYPES,
|
|
162
|
-
method: "GET",
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
name: "Mobile API - getTypes",
|
|
166
|
-
func: mobileApi.getTypes,
|
|
167
|
-
path: MOBILE_API_TYPES,
|
|
168
|
-
method: "GET",
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
name: "Stationary API - getTypes",
|
|
172
|
-
func: stationaryApi.getTypes,
|
|
173
|
-
path: STATIONARY_API_TYPES,
|
|
174
|
-
method: "GET",
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
name: "Economic activity API - getTypes",
|
|
178
|
-
func: economicActivityApi.getTypes,
|
|
179
|
-
path: ECONOMIC_ACTIVITY_API_TYPES,
|
|
180
|
-
method: "GET",
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
name: "Real estate API - getTypes",
|
|
184
|
-
func: realEstateApi.getTypes,
|
|
185
|
-
path: REAL_ESTATE_API_TYPES,
|
|
186
|
-
method: "GET",
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: "GenericCalculation API - getTypes",
|
|
190
|
-
func: GenericCalculation.getTypes,
|
|
191
|
-
path: CALCULATION_TYPES,
|
|
192
|
-
method: "GET",
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
name: "Factor API - getTypes",
|
|
196
|
-
func: Factors.getTypes,
|
|
197
|
-
path: FACTOR_API_TYPES,
|
|
198
|
-
method: "GET",
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
name: "Transportation and Distribution API - getTypes",
|
|
202
|
-
func: TransportationDistributionApi.getTypes,
|
|
203
|
-
path: TRANSPORTATION_AND_DISTRIBUTION_API_TYPES,
|
|
204
|
-
method: "GET",
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
name: "Location API - getArea",
|
|
208
|
-
func: locationApi.getArea,
|
|
209
|
-
path: LOCATION_API_AREA,
|
|
210
|
-
method: "GET",
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
name: "Fugitive API - getArea",
|
|
214
|
-
func: fugitiveApi.getArea,
|
|
215
|
-
path: FUGITIVE_API_AREA,
|
|
216
|
-
method: "GET",
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
name: "Mobile API - getArea",
|
|
220
|
-
func: mobileApi.getArea,
|
|
221
|
-
path: MOBILE_API_AREA,
|
|
222
|
-
method: "GET",
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
name: "Stationary API - getArea",
|
|
226
|
-
func: stationaryApi.getArea,
|
|
227
|
-
path: STATIONARY_API_AREA,
|
|
228
|
-
method: "GET",
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
name: "Economic activity API - getArea",
|
|
232
|
-
func: economicActivityApi.getArea,
|
|
233
|
-
path: ECONOMIC_ACTIVITY_API_AREA,
|
|
234
|
-
method: "GET",
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
name: "Real estate API - getArea",
|
|
238
|
-
func: realEstateApi.getArea,
|
|
239
|
-
path: REAL_ESTATE_API_AREA,
|
|
240
|
-
method: "GET",
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
name: "GenericCalculation API - getArea",
|
|
244
|
-
func: GenericCalculation.getArea,
|
|
245
|
-
path: GENERAL_API_AREA,
|
|
246
|
-
method: "GET",
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
name: "Factor API - getArea",
|
|
250
|
-
func: Factors.getArea,
|
|
251
|
-
path: FACTOR_API_AREA,
|
|
252
|
-
method: "GET",
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
name: "Factor SEARCH API - getArea",
|
|
256
|
-
func: Factors.getSearchArea,
|
|
257
|
-
path: SEARCH_API_AREA,
|
|
258
|
-
method: "GET",
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
name: "Transportation and Distribution API - getArea",
|
|
262
|
-
func: TransportationDistributionApi.getArea,
|
|
263
|
-
path: TRANSPORTATION_AND_DISTRIBUTION_API_AREA,
|
|
264
|
-
method: "GET",
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
name: "Location API - getUnits",
|
|
268
|
-
func: locationApi.getUnits,
|
|
269
|
-
path: LOCATION_API_UNITS,
|
|
270
|
-
queryParams: { type: "electricity" },
|
|
271
|
-
method: "GET",
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
name: "Fugitive API - getUnits",
|
|
275
|
-
func: fugitiveApi.getUnits,
|
|
276
|
-
path: FUGITIVE_API_UNITS,
|
|
277
|
-
queryParams: { type: "Natural Gas - Scope 3:AAA" },
|
|
278
|
-
method: "GET",
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
name: "Mobile API - getUnits",
|
|
282
|
-
func: mobileApi.getUnits,
|
|
283
|
-
path: MOBILE_API_UNITS,
|
|
284
|
-
queryParams: { type: "Cars:B20:(NE)" },
|
|
285
|
-
method: "GET",
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
name: "Stationary API - getUnits",
|
|
289
|
-
func: stationaryApi.getUnits,
|
|
290
|
-
path: STATIONARY_API_UNITS,
|
|
291
|
-
queryParams: { type: "Jet Kerosene" },
|
|
292
|
-
method: "GET",
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
name: "Economic activity API - getUnits",
|
|
296
|
-
func: economicActivityApi.getUnits,
|
|
297
|
-
path: ECONOMIC_ACTIVITY_API_UNITS,
|
|
298
|
-
queryParams: { type: "accomodation" },
|
|
299
|
-
method: "GET",
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
name: "Real estate API - getUnits",
|
|
303
|
-
func: realEstateApi.getUnits,
|
|
304
|
-
path: REAL_ESTATE_API_UNITS,
|
|
305
|
-
queryParams: { type: "Commercial Real Estate:Hotel" },
|
|
306
|
-
method: "GET",
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
name: "GenericCalculation API - getUnits",
|
|
310
|
-
func: GenericCalculation.getUnits,
|
|
311
|
-
path: GENERAL_API_UNITS,
|
|
312
|
-
queryParams: { type: "Natural Gas - Scope 3:AAA" },
|
|
313
|
-
method: "GET",
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
name: "Factor API - getUnits",
|
|
317
|
-
func: Factors.getUnits,
|
|
318
|
-
path: FACTOR_API_UNITS,
|
|
319
|
-
queryParams: { type: "HFC-263fb" },
|
|
320
|
-
method: "GET",
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
name: "Transportation and Distribution API - getUnits",
|
|
324
|
-
func: TransportationDistributionApi.getUnits,
|
|
325
|
-
path: TRANSPORTATION_AND_DISTRIBUTION_API_UNITS,
|
|
326
|
-
queryParams: { type: "Business Travel - Cars:Diesel - Small" },
|
|
327
|
-
method: "GET",
|
|
328
|
-
},
|
|
329
126
|
{
|
|
330
127
|
name: "Usage API - getUsage with history false",
|
|
331
128
|
func: UsageApi.getUsage,
|
|
@@ -346,6 +143,13 @@ const testCases: ApiTestCase[] = [
|
|
|
346
143
|
path: USAGE_API,
|
|
347
144
|
queryParams: { history: false },
|
|
348
145
|
method: "GET",
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "VectorTypeSearch API",
|
|
149
|
+
func: VectorTypeSearch.search,
|
|
150
|
+
path: TYPE_RECOMMENDER_API_PATH,
|
|
151
|
+
payload: SearchPayload,
|
|
152
|
+
method: "POST",
|
|
349
153
|
}
|
|
350
154
|
];
|
|
351
155
|
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import * as MetadataApi from "../src/api/Metadata";
|
|
2
|
+
import { Client } from "../src/Client";
|
|
3
|
+
import {
|
|
4
|
+
METADATA_AREA_ENDPOINT,
|
|
5
|
+
METADATA_TYPES_ENDPOINT,
|
|
6
|
+
METADATA_UNITS_ENDPOINT,
|
|
7
|
+
} from "../src/Constants";
|
|
8
|
+
import * as requestModule from "../src/request";
|
|
9
|
+
|
|
10
|
+
type MetadataTestCase = {
|
|
11
|
+
name: string;
|
|
12
|
+
func: (arg?: string) => Promise<any>;
|
|
13
|
+
path: string;
|
|
14
|
+
endpoint?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
queryParams?: Record<string, string>;
|
|
17
|
+
requestBody?: Record<string, string>;
|
|
18
|
+
method: "GET" | "POST";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const mockResp = "mock-success-response";
|
|
22
|
+
|
|
23
|
+
const testCases: MetadataTestCase[] = [
|
|
24
|
+
// GET Types Tests
|
|
25
|
+
{
|
|
26
|
+
name: "Metadata API - getTypes (default)",
|
|
27
|
+
func: MetadataApi.getTypes,
|
|
28
|
+
path: METADATA_TYPES_ENDPOINT,
|
|
29
|
+
method: "GET",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "Metadata API - getTypes with endpoint",
|
|
33
|
+
func: MetadataApi.getTypes,
|
|
34
|
+
path: METADATA_TYPES_ENDPOINT,
|
|
35
|
+
endpoint: "location",
|
|
36
|
+
queryParams: { endpoint: "location" },
|
|
37
|
+
method: "GET",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "Metadata API - getTypes with stationary endpoint",
|
|
41
|
+
func: MetadataApi.getTypes,
|
|
42
|
+
path: METADATA_TYPES_ENDPOINT,
|
|
43
|
+
endpoint: "stationary",
|
|
44
|
+
queryParams: { endpoint: "stationary" },
|
|
45
|
+
method: "GET",
|
|
46
|
+
},
|
|
47
|
+
// POST Types Tests
|
|
48
|
+
{
|
|
49
|
+
name: "Metadata API - postTypes (default)",
|
|
50
|
+
func: MetadataApi.postTypes,
|
|
51
|
+
path: METADATA_TYPES_ENDPOINT,
|
|
52
|
+
requestBody: {},
|
|
53
|
+
method: "POST",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "Metadata API - postTypes with endpoint",
|
|
57
|
+
func: MetadataApi.postTypes,
|
|
58
|
+
path: METADATA_TYPES_ENDPOINT,
|
|
59
|
+
endpoint: "mobile",
|
|
60
|
+
requestBody: { endpoint: "mobile" },
|
|
61
|
+
method: "POST",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "Metadata API - postTypes with fugitive endpoint",
|
|
65
|
+
func: MetadataApi.postTypes,
|
|
66
|
+
path: METADATA_TYPES_ENDPOINT,
|
|
67
|
+
endpoint: "fugitive",
|
|
68
|
+
requestBody: { endpoint: "fugitive" },
|
|
69
|
+
method: "POST",
|
|
70
|
+
},
|
|
71
|
+
// GET Area Tests
|
|
72
|
+
{
|
|
73
|
+
name: "Metadata API - getArea (default)",
|
|
74
|
+
func: MetadataApi.getArea,
|
|
75
|
+
path: METADATA_AREA_ENDPOINT,
|
|
76
|
+
method: "GET",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "Metadata API - getArea with endpoint",
|
|
80
|
+
func: MetadataApi.getArea,
|
|
81
|
+
path: METADATA_AREA_ENDPOINT,
|
|
82
|
+
endpoint: "calculation",
|
|
83
|
+
queryParams: { endpoint: "calculation" },
|
|
84
|
+
method: "GET",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "Metadata API - getArea with transportation endpoint",
|
|
88
|
+
func: MetadataApi.getArea,
|
|
89
|
+
path: METADATA_AREA_ENDPOINT,
|
|
90
|
+
endpoint: "transportation-and-distribution",
|
|
91
|
+
queryParams: { endpoint: "transportation-and-distribution" },
|
|
92
|
+
method: "GET",
|
|
93
|
+
},
|
|
94
|
+
// POST Area Tests
|
|
95
|
+
{
|
|
96
|
+
name: "Metadata API - postArea (default)",
|
|
97
|
+
func: MetadataApi.postArea,
|
|
98
|
+
path: METADATA_AREA_ENDPOINT,
|
|
99
|
+
requestBody: {},
|
|
100
|
+
method: "POST",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "Metadata API - postArea with endpoint",
|
|
104
|
+
func: MetadataApi.postArea,
|
|
105
|
+
path: METADATA_AREA_ENDPOINT,
|
|
106
|
+
endpoint: "real-estate",
|
|
107
|
+
requestBody: { endpoint: "real-estate" },
|
|
108
|
+
method: "POST",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "Metadata API - postArea with economic-activity endpoint",
|
|
112
|
+
func: MetadataApi.postArea,
|
|
113
|
+
path: METADATA_AREA_ENDPOINT,
|
|
114
|
+
endpoint: "economic-activity",
|
|
115
|
+
requestBody: { endpoint: "economic-activity" },
|
|
116
|
+
method: "POST",
|
|
117
|
+
},
|
|
118
|
+
// GET Units Tests
|
|
119
|
+
{
|
|
120
|
+
name: "Metadata API - getUnits (default)",
|
|
121
|
+
func: MetadataApi.getUnits,
|
|
122
|
+
path: METADATA_UNITS_ENDPOINT,
|
|
123
|
+
method: "GET",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "Metadata API - getUnits with type",
|
|
127
|
+
func: MetadataApi.getUnits,
|
|
128
|
+
path: METADATA_UNITS_ENDPOINT,
|
|
129
|
+
type: "Natural Gas",
|
|
130
|
+
queryParams: { type: "Natural Gas" },
|
|
131
|
+
method: "GET",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "Metadata API - getUnits with type with subtype",
|
|
135
|
+
func: MetadataApi.getUnits,
|
|
136
|
+
path: METADATA_UNITS_ENDPOINT,
|
|
137
|
+
type: "Natural Gas - Scope 3:AAA",
|
|
138
|
+
queryParams: { type: "Natural Gas - Scope 3:AAA" },
|
|
139
|
+
method: "GET",
|
|
140
|
+
},
|
|
141
|
+
// POST Units Tests
|
|
142
|
+
{
|
|
143
|
+
name: "Metadata API - postUnits (default)",
|
|
144
|
+
func: MetadataApi.postUnits,
|
|
145
|
+
path: METADATA_UNITS_ENDPOINT,
|
|
146
|
+
requestBody: {},
|
|
147
|
+
method: "POST",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "Metadata API - postUnits with type",
|
|
151
|
+
func: MetadataApi.postUnits,
|
|
152
|
+
path: METADATA_UNITS_ENDPOINT,
|
|
153
|
+
type: "electricity",
|
|
154
|
+
requestBody: { type: "electricity" },
|
|
155
|
+
method: "POST",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "Metadata API - postUnits with complex type",
|
|
159
|
+
func: MetadataApi.postUnits,
|
|
160
|
+
path: METADATA_UNITS_ENDPOINT,
|
|
161
|
+
type: "Business Travel - Cars:Diesel - Small",
|
|
162
|
+
requestBody: { type: "Business Travel - Cars:Diesel - Small" },
|
|
163
|
+
method: "POST",
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
describe("Metadata API Tests", () => {
|
|
168
|
+
let spy: jest.SpyInstance;
|
|
169
|
+
let tokenSpy: jest.SpyInstance;
|
|
170
|
+
|
|
171
|
+
beforeEach(() => {
|
|
172
|
+
jest.clearAllMocks();
|
|
173
|
+
tokenSpy = jest
|
|
174
|
+
.spyOn(Client as any, "requestToken")
|
|
175
|
+
.mockResolvedValue(
|
|
176
|
+
"eyJpzGciOiJIUzI1NlIsInR5cCI6IkplVCJ9." +
|
|
177
|
+
Buffer.from(
|
|
178
|
+
JSON.stringify({ exp: Math.floor(Date.now() / 1000) + 3600 })
|
|
179
|
+
).toString("base64") +
|
|
180
|
+
".signature"
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
Client.getClient({
|
|
184
|
+
apiKey: "mock-api-key",
|
|
185
|
+
clientId: "mock-client-id",
|
|
186
|
+
orgId: "mock-org-id",
|
|
187
|
+
});
|
|
188
|
+
spy = jest
|
|
189
|
+
.spyOn(requestModule, "makeApiRequest")
|
|
190
|
+
.mockResolvedValue(mockResp);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
afterEach(() => {
|
|
194
|
+
tokenSpy.mockRestore();
|
|
195
|
+
spy.mockRestore();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe.each(testCases)(
|
|
199
|
+
"$name",
|
|
200
|
+
({ func, path, endpoint, type, queryParams, requestBody, method }) => {
|
|
201
|
+
it("Should call makeApiRequest with correct parameters", async () => {
|
|
202
|
+
// For units tests, pass type; for types/area tests, pass endpoint
|
|
203
|
+
const result = await func(endpoint ?? type);
|
|
204
|
+
|
|
205
|
+
const clientDomain = Client.getInstance().getDomain();
|
|
206
|
+
const expectedUrl = `${clientDomain}${path}`;
|
|
207
|
+
|
|
208
|
+
const expectedRequest: any = {
|
|
209
|
+
method,
|
|
210
|
+
url: expectedUrl,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
if (method === "POST") {
|
|
214
|
+
expectedRequest.data = requestBody;
|
|
215
|
+
} else if (method === "GET" && queryParams) {
|
|
216
|
+
expectedRequest.params = queryParams;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
expect(spy).toHaveBeenCalledWith(expectedRequest);
|
|
220
|
+
expect(result).toBe(mockResp);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
});
|
package/test/request.test.ts
CHANGED
|
@@ -2,7 +2,6 @@ import axios, { Method } from "axios";
|
|
|
2
2
|
import { makeApiRequest } from "../src/request";
|
|
3
3
|
import { Client } from "../src/Client";
|
|
4
4
|
import { RequestConfig } from "../src/interfaces/Config";
|
|
5
|
-
import { get } from "http";
|
|
6
5
|
import { CLIENT_SOURCE_HEADER } from "../src/Constants";
|
|
7
6
|
|
|
8
7
|
jest.mock("axios");
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"exclude": {
|
|
3
|
-
"files": "^.secrets.baseline$",
|
|
4
|
-
"lines": null
|
|
5
|
-
},
|
|
6
|
-
"generated_at": "2026-02-16T08:57:50Z",
|
|
7
|
-
"plugins_used": [
|
|
8
|
-
{
|
|
9
|
-
"name": "AWSKeyDetector"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"name": "ArtifactoryDetector"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "AzureStorageKeyDetector"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"base64_limit": 4.5,
|
|
19
|
-
"name": "Base64HighEntropyString"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"name": "BasicAuthDetector"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "BoxDetector"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"name": "CloudantDetector"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"ghe_instance": "github.ibm.com",
|
|
32
|
-
"name": "GheDetector"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"name": "GitHubTokenDetector"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"hex_limit": 3,
|
|
39
|
-
"name": "HexHighEntropyString"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"name": "IbmCloudIamDetector"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"name": "IbmCosHmacDetector"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"name": "JwtTokenDetector"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"keyword_exclude": null,
|
|
52
|
-
"name": "KeywordDetector"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"name": "MailchimpDetector"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"name": "NpmDetector"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"name": "PrivateKeyDetector"
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"name": "SlackDetector"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"name": "SoftlayerDetector"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"name": "SquareOAuthDetector"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"name": "StripeDetector"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"name": "TwilioKeyDetector"
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
"results": {
|
|
80
|
-
"source/authentication.rst": [
|
|
81
|
-
{
|
|
82
|
-
"hashed_secret": "d92258e9826f7923e5fa45241420653a89db10b0",
|
|
83
|
-
"is_secret": false,
|
|
84
|
-
"is_verified": false,
|
|
85
|
-
"line_number": 41,
|
|
86
|
-
"type": "Secret Keyword",
|
|
87
|
-
"verified_result": null
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"hashed_secret": "9eddf3741c2ec20058940c3225b3e387cf6166dd",
|
|
91
|
-
"is_secret": false,
|
|
92
|
-
"is_verified": false,
|
|
93
|
-
"line_number": 152,
|
|
94
|
-
"type": "Secret Keyword",
|
|
95
|
-
"verified_result": null
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
"source/client.rst": [
|
|
99
|
-
{
|
|
100
|
-
"hashed_secret": "9eddf3741c2ec20058940c3225b3e387cf6166dd",
|
|
101
|
-
"is_secret": false,
|
|
102
|
-
"is_verified": false,
|
|
103
|
-
"line_number": 108,
|
|
104
|
-
"type": "Secret Keyword",
|
|
105
|
-
"verified_result": null
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
"source/getting_started.rst": [
|
|
109
|
-
{
|
|
110
|
-
"hashed_secret": "11fa7c37d697f30e6aee828b4426a10f83ab2380",
|
|
111
|
-
"is_secret": false,
|
|
112
|
-
"is_verified": false,
|
|
113
|
-
"line_number": 122,
|
|
114
|
-
"type": "Secret Keyword",
|
|
115
|
-
"verified_result": null
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
"source/troubleshooting.rst": [
|
|
119
|
-
{
|
|
120
|
-
"hashed_secret": "ade7ae7ec3dcbc8e6efab2ad366fd59b4be60bda",
|
|
121
|
-
"is_secret": false,
|
|
122
|
-
"is_verified": false,
|
|
123
|
-
"line_number": 129,
|
|
124
|
-
"type": "Secret Keyword",
|
|
125
|
-
"verified_result": null
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"hashed_secret": "24de2a83c833555a5931a357cb9a639830db7851",
|
|
129
|
-
"is_secret": false,
|
|
130
|
-
"is_verified": false,
|
|
131
|
-
"line_number": 191,
|
|
132
|
-
"type": "Secret Keyword",
|
|
133
|
-
"verified_result": null
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
"hashed_secret": "11fa7c37d697f30e6aee828b4426a10f83ab2380",
|
|
137
|
-
"is_secret": false,
|
|
138
|
-
"is_verified": false,
|
|
139
|
-
"line_number": 224,
|
|
140
|
-
"type": "Secret Keyword",
|
|
141
|
-
"verified_result": null
|
|
142
|
-
}
|
|
143
|
-
]
|
|
144
|
-
},
|
|
145
|
-
"version": "0.13.1+ibm.64.dss",
|
|
146
|
-
"word_list": {
|
|
147
|
-
"file": null,
|
|
148
|
-
"hash": null
|
|
149
|
-
}
|
|
150
|
-
}
|