emissions-api-sdk 1.0.6 → 1.0.8
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 +2 -2
- package/dist/Constants.js +2 -1
- package/dist/api/TypeRecommender.js +62 -0
- package/dist/coverage/clover.xml +45 -34
- package/dist/coverage/coverage-final.json +4 -3
- package/dist/coverage/lcov-report/index.html +15 -15
- package/dist/coverage/lcov-report/src/Client.ts.html +22 -22
- package/dist/coverage/lcov-report/src/Constants.ts.html +10 -4
- package/dist/coverage/lcov-report/src/api/Calculation.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/EconomicActivity.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Factor.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Location.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Metadata.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Mobile.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/RealEstate.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/Stationary.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +1 -1
- 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 +19 -4
- package/dist/coverage/lcov-report/src/index.html +7 -7
- package/dist/coverage/lcov-report/src/request.ts.html +1 -1
- package/dist/coverage/lcov-report/src/utils.ts.html +5 -5
- 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 +75 -56
- package/dist/index.js +2 -1
- package/dist/interfaces/response/TypeRecommenderResponse.js +2 -0
- package/dist/types/Constants.d.ts +1 -0
- package/dist/types/api/TypeRecommender.d.ts +50 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/interfaces/response/EmissionResponse.d.ts +4 -0
- package/dist/types/interfaces/response/FactorResponse.d.ts +2 -0
- package/dist/types/interfaces/response/TypeRecommenderResponse.d.ts +14 -0
- package/package.json +7 -6
- package/sphinx-build/requirements.txt +1 -0
- package/src/Constants.ts +2 -0
- package/src/api/TypeRecommender.ts +65 -0
- package/src/index.ts +3 -1
- package/src/interfaces/response/EmissionResponse.ts +6 -0
- package/src/interfaces/response/FactorResponse.ts +3 -0
- package/src/interfaces/response/TypeRecommenderResponse.ts +18 -0
- package/test/apiTest.test.ts +9 -0
package/dist/coverage/lcov.info
CHANGED
|
@@ -11,10 +11,10 @@ FN:214,(anonymous_8)
|
|
|
11
11
|
FN:236,(anonymous_9)
|
|
12
12
|
FNF:9
|
|
13
13
|
FNH:7
|
|
14
|
-
FNDA:
|
|
15
|
-
FNDA:
|
|
16
|
-
FNDA:
|
|
17
|
-
FNDA:
|
|
14
|
+
FNDA:37,(anonymous_1)
|
|
15
|
+
FNDA:40,(anonymous_2)
|
|
16
|
+
FNDA:66,(anonymous_3)
|
|
17
|
+
FNDA:71,(anonymous_4)
|
|
18
18
|
FNDA:3,(anonymous_5)
|
|
19
19
|
FNDA:2,(anonymous_6)
|
|
20
20
|
FNDA:0,(anonymous_7)
|
|
@@ -25,36 +25,36 @@ DA:3,5
|
|
|
25
25
|
DA:4,5
|
|
26
26
|
DA:6,5
|
|
27
27
|
DA:7,5
|
|
28
|
-
DA:24,
|
|
29
|
-
DA:25,
|
|
30
|
-
DA:26,
|
|
31
|
-
DA:27,
|
|
28
|
+
DA:24,37
|
|
29
|
+
DA:25,37
|
|
30
|
+
DA:26,37
|
|
31
|
+
DA:27,37
|
|
32
32
|
DA:28,1
|
|
33
33
|
DA:29,1
|
|
34
|
-
DA:31,
|
|
35
|
-
DA:32,
|
|
36
|
-
DA:35,
|
|
37
|
-
DA:36,
|
|
38
|
-
DA:37,
|
|
39
|
-
DA:38,
|
|
40
|
-
DA:39,
|
|
41
|
-
DA:40,
|
|
42
|
-
DA:78,
|
|
34
|
+
DA:31,36
|
|
35
|
+
DA:32,36
|
|
36
|
+
DA:35,37
|
|
37
|
+
DA:36,37
|
|
38
|
+
DA:37,37
|
|
39
|
+
DA:38,37
|
|
40
|
+
DA:39,37
|
|
41
|
+
DA:40,37
|
|
42
|
+
DA:78,40
|
|
43
43
|
DA:79,1
|
|
44
|
-
DA:83,
|
|
44
|
+
DA:83,39
|
|
45
45
|
DA:84,1
|
|
46
|
-
DA:88,
|
|
46
|
+
DA:88,38
|
|
47
47
|
DA:89,1
|
|
48
|
-
DA:94,
|
|
49
|
-
DA:96,
|
|
48
|
+
DA:94,37
|
|
49
|
+
DA:96,37
|
|
50
50
|
DA:97,1
|
|
51
51
|
DA:98,1
|
|
52
|
-
DA:99,
|
|
53
|
-
DA:100,
|
|
54
|
-
DA:114,
|
|
55
|
-
DA:136,
|
|
52
|
+
DA:99,36
|
|
53
|
+
DA:100,37
|
|
54
|
+
DA:114,66
|
|
55
|
+
DA:136,71
|
|
56
56
|
DA:137,1
|
|
57
|
-
DA:141,
|
|
57
|
+
DA:141,70
|
|
58
58
|
DA:157,3
|
|
59
59
|
DA:158,2
|
|
60
60
|
DA:159,2
|
|
@@ -74,38 +74,38 @@ LH:47
|
|
|
74
74
|
BRDA:22,0,0,0
|
|
75
75
|
BRDA:24,1,0,1
|
|
76
76
|
BRDA:24,2,0,1
|
|
77
|
-
BRDA:24,3,0,
|
|
77
|
+
BRDA:24,3,0,37
|
|
78
78
|
BRDA:27,4,0,1
|
|
79
|
-
BRDA:27,4,1,
|
|
79
|
+
BRDA:27,4,1,36
|
|
80
80
|
BRDA:37,5,0,0
|
|
81
|
-
BRDA:37,5,1,
|
|
82
|
-
BRDA:37,6,0,
|
|
83
|
-
BRDA:37,6,1,
|
|
81
|
+
BRDA:37,5,1,37
|
|
82
|
+
BRDA:37,6,0,37
|
|
83
|
+
BRDA:37,6,1,37
|
|
84
84
|
BRDA:38,7,0,0
|
|
85
|
-
BRDA:38,7,1,
|
|
86
|
-
BRDA:38,8,0,
|
|
87
|
-
BRDA:38,8,1,
|
|
85
|
+
BRDA:38,7,1,37
|
|
86
|
+
BRDA:38,8,0,37
|
|
87
|
+
BRDA:38,8,1,37
|
|
88
88
|
BRDA:40,9,0,0
|
|
89
|
-
BRDA:40,9,1,
|
|
89
|
+
BRDA:40,9,1,37
|
|
90
90
|
BRDA:78,10,0,1
|
|
91
|
-
BRDA:78,10,1,
|
|
92
|
-
BRDA:78,11,0,
|
|
91
|
+
BRDA:78,10,1,39
|
|
92
|
+
BRDA:78,11,0,40
|
|
93
93
|
BRDA:78,11,1,1
|
|
94
94
|
BRDA:83,12,0,1
|
|
95
|
-
BRDA:83,12,1,
|
|
96
|
-
BRDA:83,13,0,
|
|
95
|
+
BRDA:83,12,1,38
|
|
96
|
+
BRDA:83,13,0,39
|
|
97
97
|
BRDA:83,13,1,2
|
|
98
98
|
BRDA:88,14,0,1
|
|
99
|
-
BRDA:88,14,1,
|
|
100
|
-
BRDA:88,15,0,
|
|
101
|
-
BRDA:88,15,1,
|
|
102
|
-
BRDA:88,15,2,
|
|
99
|
+
BRDA:88,14,1,37
|
|
100
|
+
BRDA:88,15,0,38
|
|
101
|
+
BRDA:88,15,1,37
|
|
102
|
+
BRDA:88,15,2,36
|
|
103
103
|
BRDA:96,16,0,1
|
|
104
|
-
BRDA:96,16,1,
|
|
105
|
-
BRDA:96,17,0,
|
|
104
|
+
BRDA:96,16,1,36
|
|
105
|
+
BRDA:96,17,0,37
|
|
106
106
|
BRDA:96,17,1,1
|
|
107
107
|
BRDA:136,18,0,1
|
|
108
|
-
BRDA:136,18,1,
|
|
108
|
+
BRDA:136,18,1,70
|
|
109
109
|
BRDA:157,19,0,2
|
|
110
110
|
BRDA:157,19,1,1
|
|
111
111
|
BRDA:159,20,0,1
|
|
@@ -138,15 +138,16 @@ DA:12,5
|
|
|
138
138
|
DA:13,5
|
|
139
139
|
DA:15,5
|
|
140
140
|
DA:17,5
|
|
141
|
-
DA:18,5
|
|
142
141
|
DA:19,5
|
|
142
|
+
DA:20,5
|
|
143
143
|
DA:21,5
|
|
144
|
-
DA:22,5
|
|
145
144
|
DA:23,5
|
|
146
145
|
DA:24,5
|
|
147
146
|
DA:25,5
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
DA:26,5
|
|
148
|
+
DA:27,5
|
|
149
|
+
LF:23
|
|
150
|
+
LH:23
|
|
150
151
|
BRF:0
|
|
151
152
|
BRH:0
|
|
152
153
|
end_of_record
|
|
@@ -175,16 +176,16 @@ SF:src/utils.ts
|
|
|
175
176
|
FN:14,findExpiryTime
|
|
176
177
|
FNF:1
|
|
177
178
|
FNH:1
|
|
178
|
-
FNDA:
|
|
179
|
+
FNDA:35,findExpiryTime
|
|
179
180
|
DA:14,5
|
|
180
|
-
DA:15,
|
|
181
|
-
DA:16,
|
|
182
|
-
DA:17,
|
|
183
|
-
DA:18,
|
|
181
|
+
DA:15,35
|
|
182
|
+
DA:16,35
|
|
183
|
+
DA:17,35
|
|
184
|
+
DA:18,35
|
|
184
185
|
LF:5
|
|
185
186
|
LH:5
|
|
186
187
|
BRDA:17,0,0,0
|
|
187
|
-
BRDA:17,0,1,
|
|
188
|
+
BRDA:17,0,1,35
|
|
188
189
|
BRF:2
|
|
189
190
|
BRH:1
|
|
190
191
|
end_of_record
|
|
@@ -435,6 +436,24 @@ BRF:0
|
|
|
435
436
|
BRH:0
|
|
436
437
|
end_of_record
|
|
437
438
|
TN:
|
|
439
|
+
SF:src/api/TypeRecommender.ts
|
|
440
|
+
FN:54,search
|
|
441
|
+
FNF:1
|
|
442
|
+
FNH:1
|
|
443
|
+
FNDA:1,search
|
|
444
|
+
DA:1,1
|
|
445
|
+
DA:2,1
|
|
446
|
+
DA:5,1
|
|
447
|
+
DA:54,1
|
|
448
|
+
DA:57,1
|
|
449
|
+
DA:58,1
|
|
450
|
+
DA:60,1
|
|
451
|
+
LF:7
|
|
452
|
+
LH:7
|
|
453
|
+
BRF:0
|
|
454
|
+
BRH:0
|
|
455
|
+
end_of_record
|
|
456
|
+
TN:
|
|
438
457
|
SF:src/api/Usage.ts
|
|
439
458
|
FN:17,getUsage
|
|
440
459
|
FNF:1
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Metadata = exports.RealEstate = exports.EconomicActivity = exports.FactorSets = exports.Factor = exports.Usage = exports.TransportationAndDistribution = exports.Calculation = exports.Stationary = exports.Mobile = exports.Fugitive = exports.Location = exports.Client = void 0;
|
|
36
|
+
exports.TypeRecommender = exports.Metadata = exports.RealEstate = exports.EconomicActivity = exports.FactorSets = exports.Factor = exports.Usage = exports.TransportationAndDistribution = exports.Calculation = exports.Stationary = exports.Mobile = exports.Fugitive = exports.Location = exports.Client = void 0;
|
|
37
37
|
var Client_1 = require("./Client");
|
|
38
38
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_1.Client; } });
|
|
39
39
|
exports.Location = __importStar(require("./api/Location"));
|
|
@@ -48,3 +48,4 @@ exports.FactorSets = __importStar(require("./api/FactorSets"));
|
|
|
48
48
|
exports.EconomicActivity = __importStar(require("./api/EconomicActivity"));
|
|
49
49
|
exports.RealEstate = __importStar(require("./api/RealEstate"));
|
|
50
50
|
exports.Metadata = __importStar(require("./api/Metadata"));
|
|
51
|
+
exports.TypeRecommender = __importStar(require("./api/TypeRecommender"));
|
|
@@ -11,6 +11,7 @@ export declare const FACTOR_SET_API_PATH = "/v3/carbon/factorset";
|
|
|
11
11
|
export declare const SEARCH_API_PATH = "/v3/carbon/factor/search";
|
|
12
12
|
export declare const ECONOMIC_ACTIVITY_API_PATH = "/v3/carbon/economic-activity";
|
|
13
13
|
export declare const REAL_ESTATE_API_PATH = "/v3/carbon/real-estate";
|
|
14
|
+
export declare const TYPE_RECOMMENDER_API_PATH = "/v3/carbon/recommender/type/search";
|
|
14
15
|
export declare const USAGE_API = "/v3/carbon/usage";
|
|
15
16
|
export declare const METADATA_TYPES_ENDPOINT = "/v3/carbon/metadata/types";
|
|
16
17
|
export declare const METADATA_AREA_ENDPOINT = "/v3/carbon/metadata/area";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SearchRequest } from "../interfaces/Api";
|
|
2
|
+
import { TypeRecommenderResponse } from "../interfaces/response/TypeRecommenderResponse";
|
|
3
|
+
/**
|
|
4
|
+
* Search for activity types using semantic search with location, time, and license context. Supports pagination.
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @param {SearchRequest} payload - The search request data to be sent to the API
|
|
8
|
+
* @return {Promise<TypeResponse>} A promise that resolves to the activity types returned by the API
|
|
9
|
+
* @throws {Error} May throw an error if the API request fails
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const result = await search({
|
|
13
|
+
"location": {
|
|
14
|
+
"country": "usa"
|
|
15
|
+
},
|
|
16
|
+
"activity": {
|
|
17
|
+
"search": "electricity"
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
* @example
|
|
22
|
+
* const result = await search({
|
|
23
|
+
"location": {
|
|
24
|
+
"country": "usa",
|
|
25
|
+
"stateProvince": "california"
|
|
26
|
+
},
|
|
27
|
+
"time": {
|
|
28
|
+
"date": "2025-06-10"
|
|
29
|
+
},
|
|
30
|
+
"activity": {
|
|
31
|
+
"search": "electricity"
|
|
32
|
+
},
|
|
33
|
+
"pagination": {
|
|
34
|
+
"page": 1,
|
|
35
|
+
"size": 10
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
* @example
|
|
40
|
+
* const result = await search({
|
|
41
|
+
"location": {
|
|
42
|
+
"country": "usa",
|
|
43
|
+
"powerGrid": "WECC"
|
|
44
|
+
},
|
|
45
|
+
"activity": {
|
|
46
|
+
"search": "renewable energy"
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
*/
|
|
50
|
+
export declare function search(payload: SearchRequest): Promise<TypeRecommenderResponse>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * as FactorSets from './api/FactorSets';
|
|
|
11
11
|
export * as EconomicActivity from './api/EconomicActivity';
|
|
12
12
|
export * as RealEstate from './api/RealEstate';
|
|
13
13
|
export * as Metadata from './api/Metadata';
|
|
14
|
+
export * as TypeRecommender from './api/TypeRecommender';
|
|
14
15
|
export { ClientConfig } from './interfaces/Config';
|
|
15
16
|
export { AreaResponse, Location as LocationInfo } from './interfaces/response/AreaResponse';
|
|
16
17
|
export { EmissionResponse } from './interfaces/response/EmissionResponse';
|
|
@@ -21,3 +22,4 @@ export { SearchResponse, Pagination, PaginationBody, SearchLink } from './interf
|
|
|
21
22
|
export { TypeResponse } from './interfaces/response/TypeResponse';
|
|
22
23
|
export { UnitResponse } from './interfaces/response/UnitResponse';
|
|
23
24
|
export { UsageResponse } from './interfaces/response/UsageResponse';
|
|
25
|
+
export { TypeRecommenderResponse, ActivityRequest } from './interfaces/response/TypeRecommenderResponse';
|
|
@@ -24,6 +24,10 @@ export interface EmissionResponse {
|
|
|
24
24
|
SF6?: number;
|
|
25
25
|
/** Nitrogen trifluoride emissions value (optional) */
|
|
26
26
|
NF3?: number;
|
|
27
|
+
/** Energy consumption in megawatt-hours (optional) */
|
|
28
|
+
'energy(MWh)'?: number;
|
|
29
|
+
/** Asset turnover ratio (optional) */
|
|
30
|
+
assetTurnoverRatio?: number;
|
|
27
31
|
/** Unit of measurement for emissions (required) */
|
|
28
32
|
unit: string;
|
|
29
33
|
/** Description of the emission calculation (required) */
|
|
@@ -24,6 +24,8 @@ export interface FactorResponse {
|
|
|
24
24
|
SF6?: number;
|
|
25
25
|
/** Nitrogen trifluoride emissions value (optional - not present in all responses) */
|
|
26
26
|
NF3?: number;
|
|
27
|
+
/** Energy consumption in megawatt-hours (optional) */
|
|
28
|
+
'energy(MWh)'?: number;
|
|
27
29
|
/** Unit of measurement for emissions */
|
|
28
30
|
unit?: string;
|
|
29
31
|
/** Description of the emission factors (optional)*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for type recommender API
|
|
3
|
+
*/
|
|
4
|
+
export interface TypeRecommenderResponse {
|
|
5
|
+
/** Array of string*/
|
|
6
|
+
types: ActivityRequest[];
|
|
7
|
+
}
|
|
8
|
+
export interface ActivityRequest {
|
|
9
|
+
activityType: string;
|
|
10
|
+
/** Array of string*/
|
|
11
|
+
activityUnit: string[];
|
|
12
|
+
activityDescription: string;
|
|
13
|
+
confidence: number;
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emissions-api-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "sdk for IBM Emissions APIs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -35,21 +35,22 @@
|
|
|
35
35
|
"author": "santhosh0703,Prakhar-sahu,taylorsteffanj",
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"resolutions": {
|
|
38
|
+
"handlebars": "^4.7.9",
|
|
38
39
|
"markdown-it": "^14.1.1",
|
|
39
|
-
"minimatch": "^10.2.
|
|
40
|
+
"minimatch": "^10.2.5",
|
|
40
41
|
"test-exclude": "^7.0.1"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"axios": "
|
|
44
|
+
"axios": "1.15.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/jest": "^30.0.0",
|
|
47
48
|
"@types/node": "^24.0.4",
|
|
48
49
|
"axios-mock-adapter": "^2.1.0",
|
|
49
|
-
"jest": "^30.0
|
|
50
|
+
"jest": "^30.3.0",
|
|
50
51
|
"nock": "^14.0.6",
|
|
51
|
-
"ts-jest": "^29.4.
|
|
52
|
-
"typedoc": "^0.28.
|
|
52
|
+
"ts-jest": "^29.4.6",
|
|
53
|
+
"typedoc": "^0.28.18",
|
|
53
54
|
"typescript": "^5.9.2"
|
|
54
55
|
}
|
|
55
56
|
}
|
package/src/Constants.ts
CHANGED
|
@@ -12,6 +12,8 @@ export const SEARCH_API_PATH = "/v3/carbon/factor/search";
|
|
|
12
12
|
export const ECONOMIC_ACTIVITY_API_PATH = "/v3/carbon/economic-activity";
|
|
13
13
|
export const REAL_ESTATE_API_PATH = "/v3/carbon/real-estate";
|
|
14
14
|
|
|
15
|
+
export const TYPE_RECOMMENDER_API_PATH = "/v3/carbon/recommender/type/search";
|
|
16
|
+
|
|
15
17
|
export const USAGE_API = "/v3/carbon/usage";
|
|
16
18
|
|
|
17
19
|
export const METADATA_TYPES_ENDPOINT = "/v3/carbon/metadata/types";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Client } from "../Client";
|
|
2
|
+
import { TYPE_RECOMMENDER_API_PATH, POST } from "../Constants";
|
|
3
|
+
import { SearchRequest } from "../interfaces/Api";
|
|
4
|
+
import { TypeRecommenderResponse } from "../interfaces/response/TypeRecommenderResponse";
|
|
5
|
+
import { makeApiRequest } from "../request";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Search for activity types using semantic search with location, time, and license context. Supports pagination.
|
|
9
|
+
*
|
|
10
|
+
* @export
|
|
11
|
+
* @param {SearchRequest} payload - The search request data to be sent to the API
|
|
12
|
+
* @return {Promise<TypeResponse>} A promise that resolves to the activity types returned by the API
|
|
13
|
+
* @throws {Error} May throw an error if the API request fails
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const result = await search({
|
|
17
|
+
"location": {
|
|
18
|
+
"country": "usa"
|
|
19
|
+
},
|
|
20
|
+
"activity": {
|
|
21
|
+
"search": "electricity"
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
* @example
|
|
26
|
+
* const result = await search({
|
|
27
|
+
"location": {
|
|
28
|
+
"country": "usa",
|
|
29
|
+
"stateProvince": "california"
|
|
30
|
+
},
|
|
31
|
+
"time": {
|
|
32
|
+
"date": "2025-06-10"
|
|
33
|
+
},
|
|
34
|
+
"activity": {
|
|
35
|
+
"search": "electricity"
|
|
36
|
+
},
|
|
37
|
+
"pagination": {
|
|
38
|
+
"page": 1,
|
|
39
|
+
"size": 10
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
* @example
|
|
44
|
+
* const result = await search({
|
|
45
|
+
"location": {
|
|
46
|
+
"country": "usa",
|
|
47
|
+
"powerGrid": "WECC"
|
|
48
|
+
},
|
|
49
|
+
"activity": {
|
|
50
|
+
"search": "renewable energy"
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
*/
|
|
54
|
+
export async function search(
|
|
55
|
+
payload: SearchRequest
|
|
56
|
+
): Promise<TypeRecommenderResponse> {
|
|
57
|
+
const client = Client.getInstance();
|
|
58
|
+
const url = client.getDomain() + TYPE_RECOMMENDER_API_PATH;
|
|
59
|
+
|
|
60
|
+
return makeApiRequest<TypeRecommenderResponse>({
|
|
61
|
+
method: POST,
|
|
62
|
+
url,
|
|
63
|
+
data: payload,
|
|
64
|
+
});
|
|
65
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * as FactorSets from './api/FactorSets'
|
|
|
11
11
|
export * as EconomicActivity from './api/EconomicActivity';
|
|
12
12
|
export * as RealEstate from './api/RealEstate';
|
|
13
13
|
export * as Metadata from './api/Metadata';
|
|
14
|
+
export * as TypeRecommender from './api/TypeRecommender';
|
|
14
15
|
export { ClientConfig } from './interfaces/Config';
|
|
15
16
|
|
|
16
17
|
// Response interfaces
|
|
@@ -44,4 +45,5 @@ export {
|
|
|
44
45
|
} from './interfaces/response/SearchResponse';
|
|
45
46
|
export { TypeResponse } from './interfaces/response/TypeResponse';
|
|
46
47
|
export { UnitResponse } from './interfaces/response/UnitResponse';
|
|
47
|
-
export { UsageResponse } from './interfaces/response/UsageResponse';
|
|
48
|
+
export { UsageResponse } from './interfaces/response/UsageResponse';
|
|
49
|
+
export { TypeRecommenderResponse, ActivityRequest } from './interfaces/response/TypeRecommenderResponse';
|
|
@@ -35,6 +35,12 @@ export interface EmissionResponse {
|
|
|
35
35
|
/** Nitrogen trifluoride emissions value (optional) */
|
|
36
36
|
NF3?: number;
|
|
37
37
|
|
|
38
|
+
/** Energy consumption in megawatt-hours (optional) */
|
|
39
|
+
'energy(MWh)'?: number;
|
|
40
|
+
|
|
41
|
+
/** Asset turnover ratio (optional) */
|
|
42
|
+
assetTurnoverRatio?: number;
|
|
43
|
+
|
|
38
44
|
/** Unit of measurement for emissions (required) */
|
|
39
45
|
unit: string;
|
|
40
46
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for type recommender API
|
|
3
|
+
*/
|
|
4
|
+
export interface TypeRecommenderResponse {
|
|
5
|
+
/** Array of string*/
|
|
6
|
+
types: ActivityRequest[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ActivityRequest {
|
|
10
|
+
activityType: string;
|
|
11
|
+
|
|
12
|
+
/** Array of string*/
|
|
13
|
+
activityUnit: string[];
|
|
14
|
+
|
|
15
|
+
activityDescription: string;
|
|
16
|
+
|
|
17
|
+
confidence: number;
|
|
18
|
+
}
|
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,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
USAGE_API,
|
|
25
26
|
ECONOMIC_ACTIVITY_API_PATH,
|
|
26
27
|
REAL_ESTATE_API_PATH,
|
|
28
|
+
TYPE_RECOMMENDER_API_PATH,
|
|
27
29
|
} from "../src/Constants";
|
|
28
30
|
import locationPayload from "./mocks/LocationRequest";
|
|
29
31
|
import commonpayload from "./mocks/CommonRequest";
|
|
@@ -141,6 +143,13 @@ const testCases: ApiTestCase[] = [
|
|
|
141
143
|
path: USAGE_API,
|
|
142
144
|
queryParams: { history: false },
|
|
143
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",
|
|
144
153
|
}
|
|
145
154
|
];
|
|
146
155
|
|