oilpriceapi 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +12 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/version.d.ts +18 -0
- package/dist/version.js +20 -0
- package/package.json +2 -1
package/dist/client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OilPriceAPIError, AuthenticationError, RateLimitError, NotFoundError, ServerError, TimeoutError, } from './errors.js';
|
|
2
2
|
import { DieselResource } from './resources/diesel.js';
|
|
3
3
|
import { AlertsResource } from './resources/alerts.js';
|
|
4
|
+
import { SDK_VERSION, SDK_NAME, buildUserAgent } from './version.js';
|
|
4
5
|
/**
|
|
5
6
|
* Official Node.js client for Oil Price API
|
|
6
7
|
*
|
|
@@ -126,9 +127,9 @@ export class OilPriceAPI {
|
|
|
126
127
|
headers: {
|
|
127
128
|
'Authorization': `Bearer ${this.apiKey}`,
|
|
128
129
|
'Content-Type': 'application/json',
|
|
129
|
-
'User-Agent':
|
|
130
|
-
'X-Api-Client':
|
|
131
|
-
'X-Client-Version':
|
|
130
|
+
'User-Agent': buildUserAgent(),
|
|
131
|
+
'X-Api-Client': SDK_NAME,
|
|
132
|
+
'X-Client-Version': SDK_VERSION,
|
|
132
133
|
},
|
|
133
134
|
signal: controller.signal,
|
|
134
135
|
});
|
|
@@ -293,7 +294,14 @@ export class OilPriceAPI {
|
|
|
293
294
|
if (options?.endDate) {
|
|
294
295
|
params.end_date = options.endDate;
|
|
295
296
|
}
|
|
296
|
-
|
|
297
|
+
// CRITICAL FIX (December 17, 2025):
|
|
298
|
+
// Use /v1/prices/past_year endpoint instead of /v1/prices
|
|
299
|
+
// The /v1/prices endpoint does NOT correctly handle start_date/end_date parameters
|
|
300
|
+
// This was the same bug that affected the Python SDK (fixed in v1.4.4)
|
|
301
|
+
// Issue: SDK was returning wrong dates for historical queries
|
|
302
|
+
// Root Cause: Backend has_scope :by_period not working on /v1/prices
|
|
303
|
+
// Solution: Use /v1/prices/past_year which uses direct WHERE clauses
|
|
304
|
+
return this.request('/v1/prices/past_year', params);
|
|
297
305
|
}
|
|
298
306
|
/**
|
|
299
307
|
* Get metadata for all supported commodities
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
export { OilPriceAPI } from './client.js';
|
|
9
|
+
export { SDK_VERSION, SDK_NAME } from './version.js';
|
|
9
10
|
export type { OilPriceAPIConfig, RetryStrategy, Price, LatestPricesOptions, HistoricalPricesOptions, HistoricalPeriod, Commodity, CommoditiesResponse, CommodityCategory, CategoriesResponse, } from './types.js';
|
|
10
11
|
export type { DieselPrice, DieselStation, DieselStationsResponse, GetDieselStationsOptions, } from './resources/diesel.js';
|
|
11
12
|
export type { PriceAlert, CreateAlertParams, UpdateAlertParams, AlertOperator, WebhookTestResponse, } from './resources/alerts.js';
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Version - centralized to ensure consistency across all headers
|
|
3
|
+
*
|
|
4
|
+
* This version must be updated when publishing a new release.
|
|
5
|
+
* It's used in:
|
|
6
|
+
* - User-Agent header: oilpriceapi-node/{version}
|
|
7
|
+
* - X-Client-Version header
|
|
8
|
+
* - Package.json (should match)
|
|
9
|
+
*/
|
|
10
|
+
export declare const SDK_VERSION = "0.5.3";
|
|
11
|
+
/**
|
|
12
|
+
* SDK identifier used in User-Agent and X-Api-Client headers
|
|
13
|
+
*/
|
|
14
|
+
export declare const SDK_NAME = "oilpriceapi-node";
|
|
15
|
+
/**
|
|
16
|
+
* Build the full User-Agent string
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildUserAgent(): string;
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Version - centralized to ensure consistency across all headers
|
|
3
|
+
*
|
|
4
|
+
* This version must be updated when publishing a new release.
|
|
5
|
+
* It's used in:
|
|
6
|
+
* - User-Agent header: oilpriceapi-node/{version}
|
|
7
|
+
* - X-Client-Version header
|
|
8
|
+
* - Package.json (should match)
|
|
9
|
+
*/
|
|
10
|
+
export const SDK_VERSION = '0.5.3';
|
|
11
|
+
/**
|
|
12
|
+
* SDK identifier used in User-Agent and X-Api-Client headers
|
|
13
|
+
*/
|
|
14
|
+
export const SDK_NAME = 'oilpriceapi-node';
|
|
15
|
+
/**
|
|
16
|
+
* Build the full User-Agent string
|
|
17
|
+
*/
|
|
18
|
+
export function buildUserAgent() {
|
|
19
|
+
return `${SDK_NAME}/${SDK_VERSION} node/${process.version}`;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oilpriceapi",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Official Node.js SDK for Oil Price API - Real-time and historical oil & commodity prices",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^20.10.0",
|
|
58
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
58
59
|
"typescript": "^5.3.0",
|
|
59
60
|
"vitest": "^1.0.0"
|
|
60
61
|
}
|