oilpriceapi 0.7.0 → 0.9.0
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/README.md +244 -30
- package/dist/cjs/client.js +610 -0
- package/dist/cjs/errors.js +80 -0
- package/dist/cjs/index.js +96 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/resources/alerts.js +387 -0
- package/dist/cjs/resources/analytics.js +188 -0
- package/dist/cjs/resources/bunker-fuels.js +210 -0
- package/dist/cjs/resources/commodities.js +115 -0
- package/dist/cjs/resources/data-quality.js +144 -0
- package/dist/cjs/resources/data-sources.js +298 -0
- package/dist/cjs/resources/diesel.js +119 -0
- package/dist/cjs/resources/drilling.js +269 -0
- package/dist/cjs/resources/ei/drilling-productivity.js +108 -0
- package/dist/cjs/resources/ei/forecasts.js +106 -0
- package/dist/cjs/resources/ei/frac-focus.js +165 -0
- package/dist/cjs/resources/ei/index.js +98 -0
- package/dist/cjs/resources/ei/oil-inventories.js +97 -0
- package/dist/cjs/resources/ei/opec-production.js +97 -0
- package/dist/cjs/resources/ei/rig-counts.js +93 -0
- package/dist/cjs/resources/ei/well-permits.js +136 -0
- package/dist/cjs/resources/forecasts.js +168 -0
- package/dist/cjs/resources/futures.js +424 -0
- package/dist/cjs/resources/indicators.js +79 -0
- package/dist/cjs/resources/raw.js +128 -0
- package/dist/cjs/resources/rig-counts.js +164 -0
- package/dist/cjs/resources/spreads.js +105 -0
- package/dist/cjs/resources/storage.js +166 -0
- package/dist/cjs/resources/streaming.js +350 -0
- package/dist/cjs/resources/webhooks.js +283 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/version.js +24 -0
- package/dist/client.d.ts +130 -3
- package/dist/client.js +206 -30
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +25 -16
- package/dist/index.d.ts +28 -5
- package/dist/index.js +29 -1
- package/dist/resources/alerts.js +31 -77
- package/dist/resources/analytics.d.ts +147 -214
- package/dist/resources/analytics.js +104 -141
- package/dist/resources/bunker-fuels.d.ts +35 -12
- package/dist/resources/bunker-fuels.js +41 -26
- package/dist/resources/commodities.js +2 -1
- package/dist/resources/data-quality.js +2 -1
- package/dist/resources/data-sources.d.ts +31 -31
- package/dist/resources/data-sources.js +30 -85
- package/dist/resources/diesel.d.ts +1 -1
- package/dist/resources/diesel.js +9 -38
- package/dist/resources/drilling.js +2 -1
- package/dist/resources/ei/drilling-productivity.js +2 -1
- package/dist/resources/ei/forecasts.js +2 -1
- package/dist/resources/ei/frac-focus.d.ts +23 -9
- package/dist/resources/ei/frac-focus.js +20 -9
- package/dist/resources/ei/index.js +2 -1
- package/dist/resources/ei/oil-inventories.js +2 -1
- package/dist/resources/ei/opec-production.js +2 -1
- package/dist/resources/ei/rig-counts.js +2 -1
- package/dist/resources/ei/well-permits.d.ts +25 -9
- package/dist/resources/ei/well-permits.js +20 -7
- package/dist/resources/forecasts.d.ts +4 -1
- package/dist/resources/forecasts.js +13 -6
- package/dist/resources/futures.d.ts +178 -1
- package/dist/resources/futures.js +199 -8
- package/dist/resources/indicators.d.ts +170 -0
- package/dist/resources/indicators.js +75 -0
- package/dist/resources/raw.d.ts +94 -0
- package/dist/resources/raw.js +124 -0
- package/dist/resources/rig-counts.js +5 -2
- package/dist/resources/spreads.d.ts +121 -0
- package/dist/resources/spreads.js +101 -0
- package/dist/resources/storage.d.ts +5 -4
- package/dist/resources/storage.js +7 -6
- package/dist/resources/streaming.d.ts +272 -0
- package/dist/resources/streaming.js +342 -0
- package/dist/resources/webhooks.d.ts +73 -23
- package/dist/resources/webhooks.js +59 -77
- package/dist/types.d.ts +43 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/package.json +21 -6
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bunker Fuels Resource
|
|
4
|
+
*
|
|
5
|
+
* Access bunker fuel prices at major ports worldwide, including VLSFO, MGO,
|
|
6
|
+
* and IFO380. Compare prices across ports and track historical trends.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BunkerFuelsResource = void 0;
|
|
10
|
+
const errors_js_1 = require("../errors.js");
|
|
11
|
+
/**
|
|
12
|
+
* Bunker Fuels Resource
|
|
13
|
+
*
|
|
14
|
+
* Access bunker fuel prices at major ports worldwide. Track VLSFO, MGO, and
|
|
15
|
+
* IFO380 prices, compare across ports, and analyze historical trends.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
20
|
+
*
|
|
21
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
22
|
+
*
|
|
23
|
+
* // Get all bunker fuel prices
|
|
24
|
+
* const prices = await client.bunkerFuels.all();
|
|
25
|
+
*
|
|
26
|
+
* // Get prices for specific port
|
|
27
|
+
* const singapore = await client.bunkerFuels.port('SIN');
|
|
28
|
+
* console.log(`Singapore VLSFO: $${singapore.prices.VLSFO}/MT`);
|
|
29
|
+
*
|
|
30
|
+
* // Compare prices across ports
|
|
31
|
+
* const comparison = await client.bunkerFuels.compare(['SIN', 'RTM', 'HOU']);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
class BunkerFuelsResource {
|
|
35
|
+
constructor(client) {
|
|
36
|
+
this.client = client;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get all current bunker fuel prices
|
|
40
|
+
*
|
|
41
|
+
* Returns prices for all tracked ports and fuel types.
|
|
42
|
+
*
|
|
43
|
+
* @returns Array of bunker fuel prices
|
|
44
|
+
*
|
|
45
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
46
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const prices = await client.bunkerFuels.all();
|
|
51
|
+
* prices.forEach(price => {
|
|
52
|
+
* console.log(`${price.port_name} ${price.fuel_type}: $${price.price}/${price.unit}`);
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
async all() {
|
|
57
|
+
// Route is GET /v1/bunker-fuels/all (the bare /v1/bunker-fuels has no route).
|
|
58
|
+
const response = await this.client["request"]("/v1/bunker-fuels/all", {});
|
|
59
|
+
return Array.isArray(response) ? response : response.prices;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get bunker fuel prices for a specific port
|
|
63
|
+
*
|
|
64
|
+
* @param code - Port code (e.g., "SIN" for Singapore, "RTM" for Rotterdam)
|
|
65
|
+
* @returns Port-specific prices across fuel types
|
|
66
|
+
*
|
|
67
|
+
* @throws {NotFoundError} If port code not found
|
|
68
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const singapore = await client.bunkerFuels.port('SIN');
|
|
73
|
+
* console.log(`Singapore Bunker Prices (${singapore.timestamp}):`);
|
|
74
|
+
* console.log(`VLSFO: $${singapore.prices.VLSFO}/${singapore.unit}`);
|
|
75
|
+
* console.log(`MGO: $${singapore.prices.MGO}/${singapore.unit}`);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
async port(code) {
|
|
79
|
+
if (!code || typeof code !== "string") {
|
|
80
|
+
throw new errors_js_1.ValidationError("Port code must be a non-empty string");
|
|
81
|
+
}
|
|
82
|
+
return this.client["request"](`/v1/bunker-fuels/ports/${code}`, {});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Compare prices across multiple ports
|
|
86
|
+
*
|
|
87
|
+
* @param ports - Array of port codes to compare
|
|
88
|
+
* @returns Price comparison data
|
|
89
|
+
*
|
|
90
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const comparison = await client.bunkerFuels.compare(['SIN', 'RTM', 'HOU', 'FUJ']);
|
|
95
|
+
*
|
|
96
|
+
* console.log(`Comparing ${comparison.fuel_type} prices:`);
|
|
97
|
+
* comparison.ports.forEach((port, index) => {
|
|
98
|
+
* console.log(`${index + 1}. ${port.port_name}: $${port.price}`);
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
async compare(ports) {
|
|
103
|
+
if (!Array.isArray(ports) || ports.length === 0) {
|
|
104
|
+
throw new errors_js_1.ValidationError("Ports must be a non-empty array of port codes");
|
|
105
|
+
}
|
|
106
|
+
return this.client["request"]("/v1/bunker-fuels/compare", {
|
|
107
|
+
ports: ports.join(","),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get the bunker fuel price spread between two ports.
|
|
112
|
+
*
|
|
113
|
+
* Maps to `GET /v1/bunker-fuels/spreads/ports`, which reads `from`, `to`
|
|
114
|
+
* and `grade`. (Earlier SDKs called `/v1/bunker-fuels/spreads` with no params,
|
|
115
|
+
* which 404'd.)
|
|
116
|
+
*
|
|
117
|
+
* @param options - `{ from, to, grade? }`
|
|
118
|
+
* @returns Port-to-port fuel price spread
|
|
119
|
+
*
|
|
120
|
+
* @throws {ValidationError} If from/to are missing
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const spread = await client.bunkerFuels.spreads({ from: 'SIN', to: 'RTM', grade: 'VLSFO' });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
async spreads(options) {
|
|
128
|
+
if (!options?.from || !options?.to) {
|
|
129
|
+
throw new errors_js_1.ValidationError("Both 'from' and 'to' port codes are required");
|
|
130
|
+
}
|
|
131
|
+
const params = {
|
|
132
|
+
from: options.from,
|
|
133
|
+
to: options.to,
|
|
134
|
+
};
|
|
135
|
+
if (options.grade)
|
|
136
|
+
params.grade = options.grade;
|
|
137
|
+
return this.client["request"]("/v1/bunker-fuels/spreads/ports", params);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get historical bunker fuel prices
|
|
141
|
+
*
|
|
142
|
+
* @param port - Port code (e.g., "SIN", "RTM")
|
|
143
|
+
* @param fuelType - Fuel type (e.g., "VLSFO", "MGO", "IFO380")
|
|
144
|
+
* @param options - Date range filters
|
|
145
|
+
* @returns Array of historical prices
|
|
146
|
+
*
|
|
147
|
+
* @throws {NotFoundError} If port or fuel type not found
|
|
148
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
149
|
+
*
|
|
150
|
+
* The history endpoint is keyed by port in the PATH (`/historical/:port_code`)
|
|
151
|
+
* and returns all grades for that port; it does not filter by a single fuel
|
|
152
|
+
* type. It reads `from` / `to` / `interval` query params.
|
|
153
|
+
*
|
|
154
|
+
* @param port - Port code (e.g., "SIN", "RTM") — used as a path segment
|
|
155
|
+
* @param options - `{ startDate, endDate, interval }`
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const history = await client.bunkerFuels.historical('SIN', {
|
|
160
|
+
* startDate: '2024-01-01',
|
|
161
|
+
* endDate: '2024-12-31'
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* history.forEach(point => {
|
|
165
|
+
* console.log(`${point.date}: $${point.price}/${point.unit}`);
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
async historical(port, options) {
|
|
170
|
+
if (!port || typeof port !== "string") {
|
|
171
|
+
throw new errors_js_1.ValidationError("Port code must be a non-empty string");
|
|
172
|
+
}
|
|
173
|
+
const params = {};
|
|
174
|
+
if (options?.startDate)
|
|
175
|
+
params.from = options.startDate;
|
|
176
|
+
if (options?.endDate)
|
|
177
|
+
params.to = options.endDate;
|
|
178
|
+
if (options?.interval)
|
|
179
|
+
params.interval = options.interval;
|
|
180
|
+
// Port code is a PATH segment: GET /v1/bunker-fuels/historical/:port_code
|
|
181
|
+
const response = await this.client["request"](`/v1/bunker-fuels/historical/${port}`, params);
|
|
182
|
+
return Array.isArray(response) ? response : response.data;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Export bunker fuel data
|
|
186
|
+
*
|
|
187
|
+
* Export bunker fuel prices in specified format (CSV, JSON, Excel).
|
|
188
|
+
*
|
|
189
|
+
* @param format - Export format (default: "csv")
|
|
190
|
+
* @returns Export data or download URL
|
|
191
|
+
*
|
|
192
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* // Export as CSV
|
|
197
|
+
* const csvData = await client.bunkerFuels.export('csv');
|
|
198
|
+
*
|
|
199
|
+
* // Export as JSON
|
|
200
|
+
* const jsonData = await client.bunkerFuels.export('json');
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
async export(format) {
|
|
204
|
+
const params = {};
|
|
205
|
+
if (format)
|
|
206
|
+
params.format = format;
|
|
207
|
+
return this.client["request"]("/v1/bunker-fuels/export", params);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.BunkerFuelsResource = BunkerFuelsResource;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Commodities Resource
|
|
4
|
+
*
|
|
5
|
+
* Get metadata about supported commodities and categories.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CommoditiesResource = void 0;
|
|
9
|
+
const errors_js_1 = require("../errors.js");
|
|
10
|
+
/**
|
|
11
|
+
* Commodities Resource
|
|
12
|
+
*
|
|
13
|
+
* Access metadata about supported commodities and categories.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
18
|
+
*
|
|
19
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
20
|
+
*
|
|
21
|
+
* // List all commodities
|
|
22
|
+
* const response = await client.commodities.list();
|
|
23
|
+
* console.log(`${response.commodities.length} commodities available`);
|
|
24
|
+
*
|
|
25
|
+
* // Get specific commodity
|
|
26
|
+
* const wti = await client.commodities.get('WTI_USD');
|
|
27
|
+
* console.log(`${wti.name}: ${wti.description}`);
|
|
28
|
+
*
|
|
29
|
+
* // Get categories
|
|
30
|
+
* const categories = await client.commodities.categories();
|
|
31
|
+
* console.log(`Oil category has ${categories.oil.commodities.length} commodities`);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
class CommoditiesResource {
|
|
35
|
+
constructor(client) {
|
|
36
|
+
this.client = client;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* List all supported commodities
|
|
40
|
+
*
|
|
41
|
+
* Returns metadata for all commodities available in the API, including
|
|
42
|
+
* codes, names, units, and validation ranges.
|
|
43
|
+
*
|
|
44
|
+
* @returns Object containing array of commodities
|
|
45
|
+
*
|
|
46
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
47
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const response = await client.commodities.list();
|
|
52
|
+
*
|
|
53
|
+
* response.commodities.forEach(commodity => {
|
|
54
|
+
* console.log(`${commodity.code}: ${commodity.name} (${commodity.unit})`);
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
async list() {
|
|
59
|
+
return this.client["request"]("/v1/commodities", {});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get metadata for a specific commodity by code
|
|
63
|
+
*
|
|
64
|
+
* @param code - Commodity code (e.g., "WTI_USD", "BRENT_CRUDE_USD")
|
|
65
|
+
* @returns Commodity metadata object
|
|
66
|
+
*
|
|
67
|
+
* @throws {NotFoundError} If commodity code is invalid
|
|
68
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
69
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const commodity = await client.commodities.get('WTI_USD');
|
|
74
|
+
* console.log(`Name: ${commodity.name}`);
|
|
75
|
+
* console.log(`Unit: ${commodity.unit}`);
|
|
76
|
+
* console.log(`Currency: ${commodity.currency}`);
|
|
77
|
+
* console.log(`Category: ${commodity.category}`);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
async get(code) {
|
|
81
|
+
if (!code || typeof code !== "string") {
|
|
82
|
+
throw new errors_js_1.ValidationError("Commodity code must be a non-empty string");
|
|
83
|
+
}
|
|
84
|
+
return this.client["request"](`/v1/commodities/${code}`, {});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get all commodity categories with their commodities
|
|
88
|
+
*
|
|
89
|
+
* Returns commodities grouped by category (oil, gas, renewable, etc.).
|
|
90
|
+
* Useful for building navigation or filtering UIs.
|
|
91
|
+
*
|
|
92
|
+
* @returns Object with category keys mapped to category objects
|
|
93
|
+
*
|
|
94
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
95
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const categories = await client.commodities.categories();
|
|
100
|
+
*
|
|
101
|
+
* // Access by category key
|
|
102
|
+
* console.log(`Oil: ${categories.oil.name}`);
|
|
103
|
+
* console.log(`Commodities: ${categories.oil.commodities.length}`);
|
|
104
|
+
*
|
|
105
|
+
* // Iterate all categories
|
|
106
|
+
* Object.entries(categories).forEach(([key, category]) => {
|
|
107
|
+
* console.log(`${category.name}: ${category.commodities.length} commodities`);
|
|
108
|
+
* });
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
async categories() {
|
|
112
|
+
return this.client["request"]("/v1/commodities/categories", {});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.CommoditiesResource = CommoditiesResource;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Data Quality Resource
|
|
4
|
+
*
|
|
5
|
+
* Access data quality metrics, reports, and monitoring for commodity price data.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DataQualityResource = void 0;
|
|
9
|
+
const errors_js_1 = require("../errors.js");
|
|
10
|
+
/**
|
|
11
|
+
* Data Quality Resource
|
|
12
|
+
*
|
|
13
|
+
* Monitor data quality metrics and access detailed quality reports for
|
|
14
|
+
* commodity price data sources.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
19
|
+
*
|
|
20
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
21
|
+
*
|
|
22
|
+
* // Get quality summary
|
|
23
|
+
* const summary = await client.dataQuality.summary();
|
|
24
|
+
* console.log(`Overall quality: ${summary.overall_score}/100`);
|
|
25
|
+
* console.log(`Sources monitored: ${summary.sources_monitored}`);
|
|
26
|
+
*
|
|
27
|
+
* // Get all reports
|
|
28
|
+
* const reports = await client.dataQuality.reports();
|
|
29
|
+
* reports.forEach(report => {
|
|
30
|
+
* console.log(`${report.name}: ${report.status}`);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
class DataQualityResource {
|
|
35
|
+
constructor(client) {
|
|
36
|
+
this.client = client;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get data quality summary
|
|
40
|
+
*
|
|
41
|
+
* Returns overall data quality metrics and recent alerts.
|
|
42
|
+
*
|
|
43
|
+
* @returns Data quality summary
|
|
44
|
+
*
|
|
45
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
46
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const summary = await client.dataQuality.summary();
|
|
51
|
+
*
|
|
52
|
+
* console.log(`Overall score: ${summary.overall_score}/100`);
|
|
53
|
+
* console.log(`Completeness: ${summary.breakdown.completeness}%`);
|
|
54
|
+
* console.log(`Timeliness: ${summary.breakdown.timeliness}%`);
|
|
55
|
+
* console.log(`Accuracy: ${summary.breakdown.accuracy}%`);
|
|
56
|
+
* console.log(`Consistency: ${summary.breakdown.consistency}%`);
|
|
57
|
+
*
|
|
58
|
+
* if (summary.recent_alerts && summary.recent_alerts.length > 0) {
|
|
59
|
+
* console.log('\nRecent Alerts:');
|
|
60
|
+
* summary.recent_alerts.forEach(alert => {
|
|
61
|
+
* console.log(`[${alert.severity.toUpperCase()}] ${alert.message}`);
|
|
62
|
+
* });
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
async summary() {
|
|
67
|
+
return this.client["request"]("/v1/data-quality/summary", {});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get all data quality reports
|
|
71
|
+
*
|
|
72
|
+
* Returns metadata for all available quality reports.
|
|
73
|
+
*
|
|
74
|
+
* @returns Array of report metadata
|
|
75
|
+
*
|
|
76
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
77
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const reports = await client.dataQuality.reports();
|
|
82
|
+
*
|
|
83
|
+
* console.log(`${reports.length} quality reports available:\n`);
|
|
84
|
+
* reports.forEach(report => {
|
|
85
|
+
* console.log(`${report.name}`);
|
|
86
|
+
* console.log(` Code: ${report.code}`);
|
|
87
|
+
* console.log(` Scope: ${report.scope}`);
|
|
88
|
+
* console.log(` Status: ${report.status}`);
|
|
89
|
+
* console.log(` Last generated: ${report.last_generated}\n`);
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
async reports() {
|
|
94
|
+
const response = await this.client["request"]("/v1/data-quality/reports", {});
|
|
95
|
+
return Array.isArray(response) ? response : response.reports;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get detailed data quality report
|
|
99
|
+
*
|
|
100
|
+
* Returns comprehensive quality analysis for a specific source or commodity.
|
|
101
|
+
*
|
|
102
|
+
* @param code - Report code (e.g., "WTI_USD", "BRENT_CRUDE_USD", "EIA")
|
|
103
|
+
* @returns Detailed quality report
|
|
104
|
+
*
|
|
105
|
+
* @throws {NotFoundError} If report code not found
|
|
106
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const report = await client.dataQuality.report('WTI_USD');
|
|
111
|
+
*
|
|
112
|
+
* console.log(`Report: ${report.name}`);
|
|
113
|
+
* console.log(`Scope: ${report.scope}`);
|
|
114
|
+
* console.log(`Period: ${report.period.start} to ${report.period.end}\n`);
|
|
115
|
+
*
|
|
116
|
+
* console.log('Metrics:');
|
|
117
|
+
* console.log(` Completeness: ${report.metrics.completeness}%`);
|
|
118
|
+
* console.log(` Timeliness: ${report.metrics.timeliness}%`);
|
|
119
|
+
* console.log(` Accuracy: ${report.metrics.accuracy}%`);
|
|
120
|
+
* console.log(` Consistency: ${report.metrics.consistency}%`);
|
|
121
|
+
*
|
|
122
|
+
* if (report.issues && report.issues.length > 0) {
|
|
123
|
+
* console.log('\nIssues:');
|
|
124
|
+
* report.issues.forEach(issue => {
|
|
125
|
+
* console.log(` [${issue.severity.toUpperCase()}] ${issue.description}`);
|
|
126
|
+
* });
|
|
127
|
+
* }
|
|
128
|
+
*
|
|
129
|
+
* if (report.recommendations && report.recommendations.length > 0) {
|
|
130
|
+
* console.log('\nRecommendations:');
|
|
131
|
+
* report.recommendations.forEach(rec => {
|
|
132
|
+
* console.log(` - ${rec}`);
|
|
133
|
+
* });
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
async report(code) {
|
|
138
|
+
if (!code || typeof code !== "string") {
|
|
139
|
+
throw new errors_js_1.ValidationError("Report code must be a non-empty string");
|
|
140
|
+
}
|
|
141
|
+
return this.client["request"](`/v1/data-quality/reports/${code}`, {});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.DataQualityResource = DataQualityResource;
|