@mharj/openweathermap 0.0.8 → 0.1.1
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/index.d.mts +21 -28
- package/dist/index.d.ts +21 -28
- package/dist/index.js +36 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +43 -64
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IOption, IResult } from '@luolapeikko/result-option';
|
|
2
1
|
import { IAsyncCache } from '@luolapeikko/cache-types';
|
|
2
|
+
import { IOption, IResult } from '@luolapeikko/result-option';
|
|
3
|
+
import { Loadable } from '@luolapeikko/ts-common';
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -509,23 +510,6 @@ type WeatherDataV2 = z.infer<typeof weatherDataV2Schema>;
|
|
|
509
510
|
declare function isWeatherDataV2(data: unknown): data is WeatherDataV2;
|
|
510
511
|
declare function assertWeatherDataV2(data: unknown): asserts data is WeatherDataV2;
|
|
511
512
|
|
|
512
|
-
declare const CountryCodeList: readonly ["af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cw", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"];
|
|
513
|
-
/**
|
|
514
|
-
* @internal
|
|
515
|
-
*/
|
|
516
|
-
declare const CountryCodeSchema: z.ZodEnum<["af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cw", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"]>;
|
|
517
|
-
type CountryCode = z.infer<typeof CountryCodeSchema>;
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Generic argument which can be value, Promise of value, function which returns value or Promise of value.
|
|
521
|
-
* @example
|
|
522
|
-
* function solveLoadable(value: Loadable<string>): string | Promise<string> {
|
|
523
|
-
* return typeof value === 'function' ? value() : value;
|
|
524
|
-
* }
|
|
525
|
-
*/
|
|
526
|
-
type Loadable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
527
|
-
declare function solveLoadable(value: Loadable<string>): string | Promise<string>;
|
|
528
|
-
|
|
529
513
|
/**
|
|
530
514
|
* Interface for OpenWeatherMap API v2 implementation.
|
|
531
515
|
*/
|
|
@@ -533,21 +517,29 @@ interface IOpenWeatherV2 {
|
|
|
533
517
|
dataWeatherApi: (params: URLSearchParams) => Promise<IResult<WeatherDataV2, SyntaxError | TypeError>>;
|
|
534
518
|
}
|
|
535
519
|
|
|
520
|
+
declare const CountryCodeList: readonly ["af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cw", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"];
|
|
521
|
+
/**
|
|
522
|
+
* @internal
|
|
523
|
+
*/
|
|
524
|
+
declare const CountryCodeSchema: z.ZodEnum<["af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cw", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"]>;
|
|
525
|
+
type CountryCode = z.infer<typeof CountryCodeSchema>;
|
|
526
|
+
|
|
536
527
|
/**
|
|
537
528
|
* Open Weather V2 API Common Options
|
|
538
529
|
* @default {lang: 'en', units: 'standard'} in API
|
|
539
530
|
* @example
|
|
540
531
|
* {lang: 'fi', units: 'metric'}
|
|
532
|
+
* @since v0.0.1
|
|
541
533
|
*/
|
|
542
534
|
type OpenWeatherV2CommonOptions = {
|
|
543
535
|
/**
|
|
544
536
|
* Language code
|
|
545
537
|
*/
|
|
546
|
-
lang
|
|
538
|
+
lang: LangCode;
|
|
547
539
|
/**
|
|
548
540
|
* Weather units
|
|
549
541
|
*/
|
|
550
|
-
units
|
|
542
|
+
units: 'standard' | 'metric' | 'imperial';
|
|
551
543
|
};
|
|
552
544
|
/**
|
|
553
545
|
* Open Weather V2 API
|
|
@@ -571,6 +563,7 @@ type OpenWeatherV2CommonOptions = {
|
|
|
571
563
|
* } else {
|
|
572
564
|
* const err: DOMException | TypeError = data.err();
|
|
573
565
|
* }
|
|
566
|
+
* @since v0.0.1
|
|
574
567
|
*/
|
|
575
568
|
declare class OpenWeatherV2 {
|
|
576
569
|
private cache;
|
|
@@ -587,7 +580,7 @@ declare class OpenWeatherV2 {
|
|
|
587
580
|
/**
|
|
588
581
|
* get weather by Id
|
|
589
582
|
* @param {number} id - Weather station ID
|
|
590
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
583
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
591
584
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
592
585
|
* @example
|
|
593
586
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherResultById(id: 564, {lang: 'fi'});
|
|
@@ -597,12 +590,12 @@ declare class OpenWeatherV2 {
|
|
|
597
590
|
* const error: DOMException | TypeError = result.err();
|
|
598
591
|
* }
|
|
599
592
|
*/
|
|
600
|
-
getWeatherById(id: number,
|
|
593
|
+
getWeatherById(id: number, currentOpts?: Partial<OpenWeatherV2CommonOptions>): Promise<IResult<WeatherDataV2, DOMException | TypeError>>;
|
|
601
594
|
/**
|
|
602
595
|
* get weather with city name and optional country code
|
|
603
596
|
* @param {string} city - City name
|
|
604
597
|
* @param {countryCode=} countryCode - Optional Country code
|
|
605
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
598
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
606
599
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
607
600
|
* @example
|
|
608
601
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByCity('Helsinki', 'fi', {lang: 'fi'});
|
|
@@ -612,12 +605,12 @@ declare class OpenWeatherV2 {
|
|
|
612
605
|
* const error: DOMException | TypeError = result.err();
|
|
613
606
|
* }
|
|
614
607
|
*/
|
|
615
|
-
getWeatherByCity(city: string, countryCode?: CountryCode,
|
|
608
|
+
getWeatherByCity(city: string, countryCode?: CountryCode, currentOpts?: Partial<OpenWeatherV2CommonOptions>): Promise<IResult<WeatherDataV2, DOMException | TypeError>>;
|
|
616
609
|
/**
|
|
617
610
|
* get weather with latitude and longitude with Result
|
|
618
611
|
* @param {number} lat - Latitude
|
|
619
612
|
* @param {number} lon - Longitude
|
|
620
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
613
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
621
614
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
622
615
|
* @example
|
|
623
616
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByLatLon(60.1699, 24.9384, {lang: 'fi'});
|
|
@@ -627,13 +620,13 @@ declare class OpenWeatherV2 {
|
|
|
627
620
|
* const error: DOMException | TypeError = result.err();
|
|
628
621
|
* }
|
|
629
622
|
*/
|
|
630
|
-
getWeatherByLatLon(lat: number, lon: number,
|
|
623
|
+
getWeatherByLatLon(lat: number, lon: number, currentOpts?: Partial<OpenWeatherV2CommonOptions>): Promise<IResult<WeatherDataV2, DOMException | TypeError>>;
|
|
631
624
|
private buildBaseParams;
|
|
632
625
|
/**
|
|
633
626
|
* build base cache key
|
|
634
627
|
* @param main - main cache key prefix
|
|
635
628
|
* @param opts - OpenWeatherV2CommonOptions
|
|
636
|
-
* @returns {
|
|
629
|
+
* @returns {string} cache key
|
|
637
630
|
*/
|
|
638
631
|
private buildBaseCacheKey;
|
|
639
632
|
private handleFetch;
|
|
@@ -645,4 +638,4 @@ declare class OpenWeatherV2 {
|
|
|
645
638
|
*/
|
|
646
639
|
declare function fetchErrorWrapper(err: unknown): DOMException | TypeError;
|
|
647
640
|
|
|
648
|
-
export { type CountryCode, CountryCodeList, CountryCodeSchema, type DayIcon, type IOpenWeatherV2, type Icon, type LangCode, type
|
|
641
|
+
export { type CountryCode, CountryCodeList, CountryCodeSchema, type DayIcon, type IOpenWeatherV2, type Icon, type LangCode, type NightIcon, OpenWeatherV2, type OpenWeatherV2CommonOptions, type WeatherDataV2, type WeatherDescription, type WeatherGroup, type WeatherID, assertWeatherDataV2, fetchErrorWrapper, getWeatherV2Description, iconSchema, isWeatherDataV2, langCodeSchema, langCodes, weatherDataV2Schema, weatherIdGroup, weatherIdSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IOption, IResult } from '@luolapeikko/result-option';
|
|
2
1
|
import { IAsyncCache } from '@luolapeikko/cache-types';
|
|
2
|
+
import { IOption, IResult } from '@luolapeikko/result-option';
|
|
3
|
+
import { Loadable } from '@luolapeikko/ts-common';
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -509,23 +510,6 @@ type WeatherDataV2 = z.infer<typeof weatherDataV2Schema>;
|
|
|
509
510
|
declare function isWeatherDataV2(data: unknown): data is WeatherDataV2;
|
|
510
511
|
declare function assertWeatherDataV2(data: unknown): asserts data is WeatherDataV2;
|
|
511
512
|
|
|
512
|
-
declare const CountryCodeList: readonly ["af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cw", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"];
|
|
513
|
-
/**
|
|
514
|
-
* @internal
|
|
515
|
-
*/
|
|
516
|
-
declare const CountryCodeSchema: z.ZodEnum<["af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cw", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"]>;
|
|
517
|
-
type CountryCode = z.infer<typeof CountryCodeSchema>;
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Generic argument which can be value, Promise of value, function which returns value or Promise of value.
|
|
521
|
-
* @example
|
|
522
|
-
* function solveLoadable(value: Loadable<string>): string | Promise<string> {
|
|
523
|
-
* return typeof value === 'function' ? value() : value;
|
|
524
|
-
* }
|
|
525
|
-
*/
|
|
526
|
-
type Loadable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
527
|
-
declare function solveLoadable(value: Loadable<string>): string | Promise<string>;
|
|
528
|
-
|
|
529
513
|
/**
|
|
530
514
|
* Interface for OpenWeatherMap API v2 implementation.
|
|
531
515
|
*/
|
|
@@ -533,21 +517,29 @@ interface IOpenWeatherV2 {
|
|
|
533
517
|
dataWeatherApi: (params: URLSearchParams) => Promise<IResult<WeatherDataV2, SyntaxError | TypeError>>;
|
|
534
518
|
}
|
|
535
519
|
|
|
520
|
+
declare const CountryCodeList: readonly ["af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cw", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"];
|
|
521
|
+
/**
|
|
522
|
+
* @internal
|
|
523
|
+
*/
|
|
524
|
+
declare const CountryCodeSchema: z.ZodEnum<["af", "ax", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "bq", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cw", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"]>;
|
|
525
|
+
type CountryCode = z.infer<typeof CountryCodeSchema>;
|
|
526
|
+
|
|
536
527
|
/**
|
|
537
528
|
* Open Weather V2 API Common Options
|
|
538
529
|
* @default {lang: 'en', units: 'standard'} in API
|
|
539
530
|
* @example
|
|
540
531
|
* {lang: 'fi', units: 'metric'}
|
|
532
|
+
* @since v0.0.1
|
|
541
533
|
*/
|
|
542
534
|
type OpenWeatherV2CommonOptions = {
|
|
543
535
|
/**
|
|
544
536
|
* Language code
|
|
545
537
|
*/
|
|
546
|
-
lang
|
|
538
|
+
lang: LangCode;
|
|
547
539
|
/**
|
|
548
540
|
* Weather units
|
|
549
541
|
*/
|
|
550
|
-
units
|
|
542
|
+
units: 'standard' | 'metric' | 'imperial';
|
|
551
543
|
};
|
|
552
544
|
/**
|
|
553
545
|
* Open Weather V2 API
|
|
@@ -571,6 +563,7 @@ type OpenWeatherV2CommonOptions = {
|
|
|
571
563
|
* } else {
|
|
572
564
|
* const err: DOMException | TypeError = data.err();
|
|
573
565
|
* }
|
|
566
|
+
* @since v0.0.1
|
|
574
567
|
*/
|
|
575
568
|
declare class OpenWeatherV2 {
|
|
576
569
|
private cache;
|
|
@@ -587,7 +580,7 @@ declare class OpenWeatherV2 {
|
|
|
587
580
|
/**
|
|
588
581
|
* get weather by Id
|
|
589
582
|
* @param {number} id - Weather station ID
|
|
590
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
583
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
591
584
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
592
585
|
* @example
|
|
593
586
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherResultById(id: 564, {lang: 'fi'});
|
|
@@ -597,12 +590,12 @@ declare class OpenWeatherV2 {
|
|
|
597
590
|
* const error: DOMException | TypeError = result.err();
|
|
598
591
|
* }
|
|
599
592
|
*/
|
|
600
|
-
getWeatherById(id: number,
|
|
593
|
+
getWeatherById(id: number, currentOpts?: Partial<OpenWeatherV2CommonOptions>): Promise<IResult<WeatherDataV2, DOMException | TypeError>>;
|
|
601
594
|
/**
|
|
602
595
|
* get weather with city name and optional country code
|
|
603
596
|
* @param {string} city - City name
|
|
604
597
|
* @param {countryCode=} countryCode - Optional Country code
|
|
605
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
598
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
606
599
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
607
600
|
* @example
|
|
608
601
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByCity('Helsinki', 'fi', {lang: 'fi'});
|
|
@@ -612,12 +605,12 @@ declare class OpenWeatherV2 {
|
|
|
612
605
|
* const error: DOMException | TypeError = result.err();
|
|
613
606
|
* }
|
|
614
607
|
*/
|
|
615
|
-
getWeatherByCity(city: string, countryCode?: CountryCode,
|
|
608
|
+
getWeatherByCity(city: string, countryCode?: CountryCode, currentOpts?: Partial<OpenWeatherV2CommonOptions>): Promise<IResult<WeatherDataV2, DOMException | TypeError>>;
|
|
616
609
|
/**
|
|
617
610
|
* get weather with latitude and longitude with Result
|
|
618
611
|
* @param {number} lat - Latitude
|
|
619
612
|
* @param {number} lon - Longitude
|
|
620
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
613
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
621
614
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
622
615
|
* @example
|
|
623
616
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByLatLon(60.1699, 24.9384, {lang: 'fi'});
|
|
@@ -627,13 +620,13 @@ declare class OpenWeatherV2 {
|
|
|
627
620
|
* const error: DOMException | TypeError = result.err();
|
|
628
621
|
* }
|
|
629
622
|
*/
|
|
630
|
-
getWeatherByLatLon(lat: number, lon: number,
|
|
623
|
+
getWeatherByLatLon(lat: number, lon: number, currentOpts?: Partial<OpenWeatherV2CommonOptions>): Promise<IResult<WeatherDataV2, DOMException | TypeError>>;
|
|
631
624
|
private buildBaseParams;
|
|
632
625
|
/**
|
|
633
626
|
* build base cache key
|
|
634
627
|
* @param main - main cache key prefix
|
|
635
628
|
* @param opts - OpenWeatherV2CommonOptions
|
|
636
|
-
* @returns {
|
|
629
|
+
* @returns {string} cache key
|
|
637
630
|
*/
|
|
638
631
|
private buildBaseCacheKey;
|
|
639
632
|
private handleFetch;
|
|
@@ -645,4 +638,4 @@ declare class OpenWeatherV2 {
|
|
|
645
638
|
*/
|
|
646
639
|
declare function fetchErrorWrapper(err: unknown): DOMException | TypeError;
|
|
647
640
|
|
|
648
|
-
export { type CountryCode, CountryCodeList, CountryCodeSchema, type DayIcon, type IOpenWeatherV2, type Icon, type LangCode, type
|
|
641
|
+
export { type CountryCode, CountryCodeList, CountryCodeSchema, type DayIcon, type IOpenWeatherV2, type Icon, type LangCode, type NightIcon, OpenWeatherV2, type OpenWeatherV2CommonOptions, type WeatherDataV2, type WeatherDescription, type WeatherGroup, type WeatherID, assertWeatherDataV2, fetchErrorWrapper, getWeatherV2Description, iconSchema, isWeatherDataV2, langCodeSchema, langCodes, weatherDataV2Schema, weatherIdGroup, weatherIdSchema };
|
package/dist/index.js
CHANGED
|
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
CountryCodeList: () => CountryCodeList,
|
|
24
24
|
CountryCodeSchema: () => CountryCodeSchema,
|
|
25
25
|
OpenWeatherV2: () => OpenWeatherV2,
|
|
@@ -30,12 +30,26 @@ __export(src_exports, {
|
|
|
30
30
|
isWeatherDataV2: () => isWeatherDataV2,
|
|
31
31
|
langCodeSchema: () => langCodeSchema,
|
|
32
32
|
langCodes: () => langCodes,
|
|
33
|
-
solveLoadable: () => solveLoadable,
|
|
34
33
|
weatherDataV2Schema: () => weatherDataV2Schema,
|
|
35
34
|
weatherIdGroup: () => weatherIdGroup,
|
|
36
35
|
weatherIdSchema: () => weatherIdSchema
|
|
37
36
|
});
|
|
38
|
-
module.exports = __toCommonJS(
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
|
|
39
|
+
// src/OpenWeatherV2.ts
|
|
40
|
+
var import_result_option2 = require("@luolapeikko/result-option");
|
|
41
|
+
|
|
42
|
+
// src/lib/fetchUtils.ts
|
|
43
|
+
function fetchErrorWrapper(err) {
|
|
44
|
+
if (err instanceof DOMException || err instanceof TypeError) {
|
|
45
|
+
return err;
|
|
46
|
+
} else {
|
|
47
|
+
return new TypeError(`Unknown error: ${String(err)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/types/v2/index.ts
|
|
52
|
+
var import_zod4 = require("zod");
|
|
39
53
|
|
|
40
54
|
// src/types/v2/Icon.ts
|
|
41
55
|
var import_zod = require("zod");
|
|
@@ -338,9 +352,6 @@ function getWeatherV2Description(id) {
|
|
|
338
352
|
return (0, import_result_option.undefinedOptionWrap)(weatherIdGroup.find((x) => x.id === id)?.description);
|
|
339
353
|
}
|
|
340
354
|
|
|
341
|
-
// src/types/v2/index.ts
|
|
342
|
-
var import_zod4 = require("zod");
|
|
343
|
-
|
|
344
355
|
// src/types/v2/Language.ts
|
|
345
356
|
var import_zod3 = require("zod");
|
|
346
357
|
var langCodes = [
|
|
@@ -714,23 +725,6 @@ var CountryCodeList = [
|
|
|
714
725
|
];
|
|
715
726
|
var CountryCodeSchema = import_zod5.z.enum(CountryCodeList);
|
|
716
727
|
|
|
717
|
-
// src/types/index.ts
|
|
718
|
-
function solveLoadable(value) {
|
|
719
|
-
return typeof value === "function" ? value() : value;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
// src/OpenWeatherV2.ts
|
|
723
|
-
var import_result_option2 = require("@luolapeikko/result-option");
|
|
724
|
-
|
|
725
|
-
// src/lib/fetchUtils.ts
|
|
726
|
-
function fetchErrorWrapper(err) {
|
|
727
|
-
if (err instanceof DOMException || err instanceof TypeError) {
|
|
728
|
-
return err;
|
|
729
|
-
} else {
|
|
730
|
-
return new TypeError(`Unknown error: ${String(err)}`);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
728
|
// src/OpenWeatherV2.ts
|
|
735
729
|
var fetchResult = (0, import_result_option2.safeAsyncResultBuilder)(fetch);
|
|
736
730
|
function toParams(data) {
|
|
@@ -741,11 +735,18 @@ function toParams(data) {
|
|
|
741
735
|
}
|
|
742
736
|
function isJson(response) {
|
|
743
737
|
const contentType = response.headers.get("content-type");
|
|
744
|
-
return contentType
|
|
738
|
+
return contentType?.startsWith("application/json") ?? false;
|
|
745
739
|
}
|
|
746
740
|
function isOpenWeatherError(data) {
|
|
747
741
|
return typeof data === "object" && data !== null && "cod" in data && "message" in data;
|
|
748
742
|
}
|
|
743
|
+
var defaultCommonOptions = {
|
|
744
|
+
lang: "en",
|
|
745
|
+
units: "standard"
|
|
746
|
+
};
|
|
747
|
+
function buildOpts(opts) {
|
|
748
|
+
return Object.assign({}, defaultCommonOptions, opts);
|
|
749
|
+
}
|
|
749
750
|
var basePath = "https://api.openweathermap.org/data/2.5/weather";
|
|
750
751
|
function buildUrl(params) {
|
|
751
752
|
return `${basePath}?${params.toString()}`;
|
|
@@ -803,7 +804,7 @@ var OpenWeatherV2 = class {
|
|
|
803
804
|
/**
|
|
804
805
|
* get weather by Id
|
|
805
806
|
* @param {number} id - Weather station ID
|
|
806
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
807
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
807
808
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
808
809
|
* @example
|
|
809
810
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherResultById(id: 564, {lang: 'fi'});
|
|
@@ -813,8 +814,9 @@ var OpenWeatherV2 = class {
|
|
|
813
814
|
* const error: DOMException | TypeError = result.err();
|
|
814
815
|
* }
|
|
815
816
|
*/
|
|
816
|
-
async getWeatherById(id,
|
|
817
|
+
async getWeatherById(id, currentOpts = {}) {
|
|
817
818
|
try {
|
|
819
|
+
const opts = buildOpts(currentOpts);
|
|
818
820
|
const cacheKey = this.buildBaseCacheKey(`id:${id}`, opts);
|
|
819
821
|
let cacheEntry = this.cache && await this.cache.get(cacheKey);
|
|
820
822
|
if (!cacheEntry) {
|
|
@@ -831,7 +833,7 @@ var OpenWeatherV2 = class {
|
|
|
831
833
|
* get weather with city name and optional country code
|
|
832
834
|
* @param {string} city - City name
|
|
833
835
|
* @param {countryCode=} countryCode - Optional Country code
|
|
834
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
836
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
835
837
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
836
838
|
* @example
|
|
837
839
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByCity('Helsinki', 'fi', {lang: 'fi'});
|
|
@@ -841,8 +843,9 @@ var OpenWeatherV2 = class {
|
|
|
841
843
|
* const error: DOMException | TypeError = result.err();
|
|
842
844
|
* }
|
|
843
845
|
*/
|
|
844
|
-
async getWeatherByCity(city, countryCode,
|
|
846
|
+
async getWeatherByCity(city, countryCode, currentOpts = {}) {
|
|
845
847
|
try {
|
|
848
|
+
const opts = buildOpts(currentOpts);
|
|
846
849
|
const cacheKey = this.buildBaseCacheKey(`q:${city}:${countryCode}`, opts);
|
|
847
850
|
let cacheEntry = this.cache && await this.cache.get(cacheKey);
|
|
848
851
|
if (!cacheEntry) {
|
|
@@ -859,7 +862,7 @@ var OpenWeatherV2 = class {
|
|
|
859
862
|
* get weather with latitude and longitude with Result
|
|
860
863
|
* @param {number} lat - Latitude
|
|
861
864
|
* @param {number} lon - Longitude
|
|
862
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
865
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
863
866
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
864
867
|
* @example
|
|
865
868
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByLatLon(60.1699, 24.9384, {lang: 'fi'});
|
|
@@ -869,8 +872,9 @@ var OpenWeatherV2 = class {
|
|
|
869
872
|
* const error: DOMException | TypeError = result.err();
|
|
870
873
|
* }
|
|
871
874
|
*/
|
|
872
|
-
async getWeatherByLatLon(lat, lon,
|
|
875
|
+
async getWeatherByLatLon(lat, lon, currentOpts = {}) {
|
|
873
876
|
try {
|
|
877
|
+
const opts = buildOpts(currentOpts);
|
|
874
878
|
const cacheKey = this.buildBaseCacheKey(`latlon:${lat}:${lon}`, opts);
|
|
875
879
|
let cacheEntry = this.cache && await this.cache.get(cacheKey);
|
|
876
880
|
if (!cacheEntry) {
|
|
@@ -894,7 +898,7 @@ var OpenWeatherV2 = class {
|
|
|
894
898
|
* build base cache key
|
|
895
899
|
* @param main - main cache key prefix
|
|
896
900
|
* @param opts - OpenWeatherV2CommonOptions
|
|
897
|
-
* @returns {
|
|
901
|
+
* @returns {string} cache key
|
|
898
902
|
*/
|
|
899
903
|
buildBaseCacheKey(main, { lang, units }) {
|
|
900
904
|
return `${main}:${lang}:${units}`;
|
|
@@ -931,7 +935,6 @@ var OpenWeatherV2 = class {
|
|
|
931
935
|
isWeatherDataV2,
|
|
932
936
|
langCodeSchema,
|
|
933
937
|
langCodes,
|
|
934
|
-
solveLoadable,
|
|
935
938
|
weatherDataV2Schema,
|
|
936
939
|
weatherIdGroup,
|
|
937
940
|
weatherIdSchema
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/types/v2/Icon.ts","../src/types/v2/weatherIdGroup.ts","../src/types/v2/index.ts","../src/types/v2/Language.ts","../src/types/ISO3166-Countries.ts","../src/types/index.ts","../src/OpenWeatherV2.ts","../src/lib/fetchUtils.ts"],"sourcesContent":["export * from './OpenWeatherV2';\nexport * from './types';\nexport * from './lib';\nexport * from './interfaces';\n","import {z} from 'zod';\nconst dayIconList = ['01d', '02d', '03d', '04d', '09d', '10d', '11d', '13d', '50d'] as const;\n\n/**\n * @internal\n */\nconst dayIconListSchema = z.enum(dayIconList);\n\nexport type DayIcon = z.infer<typeof dayIconListSchema>;\n\nconst nightIconList = ['01n', '02n', '03n', '04n', '09n', '10n', '11n', '13n', '50n'] as const;\n\n/**\n * @internal\n */\nconst nightIconListSchema = z.enum(nightIconList);\nexport type NightIcon = z.infer<typeof nightIconListSchema>;\n\n/**\n * @internal\n */\nexport const iconSchema = z.union([dayIconListSchema, nightIconListSchema]);\n\nexport type Icon = z.infer<typeof iconSchema>;\n","import {type IOption, undefinedOptionWrap} from '@luolapeikko/result-option';\nimport {z} from 'zod';\n\n/**\n * This is a list of weather ids, groups and descriptions from OpenWeatherMap API\n */\nexport const weatherIdGroup = [\n\t{\n\t\tid: 200,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_light_rain',\n\t},\n\t{\n\t\tid: 201,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_rain',\n\t},\n\t{\n\t\tid: 202,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_heavy_rain',\n\t},\n\t{\n\t\tid: 210,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'light_thunderstorm',\n\t},\n\t{\n\t\tid: 211,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm',\n\t},\n\t{\n\t\tid: 212,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'heavy_thunderstorm',\n\t},\n\t{\n\t\tid: 221,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'ragged_thunderstorm',\n\t},\n\t{\n\t\tid: 230,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_light_drizzle',\n\t},\n\t{\n\t\tid: 231,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_drizzle',\n\t},\n\t{\n\t\tid: 232,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_heavy_drizzle',\n\t},\n\t{\n\t\tid: 300,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'light_intensity_drizzle',\n\t},\n\t{\n\t\tid: 301,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'drizzle',\n\t},\n\t{\n\t\tid: 302,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_intensity_drizzle',\n\t},\n\t{\n\t\tid: 310,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'light_intensity_drizzle_rain',\n\t},\n\t{\n\t\tid: 311,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'drizzle_rain',\n\t},\n\t{\n\t\tid: 312,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_intensity_drizzle_rain',\n\t},\n\t{\n\t\tid: 313,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'shower_rain_and_drizzle',\n\t},\n\t{\n\t\tid: 314,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_shower_rain_and_drizzle',\n\t},\n\t{\n\t\tid: 321,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'shower_drizzle',\n\t},\n\t{\n\t\tid: 500,\n\t\tgroup: 'rain',\n\t\tdescription: 'light_rain',\n\t},\n\t{\n\t\tid: 501,\n\t\tgroup: 'rain',\n\t\tdescription: 'moderate_rain',\n\t},\n\t{\n\t\tid: 502,\n\t\tgroup: 'rain',\n\t\tdescription: 'heavy_intensity_rain',\n\t},\n\t{\n\t\tid: 503,\n\t\tgroup: 'rain',\n\t\tdescription: 'very_heavy_rain',\n\t},\n\t{\n\t\tid: 504,\n\t\tgroup: 'rain',\n\t\tdescription: 'extreme_rain',\n\t},\n\t{\n\t\tid: 511,\n\t\tgroup: 'rain',\n\t\tdescription: 'freezing_rain',\n\t},\n\t{\n\t\tid: 520,\n\t\tgroup: 'rain',\n\t\tdescription: 'light_intensity_shower_rain',\n\t},\n\t{\n\t\tid: 521,\n\t\tgroup: 'rain',\n\t\tdescription: 'shower_rain',\n\t},\n\t{\n\t\tid: 522,\n\t\tgroup: 'rain',\n\t\tdescription: 'heavy_intensity_shower_rain',\n\t},\n\t{\n\t\tid: 531,\n\t\tgroup: 'rain',\n\t\tdescription: 'ragged_shower_rain',\n\t},\n\t{\n\t\tid: 600,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_snow',\n\t},\n\t{\n\t\tid: 601,\n\t\tgroup: 'snow',\n\t\tdescription: 'snow',\n\t},\n\t{\n\t\tid: 602,\n\t\tgroup: 'snow',\n\t\tdescription: 'heavy_snow',\n\t},\n\t{\n\t\tid: 611,\n\t\tgroup: 'snow',\n\t\tdescription: 'sleet',\n\t},\n\t{\n\t\tid: 612,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_shower_sleet',\n\t},\n\t{\n\t\tid: 613,\n\t\tgroup: 'snow',\n\t\tdescription: 'shower_sleet',\n\t},\n\t{\n\t\tid: 615,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_rain_and_snow',\n\t},\n\t{\n\t\tid: 616,\n\t\tgroup: 'snow',\n\t\tdescription: 'rain_and_snow',\n\t},\n\t{\n\t\tid: 620,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_shower_snow',\n\t},\n\t{\n\t\tid: 621,\n\t\tgroup: 'snow',\n\t\tdescription: 'shower_snow',\n\t},\n\t{\n\t\tid: 622,\n\t\tgroup: 'snow',\n\t\tdescription: 'heavy_shower_snow',\n\t},\n\t{\n\t\tid: 701,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'mist',\n\t},\n\t{\n\t\tid: 711,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'smoke',\n\t},\n\t{\n\t\tid: 721,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'haze',\n\t},\n\t{\n\t\tid: 731,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'sand_dust_whirls',\n\t},\n\t{\n\t\tid: 741,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'fog',\n\t},\n\t{\n\t\tid: 751,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'sand',\n\t},\n\t{\n\t\tid: 761,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'dust',\n\t},\n\t{\n\t\tid: 762,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'volcanic_ash',\n\t},\n\t{\n\t\tid: 771,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'squalls',\n\t},\n\t{\n\t\tid: 781,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'tornado',\n\t},\n\t{\n\t\tid: 800,\n\t\tgroup: 'clear',\n\t\tdescription: 'clear_sky',\n\t},\n\t{\n\t\tid: 801,\n\t\tgroup: 'clouds',\n\t\tdescription: 'few_clouds_11-25_percent',\n\t},\n\t{\n\t\tid: 802,\n\t\tgroup: 'clouds',\n\t\tdescription: 'scattered_clouds_25-50_percent',\n\t},\n\t{\n\t\tid: 803,\n\t\tgroup: 'clouds',\n\t\tdescription: 'broken_clouds_51-84_percent',\n\t},\n\t{\n\t\tid: 804,\n\t\tgroup: 'clouds',\n\t\tdescription: 'overcast_clouds_85-100_percent',\n\t},\n] as const;\n\nexport type WeatherID = (typeof weatherIdGroup)[number]['id'];\n\n/**\n * WeatherGroup: \"clouds\" | \"rain\" | \"snow\" | \"thunderstorm\" | \"drizzle\" | \"atmosphere\" | \"clear\"\n */\nexport type WeatherGroup = (typeof weatherIdGroup)[number]['group'];\n\n/**\n * List for weather description key types from OpenWeatherMap API based on weather id.\n *\n * This list of keys can be used to translate weather id to human readable description with different languages.\n * @example\n * const i18Weather: Record<WeatherDescription, string> = {\n * clear_sky: 'Clear sky',\n * ...\n * }\n */\nexport type WeatherDescription = (typeof weatherIdGroup)[number]['description'];\n\n/**\n * Weather id schema\n * @internal\n */\nexport const weatherIdSchema = z.custom<WeatherID>((val) => {\n\tif (typeof val !== 'number') {\n\t\treturn {message: 'Expected a number', success: false};\n\t}\n\tif (!weatherIdGroup.find((x) => x.id === val)) {\n\t\treturn {message: 'Expected a valid weather id', success: false};\n\t}\n\treturn val;\n});\n\n/**\n * get weather description key from weather id\n * @param id - weather id\n * @returns {Option<WeatherDescription>} option for weather description key\n * @example\n * const weatherComponent = ({data}) => {\n * const key = getWeatherV2Description(data.weather[0]?.id).unwrapOr('unknown');\n * return (\n * <div>\n * {t(`weather:${key}`}\n * </div>\n * );\n * }\n */\nexport function getWeatherV2Description(id: WeatherID | undefined): IOption<WeatherDescription> {\n\treturn undefinedOptionWrap(weatherIdGroup.find((x) => x.id === id)?.description);\n}\n","import {iconSchema} from './Icon';\nimport {weatherIdSchema} from './weatherIdGroup';\nimport {z} from 'zod';\nexport * from './Icon';\nexport * from './Language';\nexport * from './weatherIdGroup';\n\nconst coordSchema = z.object({\n\tlon: z.number(),\n\tlat: z.number(),\n});\n\nconst weatherSchema = z.object({\n\tdescription: z.string(),\n\ticon: iconSchema,\n\tid: weatherIdSchema,\n\tmain: z.string(),\n});\n\nconst mainSchema = z.object({\n\tgrnd_level: z.number().optional(),\n\thumidity: z.number(),\n\tpressure: z.number(),\n\tsea_level: z.number().optional(),\n\ttemp: z.number(),\n\ttemp_max: z.number(),\n\ttemp_min: z.number(),\n});\n\nconst windSchema = z.object({\n\tspeed: z.number(),\n\tdeg: z.number(),\n});\n\nconst rainSchema = z.object({\n\t'1h': z.number().optional(),\n\t'3h': z.number().optional(),\n});\n\nconst snowSchema = z.object({\n\t'1h': z.number().optional(),\n\t'3h': z.number().optional(),\n});\n\nconst sysSchema = z.object({\n\tcountry: z.string(),\n\tid: z.number().optional(),\n\tmessage: z.number().optional(),\n\tsunrise: z.number(),\n\tsunset: z.number(),\n\ttype: z.number().optional(),\n});\n\n/**\n * @internal\n */\nexport const weatherDataV2Schema = z.object({\n\tbase: z.string(),\n\tclouds: z.object({\n\t\tall: z.number(),\n\t}),\n\tcod: z.number(),\n\tcoord: coordSchema,\n\tdt: z.number(),\n\tid: z.number(),\n\tmain: mainSchema,\n\tname: z.string(),\n\train: rainSchema.optional(),\n\tsnow: snowSchema.optional(),\n\tsys: sysSchema,\n\ttimezone: z.number(),\n\tvisibility: z.number(),\n\tweather: z.array(weatherSchema),\n\twind: windSchema,\n});\n\nexport type WeatherDataV2 = z.infer<typeof weatherDataV2Schema>;\n\nexport function isWeatherDataV2(data: unknown): data is WeatherDataV2 {\n\treturn weatherDataV2Schema.safeParse(data).success;\n}\n\nexport function assertWeatherDataV2(data: unknown): asserts data is WeatherDataV2 {\n\tweatherDataV2Schema.parse(data);\n}\n","import {z} from 'zod';\nexport const langCodes = [\n\t'af',\n\t'al',\n\t'ar',\n\t'az',\n\t'bg',\n\t'ca',\n\t'cz',\n\t'da',\n\t'de',\n\t'el',\n\t'en',\n\t'eu',\n\t'fa',\n\t'fi',\n\t'fr',\n\t'gl',\n\t'he',\n\t'hi',\n\t'hr',\n\t'hu',\n\t'id',\n\t'it',\n\t'ja',\n\t'kr',\n\t'la',\n\t'lt',\n\t'mk',\n\t'no',\n\t'nl',\n\t'pl',\n\t'pt',\n\t'pt',\n\t'ro',\n\t'ru',\n\t'sv',\n\t'sk',\n\t'sl',\n\t'sp',\n\t'sr',\n\t'th',\n\t'tr',\n\t'ua',\n\t'vi',\n\t'zh_cn',\n\t'zh_tw',\n\t'zu',\n] as const;\nexport const langCodeSchema = z.enum(langCodes);\nexport type LangCode = z.infer<typeof langCodeSchema>;\n","import {z} from 'zod';\n\nexport const CountryCodeList = [\n\t'af',\n\t'ax',\n\t'al',\n\t'dz',\n\t'as',\n\t'ad',\n\t'ao',\n\t'ai',\n\t'aq',\n\t'ag',\n\t'ar',\n\t'am',\n\t'aw',\n\t'au',\n\t'at',\n\t'az',\n\t'bs',\n\t'bh',\n\t'bd',\n\t'bb',\n\t'by',\n\t'be',\n\t'bz',\n\t'bj',\n\t'bm',\n\t'bt',\n\t'bo',\n\t'bq',\n\t'ba',\n\t'bw',\n\t'bv',\n\t'br',\n\t'io',\n\t'bn',\n\t'bg',\n\t'bf',\n\t'bi',\n\t'kh',\n\t'cm',\n\t'ca',\n\t'cv',\n\t'ky',\n\t'cf',\n\t'td',\n\t'cl',\n\t'cn',\n\t'cx',\n\t'cc',\n\t'co',\n\t'km',\n\t'cg',\n\t'cd',\n\t'ck',\n\t'cr',\n\t'ci',\n\t'hr',\n\t'cu',\n\t'cw',\n\t'cy',\n\t'cz',\n\t'dk',\n\t'dj',\n\t'dm',\n\t'do',\n\t'ec',\n\t'eg',\n\t'sv',\n\t'gq',\n\t'er',\n\t'ee',\n\t'et',\n\t'fk',\n\t'fo',\n\t'fj',\n\t'fi',\n\t'fr',\n\t'gf',\n\t'pf',\n\t'tf',\n\t'ga',\n\t'gm',\n\t'ge',\n\t'de',\n\t'gh',\n\t'gi',\n\t'gr',\n\t'gl',\n\t'gd',\n\t'gp',\n\t'gu',\n\t'gt',\n\t'gg',\n\t'gn',\n\t'gw',\n\t'gy',\n\t'ht',\n\t'hm',\n\t'va',\n\t'hn',\n\t'hk',\n\t'hu',\n\t'is',\n\t'in',\n\t'id',\n\t'ir',\n\t'iq',\n\t'ie',\n\t'im',\n\t'il',\n\t'it',\n\t'jm',\n\t'jp',\n\t'je',\n\t'jo',\n\t'kz',\n\t'ke',\n\t'ki',\n\t'kp',\n\t'kr',\n\t'kw',\n\t'kg',\n\t'la',\n\t'lv',\n\t'lb',\n\t'ls',\n\t'lr',\n\t'ly',\n\t'li',\n\t'lt',\n\t'lu',\n\t'mo',\n\t'mk',\n\t'mg',\n\t'mw',\n\t'my',\n\t'mv',\n\t'ml',\n\t'mt',\n\t'mh',\n\t'mq',\n\t'mr',\n\t'mu',\n\t'yt',\n\t'mx',\n\t'fm',\n\t'md',\n\t'mc',\n\t'mn',\n\t'me',\n\t'ms',\n\t'ma',\n\t'mz',\n\t'mm',\n\t'na',\n\t'nr',\n\t'np',\n\t'nl',\n\t'nc',\n\t'nz',\n\t'ni',\n\t'ne',\n\t'ng',\n\t'nu',\n\t'nf',\n\t'mp',\n\t'no',\n\t'om',\n\t'pk',\n\t'pw',\n\t'ps',\n\t'pa',\n\t'pg',\n\t'py',\n\t'pe',\n\t'ph',\n\t'pn',\n\t'pl',\n\t'pt',\n\t'pr',\n\t'qa',\n\t're',\n\t'ro',\n\t'ru',\n\t'rw',\n\t'bl',\n\t'sh',\n\t'kn',\n\t'lc',\n\t'mf',\n\t'pm',\n\t'vc',\n\t'ws',\n\t'sm',\n\t'st',\n\t'sa',\n\t'sn',\n\t'rs',\n\t'sc',\n\t'sl',\n\t'sg',\n\t'sx',\n\t'sk',\n\t'si',\n\t'sb',\n\t'so',\n\t'za',\n\t'gs',\n\t'ss',\n\t'es',\n\t'lk',\n\t'sd',\n\t'sr',\n\t'sj',\n\t'sz',\n\t'se',\n\t'ch',\n\t'sy',\n\t'tw',\n\t'tj',\n\t'tz',\n\t'th',\n\t'tl',\n\t'tg',\n\t'tk',\n\t'to',\n\t'tt',\n\t'tn',\n\t'tr',\n\t'tm',\n\t'tc',\n\t'tv',\n\t'ug',\n\t'ua',\n\t'ae',\n\t'gb',\n\t'us',\n\t'um',\n\t'uy',\n\t'uz',\n\t'vu',\n\t've',\n\t'vn',\n\t'vg',\n\t'vi',\n\t'wf',\n\t'eh',\n\t'ye',\n\t'zm',\n\t'zw',\n] as const;\n/**\n * @internal\n */\nexport const CountryCodeSchema = z.enum(CountryCodeList);\nexport type CountryCode = z.infer<typeof CountryCodeSchema>;\n","export * from './v2';\nexport * from './ISO3166-Countries';\n\n/**\n * Generic argument which can be value, Promise of value, function which returns value or Promise of value.\n * @example\n * function solveLoadable(value: Loadable<string>): string | Promise<string> {\n * return typeof value === 'function' ? value() : value;\n * }\n */\nexport type Loadable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);\n\nexport function solveLoadable(value: Loadable<string>): string | Promise<string> {\n\treturn typeof value === 'function' ? value() : value;\n}\n","import {assertWeatherDataV2, type CountryCode, type LangCode, type Loadable, type WeatherDataV2} from './types';\nimport {Err, type IResult, Ok, safeAsyncResult, safeAsyncResultBuilder} from '@luolapeikko/result-option';\nimport {fetchErrorWrapper} from './lib/fetchUtils';\nimport {type IAsyncCache} from '@luolapeikko/cache-types';\nimport type {IOpenWeatherV2} from './interfaces/IOpenWeatherV2';\n\nconst fetchResult = safeAsyncResultBuilder<Parameters<typeof fetch>, Response, SyntaxError | TypeError>(fetch);\n\nfunction toParams(data: Record<string, string | number | boolean>): Record<string, string> {\n\treturn Object.entries(data).reduce<Record<string, string>>((acc, [key, value]) => {\n\t\tacc[key] = String(value);\n\t\treturn acc;\n\t}, {});\n}\n\nfunction isJson(response: Response): boolean {\n\tconst contentType = response.headers.get('content-type');\n\treturn (contentType && contentType.startsWith('application/json')) || false;\n}\n\nfunction isOpenWeatherError(data: unknown): data is {cod: string; message: string} {\n\treturn typeof data === 'object' && data !== null && 'cod' in data && 'message' in data;\n}\n\n/**\n * Open Weather V2 API Common Options\n * @default {lang: 'en', units: 'standard'} in API\n * @example\n * {lang: 'fi', units: 'metric'}\n */\nexport type OpenWeatherV2CommonOptions = {\n\t/**\n\t * Language code\n\t */\n\tlang?: LangCode;\n\t/**\n\t * Weather units\n\t */\n\tunits?: 'standard' | 'metric' | 'imperial';\n};\n\nconst basePath = 'https://api.openweathermap.org/data/2.5/weather';\n\nfunction buildUrl(params: URLSearchParams): string {\n\treturn `${basePath}?${params.toString()}`;\n}\n\nfunction buildLogUrl(params: URLSearchParams): string {\n\tconst logParams = new URLSearchParams(params);\n\tlogParams.set('appid', '***');\n\treturn buildUrl(logParams);\n}\n\nconst defaultImplementation: IOpenWeatherV2 = {\n\tdataWeatherApi: async (params: URLSearchParams): Promise<IResult<WeatherDataV2, SyntaxError | TypeError>> => {\n\t\tconst logUrl = buildLogUrl(params);\n\t\tconst result = await fetchResult(buildUrl(params));\n\t\tif (!result.isOk) {\n\t\t\treturn Err(result.err());\n\t\t}\n\t\tconst res = result.ok();\n\t\tif (!res.ok) {\n\t\t\tif (isJson(res)) {\n\t\t\t\tconst data: unknown = await res.json();\n\t\t\t\tif (isOpenWeatherError(data)) {\n\t\t\t\t\treturn Err(new TypeError(`OpenWeatherV2 error: ${data.message} from ${logUrl}`));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Err(new TypeError(`OpenWeatherV2 http error: ${res.status} ${res.statusText} from ${logUrl}`));\n\t\t}\n\t\tif (!isJson(res)) {\n\t\t\treturn Err(new TypeError(`OpenWeatherV2 response is not json payload from ${logUrl}`));\n\t\t}\n\t\tconst jsonResult = await safeAsyncResult<unknown, SyntaxError>(res.json());\n\t\tif (!jsonResult.isOk) {\n\t\t\treturn Err(jsonResult.err());\n\t\t}\n\t\tconst data = jsonResult.ok();\n\t\tassertWeatherDataV2(data);\n\t\treturn Ok<WeatherDataV2, SyntaxError | TypeError>(data);\n\t},\n};\n\n/**\n * Open Weather V2 API\n * @example\n * const weather = new OpenWeatherV2('your-api-key');\n *\n * const cache = new ExpireCache<WeatherDataV2>(undefined, undefined, 900000); // data 15 minutes in cache\n * const weather = new OpenWeatherV2(() => Promise.resolve('your-api-key'), cache);\n *\n * const data: WeatherDataV2 = (await weather.getWeatherById(2643743)).unwrap(); // throws if error\n * const data: WeatherDataV2 | undefined = (await weather.getWeatherByCity('Helsinki', 'fi')).ok();\n *\n * const result: Result<WeatherDataV2> = await weather.getWeatherByLatLon(60.1699, 24.9384);\n * result.match({\n * Ok: (data: WeatherDataV2) => console.log(data),\n * Err: (err: DOMException | TypeError) => console.error(err),\n * });\n *\n * if(result.isOk) {\n * const data: WeatherDataV2 = data.ok();\n * } else {\n * const err: DOMException | TypeError = data.err();\n * }\n */\nexport class OpenWeatherV2 {\n\tprivate cache: IAsyncCache<WeatherDataV2> | undefined;\n\tprivate loadableApiKey: Loadable<string>;\n\tprivate apiHandler: IOpenWeatherV2;\n\tprivate fetchPromiseMap = new Map<string, Promise<IResult<WeatherDataV2, DOMException | TypeError>>>();\n\t/**\n\t * OpenWeatherV2 constructor\n\t * @param {Loadable<string>} loadableApiKey - Loadable API key\n\t * @param {ICacheOrAsync<WeatherDataV2>=} cache - optional async cache implementation\n\t * @param {IOpenWeatherV2=} apiHandler - optional API handler implementation for mocking\n\t */\n\tconstructor(loadableApiKey: Loadable<string>, cache?: IAsyncCache<WeatherDataV2>, apiHandler: IOpenWeatherV2 = defaultImplementation) {\n\t\tthis.loadableApiKey = loadableApiKey;\n\t\tthis.cache = cache;\n\t\tthis.apiHandler = apiHandler;\n\t}\n\n\t/**\n\t * get weather by Id\n\t * @param {number} id - Weather station ID\n\t * @param {OpenWeatherV2CommonOptions=} opts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherResultById(id: 564, {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherById(id: number, opts: OpenWeatherV2CommonOptions = {}): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`id:${id}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('id', String(id));\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\t/**\n\t * get weather with city name and optional country code\n\t * @param {string} city - City name\n\t * @param {countryCode=} countryCode - Optional Country code\n\t * @param {OpenWeatherV2CommonOptions=} opts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByCity('Helsinki', 'fi', {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherByCity(\n\t\tcity: string,\n\t\tcountryCode?: CountryCode,\n\t\topts: OpenWeatherV2CommonOptions = {},\n\t): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`q:${city}:${countryCode}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('q', countryCode ? `${city},${countryCode}` : city);\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\t/**\n\t * get weather with latitude and longitude with Result\n\t * @param {number} lat - Latitude\n\t * @param {number} lon - Longitude\n\t * @param {OpenWeatherV2CommonOptions=} opts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByLatLon(60.1699, 24.9384, {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherByLatLon(lat: number, lon: number, opts: OpenWeatherV2CommonOptions = {}): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`latlon:${lat}:${lon}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('lat', String(lat));\n\t\t\t\tparams.append('lon', String(lon));\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\tprivate async buildBaseParams(options: OpenWeatherV2CommonOptions): Promise<URLSearchParams> {\n\t\tconst apiKey = await (typeof this.loadableApiKey === 'function' ? this.loadableApiKey() : this.loadableApiKey);\n\t\tconst params = new URLSearchParams(toParams(options));\n\t\tparams.append('appid', apiKey);\n\t\treturn params;\n\t}\n\n\t/**\n\t * build base cache key\n\t * @param main - main cache key prefix\n\t * @param opts - OpenWeatherV2CommonOptions\n\t * @returns {CacheKey}\n\t */\n\tprivate buildBaseCacheKey(main: string, {lang, units}: OpenWeatherV2CommonOptions): string {\n\t\treturn `${main}:${lang}:${units}`;\n\t}\n\n\tprivate async handleFetch(cacheKey: string, params: URLSearchParams, opts: OpenWeatherV2CommonOptions): Promise<WeatherDataV2> {\n\t\t// allow only one fetch per cacheKey until it is resolved\n\t\tlet promiseResult = this.fetchPromiseMap.get(cacheKey);\n\t\tif (!promiseResult) {\n\t\t\tpromiseResult = this.apiHandler.dataWeatherApi(params);\n\t\t\tthis.fetchPromiseMap.set(cacheKey, promiseResult);\n\t\t\tawait promiseResult;\n\t\t\tthis.fetchPromiseMap.delete(cacheKey); // clear promise from map\n\t\t}\n\t\tconst dataApiResult = await promiseResult;\n\t\tconst data: WeatherDataV2 = dataApiResult.unwrap();\n\t\tassertWeatherDataV2(data);\n\t\tif (this.cache) {\n\t\t\tawait this.cache.set(cacheKey, data);\n\t\t\tif (!cacheKey.startsWith('id:')) {\n\t\t\t\t// update id cache too\n\t\t\t\tawait this.cache.set(this.buildBaseCacheKey(`id:${data.id}`, opts), data);\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}\n}\n","/**\n * Ensures that the error is a DOMException or TypeError.\n * @internal\n */\nexport function fetchErrorWrapper(err: unknown): DOMException | TypeError {\n\tif (err instanceof DOMException || err instanceof TypeError) {\n\t\treturn err;\n\t} else {\n\t\treturn new TypeError(`Unknown error: ${String(err)}`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAgB;AAChB,IAAM,cAAc,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAKlF,IAAM,oBAAoB,aAAE,KAAK,WAAW;AAI5C,IAAM,gBAAgB,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAKpF,IAAM,sBAAsB,aAAE,KAAK,aAAa;AAMzC,IAAM,aAAa,aAAE,MAAM,CAAC,mBAAmB,mBAAmB,CAAC;;;ACrB1E,2BAAgD;AAChD,IAAAA,cAAgB;AAKT,IAAM,iBAAiB;AAAA,EAC7B;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EAC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A,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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Q;AAAA,IACrC;AACA,UAAM,gBAAgB,MAAM;AAC5B,UAAM,OAAsB,cAAc,OAAO;AACjD,wBAAoB,IAAI;AACxB,QAAI,KAAK,OAAO;AACf,YAAM,KAAK,MAAM,IAAI,UAAU,IAAI;AACnC,UAAI,CAAC,SAAS,WAAW,KAAK,GAAG;AAEhC,cAAM,KAAK,MAAM,IAAI,KAAK,kBAAkB,MAAM,KAAK,EAAE,IAAI,IAAI,GAAG,IAAI;AAAA,MACzE;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;","names":["import_zod","import_zod","import_zod","import_zod","import_result_option","data"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/OpenWeatherV2.ts","../src/lib/fetchUtils.ts","../src/types/v2/index.ts","../src/types/v2/Icon.ts","../src/types/v2/weatherIdGroup.ts","../src/types/v2/Language.ts","../src/types/ISO3166-Countries.ts"],"sourcesContent":["export * from './OpenWeatherV2';\nexport * from './types';\nexport * from './lib';\nexport * from './interfaces';\n","import {type IAsyncCache} from '@luolapeikko/cache-types';\nimport {Err, type IResult, Ok, safeAsyncResult, safeAsyncResultBuilder} from '@luolapeikko/result-option';\nimport {type Loadable} from '@luolapeikko/ts-common';\nimport type {IOpenWeatherV2} from './interfaces/IOpenWeatherV2';\nimport {fetchErrorWrapper} from './lib/fetchUtils';\nimport {assertWeatherDataV2, type CountryCode, type LangCode, type WeatherDataV2} from './types';\n\nconst fetchResult = safeAsyncResultBuilder<Parameters<typeof fetch>, Response, SyntaxError | TypeError>(fetch);\n\nfunction toParams(data: Record<string, string | number | boolean>): Record<string, string> {\n\treturn Object.entries(data).reduce<Record<string, string>>((acc, [key, value]) => {\n\t\tacc[key] = String(value);\n\t\treturn acc;\n\t}, {});\n}\n\nfunction isJson(response: Response): boolean {\n\tconst contentType = response.headers.get('content-type');\n\treturn contentType?.startsWith('application/json') ?? false;\n}\n\nfunction isOpenWeatherError(data: unknown): data is {cod: string; message: string} {\n\treturn typeof data === 'object' && data !== null && 'cod' in data && 'message' in data;\n}\n\n/**\n * Open Weather V2 API Common Options\n * @default {lang: 'en', units: 'standard'} in API\n * @example\n * {lang: 'fi', units: 'metric'}\n * @since v0.0.1\n */\nexport type OpenWeatherV2CommonOptions = {\n\t/**\n\t * Language code\n\t */\n\tlang: LangCode;\n\t/**\n\t * Weather units\n\t */\n\tunits: 'standard' | 'metric' | 'imperial';\n};\n\nconst defaultCommonOptions = {\n\tlang: 'en',\n\tunits: 'standard',\n} satisfies OpenWeatherV2CommonOptions;\n\nfunction buildOpts(opts: Partial<OpenWeatherV2CommonOptions>): OpenWeatherV2CommonOptions {\n\treturn Object.assign({}, defaultCommonOptions, opts);\n}\n\nconst basePath = 'https://api.openweathermap.org/data/2.5/weather';\n\nfunction buildUrl(params: URLSearchParams): string {\n\treturn `${basePath}?${params.toString()}`;\n}\n\nfunction buildLogUrl(params: URLSearchParams): string {\n\tconst logParams = new URLSearchParams(params);\n\tlogParams.set('appid', '***');\n\treturn buildUrl(logParams);\n}\n\nconst defaultImplementation: IOpenWeatherV2 = {\n\tdataWeatherApi: async (params: URLSearchParams): Promise<IResult<WeatherDataV2, SyntaxError | TypeError>> => {\n\t\tconst logUrl = buildLogUrl(params);\n\t\tconst result = await fetchResult(buildUrl(params));\n\t\tif (!result.isOk) {\n\t\t\treturn Err(result.err());\n\t\t}\n\t\tconst res = result.ok();\n\t\tif (!res.ok) {\n\t\t\tif (isJson(res)) {\n\t\t\t\tconst data: unknown = await res.json();\n\t\t\t\tif (isOpenWeatherError(data)) {\n\t\t\t\t\treturn Err(new TypeError(`OpenWeatherV2 error: ${data.message} from ${logUrl}`));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Err(new TypeError(`OpenWeatherV2 http error: ${res.status} ${res.statusText} from ${logUrl}`));\n\t\t}\n\t\tif (!isJson(res)) {\n\t\t\treturn Err(new TypeError(`OpenWeatherV2 response is not json payload from ${logUrl}`));\n\t\t}\n\t\tconst jsonResult = await safeAsyncResult<unknown, SyntaxError>(res.json());\n\t\tif (!jsonResult.isOk) {\n\t\t\treturn Err(jsonResult.err());\n\t\t}\n\t\tconst data = jsonResult.ok();\n\t\tassertWeatherDataV2(data);\n\t\treturn Ok<WeatherDataV2, SyntaxError | TypeError>(data);\n\t},\n};\n\n/**\n * Cache key types\n * @since v0.1.0\n */\ntype CacheKey = `q:${string}:${string}` | `id:${number}` | `latlon:${number}:${number}`;\n\n/**\n * Open Weather V2 API\n * @example\n * const weather = new OpenWeatherV2('your-api-key');\n *\n * const cache = new ExpireCache<WeatherDataV2>(undefined, undefined, 900000); // data 15 minutes in cache\n * const weather = new OpenWeatherV2(() => Promise.resolve('your-api-key'), cache);\n *\n * const data: WeatherDataV2 = (await weather.getWeatherById(2643743)).unwrap(); // throws if error\n * const data: WeatherDataV2 | undefined = (await weather.getWeatherByCity('Helsinki', 'fi')).ok();\n *\n * const result: Result<WeatherDataV2> = await weather.getWeatherByLatLon(60.1699, 24.9384);\n * result.match({\n * Ok: (data: WeatherDataV2) => console.log(data),\n * Err: (err: DOMException | TypeError) => console.error(err),\n * });\n *\n * if(result.isOk) {\n * const data: WeatherDataV2 = data.ok();\n * } else {\n * const err: DOMException | TypeError = data.err();\n * }\n * @since v0.0.1\n */\nexport class OpenWeatherV2 {\n\tprivate cache: IAsyncCache<WeatherDataV2> | undefined;\n\tprivate loadableApiKey: Loadable<string>;\n\tprivate apiHandler: IOpenWeatherV2;\n\tprivate fetchPromiseMap = new Map<string, Promise<IResult<WeatherDataV2, DOMException | TypeError>>>();\n\t/**\n\t * OpenWeatherV2 constructor\n\t * @param {Loadable<string>} loadableApiKey - Loadable API key\n\t * @param {ICacheOrAsync<WeatherDataV2>=} cache - optional async cache implementation\n\t * @param {IOpenWeatherV2=} apiHandler - optional API handler implementation for mocking\n\t */\n\tconstructor(loadableApiKey: Loadable<string>, cache?: IAsyncCache<WeatherDataV2>, apiHandler: IOpenWeatherV2 = defaultImplementation) {\n\t\tthis.loadableApiKey = loadableApiKey;\n\t\tthis.cache = cache;\n\t\tthis.apiHandler = apiHandler;\n\t}\n\n\t/**\n\t * get weather by Id\n\t * @param {number} id - Weather station ID\n\t * @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherResultById(id: 564, {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherById(id: number, currentOpts: Partial<OpenWeatherV2CommonOptions> = {}): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst opts = buildOpts(currentOpts);\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`id:${id}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('id', String(id));\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\t/**\n\t * get weather with city name and optional country code\n\t * @param {string} city - City name\n\t * @param {countryCode=} countryCode - Optional Country code\n\t * @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByCity('Helsinki', 'fi', {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherByCity(\n\t\tcity: string,\n\t\tcountryCode?: CountryCode,\n\t\tcurrentOpts: Partial<OpenWeatherV2CommonOptions> = {},\n\t): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst opts = buildOpts(currentOpts);\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`q:${city}:${countryCode}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('q', countryCode ? `${city},${countryCode}` : city);\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\t/**\n\t * get weather with latitude and longitude with Result\n\t * @param {number} lat - Latitude\n\t * @param {number} lon - Longitude\n\t * @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByLatLon(60.1699, 24.9384, {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherByLatLon(\n\t\tlat: number,\n\t\tlon: number,\n\t\tcurrentOpts: Partial<OpenWeatherV2CommonOptions> = {},\n\t): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst opts = buildOpts(currentOpts);\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`latlon:${lat}:${lon}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('lat', String(lat));\n\t\t\t\tparams.append('lon', String(lon));\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\tprivate async buildBaseParams(options: OpenWeatherV2CommonOptions): Promise<URLSearchParams> {\n\t\tconst apiKey = await (typeof this.loadableApiKey === 'function' ? this.loadableApiKey() : this.loadableApiKey);\n\t\tconst params = new URLSearchParams(toParams(options));\n\t\tparams.append('appid', apiKey);\n\t\treturn params;\n\t}\n\n\t/**\n\t * build base cache key\n\t * @param main - main cache key prefix\n\t * @param opts - OpenWeatherV2CommonOptions\n\t * @returns {string} cache key\n\t */\n\tprivate buildBaseCacheKey(main: CacheKey, {lang, units}: OpenWeatherV2CommonOptions): `${CacheKey}:${LangCode}:${'standard' | 'metric' | 'imperial'}` {\n\t\treturn `${main}:${lang}:${units}`;\n\t}\n\n\tprivate async handleFetch(cacheKey: string, params: URLSearchParams, opts: OpenWeatherV2CommonOptions): Promise<WeatherDataV2> {\n\t\t// allow only one fetch per cacheKey until it is resolved\n\t\tlet promiseResult = this.fetchPromiseMap.get(cacheKey);\n\t\tif (!promiseResult) {\n\t\t\tpromiseResult = this.apiHandler.dataWeatherApi(params);\n\t\t\tthis.fetchPromiseMap.set(cacheKey, promiseResult);\n\t\t\tawait promiseResult;\n\t\t\tthis.fetchPromiseMap.delete(cacheKey); // clear promise from map\n\t\t}\n\t\tconst dataApiResult = await promiseResult;\n\t\tconst data: WeatherDataV2 = dataApiResult.unwrap();\n\t\tassertWeatherDataV2(data);\n\t\tif (this.cache) {\n\t\t\tawait this.cache.set(cacheKey, data);\n\t\t\tif (!cacheKey.startsWith('id:')) {\n\t\t\t\t// update id cache too\n\t\t\t\tawait this.cache.set(this.buildBaseCacheKey(`id:${data.id}`, opts), data);\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}\n}\n","/**\n * Ensures that the error is a DOMException or TypeError.\n * @internal\n */\nexport function fetchErrorWrapper(err: unknown): DOMException | TypeError {\n\tif (err instanceof DOMException || err instanceof TypeError) {\n\t\treturn err;\n\t} else {\n\t\treturn new TypeError(`Unknown error: ${String(err)}`);\n\t}\n}\n","import {z} from 'zod';\nimport {iconSchema} from './Icon';\nimport {weatherIdSchema} from './weatherIdGroup';\nexport * from './Icon';\nexport * from './Language';\nexport * from './weatherIdGroup';\n\nconst coordSchema = z.object({\n\tlon: z.number(),\n\tlat: z.number(),\n});\n\nconst weatherSchema = z.object({\n\tdescription: z.string(),\n\ticon: iconSchema,\n\tid: weatherIdSchema,\n\tmain: z.string(),\n});\n\nconst mainSchema = z.object({\n\tgrnd_level: z.number().optional(),\n\thumidity: z.number(),\n\tpressure: z.number(),\n\tsea_level: z.number().optional(),\n\ttemp: z.number(),\n\ttemp_max: z.number(),\n\ttemp_min: z.number(),\n});\n\nconst windSchema = z.object({\n\tspeed: z.number(),\n\tdeg: z.number(),\n});\n\nconst rainSchema = z.object({\n\t'1h': z.number().optional(),\n\t'3h': z.number().optional(),\n});\n\nconst snowSchema = z.object({\n\t'1h': z.number().optional(),\n\t'3h': z.number().optional(),\n});\n\nconst sysSchema = z.object({\n\tcountry: z.string(),\n\tid: z.number().optional(),\n\tmessage: z.number().optional(),\n\tsunrise: z.number(),\n\tsunset: z.number(),\n\ttype: z.number().optional(),\n});\n\n/**\n * @internal\n */\nexport const weatherDataV2Schema = z.object({\n\tbase: z.string(),\n\tclouds: z.object({\n\t\tall: z.number(),\n\t}),\n\tcod: z.number(),\n\tcoord: coordSchema,\n\tdt: z.number(),\n\tid: z.number(),\n\tmain: mainSchema,\n\tname: z.string(),\n\train: rainSchema.optional(),\n\tsnow: snowSchema.optional(),\n\tsys: sysSchema,\n\ttimezone: z.number(),\n\tvisibility: z.number(),\n\tweather: z.array(weatherSchema),\n\twind: windSchema,\n});\n\nexport type WeatherDataV2 = z.infer<typeof weatherDataV2Schema>;\n\nexport function isWeatherDataV2(data: unknown): data is WeatherDataV2 {\n\treturn weatherDataV2Schema.safeParse(data).success;\n}\n\nexport function assertWeatherDataV2(data: unknown): asserts data is WeatherDataV2 {\n\tweatherDataV2Schema.parse(data);\n}\n","import {z} from 'zod';\nconst dayIconList = ['01d', '02d', '03d', '04d', '09d', '10d', '11d', '13d', '50d'] as const;\n\n/**\n * @internal\n */\nconst dayIconListSchema = z.enum(dayIconList);\n\nexport type DayIcon = z.infer<typeof dayIconListSchema>;\n\nconst nightIconList = ['01n', '02n', '03n', '04n', '09n', '10n', '11n', '13n', '50n'] as const;\n\n/**\n * @internal\n */\nconst nightIconListSchema = z.enum(nightIconList);\nexport type NightIcon = z.infer<typeof nightIconListSchema>;\n\n/**\n * @internal\n */\nexport const iconSchema = z.union([dayIconListSchema, nightIconListSchema]);\n\nexport type Icon = z.infer<typeof iconSchema>;\n","import {type IOption, undefinedOptionWrap} from '@luolapeikko/result-option';\nimport {z} from 'zod';\n\n/**\n * This is a list of weather ids, groups and descriptions from OpenWeatherMap API\n */\nexport const weatherIdGroup = [\n\t{\n\t\tid: 200,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_light_rain',\n\t},\n\t{\n\t\tid: 201,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_rain',\n\t},\n\t{\n\t\tid: 202,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_heavy_rain',\n\t},\n\t{\n\t\tid: 210,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'light_thunderstorm',\n\t},\n\t{\n\t\tid: 211,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm',\n\t},\n\t{\n\t\tid: 212,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'heavy_thunderstorm',\n\t},\n\t{\n\t\tid: 221,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'ragged_thunderstorm',\n\t},\n\t{\n\t\tid: 230,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_light_drizzle',\n\t},\n\t{\n\t\tid: 231,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_drizzle',\n\t},\n\t{\n\t\tid: 232,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_heavy_drizzle',\n\t},\n\t{\n\t\tid: 300,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'light_intensity_drizzle',\n\t},\n\t{\n\t\tid: 301,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'drizzle',\n\t},\n\t{\n\t\tid: 302,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_intensity_drizzle',\n\t},\n\t{\n\t\tid: 310,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'light_intensity_drizzle_rain',\n\t},\n\t{\n\t\tid: 311,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'drizzle_rain',\n\t},\n\t{\n\t\tid: 312,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_intensity_drizzle_rain',\n\t},\n\t{\n\t\tid: 313,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'shower_rain_and_drizzle',\n\t},\n\t{\n\t\tid: 314,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_shower_rain_and_drizzle',\n\t},\n\t{\n\t\tid: 321,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'shower_drizzle',\n\t},\n\t{\n\t\tid: 500,\n\t\tgroup: 'rain',\n\t\tdescription: 'light_rain',\n\t},\n\t{\n\t\tid: 501,\n\t\tgroup: 'rain',\n\t\tdescription: 'moderate_rain',\n\t},\n\t{\n\t\tid: 502,\n\t\tgroup: 'rain',\n\t\tdescription: 'heavy_intensity_rain',\n\t},\n\t{\n\t\tid: 503,\n\t\tgroup: 'rain',\n\t\tdescription: 'very_heavy_rain',\n\t},\n\t{\n\t\tid: 504,\n\t\tgroup: 'rain',\n\t\tdescription: 'extreme_rain',\n\t},\n\t{\n\t\tid: 511,\n\t\tgroup: 'rain',\n\t\tdescription: 'freezing_rain',\n\t},\n\t{\n\t\tid: 520,\n\t\tgroup: 'rain',\n\t\tdescription: 'light_intensity_shower_rain',\n\t},\n\t{\n\t\tid: 521,\n\t\tgroup: 'rain',\n\t\tdescription: 'shower_rain',\n\t},\n\t{\n\t\tid: 522,\n\t\tgroup: 'rain',\n\t\tdescription: 'heavy_intensity_shower_rain',\n\t},\n\t{\n\t\tid: 531,\n\t\tgroup: 'rain',\n\t\tdescription: 'ragged_shower_rain',\n\t},\n\t{\n\t\tid: 600,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_snow',\n\t},\n\t{\n\t\tid: 601,\n\t\tgroup: 'snow',\n\t\tdescription: 'snow',\n\t},\n\t{\n\t\tid: 602,\n\t\tgroup: 'snow',\n\t\tdescription: 'heavy_snow',\n\t},\n\t{\n\t\tid: 611,\n\t\tgroup: 'snow',\n\t\tdescription: 'sleet',\n\t},\n\t{\n\t\tid: 612,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_shower_sleet',\n\t},\n\t{\n\t\tid: 613,\n\t\tgroup: 'snow',\n\t\tdescription: 'shower_sleet',\n\t},\n\t{\n\t\tid: 615,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_rain_and_snow',\n\t},\n\t{\n\t\tid: 616,\n\t\tgroup: 'snow',\n\t\tdescription: 'rain_and_snow',\n\t},\n\t{\n\t\tid: 620,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_shower_snow',\n\t},\n\t{\n\t\tid: 621,\n\t\tgroup: 'snow',\n\t\tdescription: 'shower_snow',\n\t},\n\t{\n\t\tid: 622,\n\t\tgroup: 'snow',\n\t\tdescription: 'heavy_shower_snow',\n\t},\n\t{\n\t\tid: 701,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'mist',\n\t},\n\t{\n\t\tid: 711,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'smoke',\n\t},\n\t{\n\t\tid: 721,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'haze',\n\t},\n\t{\n\t\tid: 731,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'sand_dust_whirls',\n\t},\n\t{\n\t\tid: 741,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'fog',\n\t},\n\t{\n\t\tid: 751,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'sand',\n\t},\n\t{\n\t\tid: 761,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'dust',\n\t},\n\t{\n\t\tid: 762,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'volcanic_ash',\n\t},\n\t{\n\t\tid: 771,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'squalls',\n\t},\n\t{\n\t\tid: 781,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'tornado',\n\t},\n\t{\n\t\tid: 800,\n\t\tgroup: 'clear',\n\t\tdescription: 'clear_sky',\n\t},\n\t{\n\t\tid: 801,\n\t\tgroup: 'clouds',\n\t\tdescription: 'few_clouds_11-25_percent',\n\t},\n\t{\n\t\tid: 802,\n\t\tgroup: 'clouds',\n\t\tdescription: 'scattered_clouds_25-50_percent',\n\t},\n\t{\n\t\tid: 803,\n\t\tgroup: 'clouds',\n\t\tdescription: 'broken_clouds_51-84_percent',\n\t},\n\t{\n\t\tid: 804,\n\t\tgroup: 'clouds',\n\t\tdescription: 'overcast_clouds_85-100_percent',\n\t},\n] as const;\n\nexport type WeatherID = (typeof weatherIdGroup)[number]['id'];\n\n/**\n * WeatherGroup: \"clouds\" | \"rain\" | \"snow\" | \"thunderstorm\" | \"drizzle\" | \"atmosphere\" | \"clear\"\n */\nexport type WeatherGroup = (typeof weatherIdGroup)[number]['group'];\n\n/**\n * List for weather description key types from OpenWeatherMap API based on weather id.\n *\n * This list of keys can be used to translate weather id to human readable description with different languages.\n * @example\n * const i18Weather: Record<WeatherDescription, string> = {\n * clear_sky: 'Clear sky',\n * ...\n * }\n */\nexport type WeatherDescription = (typeof weatherIdGroup)[number]['description'];\n\n/**\n * Weather id schema\n * @internal\n */\nexport const weatherIdSchema = z.custom<WeatherID>((val) => {\n\tif (typeof val !== 'number') {\n\t\treturn {message: 'Expected a number', success: false};\n\t}\n\tif (!weatherIdGroup.find((x) => x.id === val)) {\n\t\treturn {message: 'Expected a valid weather id', success: false};\n\t}\n\treturn val;\n});\n\n/**\n * get weather description key from weather id\n * @param id - weather id\n * @returns {Option<WeatherDescription>} option for weather description key\n * @example\n * const weatherComponent = ({data}) => {\n * const key = getWeatherV2Description(data.weather[0]?.id).unwrapOr('unknown');\n * return (\n * <div>\n * {t(`weather:${key}`}\n * </div>\n * );\n * }\n */\nexport function getWeatherV2Description(id: WeatherID | undefined): IOption<WeatherDescription> {\n\treturn undefinedOptionWrap(weatherIdGroup.find((x) => x.id === id)?.description);\n}\n","import {z} from 'zod';\nexport const langCodes = [\n\t'af',\n\t'al',\n\t'ar',\n\t'az',\n\t'bg',\n\t'ca',\n\t'cz',\n\t'da',\n\t'de',\n\t'el',\n\t'en',\n\t'eu',\n\t'fa',\n\t'fi',\n\t'fr',\n\t'gl',\n\t'he',\n\t'hi',\n\t'hr',\n\t'hu',\n\t'id',\n\t'it',\n\t'ja',\n\t'kr',\n\t'la',\n\t'lt',\n\t'mk',\n\t'no',\n\t'nl',\n\t'pl',\n\t'pt',\n\t'pt',\n\t'ro',\n\t'ru',\n\t'sv',\n\t'sk',\n\t'sl',\n\t'sp',\n\t'sr',\n\t'th',\n\t'tr',\n\t'ua',\n\t'vi',\n\t'zh_cn',\n\t'zh_tw',\n\t'zu',\n] as const;\nexport const langCodeSchema = z.enum(langCodes);\nexport type LangCode = z.infer<typeof langCodeSchema>;\n","import {z} from 'zod';\n\nexport const CountryCodeList = [\n\t'af',\n\t'ax',\n\t'al',\n\t'dz',\n\t'as',\n\t'ad',\n\t'ao',\n\t'ai',\n\t'aq',\n\t'ag',\n\t'ar',\n\t'am',\n\t'aw',\n\t'au',\n\t'at',\n\t'az',\n\t'bs',\n\t'bh',\n\t'bd',\n\t'bb',\n\t'by',\n\t'be',\n\t'bz',\n\t'bj',\n\t'bm',\n\t'bt',\n\t'bo',\n\t'bq',\n\t'ba',\n\t'bw',\n\t'bv',\n\t'br',\n\t'io',\n\t'bn',\n\t'bg',\n\t'bf',\n\t'bi',\n\t'kh',\n\t'cm',\n\t'ca',\n\t'cv',\n\t'ky',\n\t'cf',\n\t'td',\n\t'cl',\n\t'cn',\n\t'cx',\n\t'cc',\n\t'co',\n\t'km',\n\t'cg',\n\t'cd',\n\t'ck',\n\t'cr',\n\t'ci',\n\t'hr',\n\t'cu',\n\t'cw',\n\t'cy',\n\t'cz',\n\t'dk',\n\t'dj',\n\t'dm',\n\t'do',\n\t'ec',\n\t'eg',\n\t'sv',\n\t'gq',\n\t'er',\n\t'ee',\n\t'et',\n\t'fk',\n\t'fo',\n\t'fj',\n\t'fi',\n\t'fr',\n\t'gf',\n\t'pf',\n\t'tf',\n\t'ga',\n\t'gm',\n\t'ge',\n\t'de',\n\t'gh',\n\t'gi',\n\t'gr',\n\t'gl',\n\t'gd',\n\t'gp',\n\t'gu',\n\t'gt',\n\t'gg',\n\t'gn',\n\t'gw',\n\t'gy',\n\t'ht',\n\t'hm',\n\t'va',\n\t'hn',\n\t'hk',\n\t'hu',\n\t'is',\n\t'in',\n\t'id',\n\t'ir',\n\t'iq',\n\t'ie',\n\t'im',\n\t'il',\n\t'it',\n\t'jm',\n\t'jp',\n\t'je',\n\t'jo',\n\t'kz',\n\t'ke',\n\t'ki',\n\t'kp',\n\t'kr',\n\t'kw',\n\t'kg',\n\t'la',\n\t'lv',\n\t'lb',\n\t'ls',\n\t'lr',\n\t'ly',\n\t'li',\n\t'lt',\n\t'lu',\n\t'mo',\n\t'mk',\n\t'mg',\n\t'mw',\n\t'my',\n\t'mv',\n\t'ml',\n\t'mt',\n\t'mh',\n\t'mq',\n\t'mr',\n\t'mu',\n\t'yt',\n\t'mx',\n\t'fm',\n\t'md',\n\t'mc',\n\t'mn',\n\t'me',\n\t'ms',\n\t'ma',\n\t'mz',\n\t'mm',\n\t'na',\n\t'nr',\n\t'np',\n\t'nl',\n\t'nc',\n\t'nz',\n\t'ni',\n\t'ne',\n\t'ng',\n\t'nu',\n\t'nf',\n\t'mp',\n\t'no',\n\t'om',\n\t'pk',\n\t'pw',\n\t'ps',\n\t'pa',\n\t'pg',\n\t'py',\n\t'pe',\n\t'ph',\n\t'pn',\n\t'pl',\n\t'pt',\n\t'pr',\n\t'qa',\n\t're',\n\t'ro',\n\t'ru',\n\t'rw',\n\t'bl',\n\t'sh',\n\t'kn',\n\t'lc',\n\t'mf',\n\t'pm',\n\t'vc',\n\t'ws',\n\t'sm',\n\t'st',\n\t'sa',\n\t'sn',\n\t'rs',\n\t'sc',\n\t'sl',\n\t'sg',\n\t'sx',\n\t'sk',\n\t'si',\n\t'sb',\n\t'so',\n\t'za',\n\t'gs',\n\t'ss',\n\t'es',\n\t'lk',\n\t'sd',\n\t'sr',\n\t'sj',\n\t'sz',\n\t'se',\n\t'ch',\n\t'sy',\n\t'tw',\n\t'tj',\n\t'tz',\n\t'th',\n\t'tl',\n\t'tg',\n\t'tk',\n\t'to',\n\t'tt',\n\t'tn',\n\t'tr',\n\t'tm',\n\t'tc',\n\t'tv',\n\t'ug',\n\t'ua',\n\t'ae',\n\t'gb',\n\t'us',\n\t'um',\n\t'uy',\n\t'uz',\n\t'vu',\n\t've',\n\t'vn',\n\t'vg',\n\t'vi',\n\t'wf',\n\t'eh',\n\t'ye',\n\t'zm',\n\t'zw',\n] as const;\n/**\n * @internal\n */\nexport const CountryCodeSchema = z.enum(CountryCodeList);\nexport type CountryCode = z.infer<typeof CountryCodeSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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M,IAAI;AAC/B;;;AIpFA,IAAAC,cAAgB;AAET,IAAM,kBAAkB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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UAAI,CAAC,SAAS,WAAW,KAAK,GAAG;AAEhC,cAAM,KAAK,MAAM,IAAI,KAAK,kBAAkB,MAAM,KAAK,EAAE,IAAI,IAAI,GAAG,IAAI;AAAA,MACzE;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;","names":["import_result_option","import_zod","import_zod","import_zod","import_zod","data"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
// src/OpenWeatherV2.ts
|
|
2
|
+
import { Err, Ok, safeAsyncResult, safeAsyncResultBuilder } from "@luolapeikko/result-option";
|
|
3
|
+
|
|
4
|
+
// src/lib/fetchUtils.ts
|
|
5
|
+
function fetchErrorWrapper(err) {
|
|
6
|
+
if (err instanceof DOMException || err instanceof TypeError) {
|
|
7
|
+
return err;
|
|
8
|
+
} else {
|
|
9
|
+
return new TypeError(`Unknown error: ${String(err)}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/types/v2/index.ts
|
|
14
|
+
import { z as z4 } from "zod";
|
|
15
|
+
|
|
1
16
|
// src/types/v2/Icon.ts
|
|
2
17
|
import { z } from "zod";
|
|
3
18
|
var dayIconList = ["01d", "02d", "03d", "04d", "09d", "10d", "11d", "13d", "50d"];
|
|
@@ -299,9 +314,6 @@ function getWeatherV2Description(id) {
|
|
|
299
314
|
return undefinedOptionWrap(weatherIdGroup.find((x) => x.id === id)?.description);
|
|
300
315
|
}
|
|
301
316
|
|
|
302
|
-
// src/types/v2/index.ts
|
|
303
|
-
import { z as z4 } from "zod";
|
|
304
|
-
|
|
305
317
|
// src/types/v2/Language.ts
|
|
306
318
|
import { z as z3 } from "zod";
|
|
307
319
|
var langCodes = [
|
|
@@ -675,23 +687,6 @@ var CountryCodeList = [
|
|
|
675
687
|
];
|
|
676
688
|
var CountryCodeSchema = z5.enum(CountryCodeList);
|
|
677
689
|
|
|
678
|
-
// src/types/index.ts
|
|
679
|
-
function solveLoadable(value) {
|
|
680
|
-
return typeof value === "function" ? value() : value;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
// src/OpenWeatherV2.ts
|
|
684
|
-
import { Err, Ok, safeAsyncResult, safeAsyncResultBuilder } from "@luolapeikko/result-option";
|
|
685
|
-
|
|
686
|
-
// src/lib/fetchUtils.ts
|
|
687
|
-
function fetchErrorWrapper(err) {
|
|
688
|
-
if (err instanceof DOMException || err instanceof TypeError) {
|
|
689
|
-
return err;
|
|
690
|
-
} else {
|
|
691
|
-
return new TypeError(`Unknown error: ${String(err)}`);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
|
|
695
690
|
// src/OpenWeatherV2.ts
|
|
696
691
|
var fetchResult = safeAsyncResultBuilder(fetch);
|
|
697
692
|
function toParams(data) {
|
|
@@ -702,11 +697,18 @@ function toParams(data) {
|
|
|
702
697
|
}
|
|
703
698
|
function isJson(response) {
|
|
704
699
|
const contentType = response.headers.get("content-type");
|
|
705
|
-
return contentType
|
|
700
|
+
return contentType?.startsWith("application/json") ?? false;
|
|
706
701
|
}
|
|
707
702
|
function isOpenWeatherError(data) {
|
|
708
703
|
return typeof data === "object" && data !== null && "cod" in data && "message" in data;
|
|
709
704
|
}
|
|
705
|
+
var defaultCommonOptions = {
|
|
706
|
+
lang: "en",
|
|
707
|
+
units: "standard"
|
|
708
|
+
};
|
|
709
|
+
function buildOpts(opts) {
|
|
710
|
+
return Object.assign({}, defaultCommonOptions, opts);
|
|
711
|
+
}
|
|
710
712
|
var basePath = "https://api.openweathermap.org/data/2.5/weather";
|
|
711
713
|
function buildUrl(params) {
|
|
712
714
|
return `${basePath}?${params.toString()}`;
|
|
@@ -764,7 +766,7 @@ var OpenWeatherV2 = class {
|
|
|
764
766
|
/**
|
|
765
767
|
* get weather by Id
|
|
766
768
|
* @param {number} id - Weather station ID
|
|
767
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
769
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
768
770
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
769
771
|
* @example
|
|
770
772
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherResultById(id: 564, {lang: 'fi'});
|
|
@@ -774,8 +776,9 @@ var OpenWeatherV2 = class {
|
|
|
774
776
|
* const error: DOMException | TypeError = result.err();
|
|
775
777
|
* }
|
|
776
778
|
*/
|
|
777
|
-
async getWeatherById(id,
|
|
779
|
+
async getWeatherById(id, currentOpts = {}) {
|
|
778
780
|
try {
|
|
781
|
+
const opts = buildOpts(currentOpts);
|
|
779
782
|
const cacheKey = this.buildBaseCacheKey(`id:${id}`, opts);
|
|
780
783
|
let cacheEntry = this.cache && await this.cache.get(cacheKey);
|
|
781
784
|
if (!cacheEntry) {
|
|
@@ -792,7 +795,7 @@ var OpenWeatherV2 = class {
|
|
|
792
795
|
* get weather with city name and optional country code
|
|
793
796
|
* @param {string} city - City name
|
|
794
797
|
* @param {countryCode=} countryCode - Optional Country code
|
|
795
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
798
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
796
799
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
797
800
|
* @example
|
|
798
801
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByCity('Helsinki', 'fi', {lang: 'fi'});
|
|
@@ -802,8 +805,9 @@ var OpenWeatherV2 = class {
|
|
|
802
805
|
* const error: DOMException | TypeError = result.err();
|
|
803
806
|
* }
|
|
804
807
|
*/
|
|
805
|
-
async getWeatherByCity(city, countryCode,
|
|
808
|
+
async getWeatherByCity(city, countryCode, currentOpts = {}) {
|
|
806
809
|
try {
|
|
810
|
+
const opts = buildOpts(currentOpts);
|
|
807
811
|
const cacheKey = this.buildBaseCacheKey(`q:${city}:${countryCode}`, opts);
|
|
808
812
|
let cacheEntry = this.cache && await this.cache.get(cacheKey);
|
|
809
813
|
if (!cacheEntry) {
|
|
@@ -820,7 +824,7 @@ var OpenWeatherV2 = class {
|
|
|
820
824
|
* get weather with latitude and longitude with Result
|
|
821
825
|
* @param {number} lat - Latitude
|
|
822
826
|
* @param {number} lon - Longitude
|
|
823
|
-
* @param {OpenWeatherV2CommonOptions=}
|
|
827
|
+
* @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```
|
|
824
828
|
* @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise
|
|
825
829
|
* @example
|
|
826
830
|
* const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByLatLon(60.1699, 24.9384, {lang: 'fi'});
|
|
@@ -830,8 +834,9 @@ var OpenWeatherV2 = class {
|
|
|
830
834
|
* const error: DOMException | TypeError = result.err();
|
|
831
835
|
* }
|
|
832
836
|
*/
|
|
833
|
-
async getWeatherByLatLon(lat, lon,
|
|
837
|
+
async getWeatherByLatLon(lat, lon, currentOpts = {}) {
|
|
834
838
|
try {
|
|
839
|
+
const opts = buildOpts(currentOpts);
|
|
835
840
|
const cacheKey = this.buildBaseCacheKey(`latlon:${lat}:${lon}`, opts);
|
|
836
841
|
let cacheEntry = this.cache && await this.cache.get(cacheKey);
|
|
837
842
|
if (!cacheEntry) {
|
|
@@ -855,7 +860,7 @@ var OpenWeatherV2 = class {
|
|
|
855
860
|
* build base cache key
|
|
856
861
|
* @param main - main cache key prefix
|
|
857
862
|
* @param opts - OpenWeatherV2CommonOptions
|
|
858
|
-
* @returns {
|
|
863
|
+
* @returns {string} cache key
|
|
859
864
|
*/
|
|
860
865
|
buildBaseCacheKey(main, { lang, units }) {
|
|
861
866
|
return `${main}:${lang}:${units}`;
|
|
@@ -891,7 +896,6 @@ export {
|
|
|
891
896
|
isWeatherDataV2,
|
|
892
897
|
langCodeSchema,
|
|
893
898
|
langCodes,
|
|
894
|
-
solveLoadable,
|
|
895
899
|
weatherDataV2Schema,
|
|
896
900
|
weatherIdGroup,
|
|
897
901
|
weatherIdSchema
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/v2/Icon.ts","../src/types/v2/weatherIdGroup.ts","../src/types/v2/index.ts","../src/types/v2/Language.ts","../src/types/ISO3166-Countries.ts","../src/types/index.ts","../src/OpenWeatherV2.ts","../src/lib/fetchUtils.ts"],"sourcesContent":["import {z} from 'zod';\nconst dayIconList = ['01d', '02d', '03d', '04d', '09d', '10d', '11d', '13d', '50d'] as const;\n\n/**\n * @internal\n */\nconst dayIconListSchema = z.enum(dayIconList);\n\nexport type DayIcon = z.infer<typeof dayIconListSchema>;\n\nconst nightIconList = ['01n', '02n', '03n', '04n', '09n', '10n', '11n', '13n', '50n'] as const;\n\n/**\n * @internal\n */\nconst nightIconListSchema = z.enum(nightIconList);\nexport type NightIcon = z.infer<typeof nightIconListSchema>;\n\n/**\n * @internal\n */\nexport const iconSchema = z.union([dayIconListSchema, nightIconListSchema]);\n\nexport type Icon = z.infer<typeof iconSchema>;\n","import {type IOption, undefinedOptionWrap} from '@luolapeikko/result-option';\nimport {z} from 'zod';\n\n/**\n * This is a list of weather ids, groups and descriptions from OpenWeatherMap API\n */\nexport const weatherIdGroup = [\n\t{\n\t\tid: 200,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_light_rain',\n\t},\n\t{\n\t\tid: 201,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_rain',\n\t},\n\t{\n\t\tid: 202,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_heavy_rain',\n\t},\n\t{\n\t\tid: 210,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'light_thunderstorm',\n\t},\n\t{\n\t\tid: 211,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm',\n\t},\n\t{\n\t\tid: 212,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'heavy_thunderstorm',\n\t},\n\t{\n\t\tid: 221,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'ragged_thunderstorm',\n\t},\n\t{\n\t\tid: 230,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_light_drizzle',\n\t},\n\t{\n\t\tid: 231,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_drizzle',\n\t},\n\t{\n\t\tid: 232,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_heavy_drizzle',\n\t},\n\t{\n\t\tid: 300,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'light_intensity_drizzle',\n\t},\n\t{\n\t\tid: 301,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'drizzle',\n\t},\n\t{\n\t\tid: 302,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_intensity_drizzle',\n\t},\n\t{\n\t\tid: 310,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'light_intensity_drizzle_rain',\n\t},\n\t{\n\t\tid: 311,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'drizzle_rain',\n\t},\n\t{\n\t\tid: 312,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_intensity_drizzle_rain',\n\t},\n\t{\n\t\tid: 313,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'shower_rain_and_drizzle',\n\t},\n\t{\n\t\tid: 314,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_shower_rain_and_drizzle',\n\t},\n\t{\n\t\tid: 321,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'shower_drizzle',\n\t},\n\t{\n\t\tid: 500,\n\t\tgroup: 'rain',\n\t\tdescription: 'light_rain',\n\t},\n\t{\n\t\tid: 501,\n\t\tgroup: 'rain',\n\t\tdescription: 'moderate_rain',\n\t},\n\t{\n\t\tid: 502,\n\t\tgroup: 'rain',\n\t\tdescription: 'heavy_intensity_rain',\n\t},\n\t{\n\t\tid: 503,\n\t\tgroup: 'rain',\n\t\tdescription: 'very_heavy_rain',\n\t},\n\t{\n\t\tid: 504,\n\t\tgroup: 'rain',\n\t\tdescription: 'extreme_rain',\n\t},\n\t{\n\t\tid: 511,\n\t\tgroup: 'rain',\n\t\tdescription: 'freezing_rain',\n\t},\n\t{\n\t\tid: 520,\n\t\tgroup: 'rain',\n\t\tdescription: 'light_intensity_shower_rain',\n\t},\n\t{\n\t\tid: 521,\n\t\tgroup: 'rain',\n\t\tdescription: 'shower_rain',\n\t},\n\t{\n\t\tid: 522,\n\t\tgroup: 'rain',\n\t\tdescription: 'heavy_intensity_shower_rain',\n\t},\n\t{\n\t\tid: 531,\n\t\tgroup: 'rain',\n\t\tdescription: 'ragged_shower_rain',\n\t},\n\t{\n\t\tid: 600,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_snow',\n\t},\n\t{\n\t\tid: 601,\n\t\tgroup: 'snow',\n\t\tdescription: 'snow',\n\t},\n\t{\n\t\tid: 602,\n\t\tgroup: 'snow',\n\t\tdescription: 'heavy_snow',\n\t},\n\t{\n\t\tid: 611,\n\t\tgroup: 'snow',\n\t\tdescription: 'sleet',\n\t},\n\t{\n\t\tid: 612,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_shower_sleet',\n\t},\n\t{\n\t\tid: 613,\n\t\tgroup: 'snow',\n\t\tdescription: 'shower_sleet',\n\t},\n\t{\n\t\tid: 615,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_rain_and_snow',\n\t},\n\t{\n\t\tid: 616,\n\t\tgroup: 'snow',\n\t\tdescription: 'rain_and_snow',\n\t},\n\t{\n\t\tid: 620,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_shower_snow',\n\t},\n\t{\n\t\tid: 621,\n\t\tgroup: 'snow',\n\t\tdescription: 'shower_snow',\n\t},\n\t{\n\t\tid: 622,\n\t\tgroup: 'snow',\n\t\tdescription: 'heavy_shower_snow',\n\t},\n\t{\n\t\tid: 701,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'mist',\n\t},\n\t{\n\t\tid: 711,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'smoke',\n\t},\n\t{\n\t\tid: 721,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'haze',\n\t},\n\t{\n\t\tid: 731,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'sand_dust_whirls',\n\t},\n\t{\n\t\tid: 741,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'fog',\n\t},\n\t{\n\t\tid: 751,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'sand',\n\t},\n\t{\n\t\tid: 761,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'dust',\n\t},\n\t{\n\t\tid: 762,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'volcanic_ash',\n\t},\n\t{\n\t\tid: 771,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'squalls',\n\t},\n\t{\n\t\tid: 781,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'tornado',\n\t},\n\t{\n\t\tid: 800,\n\t\tgroup: 'clear',\n\t\tdescription: 'clear_sky',\n\t},\n\t{\n\t\tid: 801,\n\t\tgroup: 'clouds',\n\t\tdescription: 'few_clouds_11-25_percent',\n\t},\n\t{\n\t\tid: 802,\n\t\tgroup: 'clouds',\n\t\tdescription: 'scattered_clouds_25-50_percent',\n\t},\n\t{\n\t\tid: 803,\n\t\tgroup: 'clouds',\n\t\tdescription: 'broken_clouds_51-84_percent',\n\t},\n\t{\n\t\tid: 804,\n\t\tgroup: 'clouds',\n\t\tdescription: 'overcast_clouds_85-100_percent',\n\t},\n] as const;\n\nexport type WeatherID = (typeof weatherIdGroup)[number]['id'];\n\n/**\n * WeatherGroup: \"clouds\" | \"rain\" | \"snow\" | \"thunderstorm\" | \"drizzle\" | \"atmosphere\" | \"clear\"\n */\nexport type WeatherGroup = (typeof weatherIdGroup)[number]['group'];\n\n/**\n * List for weather description key types from OpenWeatherMap API based on weather id.\n *\n * This list of keys can be used to translate weather id to human readable description with different languages.\n * @example\n * const i18Weather: Record<WeatherDescription, string> = {\n * clear_sky: 'Clear sky',\n * ...\n * }\n */\nexport type WeatherDescription = (typeof weatherIdGroup)[number]['description'];\n\n/**\n * Weather id schema\n * @internal\n */\nexport const weatherIdSchema = z.custom<WeatherID>((val) => {\n\tif (typeof val !== 'number') {\n\t\treturn {message: 'Expected a number', success: false};\n\t}\n\tif (!weatherIdGroup.find((x) => x.id === val)) {\n\t\treturn {message: 'Expected a valid weather id', success: false};\n\t}\n\treturn val;\n});\n\n/**\n * get weather description key from weather id\n * @param id - weather id\n * @returns {Option<WeatherDescription>} option for weather description key\n * @example\n * const weatherComponent = ({data}) => {\n * const key = getWeatherV2Description(data.weather[0]?.id).unwrapOr('unknown');\n * return (\n * <div>\n * {t(`weather:${key}`}\n * </div>\n * );\n * }\n */\nexport function getWeatherV2Description(id: WeatherID | undefined): IOption<WeatherDescription> {\n\treturn undefinedOptionWrap(weatherIdGroup.find((x) => x.id === id)?.description);\n}\n","import {iconSchema} from './Icon';\nimport {weatherIdSchema} from './weatherIdGroup';\nimport {z} from 'zod';\nexport * from './Icon';\nexport * from './Language';\nexport * from './weatherIdGroup';\n\nconst coordSchema = z.object({\n\tlon: z.number(),\n\tlat: z.number(),\n});\n\nconst weatherSchema = z.object({\n\tdescription: z.string(),\n\ticon: iconSchema,\n\tid: weatherIdSchema,\n\tmain: z.string(),\n});\n\nconst mainSchema = z.object({\n\tgrnd_level: z.number().optional(),\n\thumidity: z.number(),\n\tpressure: z.number(),\n\tsea_level: z.number().optional(),\n\ttemp: z.number(),\n\ttemp_max: z.number(),\n\ttemp_min: z.number(),\n});\n\nconst windSchema = z.object({\n\tspeed: z.number(),\n\tdeg: z.number(),\n});\n\nconst rainSchema = z.object({\n\t'1h': z.number().optional(),\n\t'3h': z.number().optional(),\n});\n\nconst snowSchema = z.object({\n\t'1h': z.number().optional(),\n\t'3h': z.number().optional(),\n});\n\nconst sysSchema = z.object({\n\tcountry: z.string(),\n\tid: z.number().optional(),\n\tmessage: z.number().optional(),\n\tsunrise: z.number(),\n\tsunset: z.number(),\n\ttype: z.number().optional(),\n});\n\n/**\n * @internal\n */\nexport const weatherDataV2Schema = z.object({\n\tbase: z.string(),\n\tclouds: z.object({\n\t\tall: z.number(),\n\t}),\n\tcod: z.number(),\n\tcoord: coordSchema,\n\tdt: z.number(),\n\tid: z.number(),\n\tmain: mainSchema,\n\tname: z.string(),\n\train: rainSchema.optional(),\n\tsnow: snowSchema.optional(),\n\tsys: sysSchema,\n\ttimezone: z.number(),\n\tvisibility: z.number(),\n\tweather: z.array(weatherSchema),\n\twind: windSchema,\n});\n\nexport type WeatherDataV2 = z.infer<typeof weatherDataV2Schema>;\n\nexport function isWeatherDataV2(data: unknown): data is WeatherDataV2 {\n\treturn weatherDataV2Schema.safeParse(data).success;\n}\n\nexport function assertWeatherDataV2(data: unknown): asserts data is WeatherDataV2 {\n\tweatherDataV2Schema.parse(data);\n}\n","import {z} from 'zod';\nexport const langCodes = [\n\t'af',\n\t'al',\n\t'ar',\n\t'az',\n\t'bg',\n\t'ca',\n\t'cz',\n\t'da',\n\t'de',\n\t'el',\n\t'en',\n\t'eu',\n\t'fa',\n\t'fi',\n\t'fr',\n\t'gl',\n\t'he',\n\t'hi',\n\t'hr',\n\t'hu',\n\t'id',\n\t'it',\n\t'ja',\n\t'kr',\n\t'la',\n\t'lt',\n\t'mk',\n\t'no',\n\t'nl',\n\t'pl',\n\t'pt',\n\t'pt',\n\t'ro',\n\t'ru',\n\t'sv',\n\t'sk',\n\t'sl',\n\t'sp',\n\t'sr',\n\t'th',\n\t'tr',\n\t'ua',\n\t'vi',\n\t'zh_cn',\n\t'zh_tw',\n\t'zu',\n] as const;\nexport const langCodeSchema = z.enum(langCodes);\nexport type LangCode = z.infer<typeof langCodeSchema>;\n","import {z} from 'zod';\n\nexport const CountryCodeList = [\n\t'af',\n\t'ax',\n\t'al',\n\t'dz',\n\t'as',\n\t'ad',\n\t'ao',\n\t'ai',\n\t'aq',\n\t'ag',\n\t'ar',\n\t'am',\n\t'aw',\n\t'au',\n\t'at',\n\t'az',\n\t'bs',\n\t'bh',\n\t'bd',\n\t'bb',\n\t'by',\n\t'be',\n\t'bz',\n\t'bj',\n\t'bm',\n\t'bt',\n\t'bo',\n\t'bq',\n\t'ba',\n\t'bw',\n\t'bv',\n\t'br',\n\t'io',\n\t'bn',\n\t'bg',\n\t'bf',\n\t'bi',\n\t'kh',\n\t'cm',\n\t'ca',\n\t'cv',\n\t'ky',\n\t'cf',\n\t'td',\n\t'cl',\n\t'cn',\n\t'cx',\n\t'cc',\n\t'co',\n\t'km',\n\t'cg',\n\t'cd',\n\t'ck',\n\t'cr',\n\t'ci',\n\t'hr',\n\t'cu',\n\t'cw',\n\t'cy',\n\t'cz',\n\t'dk',\n\t'dj',\n\t'dm',\n\t'do',\n\t'ec',\n\t'eg',\n\t'sv',\n\t'gq',\n\t'er',\n\t'ee',\n\t'et',\n\t'fk',\n\t'fo',\n\t'fj',\n\t'fi',\n\t'fr',\n\t'gf',\n\t'pf',\n\t'tf',\n\t'ga',\n\t'gm',\n\t'ge',\n\t'de',\n\t'gh',\n\t'gi',\n\t'gr',\n\t'gl',\n\t'gd',\n\t'gp',\n\t'gu',\n\t'gt',\n\t'gg',\n\t'gn',\n\t'gw',\n\t'gy',\n\t'ht',\n\t'hm',\n\t'va',\n\t'hn',\n\t'hk',\n\t'hu',\n\t'is',\n\t'in',\n\t'id',\n\t'ir',\n\t'iq',\n\t'ie',\n\t'im',\n\t'il',\n\t'it',\n\t'jm',\n\t'jp',\n\t'je',\n\t'jo',\n\t'kz',\n\t'ke',\n\t'ki',\n\t'kp',\n\t'kr',\n\t'kw',\n\t'kg',\n\t'la',\n\t'lv',\n\t'lb',\n\t'ls',\n\t'lr',\n\t'ly',\n\t'li',\n\t'lt',\n\t'lu',\n\t'mo',\n\t'mk',\n\t'mg',\n\t'mw',\n\t'my',\n\t'mv',\n\t'ml',\n\t'mt',\n\t'mh',\n\t'mq',\n\t'mr',\n\t'mu',\n\t'yt',\n\t'mx',\n\t'fm',\n\t'md',\n\t'mc',\n\t'mn',\n\t'me',\n\t'ms',\n\t'ma',\n\t'mz',\n\t'mm',\n\t'na',\n\t'nr',\n\t'np',\n\t'nl',\n\t'nc',\n\t'nz',\n\t'ni',\n\t'ne',\n\t'ng',\n\t'nu',\n\t'nf',\n\t'mp',\n\t'no',\n\t'om',\n\t'pk',\n\t'pw',\n\t'ps',\n\t'pa',\n\t'pg',\n\t'py',\n\t'pe',\n\t'ph',\n\t'pn',\n\t'pl',\n\t'pt',\n\t'pr',\n\t'qa',\n\t're',\n\t'ro',\n\t'ru',\n\t'rw',\n\t'bl',\n\t'sh',\n\t'kn',\n\t'lc',\n\t'mf',\n\t'pm',\n\t'vc',\n\t'ws',\n\t'sm',\n\t'st',\n\t'sa',\n\t'sn',\n\t'rs',\n\t'sc',\n\t'sl',\n\t'sg',\n\t'sx',\n\t'sk',\n\t'si',\n\t'sb',\n\t'so',\n\t'za',\n\t'gs',\n\t'ss',\n\t'es',\n\t'lk',\n\t'sd',\n\t'sr',\n\t'sj',\n\t'sz',\n\t'se',\n\t'ch',\n\t'sy',\n\t'tw',\n\t'tj',\n\t'tz',\n\t'th',\n\t'tl',\n\t'tg',\n\t'tk',\n\t'to',\n\t'tt',\n\t'tn',\n\t'tr',\n\t'tm',\n\t'tc',\n\t'tv',\n\t'ug',\n\t'ua',\n\t'ae',\n\t'gb',\n\t'us',\n\t'um',\n\t'uy',\n\t'uz',\n\t'vu',\n\t've',\n\t'vn',\n\t'vg',\n\t'vi',\n\t'wf',\n\t'eh',\n\t'ye',\n\t'zm',\n\t'zw',\n] as const;\n/**\n * @internal\n */\nexport const CountryCodeSchema = z.enum(CountryCodeList);\nexport type CountryCode = z.infer<typeof CountryCodeSchema>;\n","export * from './v2';\nexport * from './ISO3166-Countries';\n\n/**\n * Generic argument which can be value, Promise of value, function which returns value or Promise of value.\n * @example\n * function solveLoadable(value: Loadable<string>): string | Promise<string> {\n * return typeof value === 'function' ? value() : value;\n * }\n */\nexport type Loadable<T> = T | Promise<T> | (() => T) | (() => Promise<T>);\n\nexport function solveLoadable(value: Loadable<string>): string | Promise<string> {\n\treturn typeof value === 'function' ? value() : value;\n}\n","import {assertWeatherDataV2, type CountryCode, type LangCode, type Loadable, type WeatherDataV2} from './types';\nimport {Err, type IResult, Ok, safeAsyncResult, safeAsyncResultBuilder} from '@luolapeikko/result-option';\nimport {fetchErrorWrapper} from './lib/fetchUtils';\nimport {type IAsyncCache} from '@luolapeikko/cache-types';\nimport type {IOpenWeatherV2} from './interfaces/IOpenWeatherV2';\n\nconst fetchResult = safeAsyncResultBuilder<Parameters<typeof fetch>, Response, SyntaxError | TypeError>(fetch);\n\nfunction toParams(data: Record<string, string | number | boolean>): Record<string, string> {\n\treturn Object.entries(data).reduce<Record<string, string>>((acc, [key, value]) => {\n\t\tacc[key] = String(value);\n\t\treturn acc;\n\t}, {});\n}\n\nfunction isJson(response: Response): boolean {\n\tconst contentType = response.headers.get('content-type');\n\treturn (contentType && contentType.startsWith('application/json')) || false;\n}\n\nfunction isOpenWeatherError(data: unknown): data is {cod: string; message: string} {\n\treturn typeof data === 'object' && data !== null && 'cod' in data && 'message' in data;\n}\n\n/**\n * Open Weather V2 API Common Options\n * @default {lang: 'en', units: 'standard'} in API\n * @example\n * {lang: 'fi', units: 'metric'}\n */\nexport type OpenWeatherV2CommonOptions = {\n\t/**\n\t * Language code\n\t */\n\tlang?: LangCode;\n\t/**\n\t * Weather units\n\t */\n\tunits?: 'standard' | 'metric' | 'imperial';\n};\n\nconst basePath = 'https://api.openweathermap.org/data/2.5/weather';\n\nfunction buildUrl(params: URLSearchParams): string {\n\treturn `${basePath}?${params.toString()}`;\n}\n\nfunction buildLogUrl(params: URLSearchParams): string {\n\tconst logParams = new URLSearchParams(params);\n\tlogParams.set('appid', '***');\n\treturn buildUrl(logParams);\n}\n\nconst defaultImplementation: IOpenWeatherV2 = {\n\tdataWeatherApi: async (params: URLSearchParams): Promise<IResult<WeatherDataV2, SyntaxError | TypeError>> => {\n\t\tconst logUrl = buildLogUrl(params);\n\t\tconst result = await fetchResult(buildUrl(params));\n\t\tif (!result.isOk) {\n\t\t\treturn Err(result.err());\n\t\t}\n\t\tconst res = result.ok();\n\t\tif (!res.ok) {\n\t\t\tif (isJson(res)) {\n\t\t\t\tconst data: unknown = await res.json();\n\t\t\t\tif (isOpenWeatherError(data)) {\n\t\t\t\t\treturn Err(new TypeError(`OpenWeatherV2 error: ${data.message} from ${logUrl}`));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Err(new TypeError(`OpenWeatherV2 http error: ${res.status} ${res.statusText} from ${logUrl}`));\n\t\t}\n\t\tif (!isJson(res)) {\n\t\t\treturn Err(new TypeError(`OpenWeatherV2 response is not json payload from ${logUrl}`));\n\t\t}\n\t\tconst jsonResult = await safeAsyncResult<unknown, SyntaxError>(res.json());\n\t\tif (!jsonResult.isOk) {\n\t\t\treturn Err(jsonResult.err());\n\t\t}\n\t\tconst data = jsonResult.ok();\n\t\tassertWeatherDataV2(data);\n\t\treturn Ok<WeatherDataV2, SyntaxError | TypeError>(data);\n\t},\n};\n\n/**\n * Open Weather V2 API\n * @example\n * const weather = new OpenWeatherV2('your-api-key');\n *\n * const cache = new ExpireCache<WeatherDataV2>(undefined, undefined, 900000); // data 15 minutes in cache\n * const weather = new OpenWeatherV2(() => Promise.resolve('your-api-key'), cache);\n *\n * const data: WeatherDataV2 = (await weather.getWeatherById(2643743)).unwrap(); // throws if error\n * const data: WeatherDataV2 | undefined = (await weather.getWeatherByCity('Helsinki', 'fi')).ok();\n *\n * const result: Result<WeatherDataV2> = await weather.getWeatherByLatLon(60.1699, 24.9384);\n * result.match({\n * Ok: (data: WeatherDataV2) => console.log(data),\n * Err: (err: DOMException | TypeError) => console.error(err),\n * });\n *\n * if(result.isOk) {\n * const data: WeatherDataV2 = data.ok();\n * } else {\n * const err: DOMException | TypeError = data.err();\n * }\n */\nexport class OpenWeatherV2 {\n\tprivate cache: IAsyncCache<WeatherDataV2> | undefined;\n\tprivate loadableApiKey: Loadable<string>;\n\tprivate apiHandler: IOpenWeatherV2;\n\tprivate fetchPromiseMap = new Map<string, Promise<IResult<WeatherDataV2, DOMException | TypeError>>>();\n\t/**\n\t * OpenWeatherV2 constructor\n\t * @param {Loadable<string>} loadableApiKey - Loadable API key\n\t * @param {ICacheOrAsync<WeatherDataV2>=} cache - optional async cache implementation\n\t * @param {IOpenWeatherV2=} apiHandler - optional API handler implementation for mocking\n\t */\n\tconstructor(loadableApiKey: Loadable<string>, cache?: IAsyncCache<WeatherDataV2>, apiHandler: IOpenWeatherV2 = defaultImplementation) {\n\t\tthis.loadableApiKey = loadableApiKey;\n\t\tthis.cache = cache;\n\t\tthis.apiHandler = apiHandler;\n\t}\n\n\t/**\n\t * get weather by Id\n\t * @param {number} id - Weather station ID\n\t * @param {OpenWeatherV2CommonOptions=} opts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherResultById(id: 564, {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherById(id: number, opts: OpenWeatherV2CommonOptions = {}): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`id:${id}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('id', String(id));\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\t/**\n\t * get weather with city name and optional country code\n\t * @param {string} city - City name\n\t * @param {countryCode=} countryCode - Optional Country code\n\t * @param {OpenWeatherV2CommonOptions=} opts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByCity('Helsinki', 'fi', {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherByCity(\n\t\tcity: string,\n\t\tcountryCode?: CountryCode,\n\t\topts: OpenWeatherV2CommonOptions = {},\n\t): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`q:${city}:${countryCode}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('q', countryCode ? `${city},${countryCode}` : city);\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\t/**\n\t * get weather with latitude and longitude with Result\n\t * @param {number} lat - Latitude\n\t * @param {number} lon - Longitude\n\t * @param {OpenWeatherV2CommonOptions=} opts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByLatLon(60.1699, 24.9384, {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherByLatLon(lat: number, lon: number, opts: OpenWeatherV2CommonOptions = {}): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`latlon:${lat}:${lon}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('lat', String(lat));\n\t\t\t\tparams.append('lon', String(lon));\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\tprivate async buildBaseParams(options: OpenWeatherV2CommonOptions): Promise<URLSearchParams> {\n\t\tconst apiKey = await (typeof this.loadableApiKey === 'function' ? this.loadableApiKey() : this.loadableApiKey);\n\t\tconst params = new URLSearchParams(toParams(options));\n\t\tparams.append('appid', apiKey);\n\t\treturn params;\n\t}\n\n\t/**\n\t * build base cache key\n\t * @param main - main cache key prefix\n\t * @param opts - OpenWeatherV2CommonOptions\n\t * @returns {CacheKey}\n\t */\n\tprivate buildBaseCacheKey(main: string, {lang, units}: OpenWeatherV2CommonOptions): string {\n\t\treturn `${main}:${lang}:${units}`;\n\t}\n\n\tprivate async handleFetch(cacheKey: string, params: URLSearchParams, opts: OpenWeatherV2CommonOptions): Promise<WeatherDataV2> {\n\t\t// allow only one fetch per cacheKey until it is resolved\n\t\tlet promiseResult = this.fetchPromiseMap.get(cacheKey);\n\t\tif (!promiseResult) {\n\t\t\tpromiseResult = this.apiHandler.dataWeatherApi(params);\n\t\t\tthis.fetchPromiseMap.set(cacheKey, promiseResult);\n\t\t\tawait promiseResult;\n\t\t\tthis.fetchPromiseMap.delete(cacheKey); // clear promise from map\n\t\t}\n\t\tconst dataApiResult = await promiseResult;\n\t\tconst data: WeatherDataV2 = dataApiResult.unwrap();\n\t\tassertWeatherDataV2(data);\n\t\tif (this.cache) {\n\t\t\tawait this.cache.set(cacheKey, data);\n\t\t\tif (!cacheKey.startsWith('id:')) {\n\t\t\t\t// update id cache too\n\t\t\t\tawait this.cache.set(this.buildBaseCacheKey(`id:${data.id}`, opts), data);\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}\n}\n","/**\n * Ensures that the error is a DOMException or TypeError.\n * @internal\n */\nexport function fetchErrorWrapper(err: unknown): DOMException | TypeError {\n\tif (err instanceof DOMException || err instanceof TypeError) {\n\t\treturn err;\n\t} else {\n\t\treturn new TypeError(`Unknown error: ${String(err)}`);\n\t}\n}\n"],"mappings":";AAAA,SAAQ,SAAQ;AAChB,IAAM,cAAc,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAKlF,IAAM,oBAAoB,EAAE,KAAK,WAAW;AAI5C,IAAM,gBAAgB,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAKpF,IAAM,sBAAsB,EAAE,KAAK,aAAa;AAMzC,IAAM,aAAa,EAAE,MAAM,CAAC,mBAAmB,mBAAmB,CAAC;;;ACrB1E,SAAsB,2BAA0B;AAChD,SAAQ,KAAAA,UAAQ;AAKT,IAAM,iBAAiB;AAAA,EAC7B;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAA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AAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,kBAAkB,MAAc,EAAC,MAAM,MAAK,GAAuC;AAC1F,WAAO,GAAG,IAAI,IAAI,IAAI,IAAI,KAAK;AAAA,EAChC;AAAA,EAEA,MAAc,YAAY,UAAkB,QAAyB,MAA0D;AAE9H,QAAI,gBAAgB,KAAK,gBAAgB,IAAI,QAAQ;AACrD,QAAI,CAAC,eAAe;AACnB,sBAAgB,KAAK,WAAW,eAAe,MAAM;AACrD,WAAK,gBAAgB,IAAI,UAAU,aAAa;AAChD,YAAM;AACN,WAAK,gBAAgB,OAAO,QAAQ;AAAA,IACrC;AACA,UAAM,gBAAgB,MAAM;AAC5B,UAAM,OAAsB,cAAc,OAAO;AACjD,wBAAoB,IAAI;AACxB,QAAI,KAAK,OAAO;AACf,YAAM,KAAK,MAAM,IAAI,UAAU,IAAI;AACnC,UAAI,CAAC,SAAS,WAAW,KAAK,GAAG;AAEhC,cAAM,KAAK,MAAM,IAAI,KAAK,kBAAkB,MAAM,KAAK,EAAE,IAAI,IAAI,GAAG,IAAI;AAAA,MACzE;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;","names":["z","z","z","z","z","data"]}
|
|
1
|
+
{"version":3,"sources":["../src/OpenWeatherV2.ts","../src/lib/fetchUtils.ts","../src/types/v2/index.ts","../src/types/v2/Icon.ts","../src/types/v2/weatherIdGroup.ts","../src/types/v2/Language.ts","../src/types/ISO3166-Countries.ts"],"sourcesContent":["import {type IAsyncCache} from '@luolapeikko/cache-types';\nimport {Err, type IResult, Ok, safeAsyncResult, safeAsyncResultBuilder} from '@luolapeikko/result-option';\nimport {type Loadable} from '@luolapeikko/ts-common';\nimport type {IOpenWeatherV2} from './interfaces/IOpenWeatherV2';\nimport {fetchErrorWrapper} from './lib/fetchUtils';\nimport {assertWeatherDataV2, type CountryCode, type LangCode, type WeatherDataV2} from './types';\n\nconst fetchResult = safeAsyncResultBuilder<Parameters<typeof fetch>, Response, SyntaxError | TypeError>(fetch);\n\nfunction toParams(data: Record<string, string | number | boolean>): Record<string, string> {\n\treturn Object.entries(data).reduce<Record<string, string>>((acc, [key, value]) => {\n\t\tacc[key] = String(value);\n\t\treturn acc;\n\t}, {});\n}\n\nfunction isJson(response: Response): boolean {\n\tconst contentType = response.headers.get('content-type');\n\treturn contentType?.startsWith('application/json') ?? false;\n}\n\nfunction isOpenWeatherError(data: unknown): data is {cod: string; message: string} {\n\treturn typeof data === 'object' && data !== null && 'cod' in data && 'message' in data;\n}\n\n/**\n * Open Weather V2 API Common Options\n * @default {lang: 'en', units: 'standard'} in API\n * @example\n * {lang: 'fi', units: 'metric'}\n * @since v0.0.1\n */\nexport type OpenWeatherV2CommonOptions = {\n\t/**\n\t * Language code\n\t */\n\tlang: LangCode;\n\t/**\n\t * Weather units\n\t */\n\tunits: 'standard' | 'metric' | 'imperial';\n};\n\nconst defaultCommonOptions = {\n\tlang: 'en',\n\tunits: 'standard',\n} satisfies OpenWeatherV2CommonOptions;\n\nfunction buildOpts(opts: Partial<OpenWeatherV2CommonOptions>): OpenWeatherV2CommonOptions {\n\treturn Object.assign({}, defaultCommonOptions, opts);\n}\n\nconst basePath = 'https://api.openweathermap.org/data/2.5/weather';\n\nfunction buildUrl(params: URLSearchParams): string {\n\treturn `${basePath}?${params.toString()}`;\n}\n\nfunction buildLogUrl(params: URLSearchParams): string {\n\tconst logParams = new URLSearchParams(params);\n\tlogParams.set('appid', '***');\n\treturn buildUrl(logParams);\n}\n\nconst defaultImplementation: IOpenWeatherV2 = {\n\tdataWeatherApi: async (params: URLSearchParams): Promise<IResult<WeatherDataV2, SyntaxError | TypeError>> => {\n\t\tconst logUrl = buildLogUrl(params);\n\t\tconst result = await fetchResult(buildUrl(params));\n\t\tif (!result.isOk) {\n\t\t\treturn Err(result.err());\n\t\t}\n\t\tconst res = result.ok();\n\t\tif (!res.ok) {\n\t\t\tif (isJson(res)) {\n\t\t\t\tconst data: unknown = await res.json();\n\t\t\t\tif (isOpenWeatherError(data)) {\n\t\t\t\t\treturn Err(new TypeError(`OpenWeatherV2 error: ${data.message} from ${logUrl}`));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn Err(new TypeError(`OpenWeatherV2 http error: ${res.status} ${res.statusText} from ${logUrl}`));\n\t\t}\n\t\tif (!isJson(res)) {\n\t\t\treturn Err(new TypeError(`OpenWeatherV2 response is not json payload from ${logUrl}`));\n\t\t}\n\t\tconst jsonResult = await safeAsyncResult<unknown, SyntaxError>(res.json());\n\t\tif (!jsonResult.isOk) {\n\t\t\treturn Err(jsonResult.err());\n\t\t}\n\t\tconst data = jsonResult.ok();\n\t\tassertWeatherDataV2(data);\n\t\treturn Ok<WeatherDataV2, SyntaxError | TypeError>(data);\n\t},\n};\n\n/**\n * Cache key types\n * @since v0.1.0\n */\ntype CacheKey = `q:${string}:${string}` | `id:${number}` | `latlon:${number}:${number}`;\n\n/**\n * Open Weather V2 API\n * @example\n * const weather = new OpenWeatherV2('your-api-key');\n *\n * const cache = new ExpireCache<WeatherDataV2>(undefined, undefined, 900000); // data 15 minutes in cache\n * const weather = new OpenWeatherV2(() => Promise.resolve('your-api-key'), cache);\n *\n * const data: WeatherDataV2 = (await weather.getWeatherById(2643743)).unwrap(); // throws if error\n * const data: WeatherDataV2 | undefined = (await weather.getWeatherByCity('Helsinki', 'fi')).ok();\n *\n * const result: Result<WeatherDataV2> = await weather.getWeatherByLatLon(60.1699, 24.9384);\n * result.match({\n * Ok: (data: WeatherDataV2) => console.log(data),\n * Err: (err: DOMException | TypeError) => console.error(err),\n * });\n *\n * if(result.isOk) {\n * const data: WeatherDataV2 = data.ok();\n * } else {\n * const err: DOMException | TypeError = data.err();\n * }\n * @since v0.0.1\n */\nexport class OpenWeatherV2 {\n\tprivate cache: IAsyncCache<WeatherDataV2> | undefined;\n\tprivate loadableApiKey: Loadable<string>;\n\tprivate apiHandler: IOpenWeatherV2;\n\tprivate fetchPromiseMap = new Map<string, Promise<IResult<WeatherDataV2, DOMException | TypeError>>>();\n\t/**\n\t * OpenWeatherV2 constructor\n\t * @param {Loadable<string>} loadableApiKey - Loadable API key\n\t * @param {ICacheOrAsync<WeatherDataV2>=} cache - optional async cache implementation\n\t * @param {IOpenWeatherV2=} apiHandler - optional API handler implementation for mocking\n\t */\n\tconstructor(loadableApiKey: Loadable<string>, cache?: IAsyncCache<WeatherDataV2>, apiHandler: IOpenWeatherV2 = defaultImplementation) {\n\t\tthis.loadableApiKey = loadableApiKey;\n\t\tthis.cache = cache;\n\t\tthis.apiHandler = apiHandler;\n\t}\n\n\t/**\n\t * get weather by Id\n\t * @param {number} id - Weather station ID\n\t * @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherResultById(id: 564, {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherById(id: number, currentOpts: Partial<OpenWeatherV2CommonOptions> = {}): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst opts = buildOpts(currentOpts);\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`id:${id}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('id', String(id));\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\t/**\n\t * get weather with city name and optional country code\n\t * @param {string} city - City name\n\t * @param {countryCode=} countryCode - Optional Country code\n\t * @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByCity('Helsinki', 'fi', {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherByCity(\n\t\tcity: string,\n\t\tcountryCode?: CountryCode,\n\t\tcurrentOpts: Partial<OpenWeatherV2CommonOptions> = {},\n\t): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst opts = buildOpts(currentOpts);\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`q:${city}:${countryCode}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('q', countryCode ? `${city},${countryCode}` : city);\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\t/**\n\t * get weather with latitude and longitude with Result\n\t * @param {number} lat - Latitude\n\t * @param {number} lon - Longitude\n\t * @param {OpenWeatherV2CommonOptions=} currentOpts - Common options, example ```{lang: 'fi', units: 'metric'}```, defaults ```{lang: 'en', units: 'standard'}```\n\t * @return {Promise<Result<WeatherDataV2, DOMException | TypeError>>} Weather data Result Promise\n\t * @example\n\t * const result: Result<WeatherDataV2, DOMException | TypeError> = await weather.getWeatherByLatLon(60.1699, 24.9384, {lang: 'fi'});\n\t * if (result.isOk) {\n\t * const weatherData: WeatherDataV2 = result.ok();\n\t * } else {\n\t * const error: DOMException | TypeError = result.err();\n\t * }\n\t */\n\tpublic async getWeatherByLatLon(\n\t\tlat: number,\n\t\tlon: number,\n\t\tcurrentOpts: Partial<OpenWeatherV2CommonOptions> = {},\n\t): Promise<IResult<WeatherDataV2, DOMException | TypeError>> {\n\t\ttry {\n\t\t\tconst opts = buildOpts(currentOpts);\n\t\t\tconst cacheKey = this.buildBaseCacheKey(`latlon:${lat}:${lon}`, opts);\n\t\t\tlet cacheEntry = this.cache && (await this.cache.get(cacheKey));\n\t\t\tif (!cacheEntry) {\n\t\t\t\tconst params = await this.buildBaseParams(opts);\n\t\t\t\tparams.append('lat', String(lat));\n\t\t\t\tparams.append('lon', String(lon));\n\t\t\t\tcacheEntry = await this.handleFetch(cacheKey, params, opts);\n\t\t\t}\n\t\t\treturn Ok(cacheEntry);\n\t\t} catch (err) {\n\t\t\treturn Err(fetchErrorWrapper(err));\n\t\t}\n\t}\n\n\tprivate async buildBaseParams(options: OpenWeatherV2CommonOptions): Promise<URLSearchParams> {\n\t\tconst apiKey = await (typeof this.loadableApiKey === 'function' ? this.loadableApiKey() : this.loadableApiKey);\n\t\tconst params = new URLSearchParams(toParams(options));\n\t\tparams.append('appid', apiKey);\n\t\treturn params;\n\t}\n\n\t/**\n\t * build base cache key\n\t * @param main - main cache key prefix\n\t * @param opts - OpenWeatherV2CommonOptions\n\t * @returns {string} cache key\n\t */\n\tprivate buildBaseCacheKey(main: CacheKey, {lang, units}: OpenWeatherV2CommonOptions): `${CacheKey}:${LangCode}:${'standard' | 'metric' | 'imperial'}` {\n\t\treturn `${main}:${lang}:${units}`;\n\t}\n\n\tprivate async handleFetch(cacheKey: string, params: URLSearchParams, opts: OpenWeatherV2CommonOptions): Promise<WeatherDataV2> {\n\t\t// allow only one fetch per cacheKey until it is resolved\n\t\tlet promiseResult = this.fetchPromiseMap.get(cacheKey);\n\t\tif (!promiseResult) {\n\t\t\tpromiseResult = this.apiHandler.dataWeatherApi(params);\n\t\t\tthis.fetchPromiseMap.set(cacheKey, promiseResult);\n\t\t\tawait promiseResult;\n\t\t\tthis.fetchPromiseMap.delete(cacheKey); // clear promise from map\n\t\t}\n\t\tconst dataApiResult = await promiseResult;\n\t\tconst data: WeatherDataV2 = dataApiResult.unwrap();\n\t\tassertWeatherDataV2(data);\n\t\tif (this.cache) {\n\t\t\tawait this.cache.set(cacheKey, data);\n\t\t\tif (!cacheKey.startsWith('id:')) {\n\t\t\t\t// update id cache too\n\t\t\t\tawait this.cache.set(this.buildBaseCacheKey(`id:${data.id}`, opts), data);\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}\n}\n","/**\n * Ensures that the error is a DOMException or TypeError.\n * @internal\n */\nexport function fetchErrorWrapper(err: unknown): DOMException | TypeError {\n\tif (err instanceof DOMException || err instanceof TypeError) {\n\t\treturn err;\n\t} else {\n\t\treturn new TypeError(`Unknown error: ${String(err)}`);\n\t}\n}\n","import {z} from 'zod';\nimport {iconSchema} from './Icon';\nimport {weatherIdSchema} from './weatherIdGroup';\nexport * from './Icon';\nexport * from './Language';\nexport * from './weatherIdGroup';\n\nconst coordSchema = z.object({\n\tlon: z.number(),\n\tlat: z.number(),\n});\n\nconst weatherSchema = z.object({\n\tdescription: z.string(),\n\ticon: iconSchema,\n\tid: weatherIdSchema,\n\tmain: z.string(),\n});\n\nconst mainSchema = z.object({\n\tgrnd_level: z.number().optional(),\n\thumidity: z.number(),\n\tpressure: z.number(),\n\tsea_level: z.number().optional(),\n\ttemp: z.number(),\n\ttemp_max: z.number(),\n\ttemp_min: z.number(),\n});\n\nconst windSchema = z.object({\n\tspeed: z.number(),\n\tdeg: z.number(),\n});\n\nconst rainSchema = z.object({\n\t'1h': z.number().optional(),\n\t'3h': z.number().optional(),\n});\n\nconst snowSchema = z.object({\n\t'1h': z.number().optional(),\n\t'3h': z.number().optional(),\n});\n\nconst sysSchema = z.object({\n\tcountry: z.string(),\n\tid: z.number().optional(),\n\tmessage: z.number().optional(),\n\tsunrise: z.number(),\n\tsunset: z.number(),\n\ttype: z.number().optional(),\n});\n\n/**\n * @internal\n */\nexport const weatherDataV2Schema = z.object({\n\tbase: z.string(),\n\tclouds: z.object({\n\t\tall: z.number(),\n\t}),\n\tcod: z.number(),\n\tcoord: coordSchema,\n\tdt: z.number(),\n\tid: z.number(),\n\tmain: mainSchema,\n\tname: z.string(),\n\train: rainSchema.optional(),\n\tsnow: snowSchema.optional(),\n\tsys: sysSchema,\n\ttimezone: z.number(),\n\tvisibility: z.number(),\n\tweather: z.array(weatherSchema),\n\twind: windSchema,\n});\n\nexport type WeatherDataV2 = z.infer<typeof weatherDataV2Schema>;\n\nexport function isWeatherDataV2(data: unknown): data is WeatherDataV2 {\n\treturn weatherDataV2Schema.safeParse(data).success;\n}\n\nexport function assertWeatherDataV2(data: unknown): asserts data is WeatherDataV2 {\n\tweatherDataV2Schema.parse(data);\n}\n","import {z} from 'zod';\nconst dayIconList = ['01d', '02d', '03d', '04d', '09d', '10d', '11d', '13d', '50d'] as const;\n\n/**\n * @internal\n */\nconst dayIconListSchema = z.enum(dayIconList);\n\nexport type DayIcon = z.infer<typeof dayIconListSchema>;\n\nconst nightIconList = ['01n', '02n', '03n', '04n', '09n', '10n', '11n', '13n', '50n'] as const;\n\n/**\n * @internal\n */\nconst nightIconListSchema = z.enum(nightIconList);\nexport type NightIcon = z.infer<typeof nightIconListSchema>;\n\n/**\n * @internal\n */\nexport const iconSchema = z.union([dayIconListSchema, nightIconListSchema]);\n\nexport type Icon = z.infer<typeof iconSchema>;\n","import {type IOption, undefinedOptionWrap} from '@luolapeikko/result-option';\nimport {z} from 'zod';\n\n/**\n * This is a list of weather ids, groups and descriptions from OpenWeatherMap API\n */\nexport const weatherIdGroup = [\n\t{\n\t\tid: 200,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_light_rain',\n\t},\n\t{\n\t\tid: 201,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_rain',\n\t},\n\t{\n\t\tid: 202,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_heavy_rain',\n\t},\n\t{\n\t\tid: 210,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'light_thunderstorm',\n\t},\n\t{\n\t\tid: 211,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm',\n\t},\n\t{\n\t\tid: 212,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'heavy_thunderstorm',\n\t},\n\t{\n\t\tid: 221,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'ragged_thunderstorm',\n\t},\n\t{\n\t\tid: 230,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_light_drizzle',\n\t},\n\t{\n\t\tid: 231,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_drizzle',\n\t},\n\t{\n\t\tid: 232,\n\t\tgroup: 'thunderstorm',\n\t\tdescription: 'thunderstorm_with_heavy_drizzle',\n\t},\n\t{\n\t\tid: 300,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'light_intensity_drizzle',\n\t},\n\t{\n\t\tid: 301,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'drizzle',\n\t},\n\t{\n\t\tid: 302,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_intensity_drizzle',\n\t},\n\t{\n\t\tid: 310,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'light_intensity_drizzle_rain',\n\t},\n\t{\n\t\tid: 311,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'drizzle_rain',\n\t},\n\t{\n\t\tid: 312,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_intensity_drizzle_rain',\n\t},\n\t{\n\t\tid: 313,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'shower_rain_and_drizzle',\n\t},\n\t{\n\t\tid: 314,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'heavy_shower_rain_and_drizzle',\n\t},\n\t{\n\t\tid: 321,\n\t\tgroup: 'drizzle',\n\t\tdescription: 'shower_drizzle',\n\t},\n\t{\n\t\tid: 500,\n\t\tgroup: 'rain',\n\t\tdescription: 'light_rain',\n\t},\n\t{\n\t\tid: 501,\n\t\tgroup: 'rain',\n\t\tdescription: 'moderate_rain',\n\t},\n\t{\n\t\tid: 502,\n\t\tgroup: 'rain',\n\t\tdescription: 'heavy_intensity_rain',\n\t},\n\t{\n\t\tid: 503,\n\t\tgroup: 'rain',\n\t\tdescription: 'very_heavy_rain',\n\t},\n\t{\n\t\tid: 504,\n\t\tgroup: 'rain',\n\t\tdescription: 'extreme_rain',\n\t},\n\t{\n\t\tid: 511,\n\t\tgroup: 'rain',\n\t\tdescription: 'freezing_rain',\n\t},\n\t{\n\t\tid: 520,\n\t\tgroup: 'rain',\n\t\tdescription: 'light_intensity_shower_rain',\n\t},\n\t{\n\t\tid: 521,\n\t\tgroup: 'rain',\n\t\tdescription: 'shower_rain',\n\t},\n\t{\n\t\tid: 522,\n\t\tgroup: 'rain',\n\t\tdescription: 'heavy_intensity_shower_rain',\n\t},\n\t{\n\t\tid: 531,\n\t\tgroup: 'rain',\n\t\tdescription: 'ragged_shower_rain',\n\t},\n\t{\n\t\tid: 600,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_snow',\n\t},\n\t{\n\t\tid: 601,\n\t\tgroup: 'snow',\n\t\tdescription: 'snow',\n\t},\n\t{\n\t\tid: 602,\n\t\tgroup: 'snow',\n\t\tdescription: 'heavy_snow',\n\t},\n\t{\n\t\tid: 611,\n\t\tgroup: 'snow',\n\t\tdescription: 'sleet',\n\t},\n\t{\n\t\tid: 612,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_shower_sleet',\n\t},\n\t{\n\t\tid: 613,\n\t\tgroup: 'snow',\n\t\tdescription: 'shower_sleet',\n\t},\n\t{\n\t\tid: 615,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_rain_and_snow',\n\t},\n\t{\n\t\tid: 616,\n\t\tgroup: 'snow',\n\t\tdescription: 'rain_and_snow',\n\t},\n\t{\n\t\tid: 620,\n\t\tgroup: 'snow',\n\t\tdescription: 'light_shower_snow',\n\t},\n\t{\n\t\tid: 621,\n\t\tgroup: 'snow',\n\t\tdescription: 'shower_snow',\n\t},\n\t{\n\t\tid: 622,\n\t\tgroup: 'snow',\n\t\tdescription: 'heavy_shower_snow',\n\t},\n\t{\n\t\tid: 701,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'mist',\n\t},\n\t{\n\t\tid: 711,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'smoke',\n\t},\n\t{\n\t\tid: 721,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'haze',\n\t},\n\t{\n\t\tid: 731,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'sand_dust_whirls',\n\t},\n\t{\n\t\tid: 741,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'fog',\n\t},\n\t{\n\t\tid: 751,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'sand',\n\t},\n\t{\n\t\tid: 761,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'dust',\n\t},\n\t{\n\t\tid: 762,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'volcanic_ash',\n\t},\n\t{\n\t\tid: 771,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'squalls',\n\t},\n\t{\n\t\tid: 781,\n\t\tgroup: 'atmosphere',\n\t\tdescription: 'tornado',\n\t},\n\t{\n\t\tid: 800,\n\t\tgroup: 'clear',\n\t\tdescription: 'clear_sky',\n\t},\n\t{\n\t\tid: 801,\n\t\tgroup: 'clouds',\n\t\tdescription: 'few_clouds_11-25_percent',\n\t},\n\t{\n\t\tid: 802,\n\t\tgroup: 'clouds',\n\t\tdescription: 'scattered_clouds_25-50_percent',\n\t},\n\t{\n\t\tid: 803,\n\t\tgroup: 'clouds',\n\t\tdescription: 'broken_clouds_51-84_percent',\n\t},\n\t{\n\t\tid: 804,\n\t\tgroup: 'clouds',\n\t\tdescription: 'overcast_clouds_85-100_percent',\n\t},\n] as const;\n\nexport type WeatherID = (typeof weatherIdGroup)[number]['id'];\n\n/**\n * WeatherGroup: \"clouds\" | \"rain\" | \"snow\" | \"thunderstorm\" | \"drizzle\" | \"atmosphere\" | \"clear\"\n */\nexport type WeatherGroup = (typeof weatherIdGroup)[number]['group'];\n\n/**\n * List for weather description key types from OpenWeatherMap API based on weather id.\n *\n * This list of keys can be used to translate weather id to human readable description with different languages.\n * @example\n * const i18Weather: Record<WeatherDescription, string> = {\n * clear_sky: 'Clear sky',\n * ...\n * }\n */\nexport type WeatherDescription = (typeof weatherIdGroup)[number]['description'];\n\n/**\n * Weather id schema\n * @internal\n */\nexport const weatherIdSchema = z.custom<WeatherID>((val) => {\n\tif (typeof val !== 'number') {\n\t\treturn {message: 'Expected a number', success: false};\n\t}\n\tif (!weatherIdGroup.find((x) => x.id === val)) {\n\t\treturn {message: 'Expected a valid weather id', success: false};\n\t}\n\treturn val;\n});\n\n/**\n * get weather description key from weather id\n * @param id - weather id\n * @returns {Option<WeatherDescription>} option for weather description key\n * @example\n * const weatherComponent = ({data}) => {\n * const key = getWeatherV2Description(data.weather[0]?.id).unwrapOr('unknown');\n * return (\n * <div>\n * {t(`weather:${key}`}\n * </div>\n * );\n * }\n */\nexport function getWeatherV2Description(id: WeatherID | undefined): IOption<WeatherDescription> {\n\treturn undefinedOptionWrap(weatherIdGroup.find((x) => x.id === id)?.description);\n}\n","import {z} from 'zod';\nexport const langCodes = [\n\t'af',\n\t'al',\n\t'ar',\n\t'az',\n\t'bg',\n\t'ca',\n\t'cz',\n\t'da',\n\t'de',\n\t'el',\n\t'en',\n\t'eu',\n\t'fa',\n\t'fi',\n\t'fr',\n\t'gl',\n\t'he',\n\t'hi',\n\t'hr',\n\t'hu',\n\t'id',\n\t'it',\n\t'ja',\n\t'kr',\n\t'la',\n\t'lt',\n\t'mk',\n\t'no',\n\t'nl',\n\t'pl',\n\t'pt',\n\t'pt',\n\t'ro',\n\t'ru',\n\t'sv',\n\t'sk',\n\t'sl',\n\t'sp',\n\t'sr',\n\t'th',\n\t'tr',\n\t'ua',\n\t'vi',\n\t'zh_cn',\n\t'zh_tw',\n\t'zu',\n] as const;\nexport const langCodeSchema = z.enum(langCodes);\nexport type LangCode = z.infer<typeof langCodeSchema>;\n","import {z} from 'zod';\n\nexport const CountryCodeList = [\n\t'af',\n\t'ax',\n\t'al',\n\t'dz',\n\t'as',\n\t'ad',\n\t'ao',\n\t'ai',\n\t'aq',\n\t'ag',\n\t'ar',\n\t'am',\n\t'aw',\n\t'au',\n\t'at',\n\t'az',\n\t'bs',\n\t'bh',\n\t'bd',\n\t'bb',\n\t'by',\n\t'be',\n\t'bz',\n\t'bj',\n\t'bm',\n\t'bt',\n\t'bo',\n\t'bq',\n\t'ba',\n\t'bw',\n\t'bv',\n\t'br',\n\t'io',\n\t'bn',\n\t'bg',\n\t'bf',\n\t'bi',\n\t'kh',\n\t'cm',\n\t'ca',\n\t'cv',\n\t'ky',\n\t'cf',\n\t'td',\n\t'cl',\n\t'cn',\n\t'cx',\n\t'cc',\n\t'co',\n\t'km',\n\t'cg',\n\t'cd',\n\t'ck',\n\t'cr',\n\t'ci',\n\t'hr',\n\t'cu',\n\t'cw',\n\t'cy',\n\t'cz',\n\t'dk',\n\t'dj',\n\t'dm',\n\t'do',\n\t'ec',\n\t'eg',\n\t'sv',\n\t'gq',\n\t'er',\n\t'ee',\n\t'et',\n\t'fk',\n\t'fo',\n\t'fj',\n\t'fi',\n\t'fr',\n\t'gf',\n\t'pf',\n\t'tf',\n\t'ga',\n\t'gm',\n\t'ge',\n\t'de',\n\t'gh',\n\t'gi',\n\t'gr',\n\t'gl',\n\t'gd',\n\t'gp',\n\t'gu',\n\t'gt',\n\t'gg',\n\t'gn',\n\t'gw',\n\t'gy',\n\t'ht',\n\t'hm',\n\t'va',\n\t'hn',\n\t'hk',\n\t'hu',\n\t'is',\n\t'in',\n\t'id',\n\t'ir',\n\t'iq',\n\t'ie',\n\t'im',\n\t'il',\n\t'it',\n\t'jm',\n\t'jp',\n\t'je',\n\t'jo',\n\t'kz',\n\t'ke',\n\t'ki',\n\t'kp',\n\t'kr',\n\t'kw',\n\t'kg',\n\t'la',\n\t'lv',\n\t'lb',\n\t'ls',\n\t'lr',\n\t'ly',\n\t'li',\n\t'lt',\n\t'lu',\n\t'mo',\n\t'mk',\n\t'mg',\n\t'mw',\n\t'my',\n\t'mv',\n\t'ml',\n\t'mt',\n\t'mh',\n\t'mq',\n\t'mr',\n\t'mu',\n\t'yt',\n\t'mx',\n\t'fm',\n\t'md',\n\t'mc',\n\t'mn',\n\t'me',\n\t'ms',\n\t'ma',\n\t'mz',\n\t'mm',\n\t'na',\n\t'nr',\n\t'np',\n\t'nl',\n\t'nc',\n\t'nz',\n\t'ni',\n\t'ne',\n\t'ng',\n\t'nu',\n\t'nf',\n\t'mp',\n\t'no',\n\t'om',\n\t'pk',\n\t'pw',\n\t'ps',\n\t'pa',\n\t'pg',\n\t'py',\n\t'pe',\n\t'ph',\n\t'pn',\n\t'pl',\n\t'pt',\n\t'pr',\n\t'qa',\n\t're',\n\t'ro',\n\t'ru',\n\t'rw',\n\t'bl',\n\t'sh',\n\t'kn',\n\t'lc',\n\t'mf',\n\t'pm',\n\t'vc',\n\t'ws',\n\t'sm',\n\t'st',\n\t'sa',\n\t'sn',\n\t'rs',\n\t'sc',\n\t'sl',\n\t'sg',\n\t'sx',\n\t'sk',\n\t'si',\n\t'sb',\n\t'so',\n\t'za',\n\t'gs',\n\t'ss',\n\t'es',\n\t'lk',\n\t'sd',\n\t'sr',\n\t'sj',\n\t'sz',\n\t'se',\n\t'ch',\n\t'sy',\n\t'tw',\n\t'tj',\n\t'tz',\n\t'th',\n\t'tl',\n\t'tg',\n\t'tk',\n\t'to',\n\t'tt',\n\t'tn',\n\t'tr',\n\t'tm',\n\t'tc',\n\t'tv',\n\t'ug',\n\t'ua',\n\t'ae',\n\t'gb',\n\t'us',\n\t'um',\n\t'uy',\n\t'uz',\n\t'vu',\n\t've',\n\t'vn',\n\t'vg',\n\t'vi',\n\t'wf',\n\t'eh',\n\t'ye',\n\t'zm',\n\t'zw',\n] as const;\n/**\n * @internal\n */\nexport const CountryCodeSchema = z.enum(CountryCodeList);\nexport type CountryCode = z.infer<typeof CountryCodeSchema>;\n"],"mappings":";AACA,SAAQ,KAAmB,IAAI,iBAAiB,8BAA6B;;;ACGtE,SAAS,kBAAkB,KAAwC;AACzE,MAAI,eAAe,gBAAgB,eAAe,WAAW;AAC5D,WAAO;AAAA,EACR,OAAO;AACN,WAAO,IAAI,UAAU,kBAAkB,OAAO,GAAG,CAAC,EAAE;AAAA,EACrD;AACD;;;ACVA,SAAQ,KAAAA,UAAQ;;;ACAhB,SAAQ,SAAQ;AAChB,IAAM,cAAc,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAKlF,IAAM,oBAAoB,EAAE,KAAK,WAAW;AAI5C,IAAM,gBAAgB,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAKpF,IAAM,sBAAsB,EAAE,KAAK,aAAa;AAMzC,IAAM,aAAa,EAAE,MAAM,CAAC,mBAAmB,mBAAmB,CAAC;;;ACrB1E,SAAsB,2BAA0B;AAChD,SAAQ,KAAAC,UAAQ;AAKT,IAAM,iBAAiB;AAAA,EAC7B;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,IAAI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AA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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Ae,MAAM;AACrD,WAAK,gBAAgB,IAAI,UAAU,aAAa;AAChD,YAAM;AACN,WAAK,gBAAgB,OAAO,QAAQ;AAAA,IACrC;AACA,UAAM,gBAAgB,MAAM;AAC5B,UAAM,OAAsB,cAAc,OAAO;AACjD,wBAAoB,IAAI;AACxB,QAAI,KAAK,OAAO;AACf,YAAM,KAAK,MAAM,IAAI,UAAU,IAAI;AACnC,UAAI,CAAC,SAAS,WAAW,KAAK,GAAG;AAEhC,cAAM,KAAK,MAAM,IAAI,KAAK,kBAAkB,MAAM,KAAK,EAAE,IAAI,IAAI,GAAG,IAAI;AAAA,MACzE;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;","names":["z","z","z","z","z","data"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mharj/openweathermap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Open Weather API Client",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -12,46 +12,9 @@
|
|
|
12
12
|
"import": "./dist/index.mjs"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"doc": "typedoc",
|
|
17
|
-
"build": "tsup src/index.ts --sourcemap --format cjs,esm --dts --clean",
|
|
18
|
-
"prepublishOnly": "npm run build",
|
|
19
|
-
"test": "vitest test --run --no-isolate --coverage",
|
|
20
|
-
"coverage": "vitest test --run --no-isolate --reporter=dot --coverage --coverage.reporter=lcov",
|
|
21
|
-
"lint": "eslint . --ext .ts"
|
|
22
|
-
},
|
|
23
15
|
"files": [
|
|
24
16
|
"dist"
|
|
25
17
|
],
|
|
26
|
-
"mocha": {
|
|
27
|
-
"exit": true,
|
|
28
|
-
"extension": [
|
|
29
|
-
"ts",
|
|
30
|
-
"js"
|
|
31
|
-
],
|
|
32
|
-
"recursive": true,
|
|
33
|
-
"require": [
|
|
34
|
-
"ts-node/register",
|
|
35
|
-
"source-map-support/register"
|
|
36
|
-
],
|
|
37
|
-
"reporters": [
|
|
38
|
-
"spec",
|
|
39
|
-
"mocha-junit-reporter"
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
"nyc": {
|
|
43
|
-
"extension": [
|
|
44
|
-
".ts"
|
|
45
|
-
],
|
|
46
|
-
"include": [
|
|
47
|
-
"src"
|
|
48
|
-
],
|
|
49
|
-
"reporter": [
|
|
50
|
-
"text",
|
|
51
|
-
"html"
|
|
52
|
-
],
|
|
53
|
-
"all": true
|
|
54
|
-
},
|
|
55
18
|
"repository": {
|
|
56
19
|
"type": "git",
|
|
57
20
|
"url": "git+https://github.com/mharj/ts-openweather.git"
|
|
@@ -67,33 +30,49 @@
|
|
|
67
30
|
"url": "https://github.com/mharj/ts-openweather/issues"
|
|
68
31
|
},
|
|
69
32
|
"homepage": "https://github.com/mharj/ts-openweather#readme",
|
|
70
|
-
"dependencies": {
|
|
71
|
-
"@luolapeikko/cache-types": "^0.0.7",
|
|
72
|
-
"@luolapeikko/result-option": "^1.0.3",
|
|
73
|
-
"zod": "^3.23.8"
|
|
74
|
-
},
|
|
75
33
|
"devDependencies": {
|
|
76
|
-
"@avanio/expire-cache": "^0.6.
|
|
77
|
-
"@
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"@
|
|
83
|
-
"
|
|
84
|
-
"eslint": "^
|
|
85
|
-
"
|
|
86
|
-
"eslint-
|
|
87
|
-
"eslint
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
34
|
+
"@avanio/expire-cache": "^0.6.7",
|
|
35
|
+
"@avanio/logger-like": "^0.2.11",
|
|
36
|
+
"@cspell/eslint-plugin": "^8.17.5",
|
|
37
|
+
"@eslint/js": "^9.22.0",
|
|
38
|
+
"@luolapeikko/cache-types": "^0.0.8",
|
|
39
|
+
"@luolapeikko/result-option": "^1.0.5",
|
|
40
|
+
"@luolapeikko/ts-common": "^0.3.3",
|
|
41
|
+
"@stylistic/eslint-plugin": "^4.2.0",
|
|
42
|
+
"@stylistic/eslint-plugin-ts": "^4.2.0",
|
|
43
|
+
"@types/node": "^22.13.10",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
45
|
+
"@typescript-eslint/parser": "^8.26.1",
|
|
46
|
+
"@vitest/coverage-v8": "^3.0.8",
|
|
47
|
+
"c8": "^10.1.3",
|
|
48
|
+
"eslint": "^9.22.0",
|
|
49
|
+
"eslint-config-prettier": "^10.1.1",
|
|
50
|
+
"eslint-import-resolver-typescript": "^3.8.6",
|
|
51
|
+
"eslint-plugin-import": "^2.31.0",
|
|
52
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
53
|
+
"eslint-plugin-sonarjs": "^3.0.2",
|
|
54
|
+
"prettier": "^3.5.3",
|
|
91
55
|
"source-map-support": "^0.5.21",
|
|
92
56
|
"tslib": "^2.8.1",
|
|
93
|
-
"tsup": "^8.
|
|
94
|
-
"typedoc": "^0.
|
|
95
|
-
"typedoc-plugin-zod": "^1.
|
|
96
|
-
"
|
|
97
|
-
"
|
|
57
|
+
"tsup": "^8.4.0",
|
|
58
|
+
"typedoc": "^0.27.9",
|
|
59
|
+
"typedoc-plugin-zod": "^1.4.0",
|
|
60
|
+
"typescript-eslint": "^8.26.1",
|
|
61
|
+
"vite": "^6.2.1",
|
|
62
|
+
"vitest": "^3.0.8",
|
|
63
|
+
"zod": "^3.24.2"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"@luolapeikko/cache-types": "^0.0",
|
|
67
|
+
"@luolapeikko/result-option": "^1",
|
|
68
|
+
"@luolapeikko/ts-common": ">= 0.0.1",
|
|
69
|
+
"zod": "^3"
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"doc": "typedoc",
|
|
73
|
+
"build": "tsup src/index.ts --sourcemap --format cjs,esm --dts --clean",
|
|
74
|
+
"test": "vitest test --run --no-isolate --coverage",
|
|
75
|
+
"coverage": "vitest test --run --no-isolate --reporter=dot --coverage --coverage.reporter=lcov",
|
|
76
|
+
"lint": "eslint . --ext .ts"
|
|
98
77
|
}
|
|
99
|
-
}
|
|
78
|
+
}
|