Socket
Socket
Sign inDemoInstall

openweather-api-node

Package Overview
Dependencies
2
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.2 to 3.0.0

dist/parsers/onecall/history-parser.d.ts

1

dist/constants.d.ts

@@ -6,2 +6,3 @@ export declare const SUP_LANGS: readonly ["af", "al", "ar", "az", "bg", "ca", "cz", "da", "de", "el", "en", "eu", "fa", "fi", "fr", "gl", "he", "hi", "hr", "hu", "id", "it", "ja", "kr", "la", "lt", "mk", "no", "nl", "pl", "pt", "pt_br", "ro", "ru", "sv", "se", "sk", "sl", "sp", "es", "sr", "th", "tr", "ua", "uk", "vi", "zh_cn", "zh_tw", "zu"];

export declare const DATA_PATH = "data/2.5";
export declare const DATA_3_PATH = "data/3.0";
export declare const WEATHER_PATH: string;

@@ -8,0 +9,0 @@ export declare const FORECAST_PATH: string;

5

dist/constants.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AIR_POLLUTION_PATH = exports.ONECALL_PATH = exports.FORECAST_PATH = exports.WEATHER_PATH = exports.DATA_PATH = exports.GEO_PATH = exports.API_ENDPOINT = exports.SUP_UNITS = exports.SUP_LANGS = void 0;
exports.AIR_POLLUTION_PATH = exports.ONECALL_PATH = exports.FORECAST_PATH = exports.WEATHER_PATH = exports.DATA_3_PATH = exports.DATA_PATH = exports.GEO_PATH = exports.API_ENDPOINT = exports.SUP_UNITS = exports.SUP_LANGS = void 0;
exports.SUP_LANGS = [

@@ -59,5 +59,6 @@ "af",

exports.DATA_PATH = "data/2.5";
exports.DATA_3_PATH = "data/3.0";
exports.WEATHER_PATH = exports.DATA_PATH + "/weather";
exports.FORECAST_PATH = exports.DATA_PATH + "/forecast";
exports.ONECALL_PATH = exports.DATA_PATH + "/onecall";
exports.ONECALL_PATH = exports.DATA_3_PATH + "/onecall";
exports.AIR_POLLUTION_PATH = exports.DATA_PATH + "/air_pollution";

@@ -1,2 +0,2 @@

import { Alert, Language, Location, Options, Unit, CurrentWeather, MinutelyWeather, HourlyWeather, DailyWeather, Everything, AirPollution, WeatherHistory, ForecastWeather } from "./types";
import { Alert, Language, Location, Options, Unit, CurrentWeather, MinutelyWeather, HourlyWeather, DailyWeather, HistoricalWeather, Everything, AirPollution, ForecastWeather } from "./types";
export declare class OpenWeatherAPI {

@@ -103,4 +103,3 @@ private globalOptions;

/**
* Getter for minutely weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for minutely weather
*

@@ -113,4 +112,3 @@ * @param limit - maximum length of returned array

/**
* Getter for hourly weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for hourly weather
*

@@ -123,4 +121,3 @@ * @param limit - maximum length of returned array

/**
* Getter for daily weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for daily weather
*

@@ -134,4 +131,3 @@ * @param limit - maximum length of returned array

/**
* Getter for today's weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for today's weather
*

@@ -144,4 +140,3 @@ * @param options - options used only for this call

* Getter for alerts\
* **Note:** some agencies provide the alert’s description only in a local language.\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* **Note:** some agencies provide the alert’s description only in a local language.
*

@@ -153,4 +148,3 @@ * @param options - options used only for this call

/**
* Getter for every type of weather call and alerts\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for every type of weather call and alerts
*

@@ -162,4 +156,3 @@ * @param options - options used only for this call

/**
* Getter for historical data about weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for historical data about weather
*

@@ -169,3 +162,3 @@ * @param dt - Date from the **previous five days** (Unix time, UTC time zone)

*/
getHistory(dt: Date | number | string, options?: Options): Promise<WeatherHistory>;
getHistory(dt: Date | number | string, options?: Options): Promise<HistoricalWeather>;
/**

@@ -172,0 +165,0 @@ * Getter for current data about air pollution

@@ -28,2 +28,3 @@ "use strict";

const daily_parser_1 = __importDefault(require("./parsers/onecall/daily-parser"));
const history_parser_1 = __importDefault(require("./parsers/onecall/history-parser"));
const single_parser_1 = __importDefault(require("./parsers/air-pollution/single-parser"));

@@ -291,4 +292,3 @@ const list_parser_1 = __importDefault(require("./parsers/air-pollution/list-parser"));

/**
* Getter for minutely weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for minutely weather
*

@@ -309,4 +309,3 @@ * @param limit - maximum length of returned array

/**
* Getter for hourly weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for hourly weather
*

@@ -327,4 +326,3 @@ * @param limit - maximum length of returned array

/**
* Getter for daily weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for daily weather
*

@@ -348,4 +346,3 @@ * @param limit - maximum length of returned array

/**
* Getter for today's weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for today's weather
*

@@ -360,4 +357,3 @@ * @param options - options used only for this call

* Getter for alerts\
* **Note:** some agencies provide the alert’s description only in a local language.\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* **Note:** some agencies provide the alert’s description only in a local language.
*

@@ -377,4 +373,3 @@ * @param options - options used only for this call

/**
* Getter for every type of weather call and alerts\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for every type of weather call and alerts
*

@@ -402,4 +397,3 @@ * @param options - options used only for this call

/**
* Getter for historical data about weather\
* ⚠️ This method uses the old OneCall api endpoint. See [this](https://lolotoster.github.io/openweather-api-node/#old-onecall-api-endpoint) for more information.
* Getter for historical data about weather
*

@@ -419,10 +413,3 @@ * @param dt - Date from the **previous five days** (Unix time, UTC time zone)

let data = response.data;
return {
lat: data.lat,
lon: data.lon,
timezone: data.timezone,
timezoneOffset: data.timezone_offset,
current: (0, current_parser_2.default)(data),
hourly: (0, hourly_parser_1.default)(data, Number.POSITIVE_INFINITY),
};
return (0, history_parser_1.default)(data);
}

@@ -429,0 +416,0 @@ // Uncategorized Methods

@@ -10,4 +10,4 @@ "use strict";

dtRaw: data.current.dt,
timezone: undefined,
timezoneOffset: data.timezone,
timezone: data.timezone,
timezoneOffset: data.timezone_offset,
astronomical: {

@@ -14,0 +14,0 @@ sunrise: new Date(data.current.sunrise * 1000),

@@ -10,4 +10,4 @@ "use strict";

dtRaw: data.dt,
timezone: data.timezone,
timezoneOffset: data.timezone_offset,
timezone: undefined,
timezoneOffset: data.timezone,
astronomical: {

@@ -14,0 +14,0 @@ sunrise: new Date(data.sys.sunrise * 1000),

@@ -6,2 +6,3 @@ import { CurrentWeather } from "./current";

import { DailyWeather } from "./daily";
import { HistoricalWeather } from "./historical";
export * from "./current";

@@ -12,2 +13,3 @@ export * from "./forecast";

export * from "./daily";
export * from "./historical";
export interface Alert {

@@ -75,3 +77,3 @@ /**

/**
* Date and time, Unix, UTC
* Timezone name for the requested location
*/

@@ -84,3 +86,3 @@ timezone: string | undefined;

}
export type Weather = WeatherBase & CurrentWeather & ForecastWeather & MinutelyWeather & HourlyWeather & DailyWeather;
export type Weather = WeatherBase & CurrentWeather & ForecastWeather & MinutelyWeather & HourlyWeather & DailyWeather & HistoricalWeather;
export interface Everything {

@@ -97,9 +99,1 @@ lat: number;

}
export interface WeatherHistory {
lat: number;
lon: number;
timezone: string;
timezoneOffset: number;
current: CurrentWeather;
hourly: HourlyWeather[];
}

@@ -22,1 +22,2 @@ "use strict";

__exportStar(require("./daily"), exports);
__exportStar(require("./historical"), exports);
{
"name": "openweather-api-node",
"version": "2.1.2",
"version": "3.0.0",
"description": "Simple Node.js package that makes it easy to work with OpenWeather API",

@@ -16,3 +16,3 @@ "main": "dist/index.js",

"build:esm": "gen-esm-wrapper ./dist/index.js ./dist/index.mjs",
"docs": "typedoc ./src/index.ts --out ./docs --media ./media --customCss ./media/style.css",
"docs": "typedoc --plugin typedoc-plugin-extras ./src/index.ts --out ./docs --media ./media --customCss ./media/style.css --favicon ./media/favicon.ico",
"docs:deploy": "gh-pages -d ./docs"

@@ -43,3 +43,4 @@ },

"ts-node": "^10.9.1",
"typedoc": "^0.23.22",
"typedoc": "^0.24.4",
"typedoc-plugin-extras": "^2.3.3",
"typescript": "^4.9.4"

@@ -46,0 +47,0 @@ },

@@ -38,3 +38,3 @@ <br>

* Geocoding - get location **latitude and longitude from its name** and vice versa
* Historical - get weather from **previous 5 days**
* Historical - get weather data for **more that 40 years back**
* Air pollution - get **current, forecasted and historical data about air pollution**

@@ -92,3 +92,3 @@

# [Documentation for v2](https://lolotoster.github.io/openweather-api-node/)
# [Documentation for v2 & v3](https://lolotoster.github.io/openweather-api-node/)

@@ -99,4 +99,8 @@ [Documentation for older versions](https://github.com/loloToster/openweather-api-node/blob/829077b6653ffcde4736f3c7aec259e222c9d395/README.md)

#### Old OneCall api endpoint
#### Old OneCall API support
⚠️This package uses the OneCall v2 api endpoint and some of the methods like `getMinutelyForecast` or `getAlerts` will not work with API keys created after the introduction of OneCall v3 api. Support for version 3 is is planned to be a part of `openweather-api-node@3.0.0`
This package partially uses the OneCall 3.0 api endpoint. If you want to use older version of the OneCall api you can install the latest version of the package that supported it:
```
npm i openweather-api-node@2.1.2
```

@@ -77,12 +77,6 @@ import fs from "fs";

await expect(
weather.getHistory(new Date().getTime() + 900000)
weather.getHistory(new Date().getTime() + 365 * 24 * 60 * 60 * 1000)
).rejects.toThrow(/requested time is in the future/i);
});
it("handles not within 5 days in history", async () => {
await expect(
weather.getHistory(new Date().getTime() - 6 * 24 * 60 * 60 * 1000)
).rejects.toThrow(/requested time is out of allowed range of 5 days back/i);
});
it("handles no time in history", async () => {

@@ -89,0 +83,0 @@ await expect(

@@ -117,3 +117,3 @@ import fs from "fs";

let history = await weather.getHistory(date);
expect(Math.round(date / 1000)).toBe(history.current.dtRaw);
expect(Math.round(date / 1000)).toBe(history.dtRaw);
});

@@ -120,0 +120,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc