oilpriceapi 0.5.3 → 0.7.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 +395 -110
- package/dist/client.d.ts +83 -3
- package/dist/client.js +118 -38
- package/dist/index.d.ts +31 -6
- package/dist/index.js +17 -3
- package/dist/resources/alerts.d.ts +52 -15
- package/dist/resources/alerts.js +143 -85
- package/dist/resources/analytics.d.ts +325 -0
- package/dist/resources/analytics.js +221 -0
- package/dist/resources/bunker-fuels.d.ts +270 -0
- package/dist/resources/bunker-fuels.js +191 -0
- package/dist/resources/commodities.d.ts +148 -0
- package/dist/resources/commodities.js +110 -0
- package/dist/resources/data-quality.d.ts +229 -0
- package/dist/resources/data-quality.js +139 -0
- package/dist/resources/data-sources.d.ts +365 -0
- package/dist/resources/data-sources.js +349 -0
- package/dist/resources/drilling.d.ts +403 -0
- package/dist/resources/drilling.js +264 -0
- package/dist/resources/ei/drilling-productivity.d.ts +173 -0
- package/dist/resources/ei/drilling-productivity.js +103 -0
- package/dist/resources/ei/forecasts.d.ts +177 -0
- package/dist/resources/ei/forecasts.js +101 -0
- package/dist/resources/ei/frac-focus.d.ts +212 -0
- package/dist/resources/ei/frac-focus.js +150 -0
- package/dist/resources/ei/index.d.ts +140 -0
- package/dist/resources/ei/index.js +87 -0
- package/dist/resources/ei/oil-inventories.d.ts +155 -0
- package/dist/resources/ei/oil-inventories.js +92 -0
- package/dist/resources/ei/opec-production.d.ts +146 -0
- package/dist/resources/ei/opec-production.js +92 -0
- package/dist/resources/ei/rig-counts.d.ts +131 -0
- package/dist/resources/ei/rig-counts.js +88 -0
- package/dist/resources/ei/well-permits.d.ts +178 -0
- package/dist/resources/ei/well-permits.js +119 -0
- package/dist/resources/forecasts.d.ts +200 -0
- package/dist/resources/forecasts.js +157 -0
- package/dist/resources/futures.d.ts +322 -0
- package/dist/resources/futures.js +228 -0
- package/dist/resources/rig-counts.d.ts +221 -0
- package/dist/resources/rig-counts.js +157 -0
- package/dist/resources/storage.d.ts +182 -0
- package/dist/resources/storage.js +161 -0
- package/dist/resources/webhooks.d.ts +290 -0
- package/dist/resources/webhooks.js +297 -0
- package/dist/types.d.ts +106 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commodities Resource
|
|
3
|
+
*
|
|
4
|
+
* Get metadata about supported commodities and categories.
|
|
5
|
+
*/
|
|
6
|
+
import type { OilPriceAPI } from "../client.js";
|
|
7
|
+
/**
|
|
8
|
+
* Commodity metadata
|
|
9
|
+
*/
|
|
10
|
+
export interface Commodity {
|
|
11
|
+
/** Unique commodity identifier */
|
|
12
|
+
code: string;
|
|
13
|
+
/** Human-readable commodity name */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Base currency for pricing */
|
|
16
|
+
currency: string;
|
|
17
|
+
/** Commodity category (e.g., "oil", "gas", "renewable") */
|
|
18
|
+
category: string;
|
|
19
|
+
/** Detailed description */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Unit of measurement (e.g., "barrel", "gallon") */
|
|
22
|
+
unit: string;
|
|
23
|
+
/** Detailed unit description */
|
|
24
|
+
unit_description?: string;
|
|
25
|
+
/** Storage multiplier for price values */
|
|
26
|
+
multiplier?: number;
|
|
27
|
+
/** Price validation ranges */
|
|
28
|
+
validation?: {
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
};
|
|
32
|
+
/** Threshold for significant price change alerts */
|
|
33
|
+
price_change_threshold?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Response from /v1/commodities endpoint
|
|
37
|
+
*/
|
|
38
|
+
export interface CommoditiesResponse {
|
|
39
|
+
commodities: Commodity[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Category with its commodities
|
|
43
|
+
*/
|
|
44
|
+
export interface CommodityCategory {
|
|
45
|
+
name: string;
|
|
46
|
+
commodities: Commodity[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Response from /v1/commodities/categories endpoint
|
|
50
|
+
*/
|
|
51
|
+
export interface CategoriesResponse {
|
|
52
|
+
[categoryKey: string]: CommodityCategory;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Commodities Resource
|
|
56
|
+
*
|
|
57
|
+
* Access metadata about supported commodities and categories.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
62
|
+
*
|
|
63
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
64
|
+
*
|
|
65
|
+
* // List all commodities
|
|
66
|
+
* const response = await client.commodities.list();
|
|
67
|
+
* console.log(`${response.commodities.length} commodities available`);
|
|
68
|
+
*
|
|
69
|
+
* // Get specific commodity
|
|
70
|
+
* const wti = await client.commodities.get('WTI_USD');
|
|
71
|
+
* console.log(`${wti.name}: ${wti.description}`);
|
|
72
|
+
*
|
|
73
|
+
* // Get categories
|
|
74
|
+
* const categories = await client.commodities.categories();
|
|
75
|
+
* console.log(`Oil category has ${categories.oil.commodities.length} commodities`);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare class CommoditiesResource {
|
|
79
|
+
private client;
|
|
80
|
+
constructor(client: OilPriceAPI);
|
|
81
|
+
/**
|
|
82
|
+
* List all supported commodities
|
|
83
|
+
*
|
|
84
|
+
* Returns metadata for all commodities available in the API, including
|
|
85
|
+
* codes, names, units, and validation ranges.
|
|
86
|
+
*
|
|
87
|
+
* @returns Object containing array of commodities
|
|
88
|
+
*
|
|
89
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
90
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const response = await client.commodities.list();
|
|
95
|
+
*
|
|
96
|
+
* response.commodities.forEach(commodity => {
|
|
97
|
+
* console.log(`${commodity.code}: ${commodity.name} (${commodity.unit})`);
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
list(): Promise<CommoditiesResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Get metadata for a specific commodity by code
|
|
104
|
+
*
|
|
105
|
+
* @param code - Commodity code (e.g., "WTI_USD", "BRENT_CRUDE_USD")
|
|
106
|
+
* @returns Commodity metadata object
|
|
107
|
+
*
|
|
108
|
+
* @throws {NotFoundError} If commodity code is invalid
|
|
109
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
110
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const commodity = await client.commodities.get('WTI_USD');
|
|
115
|
+
* console.log(`Name: ${commodity.name}`);
|
|
116
|
+
* console.log(`Unit: ${commodity.unit}`);
|
|
117
|
+
* console.log(`Currency: ${commodity.currency}`);
|
|
118
|
+
* console.log(`Category: ${commodity.category}`);
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
get(code: string): Promise<Commodity>;
|
|
122
|
+
/**
|
|
123
|
+
* Get all commodity categories with their commodities
|
|
124
|
+
*
|
|
125
|
+
* Returns commodities grouped by category (oil, gas, renewable, etc.).
|
|
126
|
+
* Useful for building navigation or filtering UIs.
|
|
127
|
+
*
|
|
128
|
+
* @returns Object with category keys mapped to category objects
|
|
129
|
+
*
|
|
130
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
131
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const categories = await client.commodities.categories();
|
|
136
|
+
*
|
|
137
|
+
* // Access by category key
|
|
138
|
+
* console.log(`Oil: ${categories.oil.name}`);
|
|
139
|
+
* console.log(`Commodities: ${categories.oil.commodities.length}`);
|
|
140
|
+
*
|
|
141
|
+
* // Iterate all categories
|
|
142
|
+
* Object.entries(categories).forEach(([key, category]) => {
|
|
143
|
+
* console.log(`${category.name}: ${category.commodities.length} commodities`);
|
|
144
|
+
* });
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
categories(): Promise<CategoriesResponse>;
|
|
148
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commodities Resource
|
|
3
|
+
*
|
|
4
|
+
* Get metadata about supported commodities and categories.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Commodities Resource
|
|
8
|
+
*
|
|
9
|
+
* Access metadata about supported commodities and categories.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
14
|
+
*
|
|
15
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
16
|
+
*
|
|
17
|
+
* // List all commodities
|
|
18
|
+
* const response = await client.commodities.list();
|
|
19
|
+
* console.log(`${response.commodities.length} commodities available`);
|
|
20
|
+
*
|
|
21
|
+
* // Get specific commodity
|
|
22
|
+
* const wti = await client.commodities.get('WTI_USD');
|
|
23
|
+
* console.log(`${wti.name}: ${wti.description}`);
|
|
24
|
+
*
|
|
25
|
+
* // Get categories
|
|
26
|
+
* const categories = await client.commodities.categories();
|
|
27
|
+
* console.log(`Oil category has ${categories.oil.commodities.length} commodities`);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export class CommoditiesResource {
|
|
31
|
+
constructor(client) {
|
|
32
|
+
this.client = client;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* List all supported commodities
|
|
36
|
+
*
|
|
37
|
+
* Returns metadata for all commodities available in the API, including
|
|
38
|
+
* codes, names, units, and validation ranges.
|
|
39
|
+
*
|
|
40
|
+
* @returns Object containing array of commodities
|
|
41
|
+
*
|
|
42
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
43
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const response = await client.commodities.list();
|
|
48
|
+
*
|
|
49
|
+
* response.commodities.forEach(commodity => {
|
|
50
|
+
* console.log(`${commodity.code}: ${commodity.name} (${commodity.unit})`);
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
async list() {
|
|
55
|
+
return this.client["request"]("/v1/commodities", {});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get metadata for a specific commodity by code
|
|
59
|
+
*
|
|
60
|
+
* @param code - Commodity code (e.g., "WTI_USD", "BRENT_CRUDE_USD")
|
|
61
|
+
* @returns Commodity metadata object
|
|
62
|
+
*
|
|
63
|
+
* @throws {NotFoundError} If commodity code is invalid
|
|
64
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
65
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const commodity = await client.commodities.get('WTI_USD');
|
|
70
|
+
* console.log(`Name: ${commodity.name}`);
|
|
71
|
+
* console.log(`Unit: ${commodity.unit}`);
|
|
72
|
+
* console.log(`Currency: ${commodity.currency}`);
|
|
73
|
+
* console.log(`Category: ${commodity.category}`);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
async get(code) {
|
|
77
|
+
if (!code || typeof code !== "string") {
|
|
78
|
+
throw new Error("Commodity code must be a non-empty string");
|
|
79
|
+
}
|
|
80
|
+
return this.client["request"](`/v1/commodities/${code}`, {});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get all commodity categories with their commodities
|
|
84
|
+
*
|
|
85
|
+
* Returns commodities grouped by category (oil, gas, renewable, etc.).
|
|
86
|
+
* Useful for building navigation or filtering UIs.
|
|
87
|
+
*
|
|
88
|
+
* @returns Object with category keys mapped to category objects
|
|
89
|
+
*
|
|
90
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
91
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const categories = await client.commodities.categories();
|
|
96
|
+
*
|
|
97
|
+
* // Access by category key
|
|
98
|
+
* console.log(`Oil: ${categories.oil.name}`);
|
|
99
|
+
* console.log(`Commodities: ${categories.oil.commodities.length}`);
|
|
100
|
+
*
|
|
101
|
+
* // Iterate all categories
|
|
102
|
+
* Object.entries(categories).forEach(([key, category]) => {
|
|
103
|
+
* console.log(`${category.name}: ${category.commodities.length} commodities`);
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
async categories() {
|
|
108
|
+
return this.client["request"]("/v1/commodities/categories", {});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Quality Resource
|
|
3
|
+
*
|
|
4
|
+
* Access data quality metrics, reports, and monitoring for commodity price data.
|
|
5
|
+
*/
|
|
6
|
+
import type { OilPriceAPI } from "../client.js";
|
|
7
|
+
/**
|
|
8
|
+
* Data quality summary
|
|
9
|
+
*/
|
|
10
|
+
export interface DataQualitySummary {
|
|
11
|
+
/** Overall quality score (0-100) */
|
|
12
|
+
overall_score: number;
|
|
13
|
+
/** Total number of data sources monitored */
|
|
14
|
+
sources_monitored: number;
|
|
15
|
+
/** Number of sources with issues */
|
|
16
|
+
sources_with_issues: number;
|
|
17
|
+
/** Last update timestamp */
|
|
18
|
+
last_updated: string;
|
|
19
|
+
/** Quality breakdown by category */
|
|
20
|
+
breakdown: {
|
|
21
|
+
/** Completeness score (0-100) */
|
|
22
|
+
completeness: number;
|
|
23
|
+
/** Timeliness score (0-100) */
|
|
24
|
+
timeliness: number;
|
|
25
|
+
/** Accuracy score (0-100) */
|
|
26
|
+
accuracy: number;
|
|
27
|
+
/** Consistency score (0-100) */
|
|
28
|
+
consistency: number;
|
|
29
|
+
};
|
|
30
|
+
/** Recent alerts */
|
|
31
|
+
recent_alerts?: Array<{
|
|
32
|
+
/** Alert severity */
|
|
33
|
+
severity: "critical" | "warning" | "info";
|
|
34
|
+
/** Alert message */
|
|
35
|
+
message: string;
|
|
36
|
+
/** ISO timestamp */
|
|
37
|
+
timestamp: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Data quality report metadata
|
|
42
|
+
*/
|
|
43
|
+
export interface DataQualityReportMeta {
|
|
44
|
+
/** Report code */
|
|
45
|
+
code: string;
|
|
46
|
+
/** Report name */
|
|
47
|
+
name: string;
|
|
48
|
+
/** Report type */
|
|
49
|
+
type: string;
|
|
50
|
+
/** Data source or commodity covered */
|
|
51
|
+
scope: string;
|
|
52
|
+
/** Last generated timestamp */
|
|
53
|
+
last_generated: string;
|
|
54
|
+
/** Report status */
|
|
55
|
+
status: "healthy" | "warning" | "critical";
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Detailed data quality report
|
|
59
|
+
*/
|
|
60
|
+
export interface DataQualityReport {
|
|
61
|
+
/** Report code */
|
|
62
|
+
code: string;
|
|
63
|
+
/** Report name */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Data source or commodity */
|
|
66
|
+
scope: string;
|
|
67
|
+
/** Report period */
|
|
68
|
+
period: {
|
|
69
|
+
/** Start date */
|
|
70
|
+
start: string;
|
|
71
|
+
/** End date */
|
|
72
|
+
end: string;
|
|
73
|
+
};
|
|
74
|
+
/** Quality metrics */
|
|
75
|
+
metrics: {
|
|
76
|
+
/** Completeness (0-100) */
|
|
77
|
+
completeness: number;
|
|
78
|
+
/** Timeliness (0-100) */
|
|
79
|
+
timeliness: number;
|
|
80
|
+
/** Accuracy (0-100) */
|
|
81
|
+
accuracy: number;
|
|
82
|
+
/** Consistency (0-100) */
|
|
83
|
+
consistency: number;
|
|
84
|
+
/** Missing data points */
|
|
85
|
+
missing_points?: number;
|
|
86
|
+
/** Late updates */
|
|
87
|
+
late_updates?: number;
|
|
88
|
+
/** Anomalies detected */
|
|
89
|
+
anomalies?: number;
|
|
90
|
+
};
|
|
91
|
+
/** Issues found */
|
|
92
|
+
issues?: Array<{
|
|
93
|
+
/** Issue severity */
|
|
94
|
+
severity: "critical" | "warning" | "info";
|
|
95
|
+
/** Issue description */
|
|
96
|
+
description: string;
|
|
97
|
+
/** Affected data points */
|
|
98
|
+
affected_points?: number;
|
|
99
|
+
/** Detection timestamp */
|
|
100
|
+
detected_at: string;
|
|
101
|
+
}>;
|
|
102
|
+
/** Recommendations */
|
|
103
|
+
recommendations?: string[];
|
|
104
|
+
/** Generated timestamp */
|
|
105
|
+
generated_at: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Data Quality Resource
|
|
109
|
+
*
|
|
110
|
+
* Monitor data quality metrics and access detailed quality reports for
|
|
111
|
+
* commodity price data sources.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
116
|
+
*
|
|
117
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
118
|
+
*
|
|
119
|
+
* // Get quality summary
|
|
120
|
+
* const summary = await client.dataQuality.summary();
|
|
121
|
+
* console.log(`Overall quality: ${summary.overall_score}/100`);
|
|
122
|
+
* console.log(`Sources monitored: ${summary.sources_monitored}`);
|
|
123
|
+
*
|
|
124
|
+
* // Get all reports
|
|
125
|
+
* const reports = await client.dataQuality.reports();
|
|
126
|
+
* reports.forEach(report => {
|
|
127
|
+
* console.log(`${report.name}: ${report.status}`);
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export declare class DataQualityResource {
|
|
132
|
+
private client;
|
|
133
|
+
constructor(client: OilPriceAPI);
|
|
134
|
+
/**
|
|
135
|
+
* Get data quality summary
|
|
136
|
+
*
|
|
137
|
+
* Returns overall data quality metrics and recent alerts.
|
|
138
|
+
*
|
|
139
|
+
* @returns Data quality summary
|
|
140
|
+
*
|
|
141
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
142
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const summary = await client.dataQuality.summary();
|
|
147
|
+
*
|
|
148
|
+
* console.log(`Overall score: ${summary.overall_score}/100`);
|
|
149
|
+
* console.log(`Completeness: ${summary.breakdown.completeness}%`);
|
|
150
|
+
* console.log(`Timeliness: ${summary.breakdown.timeliness}%`);
|
|
151
|
+
* console.log(`Accuracy: ${summary.breakdown.accuracy}%`);
|
|
152
|
+
* console.log(`Consistency: ${summary.breakdown.consistency}%`);
|
|
153
|
+
*
|
|
154
|
+
* if (summary.recent_alerts && summary.recent_alerts.length > 0) {
|
|
155
|
+
* console.log('\nRecent Alerts:');
|
|
156
|
+
* summary.recent_alerts.forEach(alert => {
|
|
157
|
+
* console.log(`[${alert.severity.toUpperCase()}] ${alert.message}`);
|
|
158
|
+
* });
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
summary(): Promise<DataQualitySummary>;
|
|
163
|
+
/**
|
|
164
|
+
* Get all data quality reports
|
|
165
|
+
*
|
|
166
|
+
* Returns metadata for all available quality reports.
|
|
167
|
+
*
|
|
168
|
+
* @returns Array of report metadata
|
|
169
|
+
*
|
|
170
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
171
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const reports = await client.dataQuality.reports();
|
|
176
|
+
*
|
|
177
|
+
* console.log(`${reports.length} quality reports available:\n`);
|
|
178
|
+
* reports.forEach(report => {
|
|
179
|
+
* console.log(`${report.name}`);
|
|
180
|
+
* console.log(` Code: ${report.code}`);
|
|
181
|
+
* console.log(` Scope: ${report.scope}`);
|
|
182
|
+
* console.log(` Status: ${report.status}`);
|
|
183
|
+
* console.log(` Last generated: ${report.last_generated}\n`);
|
|
184
|
+
* });
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
reports(): Promise<DataQualityReportMeta[]>;
|
|
188
|
+
/**
|
|
189
|
+
* Get detailed data quality report
|
|
190
|
+
*
|
|
191
|
+
* Returns comprehensive quality analysis for a specific source or commodity.
|
|
192
|
+
*
|
|
193
|
+
* @param code - Report code (e.g., "WTI_USD", "BRENT_CRUDE_USD", "EIA")
|
|
194
|
+
* @returns Detailed quality report
|
|
195
|
+
*
|
|
196
|
+
* @throws {NotFoundError} If report code not found
|
|
197
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const report = await client.dataQuality.report('WTI_USD');
|
|
202
|
+
*
|
|
203
|
+
* console.log(`Report: ${report.name}`);
|
|
204
|
+
* console.log(`Scope: ${report.scope}`);
|
|
205
|
+
* console.log(`Period: ${report.period.start} to ${report.period.end}\n`);
|
|
206
|
+
*
|
|
207
|
+
* console.log('Metrics:');
|
|
208
|
+
* console.log(` Completeness: ${report.metrics.completeness}%`);
|
|
209
|
+
* console.log(` Timeliness: ${report.metrics.timeliness}%`);
|
|
210
|
+
* console.log(` Accuracy: ${report.metrics.accuracy}%`);
|
|
211
|
+
* console.log(` Consistency: ${report.metrics.consistency}%`);
|
|
212
|
+
*
|
|
213
|
+
* if (report.issues && report.issues.length > 0) {
|
|
214
|
+
* console.log('\nIssues:');
|
|
215
|
+
* report.issues.forEach(issue => {
|
|
216
|
+
* console.log(` [${issue.severity.toUpperCase()}] ${issue.description}`);
|
|
217
|
+
* });
|
|
218
|
+
* }
|
|
219
|
+
*
|
|
220
|
+
* if (report.recommendations && report.recommendations.length > 0) {
|
|
221
|
+
* console.log('\nRecommendations:');
|
|
222
|
+
* report.recommendations.forEach(rec => {
|
|
223
|
+
* console.log(` - ${rec}`);
|
|
224
|
+
* });
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
report(code: string): Promise<DataQualityReport>;
|
|
229
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Quality Resource
|
|
3
|
+
*
|
|
4
|
+
* Access data quality metrics, reports, and monitoring for commodity price data.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Data Quality Resource
|
|
8
|
+
*
|
|
9
|
+
* Monitor data quality metrics and access detailed quality reports for
|
|
10
|
+
* commodity price data sources.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { OilPriceAPI } from 'oilpriceapi';
|
|
15
|
+
*
|
|
16
|
+
* const client = new OilPriceAPI({ apiKey: 'your_key' });
|
|
17
|
+
*
|
|
18
|
+
* // Get quality summary
|
|
19
|
+
* const summary = await client.dataQuality.summary();
|
|
20
|
+
* console.log(`Overall quality: ${summary.overall_score}/100`);
|
|
21
|
+
* console.log(`Sources monitored: ${summary.sources_monitored}`);
|
|
22
|
+
*
|
|
23
|
+
* // Get all reports
|
|
24
|
+
* const reports = await client.dataQuality.reports();
|
|
25
|
+
* reports.forEach(report => {
|
|
26
|
+
* console.log(`${report.name}: ${report.status}`);
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export class DataQualityResource {
|
|
31
|
+
constructor(client) {
|
|
32
|
+
this.client = client;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get data quality summary
|
|
36
|
+
*
|
|
37
|
+
* Returns overall data quality metrics and recent alerts.
|
|
38
|
+
*
|
|
39
|
+
* @returns Data quality summary
|
|
40
|
+
*
|
|
41
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
42
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const summary = await client.dataQuality.summary();
|
|
47
|
+
*
|
|
48
|
+
* console.log(`Overall score: ${summary.overall_score}/100`);
|
|
49
|
+
* console.log(`Completeness: ${summary.breakdown.completeness}%`);
|
|
50
|
+
* console.log(`Timeliness: ${summary.breakdown.timeliness}%`);
|
|
51
|
+
* console.log(`Accuracy: ${summary.breakdown.accuracy}%`);
|
|
52
|
+
* console.log(`Consistency: ${summary.breakdown.consistency}%`);
|
|
53
|
+
*
|
|
54
|
+
* if (summary.recent_alerts && summary.recent_alerts.length > 0) {
|
|
55
|
+
* console.log('\nRecent Alerts:');
|
|
56
|
+
* summary.recent_alerts.forEach(alert => {
|
|
57
|
+
* console.log(`[${alert.severity.toUpperCase()}] ${alert.message}`);
|
|
58
|
+
* });
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
async summary() {
|
|
63
|
+
return this.client["request"]("/v1/data-quality/summary", {});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get all data quality reports
|
|
67
|
+
*
|
|
68
|
+
* Returns metadata for all available quality reports.
|
|
69
|
+
*
|
|
70
|
+
* @returns Array of report metadata
|
|
71
|
+
*
|
|
72
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
73
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const reports = await client.dataQuality.reports();
|
|
78
|
+
*
|
|
79
|
+
* console.log(`${reports.length} quality reports available:\n`);
|
|
80
|
+
* reports.forEach(report => {
|
|
81
|
+
* console.log(`${report.name}`);
|
|
82
|
+
* console.log(` Code: ${report.code}`);
|
|
83
|
+
* console.log(` Scope: ${report.scope}`);
|
|
84
|
+
* console.log(` Status: ${report.status}`);
|
|
85
|
+
* console.log(` Last generated: ${report.last_generated}\n`);
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
async reports() {
|
|
90
|
+
const response = await this.client["request"]("/v1/data-quality/reports", {});
|
|
91
|
+
return Array.isArray(response) ? response : response.reports;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get detailed data quality report
|
|
95
|
+
*
|
|
96
|
+
* Returns comprehensive quality analysis for a specific source or commodity.
|
|
97
|
+
*
|
|
98
|
+
* @param code - Report code (e.g., "WTI_USD", "BRENT_CRUDE_USD", "EIA")
|
|
99
|
+
* @returns Detailed quality report
|
|
100
|
+
*
|
|
101
|
+
* @throws {NotFoundError} If report code not found
|
|
102
|
+
* @throws {OilPriceAPIError} If API request fails
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const report = await client.dataQuality.report('WTI_USD');
|
|
107
|
+
*
|
|
108
|
+
* console.log(`Report: ${report.name}`);
|
|
109
|
+
* console.log(`Scope: ${report.scope}`);
|
|
110
|
+
* console.log(`Period: ${report.period.start} to ${report.period.end}\n`);
|
|
111
|
+
*
|
|
112
|
+
* console.log('Metrics:');
|
|
113
|
+
* console.log(` Completeness: ${report.metrics.completeness}%`);
|
|
114
|
+
* console.log(` Timeliness: ${report.metrics.timeliness}%`);
|
|
115
|
+
* console.log(` Accuracy: ${report.metrics.accuracy}%`);
|
|
116
|
+
* console.log(` Consistency: ${report.metrics.consistency}%`);
|
|
117
|
+
*
|
|
118
|
+
* if (report.issues && report.issues.length > 0) {
|
|
119
|
+
* console.log('\nIssues:');
|
|
120
|
+
* report.issues.forEach(issue => {
|
|
121
|
+
* console.log(` [${issue.severity.toUpperCase()}] ${issue.description}`);
|
|
122
|
+
* });
|
|
123
|
+
* }
|
|
124
|
+
*
|
|
125
|
+
* if (report.recommendations && report.recommendations.length > 0) {
|
|
126
|
+
* console.log('\nRecommendations:');
|
|
127
|
+
* report.recommendations.forEach(rec => {
|
|
128
|
+
* console.log(` - ${rec}`);
|
|
129
|
+
* });
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
async report(code) {
|
|
134
|
+
if (!code || typeof code !== "string") {
|
|
135
|
+
throw new Error("Report code must be a non-empty string");
|
|
136
|
+
}
|
|
137
|
+
return this.client["request"](`/v1/data-quality/reports/${code}`, {});
|
|
138
|
+
}
|
|
139
|
+
}
|