emissions-api-sdk 1.0.2 → 1.0.3

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.
Files changed (62) hide show
  1. package/README.md +9 -0
  2. package/dist/Constants.js +2 -1
  3. package/dist/api/Usage.js +26 -0
  4. package/dist/coverage/clover.xml +44 -33
  5. package/dist/coverage/coverage-final.json +4 -3
  6. package/dist/coverage/lcov-report/index.html +19 -19
  7. package/dist/coverage/lcov-report/src/Client.ts.html +23 -23
  8. package/dist/coverage/lcov-report/src/Constants.ts.html +10 -4
  9. package/dist/coverage/lcov-report/src/api/Calculation.ts.html +1 -1
  10. package/dist/coverage/lcov-report/src/api/Factor.ts.html +1 -1
  11. package/dist/coverage/lcov-report/src/api/FactorSets.ts.html +1 -1
  12. package/dist/coverage/lcov-report/src/api/Fugitive.ts.html +1 -1
  13. package/dist/coverage/lcov-report/src/api/Location.ts.html +1 -1
  14. package/dist/coverage/lcov-report/src/api/Mobile.ts.html +1 -1
  15. package/dist/coverage/lcov-report/src/api/Stationary.ts.html +1 -1
  16. package/dist/coverage/lcov-report/src/api/TransportationAndDistribution.ts.html +1 -1
  17. package/dist/coverage/lcov-report/src/api/Usage.ts.html +160 -0
  18. package/dist/coverage/lcov-report/src/api/index.html +21 -6
  19. package/dist/coverage/lcov-report/src/index.html +7 -7
  20. package/dist/coverage/lcov-report/src/request.ts.html +1 -1
  21. package/dist/coverage/lcov-report/src/utils.ts.html +5 -5
  22. package/dist/coverage/lcov-report/test/index.html +1 -1
  23. package/dist/coverage/lcov-report/test/mocks/CommonRequest.ts.html +1 -1
  24. package/dist/coverage/lcov-report/test/mocks/FactorRequest.ts.html +1 -1
  25. package/dist/coverage/lcov-report/test/mocks/GenericCalculationRequest.ts.html +1 -1
  26. package/dist/coverage/lcov-report/test/mocks/LocationRequest.ts.html +1 -1
  27. package/dist/coverage/lcov-report/test/mocks/SearchRequest.ts.html +1 -1
  28. package/dist/coverage/lcov-report/test/mocks/index.html +1 -1
  29. package/dist/coverage/lcov-report/test/testUtils.ts.html +1 -1
  30. package/dist/coverage/lcov.info +75 -55
  31. package/dist/index.js +2 -1
  32. package/dist/interfaces/response/UsageResponse.js +5 -0
  33. package/dist/types/Constants.d.ts +1 -0
  34. package/dist/types/api/Usage.d.ts +13 -0
  35. package/dist/types/index.d.ts +2 -0
  36. package/dist/types/interfaces/response/UnitResponse.d.ts +11 -2
  37. package/dist/types/interfaces/response/UsageResponse.d.ts +17 -0
  38. package/docs/_sources/reference.rst.txt +6 -0
  39. package/docs/_static/basic.css +0 -8
  40. package/docs/_static/pygments.css +164 -146
  41. package/docs/_static/searchtools.js +8 -5
  42. package/docs/_static/styles/furo.css +1 -1
  43. package/docs/_static/styles/furo.css.map +1 -1
  44. package/docs/authentication.html +19 -28
  45. package/docs/client.html +19 -28
  46. package/docs/genindex.html +23 -28
  47. package/docs/getting_started.html +19 -28
  48. package/docs/index.html +20 -28
  49. package/docs/objects.inv +0 -0
  50. package/docs/reference.html +48 -28
  51. package/docs/sdk.html +19 -28
  52. package/docs/search.html +19 -28
  53. package/docs/searchindex.js +1 -1
  54. package/docs/troubleshooting.html +19 -28
  55. package/package.json +1 -1
  56. package/sphinx-build/source/reference.rst +6 -0
  57. package/src/Constants.ts +2 -0
  58. package/src/api/Usage.ts +26 -0
  59. package/src/index.ts +3 -1
  60. package/src/interfaces/response/UnitResponse.ts +12 -2
  61. package/src/interfaces/response/UsageResponse.ts +23 -0
  62. package/test/apiTest.test.ts +34 -3
@@ -82,7 +82,7 @@
82
82
  <div class='footer quiet pad2 space-top1 center small'>
83
83
  Code coverage generated by
84
84
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
85
- at 2025-12-11T17:06:20.018Z
85
+ at 2025-12-23T04:53:24.226Z
86
86
  </div>
87
87
  <script src="../prettify.js"></script>
88
88
  <script>
@@ -11,10 +11,10 @@ FN:214,(anonymous_8)
11
11
  FN:236,(anonymous_9)
12
12
  FNF:9
13
13
  FNH:7
14
- FNDA:35,(anonymous_1)
15
- FNDA:38,(anonymous_2)
16
- FNDA:62,(anonymous_3)
17
- FNDA:67,(anonymous_4)
14
+ FNDA:38,(anonymous_1)
15
+ FNDA:41,(anonymous_2)
16
+ FNDA:68,(anonymous_3)
17
+ FNDA:73,(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,4
25
25
  DA:4,4
26
26
  DA:6,4
27
27
  DA:7,4
28
- DA:24,35
29
- DA:25,35
30
- DA:26,35
31
- DA:27,35
28
+ DA:24,38
29
+ DA:25,38
30
+ DA:26,38
31
+ DA:27,38
32
32
  DA:28,1
33
33
  DA:29,1
34
- DA:31,34
35
- DA:32,34
36
- DA:35,35
37
- DA:36,35
38
- DA:37,35
39
- DA:38,35
40
- DA:39,35
41
- DA:40,35
42
- DA:78,38
34
+ DA:31,37
35
+ DA:32,37
36
+ DA:35,38
37
+ DA:36,38
38
+ DA:37,38
39
+ DA:38,38
40
+ DA:39,38
41
+ DA:40,38
42
+ DA:78,41
43
43
  DA:79,1
44
- DA:83,37
44
+ DA:83,40
45
45
  DA:84,1
46
- DA:88,36
46
+ DA:88,39
47
47
  DA:89,1
48
- DA:94,35
49
- DA:96,35
48
+ DA:94,38
49
+ DA:96,38
50
50
  DA:97,1
51
51
  DA:98,1
52
- DA:99,34
53
- DA:100,35
54
- DA:114,62
55
- DA:136,67
52
+ DA:99,37
53
+ DA:100,38
54
+ DA:114,68
55
+ DA:136,73
56
56
  DA:137,1
57
- DA:141,66
57
+ DA:141,72
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,35
77
+ BRDA:24,3,0,38
78
78
  BRDA:27,4,0,1
79
- BRDA:27,4,1,34
79
+ BRDA:27,4,1,37
80
80
  BRDA:37,5,0,0
81
- BRDA:37,5,1,35
82
- BRDA:37,6,0,35
83
- BRDA:37,6,1,35
81
+ BRDA:37,5,1,38
82
+ BRDA:37,6,0,38
83
+ BRDA:37,6,1,38
84
84
  BRDA:38,7,0,0
85
- BRDA:38,7,1,35
86
- BRDA:38,8,0,35
87
- BRDA:38,8,1,35
85
+ BRDA:38,7,1,38
86
+ BRDA:38,8,0,38
87
+ BRDA:38,8,1,38
88
88
  BRDA:40,9,0,0
89
- BRDA:40,9,1,35
89
+ BRDA:40,9,1,38
90
90
  BRDA:78,10,0,1
91
- BRDA:78,10,1,37
92
- BRDA:78,11,0,38
91
+ BRDA:78,10,1,40
92
+ BRDA:78,11,0,41
93
93
  BRDA:78,11,1,1
94
94
  BRDA:83,12,0,1
95
- BRDA:83,12,1,36
96
- BRDA:83,13,0,37
95
+ BRDA:83,12,1,39
96
+ BRDA:83,13,0,40
97
97
  BRDA:83,13,1,2
98
98
  BRDA:88,14,0,1
99
- BRDA:88,14,1,35
100
- BRDA:88,15,0,36
101
- BRDA:88,15,1,35
102
- BRDA:88,15,2,34
99
+ BRDA:88,14,1,38
100
+ BRDA:88,15,0,39
101
+ BRDA:88,15,1,38
102
+ BRDA:88,15,2,37
103
103
  BRDA:96,16,0,1
104
- BRDA:96,16,1,34
105
- BRDA:96,17,0,35
104
+ BRDA:96,16,1,37
105
+ BRDA:96,17,0,38
106
106
  BRDA:96,17,1,1
107
107
  BRDA:136,18,0,1
108
- BRDA:136,18,1,66
108
+ BRDA:136,18,1,72
109
109
  BRDA:157,19,0,2
110
110
  BRDA:157,19,1,1
111
111
  BRDA:159,20,0,1
@@ -157,12 +157,13 @@ DA:34,4
157
157
  DA:35,4
158
158
  DA:36,4
159
159
  DA:38,4
160
- DA:39,4
161
160
  DA:40,4
162
161
  DA:41,4
163
162
  DA:42,4
164
- LF:38
165
- LH:38
163
+ DA:43,4
164
+ DA:44,4
165
+ LF:39
166
+ LH:39
166
167
  BRF:0
167
168
  BRH:0
168
169
  end_of_record
@@ -191,16 +192,16 @@ SF:src/utils.ts
191
192
  FN:14,findExpiryTime
192
193
  FNF:1
193
194
  FNH:1
194
- FNDA:33,findExpiryTime
195
+ FNDA:36,findExpiryTime
195
196
  DA:14,4
196
- DA:15,33
197
- DA:16,33
198
- DA:17,33
199
- DA:18,33
197
+ DA:15,36
198
+ DA:16,36
199
+ DA:17,36
200
+ DA:18,36
200
201
  LF:5
201
202
  LH:5
202
203
  BRDA:17,0,0,0
203
- BRDA:17,0,1,33
204
+ BRDA:17,0,1,36
204
205
  BRF:2
205
206
  BRH:1
206
207
  end_of_record
@@ -487,6 +488,25 @@ BRF:0
487
488
  BRH:0
488
489
  end_of_record
489
490
  TN:
491
+ SF:src/api/Usage.ts
492
+ FN:17,getUsage
493
+ FNF:1
494
+ FNH:1
495
+ FNDA:3,getUsage
496
+ DA:1,1
497
+ DA:2,1
498
+ DA:4,1
499
+ DA:17,1
500
+ DA:18,3
501
+ DA:19,3
502
+ DA:21,3
503
+ LF:7
504
+ LH:7
505
+ BRDA:17,0,0,0
506
+ BRF:1
507
+ BRH:0
508
+ end_of_record
509
+ TN:
490
510
  SF:test/testUtils.ts
491
511
  FN:1,generateMockjwt
492
512
  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.FactorSets = exports.Factor = exports.TransportationAndDistribution = exports.Calculation = exports.Stationary = exports.Mobile = exports.Fugitive = exports.Location = exports.Client = void 0;
36
+ 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"));
@@ -42,5 +42,6 @@ exports.Mobile = __importStar(require("./api/Mobile"));
42
42
  exports.Stationary = __importStar(require("./api/Stationary"));
43
43
  exports.Calculation = __importStar(require("./api/Calculation"));
44
44
  exports.TransportationAndDistribution = __importStar(require("./api/TransportationAndDistribution"));
45
+ exports.Usage = __importStar(require("./api/Usage"));
45
46
  exports.Factor = __importStar(require("./api/Factor"));
46
47
  exports.FactorSets = __importStar(require("./api/FactorSets"));
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Interface representing the GHG Metrics Usage Response
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -31,6 +31,7 @@ export declare const STATIONARY_API_UNITS = "/v3/carbon/stationary/units";
31
31
  export declare const GENERAL_API_UNITS = "/v3/carbon/calculation/units";
32
32
  export declare const FACTOR_API_UNITS = "/v3/carbon/factor/units";
33
33
  export declare const TRANSPORTATION_AND_DISTRIBUTION_API_UNITS = "/v3/carbon/transportation-and-distribution/units";
34
+ export declare const USAGE_API = "/v3/carbon/usage";
34
35
  export declare const GET = "GET";
35
36
  export declare const POST = "POST";
36
37
  export declare const CLIENT_SOURCE_HEADER = "X-Client-Source";
@@ -0,0 +1,13 @@
1
+ import { UsageResponse } from "../interfaces/response/UsageResponse";
2
+ /**
3
+ * Retrieves current billing period or historical usage data for the user by making a GET request to the API endpoint.
4
+ *
5
+ * @export
6
+ * @param {boolean} history - Flag to retrieve current billing or historical usage data.
7
+ * @return {Promise<UsageResponse>} A promise that resolves to a UsageResponse containing the organization's usage data
8
+ * @throws {Error} May throw an error if the API request fails
9
+ *
10
+ * @example
11
+ * const usage = await getUsage();
12
+ */
13
+ export declare function getUsage(history?: boolean): Promise<UsageResponse>;
@@ -5,6 +5,7 @@ export * as Mobile from './api/Mobile';
5
5
  export * as Stationary from './api/Stationary';
6
6
  export * as Calculation from './api/Calculation';
7
7
  export * as TransportationAndDistribution from './api/TransportationAndDistribution';
8
+ export * as Usage from './api/Usage';
8
9
  export * as Factor from './api/Factor';
9
10
  export * as FactorSets from './api/FactorSets';
10
11
  export { ClientConfig } from './interfaces/Config';
@@ -16,3 +17,4 @@ export { FactorSetResponse, FactorSet } from './interfaces/response/FactorSetRes
16
17
  export { SearchResponse, Pagination, PaginationBody, SearchLink } from './interfaces/response/SearchResponse';
17
18
  export { TypeResponse } from './interfaces/response/TypeResponse';
18
19
  export { UnitResponse } from './interfaces/response/UnitResponse';
20
+ export { UsageResponse } from './interfaces/response/UsageResponse';
@@ -1,7 +1,16 @@
1
+ /**
2
+ * Interface for unit object
3
+ */
4
+ export interface Unit {
5
+ /** Unit symbol */
6
+ unit: string;
7
+ /** Unit name */
8
+ unitName: string;
9
+ }
1
10
  /**
2
11
  * Interface for /units metadata API
3
12
  */
4
13
  export interface UnitResponse {
5
- /** Array of string*/
6
- units: string[];
14
+ /** Array of Unit objects */
15
+ units: Unit[];
7
16
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Interface representing the GHG Metrics Usage Response
3
+ */
4
+ export interface UsageResponse {
5
+ /** Organization ID for the API request */
6
+ orgId?: string;
7
+ /** Array of entitlement belonging to the Org */
8
+ entitlement?: Entitlement[];
9
+ }
10
+ export interface Entitlement {
11
+ /** Organization's billing start date*/
12
+ startDate?: string;
13
+ /** Organization's billing end date */
14
+ endDate?: string;
15
+ /** Total api calls made by the Organization in the billing cycle */
16
+ totalApiCalls?: number;
17
+ }
@@ -83,6 +83,12 @@ getUnits
83
83
 
84
84
  .. js:autofunction:: Fugitive.getUnits
85
85
 
86
+
87
+ Usage API
88
+ ===========
89
+
90
+ .. js:autofunction:: Usage.getUsage
91
+
86
92
  Interfaces
87
93
  ==========
88
94
 
@@ -741,14 +741,6 @@ abbr, acronym {
741
741
  cursor: help;
742
742
  }
743
743
 
744
- .translated {
745
- background-color: rgba(207, 255, 207, 0.2)
746
- }
747
-
748
- .untranslated {
749
- background-color: rgba(255, 207, 207, 0.2)
750
- }
751
-
752
744
  /* -- code displays --------------------------------------------------------- */
753
745
 
754
746
  pre {