Skip to content

Commit

Permalink
Export ForecastPeriod
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonSanford committed Jul 12, 2024
1 parent e8c3e1e commit 3d1866b
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 72 deletions.
28 changes: 5 additions & 23 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,16 @@
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"semi": ["error", "always"]
}
}
20 changes: 10 additions & 10 deletions dist/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
declare type ForecastType = 'hourly' | 'baseline';
declare type Area = 'AL' | 'AK' | 'AS' | 'AR' | 'AZ' | 'CA' | 'CO' | 'CT' | 'DE' | 'DC' | 'FL' | 'GA' | 'GU' | 'HI' | 'ID' | 'IL' | 'IN' | 'IA' | 'KS' | 'KY' | 'LA' | 'ME' | 'MD' | 'MA' | 'MI' | 'MN' | 'MS' | 'MO' | 'MT' | 'NE' | 'NV' | 'NH' | 'NJ' | 'NM' | 'NY' | 'NC' | 'ND' | 'OH' | 'OK' | 'OR' | 'PA' | 'PR' | 'RI' | 'SC' | 'SD' | 'TN' | 'TX' | 'UT' | 'VT' | 'VI' | 'VA' | 'WA' | 'WV' | 'WI' | 'WY' | 'PZ' | 'PK' | 'PH' | 'PS' | 'PM' | 'AN' | 'AM' | 'GM' | 'LS' | 'LM' | 'LH' | 'LC' | 'LE' | 'LO';
declare type Region = 'AL' | 'AT' | 'GL' | 'GM' | 'PA' | 'PI';
declare type RegionType = 'land' | 'marine';
declare type Urgency = 'immediate' | 'expected' | 'future' | 'past' | 'unknown';
declare type ForecastType = "hourly" | "baseline";
declare type Area = "AL" | "AK" | "AS" | "AR" | "AZ" | "CA" | "CO" | "CT" | "DE" | "DC" | "FL" | "GA" | "GU" | "HI" | "ID" | "IL" | "IN" | "IA" | "KS" | "KY" | "LA" | "ME" | "MD" | "MA" | "MI" | "MN" | "MS" | "MO" | "MT" | "NE" | "NV" | "NH" | "NJ" | "NM" | "NY" | "NC" | "ND" | "OH" | "OK" | "OR" | "PA" | "PR" | "RI" | "SC" | "SD" | "TN" | "TX" | "UT" | "VT" | "VI" | "VA" | "WA" | "WV" | "WI" | "WY" | "PZ" | "PK" | "PH" | "PS" | "PM" | "AN" | "AM" | "GM" | "LS" | "LM" | "LH" | "LC" | "LE" | "LO";
declare type Region = "AL" | "AT" | "GL" | "GM" | "PA" | "PI";
declare type RegionType = "land" | "marine";
declare type Urgency = "immediate" | "expected" | "future" | "past" | "unknown";
declare type Without<T, U> = {
[P in Exclude<keyof T, keyof U>]?: never;
};
declare type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
declare type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
declare type AreaOption = {
area?: Area | Area[];
};
Expand Down Expand Up @@ -41,7 +41,7 @@ declare type Station = {
stationIdentifier: string;
};
geometry: {
type: 'Point';
type: "Point";
coordinates: [number, number];
};
};
Expand Down Expand Up @@ -105,15 +105,15 @@ declare type ForecastResponse = {
properties: ForecastProperties;
};
declare type AlertsFeatureReference = {
'@id': string;
"@id": string;
identifier: string;
sender: string;
sent: string;
};
declare type AlertsFeature = {
id: string;
geometry: {
type: 'Polygon';
type: "Polygon";
coordinates: number[][];
};
properties: {
Expand Down Expand Up @@ -151,4 +151,4 @@ declare type AlertsFeature = {
declare type AlertsResponse = {
features: AlertsFeature[];
};
export { ForecastType, Area, Region, RegionType, Urgency, AlertOptions, ClientOptions, PointResponse, ForecastResponse, ForecastProperties, Station, StationsResponse, AlertsResponse, AlertsFeature, ObservationsResponse, ObservationResponse, Measure };
export { ForecastType, Area, Region, RegionType, Urgency, AlertOptions, ClientOptions, PointResponse, ForecastResponse, ForecastProperties, Station, StationsResponse, AlertsResponse, AlertsFeature, ObservationsResponse, ObservationResponse, Measure, ForecastPeriod, };
160 changes: 121 additions & 39 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,123 @@
type ForecastType = 'hourly' | 'baseline';
type ForecastType = "hourly" | "baseline";

type Area = 'AL' | 'AK' | 'AS' | 'AR' | 'AZ' | 'CA' | 'CO' | 'CT' | 'DE' |
'DC' | 'FL' | 'GA' | 'GU' | 'HI' | 'ID' | 'IL' | 'IN' | 'IA' |
'KS' | 'KY' | 'LA' | 'ME' | 'MD' | 'MA' | 'MI' | 'MN' | 'MS' |
'MO' | 'MT' | 'NE' | 'NV' | 'NH' | 'NJ' | 'NM' | 'NY' | 'NC' |
'ND' | 'OH' | 'OK' | 'OR' | 'PA' | 'PR' | 'RI' | 'SC' | 'SD' |
'TN' | 'TX' | 'UT' | 'VT' | 'VI' | 'VA' | 'WA' | 'WV' | 'WI' |
'WY' | 'PZ' | 'PK' | 'PH' | 'PS' | 'PM' | 'AN' | 'AM' | 'GM' |
'LS' | 'LM' | 'LH' | 'LC' | 'LE' | 'LO';
type Area =
| "AL"
| "AK"
| "AS"
| "AR"
| "AZ"
| "CA"
| "CO"
| "CT"
| "DE"
| "DC"
| "FL"
| "GA"
| "GU"
| "HI"
| "ID"
| "IL"
| "IN"
| "IA"
| "KS"
| "KY"
| "LA"
| "ME"
| "MD"
| "MA"
| "MI"
| "MN"
| "MS"
| "MO"
| "MT"
| "NE"
| "NV"
| "NH"
| "NJ"
| "NM"
| "NY"
| "NC"
| "ND"
| "OH"
| "OK"
| "OR"
| "PA"
| "PR"
| "RI"
| "SC"
| "SD"
| "TN"
| "TX"
| "UT"
| "VT"
| "VI"
| "VA"
| "WA"
| "WV"
| "WI"
| "WY"
| "PZ"
| "PK"
| "PH"
| "PS"
| "PM"
| "AN"
| "AM"
| "GM"
| "LS"
| "LM"
| "LH"
| "LC"
| "LE"
| "LO";

type Region = 'AL' | 'AT' | 'GL' | 'GM' | 'PA' | 'PI';
type Region = "AL" | "AT" | "GL" | "GM" | "PA" | "PI";

type RegionType = 'land' | 'marine';
type RegionType = "land" | "marine";

type Urgency = 'immediate' | 'expected' | 'future' | 'past' | 'unknown';
type Urgency = "immediate" | "expected" | "future" | "past" | "unknown";

type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };

type XOR<T, U> = (T | U) extends object // eslint-disable-line
type XOR<T, U> = T | U extends object // eslint-disable-line
? (Without<T, U> & U) | (Without<U, T> & T)
: T | U;

type AreaOption = {
area?: Area | Area[];
}
};

type PointOption = {
latitude?: number;
longitude?: number;
}
};

type RegionOption = {
region?: Region | Region[];
}
};

type RegionTypeOption = {
regionType?: RegionType;
}
};

type UrgencyOption = {
urgency?: Urgency;
}
};

type AlertOptions = UrgencyOption & XOR<AreaOption, XOR<PointOption, XOR<RegionOption, RegionTypeOption>>>;
type AlertOptions = UrgencyOption &
XOR<AreaOption, XOR<PointOption, XOR<RegionOption, RegionTypeOption>>>;

type ClientOptions = {
userAgent?: string;
}
};

type PointResponse = {
properties: {
forecast: string;
forecastHourly: string;
observationStations: string;
}
}
};
};

type Station = {
id: string;
Expand All @@ -63,23 +126,23 @@ type Station = {
stationIdentifier: string;
};
geometry: {
type: 'Point';
type: "Point";
coordinates: [number, number];
};
};
}

type StationsResponse = {
features: Station[];
}
};

type PresentWeather = {
[key: string]: string | null;
}
};

type Measure = {
value: number;
unitCode: string;
}
};

type ObservationResponse = {
properties: {
Expand All @@ -94,12 +157,12 @@ type ObservationResponse = {
visibility: Measure;
relativeHumidity: Measure;
heatIndex: Measure;
}
}
};
};

type ObservationsResponse = {
features: ObservationResponse[];
}
};

type ForecastPeriod = {
number: number;
Expand All @@ -115,7 +178,7 @@ type ForecastPeriod = {
icon: string;
shortForecast: string;
detailedForecast: string;
}
};

type ForecastProperties = {
updated: string;
Expand All @@ -124,16 +187,16 @@ type ForecastProperties = {
generatedAt: string;
updateTime: string;
validTimes: string;
elevation: { value: number, unitCode: string };
elevation: { value: number; unitCode: string };
periods: ForecastPeriod[];
}
};

type ForecastResponse = {
properties: ForecastProperties;
}
};

type AlertsFeatureReference = {
'@id': string;
"@id": string;
identifier: string;
sender: string;
sent: string;
Expand All @@ -142,7 +205,7 @@ type AlertsFeatureReference = {
type AlertsFeature = {
id: string;
geometry: {
type: 'Polygon',
type: "Polygon";
coordinates: number[][];
};
properties: {
Expand Down Expand Up @@ -176,10 +239,29 @@ type AlertsFeature = {
instruction: string;
response: string;
};
}
};

type AlertsResponse = {
features: AlertsFeature[];
}
};

export { ForecastType, Area, Region, RegionType, Urgency, AlertOptions, ClientOptions, PointResponse, ForecastResponse, ForecastProperties, Station, StationsResponse, AlertsResponse, AlertsFeature, ObservationsResponse, ObservationResponse, Measure };
export {
ForecastType,
Area,
Region,
RegionType,
Urgency,
AlertOptions,
ClientOptions,
PointResponse,
ForecastResponse,
ForecastProperties,
Station,
StationsResponse,
AlertsResponse,
AlertsFeature,
ObservationsResponse,
ObservationResponse,
Measure,
ForecastPeriod,
};

0 comments on commit 3d1866b

Please sign in to comment.