emissions-api-sdk 1.0.8 → 1.0.10
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/dist/Client.js +69 -9
- package/dist/Constants.js +2 -1
- package/dist/coverage/clover.xml +72 -57
- package/dist/coverage/coverage-final.json +4 -4
- package/dist/coverage/lcov-report/index.html +18 -18
- package/dist/coverage/lcov-report/src/Client.ts.html +242 -50
- package/dist/coverage/lcov-report/src/Constants.ts.html +7 -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 +1 -1
- package/dist/coverage/lcov-report/src/api/Usage.ts.html +1 -1
- package/dist/coverage/lcov-report/src/api/index.html +1 -1
- package/dist/coverage/lcov-report/src/index.html +21 -21
- 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 +4 -4
- package/dist/coverage/lcov.info +161 -121
- package/dist/types/Client.d.ts +26 -0
- package/dist/types/Constants.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/interfaces/Config.d.ts +6 -0
- package/dist/types/interfaces/response/EmissionResponseWithDetails.d.ts +62 -124
- package/docs/reference.html +8 -2
- package/docs/searchindex.js +1 -1
- package/package.json +3 -2
- package/src/Client.ts +79 -15
- package/src/Constants.ts +1 -0
- package/src/index.ts +3 -12
- package/src/interfaces/Config.ts +7 -0
- package/src/interfaces/response/EmissionResponseWithDetails.ts +79 -146
- package/test/client.test.ts +93 -1
- package/test/tokenRefresh.test.ts +91 -1
- package/.secrets.baseline +0 -314
package/docs/searchindex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Search.setIndex({"alltitles": {"1. Missing Auth URL with Custom Host": [[6, "missing-auth-url-with-custom-host"]], "2. Missing Client ID with Token": [[6, "missing-client-id-with-token"]], "3. Missing Parameters with API Key": [[6, "missing-parameters-with-api-key"]], "4. Invalid API Key": [[6, "invalid-api-key"]], "5. Invalid Organization ID": [[6, "invalid-organization-id"]], "6. Invalid Client ID": [[6, "invalid-client-id"]], "7. Empty Token Response": [[6, "empty-token-response"]], "8. Missing Expiry Field in Token": [[6, "missing-expiry-field-in-token"]], "API": [[4, "api"]], "API Key Authentication (Recommended)": [[0, "api-key-authentication-recommended"], [6, "api-key-authentication-recommended"]], "Architecture Diagram": [[0, "architecture-diagram"]], "Authentication": [[0, null], [2, "authentication"]], "Authentication Errors (HTTP 401)": [[6, "authentication-errors-http-401"]], "Authentication Flow": [[0, "authentication-flow"]], "Authentication Headers": [[0, "authentication-headers"]], "Authentication Integration": [[1, "authentication-integration"]], "Authentication Methods": [[0, "authentication-methods"]], "Automatic Token Refresh": [[6, "automatic-token-refresh"]], "Basic Import": [[2, "basic-import"]], "Best Practices": [[1, "best-practices"]], "Client": [[1, null]], "Client Initialization": [[1, "client-initialization"]], "Client Instance Errors": [[6, "client-instance-errors"]], "Client Not Initialized": [[6, "client-not-initialized"]], "Client Responsibilities": [[1, "client-responsibilities"]], "Common Scenarios": [[6, "common-scenarios"]], "Configuration Errors": [[6, "configuration-errors"]], "Configuration Options": [[1, "configuration-options"]], "Contents:": [[3, null]], "Endpoint-Specific Metadata APIs": [[4, "endpoint-specific-metadata-apis"]], "Error Handling": [[1, "error-handling"]], "Error Summary Table": [[6, "error-summary-table"]], "Example": [[4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null]], "Example Response": [[2, "example-response"]], "First API Call": [[2, "first-api-call"]], "Getting Started": [[2, null]], "Global Metadata API": [[4, "global-metadata-api"]], "IBM Envizi - Emissions API Node.js SDK": [[3, null]], "Initialization Checklist": [[6, "initialization-checklist"]], "Installation": [[2, "installation"]], "Interfaces": [[4, "interfaces"]], "Introduction": [[3, "introduction"]], "Overview": [[0, "overview"], [1, "overview"], [6, "overview"]], "Pre-generated Token Authentication": [[0, "pre-generated-token-authentication"]], "Prerequisites": [[2, "prerequisites"]], "Reference": [[4, null]], "Required Configuration Parameters": [[6, "required-configuration-parameters"]], "SDK": [[5, null]], "SDK Initialization Errors": [[6, "sdk-initialization-errors"]], "Scenario 1: Application Startup": [[6, "scenario-1-application-startup"]], "Scenario 2: Invalid Credentials": [[6, "scenario-2-invalid-credentials"]], "Scenario 3: Missing Configuration": [[6, "scenario-3-missing-configuration"]], "Scenario 4: Client Not Initialized": [[6, "scenario-4-client-not-initialized"]], "Security Best Practices": [[0, "security-best-practices"]], "Support": [[6, "support"]], "Supported Emission Types": [[3, "supported-emission-types"]], "Token Authentication": [[6, "token-authentication"]], "Token Management": [[6, "token-management"]], "Token lifetime & refresh": [[0, "token-lifetime-refresh"]], "Token retrieval": [[0, "token-retrieval"]], "Troubleshooting Guide": [[6, null]], "Troubleshooting Steps": [[6, "troubleshooting-steps"]], "Usage API": [[4, "usage-api"]], "Using API Key (Recommended)": [[2, "using-api-key-recommended"]], "Using Pre-generated Token": [[2, "using-pre-generated-token"]], "getArea": [[4, "getarea"], [4, "id2"]], "getTypes": [[4, "gettypes"], [4, "id1"]], "getUnits": [[4, "getunits"], [4, "id3"]]}, "docnames": ["authentication", "client", "getting_started", "index", "reference", "sdk", "troubleshooting"], "envversion": {"sphinx": 64, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1}, "filenames": ["authentication.rst", "client.rst", "getting_started.rst", "index.rst", "reference.rst", "sdk.rst", "troubleshooting.rst"], "indexentries": {"api.commonrequestwithfactorid() (interface)": [[4, "Api.CommonRequestWithFactorId", false]], "api.commonrequestwithoutfactorid() (interface)": [[4, "Api.CommonRequestWithoutFactorId", false]], "api.factorrequestwithfactorid() (interface)": [[4, "Api.FactorRequestWithFactorId", false]], "api.factorrequestwithoutfactorid() (interface)": [[4, "Api.FactorRequestWithoutFactorId", false]], "api.genericcalculationrequestwithfactorid() (interface)": [[4, "Api.GenericCalculationRequestWithFactorId", false]], "api.genericcalculationrequestwithoutfactorid() (interface)": [[4, "Api.GenericCalculationRequestWithoutFactorId", false]], "api.locationrequestwithfactorid() (interface)": [[4, "Api.LocationRequestWithFactorId", false]], "api.locationrequestwithoutfactorid() (interface)": [[4, "Api.LocationRequestWithoutFactorId", false]], "api.searchrequest() (interface)": [[4, "Api.SearchRequest", false]], "calculation.calculate() (calculation method)": [[4, "Calculation.calculate", false]], "calculation.getarea() (calculation method)": [[4, "Calculation.getArea", false]], "calculation.gettypes() (calculation method)": [[4, "Calculation.getTypes", false]], "calculation.getunits() (calculation method)": [[4, "Calculation.getUnits", false]], "client() (class)": [[4, "Client", false]], "client.getauthheader() (client method)": [[4, "Client.getAuthHeader", false]], "client.getclient() (client method)": [[4, "Client.getClient", false]], "client.getclientid() (client method)": [[4, "Client.getClientId", false]], "client.getclientsource() (client method)": [[4, "Client.getClientSource", false]], "client.getdomain() (client method)": [[4, "Client.getDomain", false]], "client.getinstance() (client method)": [[4, "Client.getInstance", false]], "client.refreshtoken() (client method)": [[4, "Client.refreshToken", false]], "common.activity() (interface)": [[4, "common.Activity", false]], "common.activitywithfactorid() (interface)": [[4, "common.ActivityWithFactorId", false]], "common.combinedunitsactivity() (interface)": [[4, "common.CombinedUnitsActivity", false]], "common.combinedunitsactivitywithfactorid() (interface)": [[4, "common.CombinedUnitsActivityWithFactorId", false]], "common.factoractivity() (interface)": [[4, "common.FactorActivity", false]], "common.factoractivitywithfactorid() (interface)": [[4, "common.FactorActivityWithFactorId", false]], "common.location() (interface)": [[4, "common.Location", false]], "common.pagination() (interface)": [[4, "common.Pagination", false]], "common.searchactivity() (interface)": [[4, "common.SearchActivity", false]], "common.time() (interface)": [[4, "common.Time", false]], "config.clientconfig() (interface)": [[4, "Config.ClientConfig", false]], "config.requestconfig() (interface)": [[4, "Config.RequestConfig", false]], "economicactivity.calculate() (economicactivity method)": [[4, "EconomicActivity.calculate", false]], "economicactivity.getarea() (economicactivity method)": [[4, "EconomicActivity.getArea", false]], "economicactivity.gettypes() (economicactivity method)": [[4, "EconomicActivity.getTypes", false]], "economicactivity.getunits() (economicactivity method)": [[4, "EconomicActivity.getUnits", false]], "factor.getarea() (factor method)": [[4, "Factor.getArea", false]], "factor.getsearcharea() (factor method)": [[4, "Factor.getSearchArea", false]], "factor.gettypes() (factor method)": [[4, "Factor.getTypes", false]], "factor.getunits() (factor method)": [[4, "Factor.getUnits", false]], "factor.retrievefactor() (factor method)": [[4, "Factor.retrieveFactor", false]], "fugitive.calculate() (fugitive method)": [[4, "Fugitive.calculate", false]], "fugitive.getarea() (fugitive method)": [[4, "Fugitive.getArea", false]], "fugitive.gettypes() (fugitive method)": [[4, "Fugitive.getTypes", false]], "fugitive.getunits() (fugitive method)": [[4, "Fugitive.getUnits", false]], "location.calculate() (location method)": [[4, "Location.calculate", false]], "location.getarea() (location method)": [[4, "Location.getArea", false]], "location.gettypes() (location method)": [[4, "Location.getTypes", false]], "location.getunits() (location method)": [[4, "Location.getUnits", false]], "metadata.getarea() (metadata method)": [[4, "Metadata.getArea", false]], "metadata.gettypes() (metadata method)": [[4, "Metadata.getTypes", false]], "metadata.getunits() (metadata method)": [[4, "Metadata.getUnits", false]], "metadata.postarea() (metadata method)": [[4, "Metadata.postArea", false]], "metadata.posttypes() (metadata method)": [[4, "Metadata.postTypes", false]], "metadata.postunits() (metadata method)": [[4, "Metadata.postUnits", false]], "mobile.calculate() (mobile method)": [[4, "Mobile.calculate", false]], "mobile.getarea() (mobile method)": [[4, "Mobile.getArea", false]], "mobile.gettypes() (mobile method)": [[4, "Mobile.getTypes", false]], "mobile.getunits() (mobile method)": [[4, "Mobile.getUnits", false]], "realestate.calculate() (realestate method)": [[4, "RealEstate.calculate", false]], "realestate.getarea() (realestate method)": [[4, "RealEstate.getArea", false]], "realestate.gettypes() (realestate method)": [[4, "RealEstate.getTypes", false]], "realestate.getunits() (realestate method)": [[4, "RealEstate.getUnits", false]], "request.makeapirequest() (request method)": [[4, "request.makeApiRequest", false]], "stationary.calculate() (stationary method)": [[4, "Stationary.calculate", false]], "stationary.getarea() (stationary method)": [[4, "Stationary.getArea", false]], "stationary.gettypes() (stationary method)": [[4, "Stationary.getTypes", false]], "stationary.getunits() (stationary method)": [[4, "Stationary.getUnits", false]], "transportationanddistribution.calculate() (transportationanddistribution method)": [[4, "TransportationAndDistribution.calculate", false]], "transportationanddistribution.getarea() (transportationanddistribution method)": [[4, "TransportationAndDistribution.getArea", false]], "transportationanddistribution.gettypes() (transportationanddistribution method)": [[4, "TransportationAndDistribution.getTypes", false]], "transportationanddistribution.getunits() (transportationanddistribution method)": [[4, "TransportationAndDistribution.getUnits", false]], "usage.getusage() (usage method)": [[4, "Usage.getUsage", false]], "utils.findexpirytime() (utils method)": [[4, "utils.findExpiryTime", false]]}, "objects": {"": [[4, 2, 1, "", "Client"]], "Api": [[4, 0, 1, "", "CommonRequestWithFactorId"], [4, 0, 1, "", "CommonRequestWithoutFactorId"], [4, 0, 1, "", "FactorRequestWithFactorId"], [4, 0, 1, "", "FactorRequestWithoutFactorId"], [4, 0, 1, "", "GenericCalculationRequestWithFactorId"], [4, 0, 1, "", "GenericCalculationRequestWithoutFactorId"], [4, 0, 1, "", "LocationRequestWithFactorId"], [4, 0, 1, "", "LocationRequestWithoutFactorId"], [4, 0, 1, "", "SearchRequest"]], "Calculation": [[4, 1, 1, "", "calculate"], [4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"]], "Client": [[4, 1, 1, "", "getAuthHeader"], [4, 1, 1, "", "getClient"], [4, 1, 1, "", "getClientId"], [4, 1, 1, "", "getClientSource"], [4, 1, 1, "", "getDomain"], [4, 1, 1, "", "getInstance"], [4, 1, 1, "", "refreshToken"]], "Config": [[4, 0, 1, "", "ClientConfig"], [4, 0, 1, "", "RequestConfig"]], "EconomicActivity": [[4, 1, 1, "", "calculate"], [4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"]], "Factor": [[4, 1, 1, "", "getArea"], [4, 1, 1, "", "getSearchArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"], [4, 1, 1, "", "retrieveFactor"]], "Fugitive": [[4, 1, 1, "", "calculate"], [4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"]], "Location": [[4, 1, 1, "", "calculate"], [4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"]], "Metadata": [[4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"], [4, 1, 1, "", "postArea"], [4, 1, 1, "", "postTypes"], [4, 1, 1, "", "postUnits"]], "Mobile": [[4, 1, 1, "", "calculate"], [4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"]], "RealEstate": [[4, 1, 1, "", "calculate"], [4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"]], "Stationary": [[4, 1, 1, "", "calculate"], [4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"]], "TransportationAndDistribution": [[4, 1, 1, "", "calculate"], [4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"]], "Usage": [[4, 1, 1, "", "getUsage"]], "common": [[4, 0, 1, "", "Activity"], [4, 0, 1, "", "ActivityWithFactorId"], [4, 0, 1, "", "CombinedUnitsActivity"], [4, 0, 1, "", "CombinedUnitsActivityWithFactorId"], [4, 0, 1, "", "FactorActivity"], [4, 0, 1, "", "FactorActivityWithFactorId"], [4, 0, 1, "", "Location"], [4, 0, 1, "", "Pagination"], [4, 0, 1, "", "SearchActivity"], [4, 0, 1, "", "Time"]], "request": [[4, 1, 1, "", "makeApiRequest"]], "utils": [[4, 1, 1, "", "findExpiryTime"]]}, "objnames": {"0": ["js", "interface", "JavaScript interface"], "1": ["js", "function", "JavaScript function"], "2": ["js", "class", "JavaScript class"]}, "objtypes": {"0": "js:interface", "1": "js:function", "2": "js:class"}, "terms": {"": [0, 2, 4, 6], "0": [0, 2, 4, 6], "00033022": 2, "00036061": 2, "01": [4, 6], "01115131": 2, "02ae": 2, "04": [4, 6], "1": [2, 4], "1000": 4, "11": 6, "12": 4, "121": 4, "1223123": 4, "123": 4, "12345": [4, 6], "14123143": 4, "150": 4, "1500": 4, "1500000": 4, "17000": 4, "2": [0, 4], "2022": [2, 4], "2025": [4, 6], "20681091": 2, "20750174": 2, "24": 6, "263fb": 4, "3": 4, "426a": 4, "47a3": 2, "60": [4, 6], "831bfca7cecd": 2, "95a7efe7": 2, "9999": 4, "A": [0, 4, 6], "For": [0, 1, 6], "If": [0, 2, 4, 6], "In": 0, "It": 1, "No": 1, "OR": [1, 4], "Or": [2, 6], "That": 6, "The": [0, 1, 2, 3, 4, 5, 6], "Then": 4, "These": 6, "a7fd": 2, "aaa": 4, "about": [0, 1, 4, 6], "accept": [0, 1, 2, 4], "access": [0, 1, 4, 6], "accomod": 4, "account": 6, "across": [1, 4], "activ": [2, 3, 4, 6], "activitywithfactorid": 4, "add": [0, 1], "after": 2, "all": [1, 4, 6], "allow": 6, "allunit": 4, "alreadi": [2, 4], "also": 6, "alwai": 6, "an": [2, 4, 6], "ani": [4, 6], "api": [1, 5], "apidomain": 4, "apikei": [0, 1, 2, 4, 6], "applic": [0, 1, 2, 3, 4], "approach": [0, 5], "appropri": [1, 4], "ar": [2, 6], "architectur": 5, "area": [2, 4], "arearespons": 4, "argument": 4, "async": [2, 4], "attempt": 6, "auth": 4, "authent": [3, 4, 5], "author": [0, 4], "authurl": [0, 1, 4, 6], "autom": 3, "automat": [0, 1], "avail": [2, 4, 6], "await": [0, 1, 2, 4, 6], "axio": 0, "b20": 4, "base": [2, 3, 4, 6], "bearer": [0, 4], "befor": [0, 1, 2, 4, 6], "best": 5, "bill": 4, "bodi": 6, "boolean": 4, "both": 6, "build": 3, "bulk": 4, "busi": [3, 4], "cach": 0, "calcul": [2, 3, 4, 6], "calculateemiss": 2, "calculationrequest": 4, "california": 2, "call": [0, 3, 4, 6], "can": [2, 4, 6], "cannot": 6, "car": 4, "carbon": 3, "cargo": 4, "carrier": 4, "catch": [1, 2], "caus": 6, "central": 1, "ch4": 2, "chain": 3, "check": [0, 6], "checklist": 3, "claim": 6, "class": 4, "client": [0, 2, 3, 4, 5], "client123": [4, 6], "clientconfig": 4, "clientid": [0, 1, 2, 4, 6], "climat": 2, "close": 1, "cloud": 6, "co2": 2, "coal": [4, 6], "code": [0, 6], "com": [0, 2, 4, 6], "combin": 6, "combinedunitsact": 4, "combinedunitsactivitywithfactorid": 4, "combust": 4, "commerci": [3, 4], "common": [3, 4], "commonrequest": 4, "commonrequestwithfactorid": 4, "commonrequestwithoutfactorid": 4, "complet": [4, 6], "complex": 4, "compon": [1, 5], "config": 4, "configur": [3, 4, 5], "confirm": 6, "connect": [1, 2, 6], "consist": 1, "consol": [1, 2, 4, 6], "const": [2, 4, 6], "consumpt": 3, "contact": 6, "contain": [4, 6], "content": 4, "control": 0, "convert": 4, "correct": 6, "correctli": 6, "correspond": 6, "countri": [2, 4, 6], "cover": [5, 6], "coverag": 6, "credenti": [0, 1, 2], "criteria": 4, "current": 4, "custom": [1, 3, 4], "dashboard": 3, "data": [1, 4], "databas": 3, "dataset": 3, "date": [4, 6], "debug": 6, "decis": 3, "decod": 0, "default": [0, 1, 4], "deploy": 0, "descript": [1, 2], "design": [1, 3], "detail": [0, 1, 4, 6], "detect": 0, "determin": 4, "diagram": 5, "diesel": 4, "differ": 4, "directli": [2, 6], "discov": 4, "distribut": [3, 4], "document": 6, "doe": 6, "doesn": [4, 6], "domain": [0, 4, 6], "dure": 6, "dwt": 4, "e": [2, 4, 6], "each": [0, 4], "econom": [3, 4], "economicact": 4, "egrid": 2, "either": 1, "electr": [2, 4], "email": 4, "embed": 3, "emiss": [0, 1, 2, 4, 5, 6], "emissionrespons": 4, "emissionresponsewithdetail": 4, "enabl": 6, "endpoint": [0, 1, 2, 3, 6], "energi": 4, "engin": 3, "enotfound": 6, "ensur": [1, 2, 4, 6], "entir": 2, "env": [0, 1], "environ": [0, 1, 6], "envizi": [0, 1, 5], "envizi_api_kei": [0, 1], "envizi_client_id": [0, 1], "envizi_org_id": [0, 1], "envizisdk": 2, "equip": 3, "error": [2, 3, 5], "estat": [3, 4], "etc": 6, "exact": 4, "exampl": [3, 6], "excel": 0, "exclud": 6, "exist": [1, 4, 6], "exp": [0, 6], "expect": 4, "expir": [0, 1, 4, 6], "expiri": [0, 4], "expirytim": 4, "explain": 0, "export": 4, "extern": 0, "extract": 4, "factor": [2, 3, 4], "factoract": 4, "factoractivitywithfactorid": 4, "factorid": 4, "factorrequest": 4, "factorrequestwithfactorid": 4, "factorrequestwithoutfactorid": 4, "factorrespons": 4, "fail": [2, 6], "failur": [1, 6], "fals": 4, "fetch": 1, "find": 4, "findexpirytim": [3, 4], "firewal": 6, "first": [3, 4, 6], "fix": 3, "flag": 4, "flow": 5, "follow": [0, 1, 2, 6], "footprint": 3, "format": [0, 2], "freight": 4, "fresh": [0, 4], "from": [0, 1, 2, 3, 4, 6], "fuel": [3, 4], "fugit": [3, 4, 6], "fugitivearea": 4, "fugitv": 4, "full": 4, "function": [2, 6], "futur": 0, "g": [4, 6], "ga": [3, 4], "gener": [1, 3, 4, 6], "genericcalculationrequestwithfactorid": 4, "genericcalculationrequestwithoutfactorid": 4, "geograph": 4, "get": [0, 3, 4, 6], "getauthhead": 4, "getclient": [0, 1, 2, 4, 6], "getclientid": 4, "getclientsourc": 4, "getdomain": 4, "getinst": [4, 6], "getsearcharea": 4, "getunit": 6, "getusag": 4, "ghg": 3, "ghgemiss": 0, "give": 4, "global": 3, "gracefulli": 1, "greas": 4, "greenhous": 3, "guid": 3, "ha": 6, "handl": [0, 5, 6], "hardcod": 0, "have": [2, 4], "header": [1, 2, 4, 5, 6], "here": 2, "hfc": 4, "histor": 4, "histori": 4, "host": [0, 1, 4], "http": [0, 1, 2, 4], "httpcode": 6, "httpmessag": 6, "hybrid": 4, "i": [0, 1, 3, 4, 6], "ibm": [0, 1, 2, 5, 6], "ibmid": 2, "id": [0, 1, 2, 4], "identifi": [0, 4], "implement": [0, 1, 6], "import": [0, 1], "includ": [0, 4, 6], "includedetail": 4, "indirectco2": 2, "industri": 4, "inform": [0, 1, 4], "init": 0, "initi": [0, 2, 3, 4, 5], "instal": 3, "instanc": [1, 3, 4], "instead": [4, 6], "integr": 5, "interact": 5, "interfac": [1, 3], "internet": 2, "invalid_api_key_12345": 6, "involv": 4, "issu": 6, "isuserprovidedtoken": 4, "its": 4, "j": [0, 1, 2, 5, 6], "jet": 4, "jetkeroseneunit": 4, "json": [0, 2, 4], "jwt": [0, 4, 6], "jwt_token": 0, "jwttoken": 4, "kei": [1, 4, 5], "kerosen": 4, "kg": 4, "kgco2e": 2, "kj": [4, 6], "km": 4, "known": 4, "kwh": [2, 4], "l": 4, "lack": 6, "larg": [3, 4], "last": 6, "layer": 0, "leader": 2, "leak": 3, "least": 0, "let": 1, "lignit": [4, 6], "list": 6, "ll": 6, "locat": [2, 3, 4, 6], "locationemiss": 2, "locationrequest": 4, "locationrequestwithfactorid": 4, "locationrequestwithoutfactorid": 4, "locationtyp": 4, "log": [2, 4], "logist": 3, "look": 4, "m2": 4, "mai": 4, "maintain": 1, "make": [2, 3, 4], "makeapirequest": [0, 3, 4], "malform": 6, "manag": [0, 1, 2, 3], "match": 6, "measur": 4, "messag": [1, 6], "metadata": 3, "method": [1, 2, 4, 5, 6], "metric": 4, "mobil": [3, 4, 6], "mobilearea": 4, "mode": 0, "modul": [1, 2], "more": [0, 6], "moreinform": 6, "multipl": 4, "must": 6, "n": 6, "n2o": 2, "name": 4, "natur": 4, "naturalgasunit": 4, "nc": 4, "ne": 4, "necessari": 0, "need": [0, 4], "network": 6, "never": 0, "new": [0, 4], "node": [0, 1, 2, 5, 6], "note": 6, "npm": 2, "null": 6, "oauth": 0, "object": 4, "obtain": [1, 2], "occur": [0, 6], "old": 0, "onc": [0, 1], "one": [0, 1], "onli": [0, 1, 4, 6], "oper": [1, 3, 4, 6], "optim": 1, "option": [0, 4, 5], "org": [2, 6], "org456": [4, 6], "organ": [0, 1, 4], "orgid": [0, 1, 2, 4, 6], "other": [4, 6], "otherwis": 4, "overview": [2, 3, 5], "own": 4, "page": [0, 1, 2], "pagin": 4, "param": [0, 4], "paramet": [0, 1, 3, 4], "pass": 6, "pattern": 5, "payload": 4, "perform": 4, "period": 4, "permiss": 6, "petroleum": 4, "point": [4, 6], "post": 4, "postarea": 4, "posttyp": 4, "postunit": 4, "practic": 5, "pre": [1, 6], "prerequisit": 3, "preview": 2, "principl": 0, "privileg": 0, "proce": 4, "process": [0, 1], "product": [0, 1], "project": [2, 3], "promis": 4, "proper": [0, 1, 6], "properli": 6, "properti": 3, "provid": [0, 1, 2, 4, 5, 6], "purchas": 4, "purpos": 4, "queri": [0, 4], "r": 4, "r134a": 4, "re": [0, 6], "real": [3, 4], "realest": 4, "record": 4, "refer": 3, "refresh": [1, 4], "refreshtoken": 4, "regener": 6, "region": [2, 3], "relat": [4, 6], "relev": 4, "replac": 0, "repres": 4, "reproduc": 6, "request": [0, 1, 3, 4], "requestconfig": 4, "requir": [0, 1, 2, 3], "residenti": 3, "resolv": 4, "respond": 6, "respons": [0, 3, 4, 5], "restart": 6, "result": [2, 4], "retriev": [2, 4], "retrievefactor": 4, "return": [0, 2, 4, 6], "reus": 1, "review": 6, "revok": 6, "run": [0, 2], "saascor": [0, 2], "sampl": 6, "scale": 3, "scenario": [0, 3], "scope": 4, "sdk": [0, 1, 2, 4], "search": 4, "searchact": 4, "searchrequest": 4, "second": [4, 6], "secret": 6, "section": 5, "secur": [1, 5, 6], "see": [0, 1], "send": 0, "sensit": 6, "sent": 4, "server": 6, "servic": [0, 1, 6], "set": [2, 6], "sever": 1, "ship": 4, "sign": 2, "singl": 4, "singleton": [0, 1, 4], "size": 4, "small": 4, "solut": 6, "sourc": [0, 3, 4], "specif": [1, 3, 6], "specifi": 4, "spend": [3, 4], "stack": 6, "standard": [4, 6], "start": [3, 6], "startup": 1, "state": 2, "stateprovinc": [2, 4], "static": 4, "stationari": [3, 4, 6], "stationarytyp": 4, "statu": [1, 6], "steam": 6, "steel": 4, "step": [0, 3], "store": [0, 1, 6], "string": [0, 4], "structur": 5, "subsequ": 6, "subtyp": 4, "successfulli": [2, 6], "summari": 3, "suppli": 3, "support": [1, 4], "sustain": 3, "t": [4, 6], "tabl": [3, 4], "target": 6, "tenantid": 2, "thei": 6, "thi": [0, 2, 4, 5, 6], "three": 6, "throw": 6, "thrown": 6, "time": [0, 4, 6], "timestamp": 4, "togeth": 6, "toisostr": 4, "token": [1, 3, 4], "totalco2": 2, "trace": 6, "track": 3, "transactionid": 2, "transport": [3, 4], "transportationanddistribut": 4, "travel": 4, "trim": 0, "troubleshoot": 3, "true": 4, "try": [1, 2], "two": [0, 2], "type": [2, 4, 6], "typerespons": 4, "u": 2, "unauthor": 6, "unifi": [1, 4], "unit": [2, 4, 6], "unitrespons": 4, "unix": 4, "unless": 1, "unreach": 6, "uom": 4, "up": [2, 4, 6], "updat": 6, "url": [0, 4], "us": [0, 1, 3, 4, 6], "usa": [2, 4, 6], "usag": [1, 3, 5], "usagerespons": 4, "usd": 4, "user": [0, 1, 4, 6], "userdata": 4, "util": [3, 4], "v": [0, 1], "valid": [0, 1, 6], "valu": [2, 4, 6], "variabl": [0, 1, 6], "vehicl": 3, "verifi": [1, 6], "version": 6, "void": 4, "wa": [2, 4, 6], "wai": 4, "waitlist": 2, "warehous": 4, "wast": 4, "web": 4, "when": [0, 4, 6], "where": [0, 4], "which": 0, "within": [4, 6], "without": [4, 6], "work": 1, "wrong": 6, "x": [0, 2, 4], "yarn": 2, "ye": 1, "year": 2, "york": 4, "you": [0, 2, 6], "your": [0, 1, 2, 3, 4, 6]}, "titles": ["Authentication", "Client", "Getting Started", "IBM Envizi - Emissions API Node.js SDK", "Reference", "SDK", "Troubleshooting Guide"], "titleterms": {"1": 6, "2": 6, "3": 6, "4": 6, "401": 6, "5": 6, "6": 6, "7": 6, "8": 6, "Not": 6, "api": [0, 2, 3, 4, 6], "applic": 6, "architectur": 0, "auth": 6, "authent": [0, 1, 2, 6], "automat": 6, "basic": 2, "best": [0, 1], "call": 2, "checklist": 6, "client": [1, 6], "common": 6, "configur": [1, 6], "content": 3, "credenti": 6, "custom": 6, "diagram": 0, "emiss": 3, "empti": 6, "endpoint": 4, "envizi": 3, "error": [1, 6], "exampl": [2, 4], "expiri": 6, "field": 6, "first": 2, "flow": 0, "gener": [0, 2], "get": 2, "getarea": 4, "gettyp": 4, "getunit": 4, "global": 4, "guid": 6, "handl": 1, "header": 0, "host": 6, "http": 6, "ibm": 3, "id": 6, "import": 2, "initi": [1, 6], "instal": 2, "instanc": 6, "integr": 1, "interfac": 4, "introduct": 3, "invalid": 6, "j": 3, "kei": [0, 2, 6], "lifetim": 0, "manag": 6, "metadata": 4, "method": 0, "miss": 6, "node": 3, "option": 1, "organ": 6, "overview": [0, 1, 6], "paramet": 6, "practic": [0, 1], "pre": [0, 2], "prerequisit": 2, "recommend": [0, 2, 6], "refer": 4, "refresh": [0, 6], "requir": 6, "respons": [1, 2, 6], "retriev": 0, "scenario": 6, "sdk": [3, 5, 6], "secur": 0, "specif": 4, "start": 2, "startup": 6, "step": 6, "summari": 6, "support": [3, 6], "tabl": 6, "token": [0, 2, 6], "troubleshoot": 6, "type": 3, "url": 6, "us": 2, "usag": 4}})
|
|
1
|
+
Search.setIndex({"alltitles": {"1. Missing Auth URL with Custom Host": [[6, "missing-auth-url-with-custom-host"]], "2. Missing Client ID with Token": [[6, "missing-client-id-with-token"]], "3. Missing Parameters with API Key": [[6, "missing-parameters-with-api-key"]], "4. Invalid API Key": [[6, "invalid-api-key"]], "5. Invalid Organization ID": [[6, "invalid-organization-id"]], "6. Invalid Client ID": [[6, "invalid-client-id"]], "7. Empty Token Response": [[6, "empty-token-response"]], "8. Missing Expiry Field in Token": [[6, "missing-expiry-field-in-token"]], "API": [[4, "api"]], "API Key Authentication (Recommended)": [[0, "api-key-authentication-recommended"], [6, "api-key-authentication-recommended"]], "Architecture Diagram": [[0, "architecture-diagram"]], "Authentication": [[0, null], [2, "authentication"]], "Authentication Errors (HTTP 401)": [[6, "authentication-errors-http-401"]], "Authentication Flow": [[0, "authentication-flow"]], "Authentication Headers": [[0, "authentication-headers"]], "Authentication Integration": [[1, "authentication-integration"]], "Authentication Methods": [[0, "authentication-methods"]], "Automatic Token Refresh": [[6, "automatic-token-refresh"]], "Basic Import": [[2, "basic-import"]], "Best Practices": [[1, "best-practices"]], "Client": [[1, null]], "Client Initialization": [[1, "client-initialization"]], "Client Instance Errors": [[6, "client-instance-errors"]], "Client Not Initialized": [[6, "client-not-initialized"]], "Client Responsibilities": [[1, "client-responsibilities"]], "Common Scenarios": [[6, "common-scenarios"]], "Configuration Errors": [[6, "configuration-errors"]], "Configuration Options": [[1, "configuration-options"]], "Contents:": [[3, null]], "Error Handling": [[1, "error-handling"]], "Error Summary Table": [[6, "error-summary-table"]], "Example": [[4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null], [4, null]], "Example Response": [[2, "example-response"]], "First API Call": [[2, "first-api-call"]], "Getting Started": [[2, null]], "Global Metadata API": [[4, "global-metadata-api"]], "IBM Envizi - Emissions API Node.js SDK": [[3, null]], "Initialization Checklist": [[6, "initialization-checklist"]], "Installation": [[2, "installation"]], "Interfaces": [[4, "interfaces"]], "Introduction": [[3, "introduction"]], "Overview": [[0, "overview"], [1, "overview"], [6, "overview"]], "Pre-generated Token Authentication": [[0, "pre-generated-token-authentication"]], "Prerequisites": [[2, "prerequisites"]], "Reference": [[4, null]], "Required Configuration Parameters": [[6, "required-configuration-parameters"]], "SDK": [[5, null]], "SDK Initialization Errors": [[6, "sdk-initialization-errors"]], "Scenario 1: Application Startup": [[6, "scenario-1-application-startup"]], "Scenario 2: Invalid Credentials": [[6, "scenario-2-invalid-credentials"]], "Scenario 3: Missing Configuration": [[6, "scenario-3-missing-configuration"]], "Scenario 4: Client Not Initialized": [[6, "scenario-4-client-not-initialized"]], "Security Best Practices": [[0, "security-best-practices"]], "Support": [[6, "support"]], "Supported Emission Types": [[3, "supported-emission-types"]], "Token Authentication": [[6, "token-authentication"]], "Token Management": [[6, "token-management"]], "Token lifetime & refresh": [[0, "token-lifetime-refresh"]], "Token retrieval": [[0, "token-retrieval"]], "Troubleshooting Guide": [[6, null]], "Troubleshooting Steps": [[6, "troubleshooting-steps"]], "Usage API": [[4, "usage-api"]], "Using API Key (Recommended)": [[2, "using-api-key-recommended"]], "Using Pre-generated Token": [[2, "using-pre-generated-token"]], "getArea": [[4, "getarea"]], "getTypes": [[4, "gettypes"]], "getUnits": [[4, "getunits"]]}, "docnames": ["authentication", "client", "getting_started", "index", "reference", "sdk", "troubleshooting"], "envversion": {"sphinx": 64, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1}, "filenames": ["authentication.rst", "client.rst", "getting_started.rst", "index.rst", "reference.rst", "sdk.rst", "troubleshooting.rst"], "indexentries": {"api.commonrequestwithfactorid() (interface)": [[4, "Api.CommonRequestWithFactorId", false]], "api.commonrequestwithoutfactorid() (interface)": [[4, "Api.CommonRequestWithoutFactorId", false]], "api.factorrequestwithfactorid() (interface)": [[4, "Api.FactorRequestWithFactorId", false]], "api.factorrequestwithoutfactorid() (interface)": [[4, "Api.FactorRequestWithoutFactorId", false]], "api.genericcalculationrequestwithfactorid() (interface)": [[4, "Api.GenericCalculationRequestWithFactorId", false]], "api.genericcalculationrequestwithoutfactorid() (interface)": [[4, "Api.GenericCalculationRequestWithoutFactorId", false]], "api.locationrequestwithfactorid() (interface)": [[4, "Api.LocationRequestWithFactorId", false]], "api.locationrequestwithoutfactorid() (interface)": [[4, "Api.LocationRequestWithoutFactorId", false]], "api.searchrequest() (interface)": [[4, "Api.SearchRequest", false]], "calculation.calculate() (calculation method)": [[4, "Calculation.calculate", false]], "client() (class)": [[4, "Client", false]], "client.getauthheader() (client method)": [[4, "Client.getAuthHeader", false]], "client.getclient() (client method)": [[4, "Client.getClient", false]], "client.getclientid() (client method)": [[4, "Client.getClientId", false]], "client.getclientsource() (client method)": [[4, "Client.getClientSource", false]], "client.getdomain() (client method)": [[4, "Client.getDomain", false]], "client.getinstance() (client method)": [[4, "Client.getInstance", false]], "client.refreshtoken() (client method)": [[4, "Client.refreshToken", false]], "common.activity() (interface)": [[4, "common.Activity", false]], "common.activitywithfactorid() (interface)": [[4, "common.ActivityWithFactorId", false]], "common.combinedunitsactivity() (interface)": [[4, "common.CombinedUnitsActivity", false]], "common.combinedunitsactivitywithfactorid() (interface)": [[4, "common.CombinedUnitsActivityWithFactorId", false]], "common.factoractivity() (interface)": [[4, "common.FactorActivity", false]], "common.factoractivitywithfactorid() (interface)": [[4, "common.FactorActivityWithFactorId", false]], "common.location() (interface)": [[4, "common.Location", false]], "common.pagination() (interface)": [[4, "common.Pagination", false]], "common.searchactivity() (interface)": [[4, "common.SearchActivity", false]], "common.time() (interface)": [[4, "common.Time", false]], "config.clientconfig() (interface)": [[4, "Config.ClientConfig", false]], "config.requestconfig() (interface)": [[4, "Config.RequestConfig", false]], "economicactivity.calculate() (economicactivity method)": [[4, "EconomicActivity.calculate", false]], "factor.retrievefactor() (factor method)": [[4, "Factor.retrieveFactor", false]], "fugitive.calculate() (fugitive method)": [[4, "Fugitive.calculate", false]], "location.calculate() (location method)": [[4, "Location.calculate", false]], "metadata.getarea() (metadata method)": [[4, "Metadata.getArea", false]], "metadata.gettypes() (metadata method)": [[4, "Metadata.getTypes", false]], "metadata.getunits() (metadata method)": [[4, "Metadata.getUnits", false]], "metadata.postarea() (metadata method)": [[4, "Metadata.postArea", false]], "metadata.posttypes() (metadata method)": [[4, "Metadata.postTypes", false]], "metadata.postunits() (metadata method)": [[4, "Metadata.postUnits", false]], "mobile.calculate() (mobile method)": [[4, "Mobile.calculate", false]], "realestate.calculate() (realestate method)": [[4, "RealEstate.calculate", false]], "request.makeapirequest() (request method)": [[4, "request.makeApiRequest", false]], "stationary.calculate() (stationary method)": [[4, "Stationary.calculate", false]], "transportationanddistribution.calculate() (transportationanddistribution method)": [[4, "TransportationAndDistribution.calculate", false]], "usage.getusage() (usage method)": [[4, "Usage.getUsage", false]], "utils.findexpirytime() (utils method)": [[4, "utils.findExpiryTime", false]]}, "objects": {"": [[4, 2, 1, "", "Client"]], "Api": [[4, 0, 1, "", "CommonRequestWithFactorId"], [4, 0, 1, "", "CommonRequestWithoutFactorId"], [4, 0, 1, "", "FactorRequestWithFactorId"], [4, 0, 1, "", "FactorRequestWithoutFactorId"], [4, 0, 1, "", "GenericCalculationRequestWithFactorId"], [4, 0, 1, "", "GenericCalculationRequestWithoutFactorId"], [4, 0, 1, "", "LocationRequestWithFactorId"], [4, 0, 1, "", "LocationRequestWithoutFactorId"], [4, 0, 1, "", "SearchRequest"]], "Calculation": [[4, 1, 1, "", "calculate"]], "Client": [[4, 1, 1, "", "getAuthHeader"], [4, 1, 1, "", "getClient"], [4, 1, 1, "", "getClientId"], [4, 1, 1, "", "getClientSource"], [4, 1, 1, "", "getDomain"], [4, 1, 1, "", "getInstance"], [4, 1, 1, "", "refreshToken"]], "Config": [[4, 0, 1, "", "ClientConfig"], [4, 0, 1, "", "RequestConfig"]], "EconomicActivity": [[4, 1, 1, "", "calculate"]], "Factor": [[4, 1, 1, "", "retrieveFactor"]], "Fugitive": [[4, 1, 1, "", "calculate"]], "Location": [[4, 1, 1, "", "calculate"]], "Metadata": [[4, 1, 1, "", "getArea"], [4, 1, 1, "", "getTypes"], [4, 1, 1, "", "getUnits"], [4, 1, 1, "", "postArea"], [4, 1, 1, "", "postTypes"], [4, 1, 1, "", "postUnits"]], "Mobile": [[4, 1, 1, "", "calculate"]], "RealEstate": [[4, 1, 1, "", "calculate"]], "Stationary": [[4, 1, 1, "", "calculate"]], "TransportationAndDistribution": [[4, 1, 1, "", "calculate"]], "Usage": [[4, 1, 1, "", "getUsage"]], "common": [[4, 0, 1, "", "Activity"], [4, 0, 1, "", "ActivityWithFactorId"], [4, 0, 1, "", "CombinedUnitsActivity"], [4, 0, 1, "", "CombinedUnitsActivityWithFactorId"], [4, 0, 1, "", "FactorActivity"], [4, 0, 1, "", "FactorActivityWithFactorId"], [4, 0, 1, "", "Location"], [4, 0, 1, "", "Pagination"], [4, 0, 1, "", "SearchActivity"], [4, 0, 1, "", "Time"]], "request": [[4, 1, 1, "", "makeApiRequest"]], "utils": [[4, 1, 1, "", "findExpiryTime"]]}, "objnames": {"0": ["js", "interface", "JavaScript interface"], "1": ["js", "function", "JavaScript function"], "2": ["js", "class", "JavaScript class"]}, "objtypes": {"0": "js:interface", "1": "js:function", "2": "js:class"}, "terms": {"": [0, 2, 4, 6], "0": [0, 2, 4, 6], "00033022": 2, "00036061": 2, "01": [4, 6], "01115131": 2, "02ae": 2, "04": [4, 6], "1": [2, 4], "1000": 4, "11": 6, "12": 4, "121": 4, "1223123": 4, "123": 4, "12345": [4, 6], "14123143": 4, "150": 4, "1500": 4, "1500000": 4, "17000": 4, "2": [0, 4], "2022": [2, 4], "2025": [4, 6], "20681091": 2, "20750174": 2, "24": 6, "3": 4, "47a3": 2, "60": [4, 6], "831bfca7cecd": 2, "95a7efe7": 2, "9999": 4, "A": [0, 4, 6], "For": [0, 1, 6], "If": [0, 2, 4, 6], "In": 0, "It": 1, "No": 1, "OR": [1, 4], "Or": [2, 6], "That": 6, "The": [0, 1, 2, 3, 4, 5, 6], "Then": 4, "These": 6, "a7fd": 2, "about": [0, 1, 4, 6], "accept": [0, 1, 2, 4], "access": [0, 1, 4, 6], "accomod": 4, "account": 6, "across": [1, 4], "activ": [2, 3, 4, 6], "activitywithfactorid": 4, "add": [0, 1], "after": 2, "all": [1, 4, 6], "allow": 6, "allunit": 4, "alreadi": [2, 4], "also": 6, "alwai": 6, "an": [2, 4, 6], "ani": [4, 6], "api": [1, 5], "apidomain": 4, "apikei": [0, 1, 2, 4, 6], "applic": [0, 1, 2, 3, 4], "approach": [0, 5], "appropri": [1, 4], "ar": [2, 6], "architectur": 5, "area": [2, 4], "arearespons": 4, "argument": 4, "async": [2, 4], "attempt": 6, "auth": 4, "authent": [3, 4, 5], "author": [0, 4], "authurl": [0, 1, 4, 6], "autom": 3, "automat": [0, 1], "avail": [2, 4, 6], "await": [0, 1, 2, 4, 6], "axio": 0, "base": [2, 3, 4, 6], "bearer": [0, 4], "befor": [0, 1, 2, 4, 6], "best": 5, "bill": 4, "bodi": 6, "boolean": 4, "both": 6, "build": 3, "bulk": 4, "busi": 3, "cach": 0, "calcul": [2, 3, 4, 6], "calculateemiss": 2, "calculationrequest": 4, "california": 2, "call": [0, 3, 4, 6], "can": [2, 4, 6], "cannot": 6, "carbon": 3, "cargo": 4, "carrier": 4, "catch": [1, 2], "caus": 6, "central": 1, "ch4": 2, "chain": 3, "check": [0, 6], "checklist": 3, "claim": 6, "class": 4, "client": [0, 2, 3, 4, 5], "client123": [4, 6], "clientconfig": 4, "clientid": [0, 1, 2, 4, 6], "climat": 2, "close": 1, "cloud": 6, "co2": 2, "coal": [4, 6], "code": [0, 6], "com": [0, 2, 4, 6], "combin": 6, "combinedunitsact": 4, "combinedunitsactivitywithfactorid": 4, "combust": 4, "commerci": [3, 4], "common": [3, 4], "commonrequest": 4, "commonrequestwithfactorid": 4, "commonrequestwithoutfactorid": 4, "complet": [4, 6], "complex": 4, "compon": [1, 5], "config": 4, "configur": [3, 4, 5], "confirm": 6, "connect": [1, 2, 6], "consist": 1, "consol": [1, 2, 4, 6], "const": [2, 4, 6], "consumpt": 3, "contact": 6, "contain": [4, 6], "content": 4, "control": 0, "convert": 4, "correct": 6, "correctli": 6, "correspond": 6, "countri": [2, 4, 6], "cover": [5, 6], "coverag": 6, "credenti": [0, 1, 2], "criteria": 4, "current": 4, "custom": [1, 3, 4], "dashboard": 3, "data": [1, 4], "databas": 3, "dataset": 3, "date": [4, 6], "debug": 6, "decis": 3, "decod": 0, "default": [0, 1, 4], "deploy": 0, "descript": [1, 2], "design": [1, 3], "detail": [0, 1, 4, 6], "detect": 0, "determin": 4, "diagram": 5, "diesel": 4, "differ": 4, "directli": [2, 6], "distribut": [3, 4], "document": 6, "doe": 6, "doesn": [4, 6], "domain": [0, 4, 6], "dure": 6, "dwt": 4, "e": [2, 4, 6], "each": 0, "econom": [3, 4], "economicact": 4, "egrid": 2, "either": 1, "electr": [2, 4], "email": 4, "embed": 3, "emiss": [0, 1, 2, 4, 5, 6], "emissionrespons": 4, "emissionresponsewithdetail": 4, "enabl": 6, "endpoint": [0, 1, 2, 4, 6], "energi": 4, "engin": 3, "enotfound": 6, "ensur": [1, 2, 4, 6], "entir": 2, "env": [0, 1], "environ": [0, 1, 6], "envizi": [0, 1, 5], "envizi_api_kei": [0, 1], "envizi_client_id": [0, 1], "envizi_org_id": [0, 1], "envizisdk": 2, "equip": 3, "error": [2, 3, 5], "estat": [3, 4], "etc": 6, "exact": 4, "exampl": [3, 6], "excel": 0, "exclud": 6, "exist": [1, 4, 6], "exp": [0, 6], "expect": 4, "expir": [0, 1, 4, 6], "expiri": [0, 4], "expirytim": 4, "explain": 0, "export": 4, "extern": 0, "extract": 4, "factor": [2, 3, 4], "factoract": 4, "factoractivitywithfactorid": 4, "factorid": 4, "factorrequest": 4, "factorrequestwithfactorid": 4, "factorrequestwithoutfactorid": 4, "factorrespons": 4, "fail": [2, 6], "failur": [1, 6], "fals": 4, "fetch": 1, "find": 4, "findexpirytim": [3, 4], "firewal": 6, "first": [3, 4, 6], "fix": 3, "flag": 4, "flow": 5, "follow": [0, 1, 2, 6], "footprint": 3, "format": [0, 2], "freight": 4, "fresh": [0, 4], "from": [0, 1, 2, 3, 4, 6], "fuel": [3, 4], "fugit": [3, 4, 6], "fugitivearea": 4, "fugitv": 4, "full": 4, "function": [2, 6], "futur": 0, "g": [4, 6], "ga": [3, 4], "gener": [1, 3, 4, 6], "genericcalculationrequestwithfactorid": 4, "genericcalculationrequestwithoutfactorid": 4, "geograph": 4, "get": [0, 3, 4, 6], "getauthhead": 4, "getclient": [0, 1, 2, 4, 6], "getclientid": 4, "getclientsourc": 4, "getdomain": 4, "getinst": [4, 6], "getunit": 6, "getusag": 4, "ghg": 3, "ghgemiss": 0, "give": 4, "global": 3, "gracefulli": 1, "greenhous": 3, "guid": 3, "ha": 6, "handl": [0, 5, 6], "hardcod": 0, "have": [2, 4], "header": [1, 2, 4, 5, 6], "here": 2, "histor": 4, "histori": 4, "host": [0, 1, 4], "http": [0, 1, 2, 4], "httpcode": 6, "httpmessag": 6, "i": [0, 1, 3, 4, 6], "ibm": [0, 1, 2, 5, 6], "ibmid": 2, "id": [0, 1, 2, 4], "identifi": [0, 4], "implement": [0, 1, 6], "import": [0, 1], "includ": [0, 4, 6], "includedetail": 4, "indirectco2": 2, "industri": 4, "inform": [0, 1, 4], "init": 0, "initi": [0, 2, 3, 4, 5], "instal": 3, "instanc": [1, 3, 4], "instead": [4, 6], "integr": 5, "interact": 5, "interfac": [1, 3], "internet": 2, "invalid_api_key_12345": 6, "involv": 4, "issu": 6, "isuserprovidedtoken": 4, "j": [0, 1, 2, 5, 6], "jet": 4, "jetkeroseneunit": 4, "json": [0, 2, 4], "jwt": [0, 4, 6], "jwt_token": 0, "jwttoken": 4, "kei": [1, 4, 5], "kerosen": 4, "kg": 4, "kgco2e": 2, "kj": [4, 6], "km": 4, "known": 4, "kwh": [2, 4], "l": 4, "lack": 6, "larg": 3, "last": 6, "layer": 0, "leader": 2, "leak": 3, "least": 0, "let": 1, "lignit": [4, 6], "list": 6, "ll": 6, "locat": [2, 3, 4, 6], "locationemiss": 2, "locationrequest": 4, "locationrequestwithfactorid": 4, "locationrequestwithoutfactorid": 4, "locationtyp": 4, "log": [2, 4], "logist": 3, "look": 4, "m2": 4, "mai": 4, "maintain": 1, "make": [2, 3, 4], "makeapirequest": [0, 3, 4], "malform": 6, "manag": [0, 1, 2, 3], "match": 6, "measur": 4, "messag": [1, 6], "metadata": 3, "method": [1, 2, 4, 5, 6], "metric": 4, "mobil": [3, 4, 6], "mobilearea": 4, "mode": 0, "modul": [1, 2], "more": [0, 6], "moreinform": 6, "multipl": 4, "must": 6, "n": 6, "n2o": 2, "name": 4, "natur": 4, "naturalgasunit": 4, "necessari": 0, "need": [0, 4], "network": 6, "never": 0, "new": [0, 4], "node": [0, 1, 2, 5, 6], "note": 6, "npm": 2, "null": 6, "oauth": 0, "object": 4, "obtain": [1, 2], "occur": [0, 6], "old": 0, "onc": [0, 1], "one": [0, 1], "onli": [0, 1, 4, 6], "oper": [1, 3, 4, 6], "optim": 1, "option": [0, 4, 5], "org": [2, 6], "org456": [4, 6], "organ": [0, 1, 4], "orgid": [0, 1, 2, 4, 6], "other": [4, 6], "otherwis": 4, "overview": [2, 3, 5], "page": [0, 1, 2], "pagin": 4, "param": [0, 4], "paramet": [0, 1, 3, 4], "pass": 6, "pat": 4, "pattern": 5, "pattoken": 4, "payload": 4, "perform": 4, "period": 4, "permiss": 6, "person": 4, "point": [4, 6], "post": 4, "postarea": 4, "posttyp": 4, "postunit": 4, "practic": 5, "pre": [1, 6], "prerequisit": 3, "preview": 2, "principl": 0, "privileg": 0, "proce": 4, "process": [0, 1], "product": [0, 1], "project": [2, 3], "promis": 4, "proper": [0, 1, 6], "properli": 6, "properti": 3, "provid": [0, 1, 2, 4, 5, 6], "purchas": 4, "purpos": 4, "queri": [0, 4], "r134a": 4, "re": [0, 6], "real": [3, 4], "realest": 4, "record": 4, "refer": 3, "refresh": [1, 4], "refreshtoken": 4, "regener": 6, "region": [2, 3], "relat": [4, 6], "relev": 4, "replac": 0, "repres": 4, "reproduc": 6, "request": [0, 1, 3, 4], "requestconfig": 4, "requir": [0, 1, 2, 3], "residenti": 3, "resolv": 4, "respond": 6, "respons": [0, 3, 4, 5], "restart": 6, "result": [2, 4], "retriev": [2, 4], "retrievefactor": 4, "return": [0, 2, 4, 6], "reus": 1, "review": 6, "revok": 6, "run": [0, 2], "saascor": [0, 2], "sampl": 6, "scale": 3, "scenario": [0, 3], "scope": 4, "sdk": [0, 1, 2, 4], "search": 4, "searchact": 4, "searchrequest": 4, "second": [4, 6], "secret": 6, "section": 5, "secur": [1, 5, 6], "see": [0, 1], "send": 0, "sensit": 6, "sent": 4, "server": 6, "servic": [0, 1, 6], "set": [2, 6], "sever": 1, "ship": 4, "sign": 2, "singl": 4, "singleton": [0, 1, 4], "solut": 6, "sourc": [0, 3, 4], "specif": [1, 3, 4, 6], "specifi": 4, "spend": [3, 4], "stack": 6, "standard": [4, 6], "start": [3, 6], "startup": 1, "state": 2, "stateprovinc": [2, 4], "static": 4, "stationari": [3, 4, 6], "stationarytyp": 4, "statu": [1, 6], "steam": 6, "steel": 4, "step": [0, 3], "store": [0, 1, 6], "string": [0, 4], "structur": 5, "subsequ": 6, "successfulli": [2, 6], "summari": 3, "suppli": 3, "support": [1, 4], "sustain": 3, "t": [4, 6], "tabl": [3, 4], "target": 6, "tenantid": 2, "thei": 6, "thi": [0, 2, 4, 5, 6], "three": 6, "throw": 6, "thrown": 6, "time": [0, 4, 6], "timestamp": 4, "togeth": 6, "toisostr": 4, "token": [1, 3, 4], "totalco2": 2, "trace": 6, "track": 3, "transactionid": 2, "transport": [3, 4], "transportationanddistribut": 4, "trim": 0, "troubleshoot": 3, "true": 4, "try": [1, 2], "two": [0, 2], "type": [2, 4, 6], "typerespons": 4, "u": 2, "unauthor": 6, "unifi": [1, 4], "unit": [2, 4, 6], "unitrespons": 4, "unix": 4, "unless": 1, "unreach": 6, "uom": 4, "up": [2, 4, 6], "updat": 6, "url": [0, 4], "us": [0, 1, 3, 4, 6], "usa": [2, 4, 6], "usag": [1, 3, 5], "usagerespons": 4, "usd": 4, "user": [0, 1, 4, 6], "userdata": 4, "util": [3, 4], "v": [0, 1], "valid": [0, 1, 6], "valu": [2, 4, 6], "variabl": [0, 1, 6], "vehicl": 3, "verifi": [1, 6], "version": 6, "void": 4, "wa": [2, 4, 6], "wai": 4, "waitlist": 2, "warehous": 4, "wast": 4, "web": 4, "when": [0, 4, 6], "where": [0, 4], "which": 0, "within": [4, 6], "without": [4, 6], "work": 1, "wrong": 6, "x": [0, 2, 4], "yarn": 2, "ye": 1, "year": 2, "york": 4, "you": [0, 2, 6], "your": [0, 1, 2, 3, 4, 6]}, "titles": ["Authentication", "Client", "Getting Started", "IBM Envizi - Emissions API Node.js SDK", "Reference", "SDK", "Troubleshooting Guide"], "titleterms": {"1": 6, "2": 6, "3": 6, "4": 6, "401": 6, "5": 6, "6": 6, "7": 6, "8": 6, "Not": 6, "api": [0, 2, 3, 4, 6], "applic": 6, "architectur": 0, "auth": 6, "authent": [0, 1, 2, 6], "automat": 6, "basic": 2, "best": [0, 1], "call": 2, "checklist": 6, "client": [1, 6], "common": 6, "configur": [1, 6], "content": 3, "credenti": 6, "custom": 6, "diagram": 0, "emiss": 3, "empti": 6, "envizi": 3, "error": [1, 6], "exampl": [2, 4], "expiri": 6, "field": 6, "first": 2, "flow": 0, "gener": [0, 2], "get": 2, "getarea": 4, "gettyp": 4, "getunit": 4, "global": 4, "guid": 6, "handl": 1, "header": 0, "host": 6, "http": 6, "ibm": 3, "id": 6, "import": 2, "initi": [1, 6], "instal": 2, "instanc": 6, "integr": 1, "interfac": 4, "introduct": 3, "invalid": 6, "j": 3, "kei": [0, 2, 6], "lifetim": 0, "manag": 6, "metadata": 4, "method": 0, "miss": 6, "node": 3, "option": 1, "organ": 6, "overview": [0, 1, 6], "paramet": 6, "practic": [0, 1], "pre": [0, 2], "prerequisit": 2, "recommend": [0, 2, 6], "refer": 4, "refresh": [0, 6], "requir": 6, "respons": [1, 2, 6], "retriev": 0, "scenario": 6, "sdk": [3, 5, 6], "secur": 0, "start": 2, "startup": 6, "step": 6, "summari": 6, "support": [3, 6], "tabl": 6, "token": [0, 2, 6], "troubleshoot": 6, "type": 3, "url": 6, "us": 2, "usag": 4}})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emissions-api-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "sdk for IBM Emissions APIs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -35,13 +35,14 @@
|
|
|
35
35
|
"author": "santhosh0703,Prakhar-sahu,taylorsteffanj",
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"resolutions": {
|
|
38
|
+
"follow-redirects": "^1.16.0",
|
|
38
39
|
"handlebars": "^4.7.9",
|
|
39
40
|
"markdown-it": "^14.1.1",
|
|
40
41
|
"minimatch": "^10.2.5",
|
|
41
42
|
"test-exclude": "^7.0.1"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"axios": "1.15.
|
|
45
|
+
"axios": "1.15.2"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/jest": "^30.0.0",
|
package/src/Client.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { ClientConfig } from "./interfaces/Config";
|
|
3
3
|
import { findExpiryTime } from "./utils";
|
|
4
|
-
import { API_DOMAIN, TOKEN_GENERATION_API, CLIENT_SOURCE_EXCEL, CLIENT_SOURCE_SDK } from "./Constants";
|
|
4
|
+
import { API_DOMAIN, TOKEN_GENERATION_API, PAT_TOKEN_EXCHANGE_API, CLIENT_SOURCE_EXCEL, CLIENT_SOURCE_SDK } from "./Constants";
|
|
5
5
|
|
|
6
6
|
export class Client {
|
|
7
7
|
private static instance: Client | null = null;
|
|
8
8
|
|
|
9
9
|
private token: string;
|
|
10
10
|
private readonly apiKey: string;
|
|
11
|
+
private readonly patToken: string;
|
|
11
12
|
private readonly clientId: string;
|
|
12
13
|
private readonly orgId: string;
|
|
13
14
|
private expiresAt: number;
|
|
@@ -21,28 +22,30 @@ export class Client {
|
|
|
21
22
|
config: ClientConfig,
|
|
22
23
|
isUserProvidedToken = false
|
|
23
24
|
) {
|
|
24
|
-
const { apiKey="", clientId, orgId="", host, authUrl, isExcelAddIn=false } = config;
|
|
25
|
+
const { apiKey="", patToken="", clientId, orgId="", host, authUrl, isExcelAddIn=false } = config;
|
|
25
26
|
this.token = token;
|
|
26
27
|
this.clientId = clientId;
|
|
27
28
|
if (isUserProvidedToken) {
|
|
28
29
|
this.apiKey = "";
|
|
30
|
+
this.patToken = "";
|
|
29
31
|
this.orgId = "";
|
|
30
32
|
} else {
|
|
31
33
|
this.apiKey = apiKey;
|
|
34
|
+
this.patToken = patToken;
|
|
32
35
|
this.orgId = orgId;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
const exp = findExpiryTime(token);
|
|
36
39
|
this.expiresAt = exp;
|
|
37
40
|
this.domain = host ?? API_DOMAIN;
|
|
38
|
-
this.tokenDomain = authUrl ?? TOKEN_GENERATION_API;
|
|
41
|
+
this.tokenDomain = authUrl ?? (patToken ? PAT_TOKEN_EXCHANGE_API : TOKEN_GENERATION_API);
|
|
39
42
|
this.isUserProvidedToken = isUserProvidedToken;
|
|
40
43
|
this.clientSource = isExcelAddIn === true ? CLIENT_SOURCE_EXCEL : CLIENT_SOURCE_SDK;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* Initializes and returns a Client instance with the provided configuration.
|
|
45
|
-
*
|
|
48
|
+
*
|
|
46
49
|
* @static
|
|
47
50
|
* @param {ClientConfig} config - The client configuration object
|
|
48
51
|
* @return {Promise<void>} A promise that resolves when the client is initialized
|
|
@@ -50,7 +53,8 @@ export class Client {
|
|
|
50
53
|
* - custom "host" is provided without "authUrl"
|
|
51
54
|
* - token is provided without "clientId"
|
|
52
55
|
* - apiKey is provided without "clientId" or "orgId"
|
|
53
|
-
*
|
|
56
|
+
* - patToken is provided without "clientId" or with "orgId"
|
|
57
|
+
*
|
|
54
58
|
* @example
|
|
55
59
|
* // Initialize with authentication URL
|
|
56
60
|
* await Client.getClient({
|
|
@@ -59,19 +63,25 @@ export class Client {
|
|
|
59
63
|
* clientId: 'client123',
|
|
60
64
|
* orgId: 'org456'
|
|
61
65
|
* });
|
|
62
|
-
*
|
|
66
|
+
*
|
|
63
67
|
* // Initialize with existing token
|
|
64
68
|
* await Client.getClient({
|
|
65
69
|
* token: 'existing-jwt-token',
|
|
66
70
|
* clientId: 'client123'
|
|
67
71
|
* });
|
|
68
|
-
*
|
|
72
|
+
*
|
|
69
73
|
* // Initialize with API key
|
|
70
74
|
* await Client.getClient({
|
|
71
75
|
* apiKey: 'your-api-key',
|
|
72
76
|
* clientId: 'client123',
|
|
73
77
|
* orgId: 'org456'
|
|
74
78
|
* });
|
|
79
|
+
*
|
|
80
|
+
* // Initialize with PAT token
|
|
81
|
+
* await Client.getClient({
|
|
82
|
+
* patToken: 'your-personal-access-token',
|
|
83
|
+
* clientId: 'client123'
|
|
84
|
+
* });
|
|
75
85
|
*/
|
|
76
86
|
|
|
77
87
|
public static async getClient(config: ClientConfig): Promise<void> {
|
|
@@ -90,14 +100,28 @@ export class Client {
|
|
|
90
100
|
'If apiKey is provided , "clientId" and "OrgId" must also be provided.'
|
|
91
101
|
);
|
|
92
102
|
}
|
|
103
|
+
if(config.patToken && !config.clientId){
|
|
104
|
+
throw new Error(
|
|
105
|
+
'If patToken is provided, "clientId" must also be provided.'
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
if(config.patToken && config.orgId){
|
|
109
|
+
throw new Error(
|
|
110
|
+
'orgId should not be provided when using patToken.'
|
|
111
|
+
);
|
|
112
|
+
}
|
|
93
113
|
let token: string;
|
|
94
114
|
let isUserProvidedToken = false;
|
|
95
115
|
|
|
96
116
|
if (config.token && config.clientId) {
|
|
97
117
|
token = config.token;
|
|
98
118
|
isUserProvidedToken = true;
|
|
99
|
-
} else
|
|
100
|
-
|
|
119
|
+
} else if (config.patToken && config.clientId) {
|
|
120
|
+
token = await Client.requestTokenFromPAT(config);
|
|
121
|
+
} else {
|
|
122
|
+
token = await Client.requestToken(config);
|
|
123
|
+
}
|
|
124
|
+
Client.instance = new Client(token, config, isUserProvidedToken);
|
|
101
125
|
}
|
|
102
126
|
|
|
103
127
|
/**
|
|
@@ -158,12 +182,21 @@ export class Client {
|
|
|
158
182
|
const now = Math.floor(Date.now() / 1000);
|
|
159
183
|
if (this.expiresAt - now < 60) {
|
|
160
184
|
console.log("[SDK] Refreshing token...");
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
let token: string;
|
|
186
|
+
if (this.patToken) {
|
|
187
|
+
token = await Client.requestTokenFromPAT({
|
|
188
|
+
patToken: this.patToken,
|
|
189
|
+
clientId: this.clientId,
|
|
190
|
+
authUrl: this.tokenDomain,
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
token = await Client.requestToken({
|
|
194
|
+
apiKey: this.apiKey,
|
|
195
|
+
clientId: this.clientId,
|
|
196
|
+
orgId: this.orgId,
|
|
197
|
+
authUrl: this.tokenDomain,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
167
200
|
this.token = token;
|
|
168
201
|
this.expiresAt = findExpiryTime(token);
|
|
169
202
|
}
|
|
@@ -249,4 +282,35 @@ export class Client {
|
|
|
249
282
|
if (!res.data) throw new Error("Token response is empty");
|
|
250
283
|
return String(res.data).trim();
|
|
251
284
|
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Requests an authentication token by exchanging a Personal Access Token (PAT).
|
|
288
|
+
*
|
|
289
|
+
* @private
|
|
290
|
+
* @static
|
|
291
|
+
* @param {ClientConfig} config - The client configuration containing PAT and client details
|
|
292
|
+
* @return {Promise<string>} A promise that resolves to the authentication token string
|
|
293
|
+
* @throws {Error} Throws an error if the token response is empty
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* // Internal usage within the Client class
|
|
297
|
+
* const token = await Client.requestTokenFromPAT({
|
|
298
|
+
* patToken: 'your-personal-access-token',
|
|
299
|
+
* clientId: 'client123',
|
|
300
|
+
* authUrl: 'https://custom-auth.example.com/exchange'
|
|
301
|
+
* });
|
|
302
|
+
*/
|
|
303
|
+
private static async requestTokenFromPAT(config: ClientConfig): Promise<string> {
|
|
304
|
+
const tokenUrl = config.authUrl ?? PAT_TOKEN_EXCHANGE_API;
|
|
305
|
+
const res = await axios.post(tokenUrl, null, {
|
|
306
|
+
headers: {
|
|
307
|
+
"X-IBM-Client-Id": `saascore-${config.clientId}`,
|
|
308
|
+
"X-IBM-Envizi-Pat": config.patToken,
|
|
309
|
+
accept: "application/json",
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
if (!res.data) throw new Error("Token response is empty");
|
|
314
|
+
return String(res.data).trim();
|
|
315
|
+
}
|
|
252
316
|
}
|
package/src/Constants.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const API_DOMAIN = "https://api.ibm.com/ghgemissions/run";
|
|
2
2
|
export const TOKEN_GENERATION_API = "https://api.ibm.com/saascore/run/authentication-retrieve/api-key";
|
|
3
|
+
export const PAT_TOKEN_EXCHANGE_API = "https://api.ibm.com/saascore/run/envizi-auth/exchange";
|
|
3
4
|
export const MOBILE_API_PATH = "/v3/carbon/mobile";
|
|
4
5
|
export const LOCATION_API_PATH = "/v3/carbon/location";
|
|
5
6
|
export const FUGITIVE_API_PATH = "/v3/carbon/fugitive";
|
package/src/index.ts
CHANGED
|
@@ -19,18 +19,9 @@ export { AreaResponse, Location as LocationInfo } from './interfaces/response/Ar
|
|
|
19
19
|
export { EmissionResponse } from './interfaces/response/EmissionResponse';
|
|
20
20
|
export {
|
|
21
21
|
EmissionResponseWithDetails,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
FactorDataTypeCategory,
|
|
26
|
-
FactorSetInfo,
|
|
27
|
-
FactorSelectionDefault,
|
|
28
|
-
FactorDataTypeCode,
|
|
29
|
-
FactorSetVersion,
|
|
30
|
-
FactorValue,
|
|
31
|
-
FactorMetaData,
|
|
32
|
-
UnitConversion,
|
|
33
|
-
EmissionData
|
|
22
|
+
FactorDetails,
|
|
23
|
+
FactorSetDetails,
|
|
24
|
+
IncludeDetails
|
|
34
25
|
} from './interfaces/response/EmissionResponseWithDetails';
|
|
35
26
|
export { FactorResponse } from './interfaces/response/FactorResponse';
|
|
36
27
|
export {
|
package/src/interfaces/Config.ts
CHANGED
|
@@ -70,6 +70,13 @@ export interface ClientConfig {
|
|
|
70
70
|
*/
|
|
71
71
|
token?: string;
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Optional Personal Access Token (PAT) for authentication.
|
|
75
|
+
* If provided, it will be exchanged for a JWT token.
|
|
76
|
+
* Requires clientId to be provided.
|
|
77
|
+
*/
|
|
78
|
+
patToken?: string;
|
|
79
|
+
|
|
73
80
|
/**
|
|
74
81
|
* Optional flag indicating whether the client is running as an Excel Add-In.
|
|
75
82
|
* This may affect certain behaviors like authentication flows.
|