@usa-open-data-connectors/usa-sources 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +339 -0
  2. package/dist/blsSeries.d.ts +73 -0
  3. package/dist/blsSeries.d.ts.map +1 -0
  4. package/dist/blsSeries.js +173 -0
  5. package/dist/blsSeries.js.map +1 -0
  6. package/dist/cdcCountyObesity.d.ts +116 -0
  7. package/dist/cdcCountyObesity.d.ts.map +1 -0
  8. package/dist/cdcCountyObesity.js +180 -0
  9. package/dist/cdcCountyObesity.js.map +1 -0
  10. package/dist/cfpbConsumerComplaints.d.ts +152 -0
  11. package/dist/cfpbConsumerComplaints.d.ts.map +1 -0
  12. package/dist/cfpbConsumerComplaints.js +273 -0
  13. package/dist/cfpbConsumerComplaints.js.map +1 -0
  14. package/dist/cpscProductRecalls.d.ts +146 -0
  15. package/dist/cpscProductRecalls.d.ts.map +1 -0
  16. package/dist/cpscProductRecalls.js +298 -0
  17. package/dist/cpscProductRecalls.js.map +1 -0
  18. package/dist/errors.d.ts +15 -0
  19. package/dist/errors.d.ts.map +1 -0
  20. package/dist/errors.js +26 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/femaDisasterDeclarations.d.ts +123 -0
  23. package/dist/femaDisasterDeclarations.d.ts.map +1 -0
  24. package/dist/femaDisasterDeclarations.js +214 -0
  25. package/dist/femaDisasterDeclarations.js.map +1 -0
  26. package/dist/fixtures.d.ts +5 -0
  27. package/dist/fixtures.d.ts.map +1 -0
  28. package/dist/fixtures.js +11 -0
  29. package/dist/fixtures.js.map +1 -0
  30. package/dist/index.d.ts +51 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +27 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/nceiAnnualTemperature.d.ts +92 -0
  35. package/dist/nceiAnnualTemperature.d.ts.map +1 -0
  36. package/dist/nceiAnnualTemperature.js +158 -0
  37. package/dist/nceiAnnualTemperature.js.map +1 -0
  38. package/dist/noaaSeaLevel.d.ts +144 -0
  39. package/dist/noaaSeaLevel.d.ts.map +1 -0
  40. package/dist/noaaSeaLevel.js +252 -0
  41. package/dist/noaaSeaLevel.js.map +1 -0
  42. package/dist/openFdaFoodRecalls.d.ts +154 -0
  43. package/dist/openFdaFoodRecalls.d.ts.map +1 -0
  44. package/dist/openFdaFoodRecalls.js +293 -0
  45. package/dist/openFdaFoodRecalls.js.map +1 -0
  46. package/dist/registry.d.ts +28 -0
  47. package/dist/registry.d.ts.map +1 -0
  48. package/dist/registry.js +79 -0
  49. package/dist/registry.js.map +1 -0
  50. package/dist/treasuryAvgInterestRate.d.ts +107 -0
  51. package/dist/treasuryAvgInterestRate.d.ts.map +1 -0
  52. package/dist/treasuryAvgInterestRate.js +191 -0
  53. package/dist/treasuryAvgInterestRate.js.map +1 -0
  54. package/dist/types.d.ts +30 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/dist/types.js +2 -0
  57. package/dist/types.js.map +1 -0
  58. package/dist/usgsEarthquakes.d.ts +108 -0
  59. package/dist/usgsEarthquakes.d.ts.map +1 -0
  60. package/dist/usgsEarthquakes.js +199 -0
  61. package/dist/usgsEarthquakes.js.map +1 -0
  62. package/dist/usgsPeakStreamflow.d.ts +116 -0
  63. package/dist/usgsPeakStreamflow.d.ts.map +1 -0
  64. package/dist/usgsPeakStreamflow.js +211 -0
  65. package/dist/usgsPeakStreamflow.js.map +1 -0
  66. package/package.json +46 -0
@@ -0,0 +1,191 @@
1
+ import { z } from 'zod';
2
+ import { UsSourceApiError, UsSourceParseError } from './errors.js';
3
+ import { readFixtureJson } from './fixtures.js';
4
+ /** Base URL for the Treasury Fiscal Data API. */
5
+ export const TREASURY_FISCAL_DATA_API_BASE = 'https://api.fiscaldata.treasury.gov/services/api/fiscal_service';
6
+ /** Dataset path for the average interest rates on Treasury securities. */
7
+ export const TREASURY_AVG_INTEREST_RATE_PATH = '/v2/accounting/od/avg_interest_rates';
8
+ /**
9
+ * Security type the adapter reads.
10
+ *
11
+ * "Interest-bearing Debt" holds the portfolio totals, the same rows the
12
+ * bureau's monthly statement is built from, rather than the rates on the
13
+ * bills, notes, and bonds issued today.
14
+ */
15
+ export const TREASURY_AVG_INTEREST_RATE_SECURITY_TYPE = 'Interest-bearing Debt';
16
+ /** Security description that carries the whole portfolio's average rate. */
17
+ export const TREASURY_AVG_INTEREST_RATE_SECURITY_DESCRIPTION = 'Total Interest-bearing Debt';
18
+ /** First year the dataset covers. */
19
+ export const TREASURY_AVG_INTEREST_RATE_FIRST_YEAR = 2001;
20
+ /**
21
+ * Row cap for one request.
22
+ *
23
+ * The API returns at most 10,000 rows a page and the series is around 300
24
+ * rows, so one request covers the whole run and the adapter never pages.
25
+ */
26
+ export const TREASURY_AVG_INTEREST_RATE_ROW_LIMIT = 10_000;
27
+ /** Columns the adapter asks for. The dataset carries a date breakdown too. */
28
+ const TREASURY_AVG_INTEREST_RATE_COLUMNS = 'record_date,security_type_desc,security_desc,avg_interest_rate_amt';
29
+ /** Committed snapshot, so a build works when the Treasury host is unreachable. */
30
+ const TREASURY_AVG_INTEREST_RATE_FIXTURE_FILENAME = 'treasury-avg-interest-rate-2026-09-28.json';
31
+ /** Shape of the agency's record date, e.g. "2026-08-31". */
32
+ const ISO_DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
33
+ // Every field arrives as a string, and a row the agency could not compute
34
+ // arrives without a value. A rejected request answers with an HTTP error and
35
+ // a body of {error, message} instead of the data.
36
+ const TREASURY_ROW_SCHEMA = z.object({
37
+ record_date: z.string().optional(),
38
+ security_type_desc: z.string().optional(),
39
+ security_desc: z.string().optional(),
40
+ avg_interest_rate_amt: z.string().optional(),
41
+ });
42
+ const TREASURY_PAYLOAD_SCHEMA = z.object({
43
+ data: z.array(TREASURY_ROW_SCHEMA).optional(),
44
+ error: z.string().optional(),
45
+ message: z.string().optional(),
46
+ });
47
+ /**
48
+ * Builds the request URL for the whole published series.
49
+ *
50
+ * The filter pins the response to the portfolio's own total, so the rows for
51
+ * bills, notes, bonds, and the non-marketable debt never reach the parser.
52
+ * The endpoint is keyless.
53
+ *
54
+ * @param options - an optional security type and row cap
55
+ * @returns the full request URL
56
+ */
57
+ export function buildTreasuryAvgInterestRateUrl(options) {
58
+ const params = new URLSearchParams({
59
+ fields: TREASURY_AVG_INTEREST_RATE_COLUMNS,
60
+ filter: `security_type_desc:eq:${options?.securityType ?? TREASURY_AVG_INTEREST_RATE_SECURITY_TYPE}`,
61
+ sort: 'record_date',
62
+ 'page[size]': String(options?.rowLimit ?? TREASURY_AVG_INTEREST_RATE_ROW_LIMIT),
63
+ });
64
+ return `${TREASURY_FISCAL_DATA_API_BASE}${TREASURY_AVG_INTEREST_RATE_PATH}?${params.toString()}`;
65
+ }
66
+ /**
67
+ * Parses one response into the months that carry a rate.
68
+ *
69
+ * A row for another security type is a changed filter and stops the parse,
70
+ * so a response that ignored the filter cannot quietly widen the series. A
71
+ * row without a rate is dropped, which is how a month the agency could not
72
+ * compute would arrive. A row without a readable date is a changed shape and
73
+ * also stops the parse.
74
+ *
75
+ * @param payload - the JSON body from the Fiscal Data API
76
+ * @returns the months that carry a rate, in the order the agency sent them
77
+ */
78
+ export function parseTreasuryAvgInterestRatePayload(payload) {
79
+ const parsed = TREASURY_PAYLOAD_SCHEMA.safeParse(payload);
80
+ if (!parsed.success) {
81
+ throw new UsSourceParseError('treasury', parsed.error.message);
82
+ }
83
+ if (parsed.data.error !== undefined) {
84
+ throw new UsSourceApiError('treasury', parsed.data.message ?? `The API rejected the request: ${parsed.data.error}`);
85
+ }
86
+ const rows = parsed.data.data ?? [];
87
+ if (rows.length === 0) {
88
+ throw new UsSourceParseError('treasury', 'The response carried no rows');
89
+ }
90
+ const months = [];
91
+ for (const row of rows) {
92
+ if (row.security_type_desc !== undefined &&
93
+ row.security_type_desc !== TREASURY_AVG_INTEREST_RATE_SECURITY_TYPE) {
94
+ throw new UsSourceParseError('treasury', `Unexpected security type in the response: ${row.security_type_desc}`);
95
+ }
96
+ if (row.security_desc !== undefined &&
97
+ row.security_desc !== TREASURY_AVG_INTEREST_RATE_SECURITY_DESCRIPTION) {
98
+ throw new UsSourceParseError('treasury', `Unexpected security in the response: ${row.security_desc}`);
99
+ }
100
+ if (row.record_date === undefined) {
101
+ throw new UsSourceParseError('treasury', 'A row carries no record date');
102
+ }
103
+ const match = ISO_DATE_PATTERN.exec(row.record_date);
104
+ if (match === null) {
105
+ throw new UsSourceParseError('treasury', `Unreadable record date: ${row.record_date}`);
106
+ }
107
+ if (row.avg_interest_rate_amt === undefined || row.avg_interest_rate_amt.trim() === '') {
108
+ continue;
109
+ }
110
+ const averageInterestRatePercent = Number(row.avg_interest_rate_amt);
111
+ if (!Number.isFinite(averageInterestRatePercent)) {
112
+ throw new UsSourceParseError('treasury', `Unreadable average interest rate: ${row.avg_interest_rate_amt}`);
113
+ }
114
+ months.push({
115
+ recordDate: row.record_date,
116
+ year: Number(match[1]),
117
+ month: Number(match[2]),
118
+ averageInterestRatePercent,
119
+ });
120
+ }
121
+ if (months.length === 0) {
122
+ throw new UsSourceParseError('treasury', 'No monthly values in the response');
123
+ }
124
+ return months;
125
+ }
126
+ /**
127
+ * Folds the parsed months into one series with the headline months named.
128
+ *
129
+ * The months are sorted oldest first, so a caller reading index 0 gets the
130
+ * start of the run and index -1 gets the newest month.
131
+ *
132
+ * @param months - the parsed months, in any order
133
+ * @returns the sorted months, the highest and lowest in the run, and the change
134
+ */
135
+ export function buildTreasuryAvgInterestRateSeries(months) {
136
+ const sorted = [...months].sort((left, right) => left.recordDate.localeCompare(right.recordDate));
137
+ const first = sorted[0];
138
+ const last = sorted[sorted.length - 1];
139
+ if (first === undefined || last === undefined) {
140
+ throw new UsSourceParseError('treasury', 'No months to summarise');
141
+ }
142
+ let highest = first;
143
+ let lowest = first;
144
+ for (const month of sorted) {
145
+ if (month.averageInterestRatePercent > highest.averageInterestRatePercent) {
146
+ highest = month;
147
+ }
148
+ if (month.averageInterestRatePercent < lowest.averageInterestRatePercent) {
149
+ lowest = month;
150
+ }
151
+ }
152
+ return {
153
+ months: sorted,
154
+ monthCount: sorted.length,
155
+ firstMonth: first,
156
+ lastMonth: last,
157
+ highest,
158
+ lowest,
159
+ changeSinceLowPercentPoints: last.averageInterestRatePercent - lowest.averageInterestRatePercent,
160
+ changeFirstToLastPercentPoints: last.averageInterestRatePercent - first.averageInterestRatePercent,
161
+ };
162
+ }
163
+ /**
164
+ * Reads the average interest rate on the Treasury's interest-bearing debt.
165
+ *
166
+ * One keyless request covers the whole published run, which starts in
167
+ * January 2001 and answers one row per month.
168
+ *
169
+ * @param options - an optional security type and fetch stub
170
+ * @returns the monthly rates, the highest and lowest months, and the change
171
+ */
172
+ export async function fetchTreasuryAvgInterestRates(options) {
173
+ const fetchImpl = options?.fetchImpl ?? globalThis.fetch;
174
+ const url = buildTreasuryAvgInterestRateUrl(options?.securityType === undefined ? {} : { securityType: options.securityType });
175
+ const response = await fetchImpl(url);
176
+ if (!response.ok) {
177
+ throw new UsSourceApiError('treasury', `HTTP ${response.status} reading the average interest rates`);
178
+ }
179
+ return buildTreasuryAvgInterestRateSeries(parseTreasuryAvgInterestRatePayload(await response.json()));
180
+ }
181
+ /** US Treasury average interest rate on the debt outstanding, keyless. */
182
+ export const treasuryAvgInterestRateAdapter = {
183
+ id: 'treasury-avg-interest-rate',
184
+ name: 'US Treasury average interest rate',
185
+ auth: 'none',
186
+ description: 'Average interest rate on the interest-bearing US Treasury debt outstanding, one row per month since 2001.',
187
+ fetchLive: async (options) => fetchTreasuryAvgInterestRates(options?.fetchImpl === undefined ? {} : { fetchImpl: options.fetchImpl }),
188
+ parse: (payload) => buildTreasuryAvgInterestRateSeries(parseTreasuryAvgInterestRatePayload(payload)),
189
+ loadFixture: () => buildTreasuryAvgInterestRateSeries(parseTreasuryAvgInterestRatePayload(readFixtureJson(TREASURY_AVG_INTEREST_RATE_FIXTURE_FILENAME))),
190
+ };
191
+ //# sourceMappingURL=treasuryAv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AAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAC3B,6BAA6B,CAC3B,OAAO,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CACzE;IACH,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CACjB,kCAAkC,CAAC,mCAAmC,CAAC,OAAO,CAAC,CAAC;IAClF,WAAW,EAAE,GAAG,EAAE,CAChB,kCAAkC,CAChC,mCAAmC,CACjC,eAAe,CAAC,2CAA2C,CAAC,CAC7D,CACF;CACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ /** What a US source needs before it will answer a request. */
2
+ export type UsSourceAuth = 'none' | 'key';
3
+ /** Options shared by every adapter's live fetch. */
4
+ export interface UsFetchOptions {
5
+ apiKey?: string;
6
+ fetchImpl?: typeof globalThis.fetch;
7
+ }
8
+ /**
9
+ * One US data source behind a uniform interface: a live fetch, a strict
10
+ * parse, and a committed fixture fallback so builds work offline.
11
+ */
12
+ export interface UsDataAdapter<T> {
13
+ readonly id: string;
14
+ readonly name: string;
15
+ readonly auth: UsSourceAuth;
16
+ readonly description: string;
17
+ fetchLive(options?: UsFetchOptions): Promise<T>;
18
+ parse(payload: unknown): T;
19
+ loadFixture(): T;
20
+ }
21
+ /** Result of a live verification probe against one source. */
22
+ export interface UsSourceProbe {
23
+ id: string;
24
+ name: string;
25
+ auth: UsSourceAuth;
26
+ ok: boolean;
27
+ status: string;
28
+ sample?: string;
29
+ }
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAE1C,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC;IAC3B,WAAW,IAAI,CAAC,CAAC;CAClB;AAED,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,108 @@
1
+ import type { UsDataAdapter } from './types.js';
2
+ /** One earthquake, as the USGS catalogue reports it. */
3
+ export interface UsgsEarthquake {
4
+ id: string;
5
+ magnitude: number;
6
+ /** Free-text place, such as "5 km S of Pāhala, Hawaii". */
7
+ place: string;
8
+ /** Origin time in milliseconds since the epoch. */
9
+ timeMs: number;
10
+ depthKm: number;
11
+ /** The agency's own event page for this earthquake. */
12
+ url: string;
13
+ }
14
+ /** A set of earthquakes with the points a story leans on. */
15
+ export interface UsgsEarthquakeCatalogue {
16
+ earthquakes: UsgsEarthquake[];
17
+ count: number;
18
+ strongest: UsgsEarthquake;
19
+ deepest: UsgsEarthquake;
20
+ earliest: UsgsEarthquake;
21
+ latest: UsgsEarthquake;
22
+ }
23
+ /** The latitude and longitude box a catalogue query filters on. */
24
+ export interface UsgsEarthquakeBounds {
25
+ minLatitude: number;
26
+ maxLatitude: number;
27
+ minLongitude: number;
28
+ maxLongitude: number;
29
+ }
30
+ /** The window, magnitude floor, and box one catalogue query reads. */
31
+ export interface UsgsEarthquakeQuery {
32
+ /** Start of the window, as YYYY-MM-DD. */
33
+ startDate: string;
34
+ /** End of the window, as YYYY-MM-DD. The catalogue excludes the end date. */
35
+ endDate: string;
36
+ minMagnitude: number;
37
+ bounds: UsgsEarthquakeBounds;
38
+ }
39
+ /** Base URL for the USGS earthquake catalogue (FDSN event query). */
40
+ export declare const USGS_EARTHQUAKE_API_BASE = "https://earthquake.usgs.gov/fdsnws/event/1/query";
41
+ /** The box the Hawaii adapter reads: the main Hawaiian islands and the water around them. */
42
+ export declare const USGS_HAWAII_BOUNDS: UsgsEarthquakeBounds;
43
+ /** Magnitude floor for the Hawaii adapter. */
44
+ export declare const USGS_HAWAII_MIN_MAGNITUDE = 2.5;
45
+ /** Days the Hawaii adapter's rolling window covers. */
46
+ export declare const USGS_ROLLING_WINDOW_DAYS = 365;
47
+ /**
48
+ * Builds the catalogue query URL for one window.
49
+ *
50
+ * The catalogue is keyless and public domain. The query asks for GeoJSON,
51
+ * ordered oldest first is left to the parser, and the box and magnitude floor
52
+ * come from the caller.
53
+ *
54
+ * @param query - the window, magnitude floor, and box to read
55
+ * @returns the full query URL
56
+ */
57
+ export declare function buildUsgsEarthquakeUrl(query: UsgsEarthquakeQuery): string;
58
+ /**
59
+ * Parses a catalogue response into earthquakes, oldest first.
60
+ *
61
+ * The catalogue holds more than tectonic earthquakes: quarry blasts,
62
+ * explosions, and ice quakes sit in the same feed, and a row can arrive with
63
+ * no magnitude. Both are dropped, so every record here is an earthquake with
64
+ * a magnitude and a depth.
65
+ *
66
+ * @param payload - the GeoJSON body from the event query endpoint
67
+ * @returns the earthquakes in the window, oldest first
68
+ */
69
+ export declare function parseUsgsEarthquakes(payload: unknown): UsgsEarthquake[];
70
+ /**
71
+ * Sorts earthquakes oldest first, with the event id breaking a tie. The
72
+ * catalogue answers newest first, and a caller reading `earthquakes[0]`
73
+ * should get the start of the window.
74
+ *
75
+ * @param earthquakes - earthquakes in any order
76
+ * @returns the same earthquakes, oldest first
77
+ */
78
+ export declare function sortEarthquakesOldestFirst(earthquakes: UsgsEarthquake[]): UsgsEarthquake[];
79
+ /**
80
+ * Folds earthquakes into one catalogue with its headline points.
81
+ *
82
+ * @param earthquakes - earthquakes in any order
83
+ * @returns the catalogue, ordered oldest first, plus the strongest and deepest
84
+ */
85
+ export declare function buildUsgsEarthquakeCatalogue(earthquakes: UsgsEarthquake[]): UsgsEarthquakeCatalogue;
86
+ /**
87
+ * Reads one window of the catalogue.
88
+ *
89
+ * Keyless. The catalogue answers a window of any length, so a caller can ask
90
+ * for a single year or for the whole record.
91
+ *
92
+ * @param query - the window, magnitude floor, and box to read
93
+ * @param options - an optional fetch stub
94
+ * @returns every earthquake in the window, oldest first
95
+ */
96
+ export declare function fetchUsgsEarthquakes(query: UsgsEarthquakeQuery, options?: {
97
+ fetchImpl?: typeof globalThis.fetch;
98
+ }): Promise<UsgsEarthquake[]>;
99
+ /**
100
+ * The window the Hawaii adapter reads by default: the last 365 days, up to today.
101
+ *
102
+ * @param now - the day to count back from, for tests
103
+ * @returns the rolling window, in the plain dates the catalogue wants
104
+ */
105
+ export declare function usgsHawaiiRollingWindow(now?: Date): UsgsEarthquakeQuery;
106
+ /** Earthquakes near Hawaii, magnitude 2.5 and above, keyless. */
107
+ export declare const usgsHawaiiEarthquakesAdapter: UsDataAdapter<UsgsEarthquakeCatalogue>;
108
+ //# sourceMappingURL=usgsEarthquakes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usgsEarthquakes.d.ts","sourceRoot":"","sources":["../src/usgsEarthquakes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA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;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,EAAE,CA8BvE;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAO1F;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,cAAc,EAAE,GAC5B,uBAAuB,CA2BzB;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAAE,GAChD,OAAO,CAAC,cAAc,EAAE,CAAC,CAO3B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,GAAE,IAAiB,GAAG,mBAAmB,CASnF;AAED,iEAAiE;AACjE,eAAO,MAAM,4BAA4B,EAAE,aAAa,CAAC,uBAAuB,CAgB/E,CAAC"}
@@ -0,0 +1,199 @@
1
+ import { z } from 'zod';
2
+ import { UsSourceApiError, UsSourceParseError } from './errors.js';
3
+ import { readFixtureJson } from './fixtures.js';
4
+ /** Base URL for the USGS earthquake catalogue (FDSN event query). */
5
+ export const USGS_EARTHQUAKE_API_BASE = 'https://earthquake.usgs.gov/fdsnws/event/1/query';
6
+ /** The box the Hawaii adapter reads: the main Hawaiian islands and the water around them. */
7
+ export const USGS_HAWAII_BOUNDS = {
8
+ minLatitude: 18.5,
9
+ maxLatitude: 22.5,
10
+ minLongitude: -161,
11
+ maxLongitude: -154,
12
+ };
13
+ /** Magnitude floor for the Hawaii adapter. */
14
+ export const USGS_HAWAII_MIN_MAGNITUDE = 2.5;
15
+ /** Days the Hawaii adapter's rolling window covers. */
16
+ export const USGS_ROLLING_WINDOW_DAYS = 365;
17
+ const MS_PER_DAY = 24 * 60 * 60 * 1000;
18
+ const USGS_FEATURE_SCHEMA = z.object({
19
+ id: z.string(),
20
+ properties: z.object({
21
+ mag: z.number().nullable(),
22
+ place: z.string().nullable(),
23
+ time: z.number(),
24
+ url: z.string(),
25
+ type: z.string(),
26
+ }),
27
+ geometry: z.object({
28
+ coordinates: z.array(z.number()).min(2),
29
+ }),
30
+ });
31
+ const USGS_RESPONSE_SCHEMA = z.object({
32
+ type: z.literal('FeatureCollection'),
33
+ metadata: z.object({
34
+ status: z.number(),
35
+ count: z.number().optional(),
36
+ }),
37
+ features: z.array(USGS_FEATURE_SCHEMA),
38
+ });
39
+ /** The catalogue's own label for a tectonic earthquake. */
40
+ const USGS_EARTHQUAKE_TYPE = 'earthquake';
41
+ /**
42
+ * Builds the catalogue query URL for one window.
43
+ *
44
+ * The catalogue is keyless and public domain. The query asks for GeoJSON,
45
+ * ordered oldest first is left to the parser, and the box and magnitude floor
46
+ * come from the caller.
47
+ *
48
+ * @param query - the window, magnitude floor, and box to read
49
+ * @returns the full query URL
50
+ */
51
+ export function buildUsgsEarthquakeUrl(query) {
52
+ const params = new URLSearchParams({
53
+ format: 'geojson',
54
+ starttime: query.startDate,
55
+ endtime: query.endDate,
56
+ minmagnitude: String(query.minMagnitude),
57
+ minlatitude: String(query.bounds.minLatitude),
58
+ maxlatitude: String(query.bounds.maxLatitude),
59
+ minlongitude: String(query.bounds.minLongitude),
60
+ maxlongitude: String(query.bounds.maxLongitude),
61
+ orderby: 'time',
62
+ });
63
+ return `${USGS_EARTHQUAKE_API_BASE}?${params.toString()}`;
64
+ }
65
+ /**
66
+ * Parses a catalogue response into earthquakes, oldest first.
67
+ *
68
+ * The catalogue holds more than tectonic earthquakes: quarry blasts,
69
+ * explosions, and ice quakes sit in the same feed, and a row can arrive with
70
+ * no magnitude. Both are dropped, so every record here is an earthquake with
71
+ * a magnitude and a depth.
72
+ *
73
+ * @param payload - the GeoJSON body from the event query endpoint
74
+ * @returns the earthquakes in the window, oldest first
75
+ */
76
+ export function parseUsgsEarthquakes(payload) {
77
+ const parsed = USGS_RESPONSE_SCHEMA.safeParse(payload);
78
+ if (!parsed.success) {
79
+ throw new UsSourceParseError('usgs', parsed.error.message);
80
+ }
81
+ if (parsed.data.metadata.status !== 200) {
82
+ throw new UsSourceApiError('usgs', `catalogue status ${parsed.data.metadata.status}`);
83
+ }
84
+ const earthquakes = [];
85
+ for (const feature of parsed.data.features) {
86
+ const { mag, place, time, url, type } = feature.properties;
87
+ if (type !== USGS_EARTHQUAKE_TYPE || mag === null || place === null) {
88
+ continue;
89
+ }
90
+ const depthKm = feature.geometry.coordinates[2];
91
+ if (typeof depthKm !== 'number' || !Number.isFinite(depthKm) || !Number.isFinite(time)) {
92
+ continue;
93
+ }
94
+ earthquakes.push({
95
+ id: feature.id,
96
+ magnitude: mag,
97
+ place,
98
+ timeMs: time,
99
+ depthKm,
100
+ url,
101
+ });
102
+ }
103
+ return sortEarthquakesOldestFirst(earthquakes);
104
+ }
105
+ /**
106
+ * Sorts earthquakes oldest first, with the event id breaking a tie. The
107
+ * catalogue answers newest first, and a caller reading `earthquakes[0]`
108
+ * should get the start of the window.
109
+ *
110
+ * @param earthquakes - earthquakes in any order
111
+ * @returns the same earthquakes, oldest first
112
+ */
113
+ export function sortEarthquakesOldestFirst(earthquakes) {
114
+ return [...earthquakes].sort((left, right) => {
115
+ if (left.timeMs !== right.timeMs) {
116
+ return left.timeMs - right.timeMs;
117
+ }
118
+ return left.id.localeCompare(right.id);
119
+ });
120
+ }
121
+ /**
122
+ * Folds earthquakes into one catalogue with its headline points.
123
+ *
124
+ * @param earthquakes - earthquakes in any order
125
+ * @returns the catalogue, ordered oldest first, plus the strongest and deepest
126
+ */
127
+ export function buildUsgsEarthquakeCatalogue(earthquakes) {
128
+ const ordered = sortEarthquakesOldestFirst(earthquakes);
129
+ const earliest = ordered[0];
130
+ const latest = ordered[ordered.length - 1];
131
+ if (earliest === undefined || latest === undefined) {
132
+ throw new UsSourceParseError('usgs', 'No earthquakes in the catalogue');
133
+ }
134
+ let strongest = earliest;
135
+ let deepest = earliest;
136
+ for (const earthquake of ordered) {
137
+ if (earthquake.magnitude > strongest.magnitude) {
138
+ strongest = earthquake;
139
+ }
140
+ if (earthquake.depthKm > deepest.depthKm) {
141
+ deepest = earthquake;
142
+ }
143
+ }
144
+ return {
145
+ earthquakes: ordered,
146
+ count: ordered.length,
147
+ strongest,
148
+ deepest,
149
+ earliest,
150
+ latest,
151
+ };
152
+ }
153
+ /**
154
+ * Reads one window of the catalogue.
155
+ *
156
+ * Keyless. The catalogue answers a window of any length, so a caller can ask
157
+ * for a single year or for the whole record.
158
+ *
159
+ * @param query - the window, magnitude floor, and box to read
160
+ * @param options - an optional fetch stub
161
+ * @returns every earthquake in the window, oldest first
162
+ */
163
+ export async function fetchUsgsEarthquakes(query, options) {
164
+ const fetchImpl = options?.fetchImpl ?? globalThis.fetch;
165
+ const response = await fetchImpl(buildUsgsEarthquakeUrl(query));
166
+ if (!response.ok) {
167
+ throw new UsSourceApiError('usgs', `HTTP ${response.status} reading the catalogue`);
168
+ }
169
+ return parseUsgsEarthquakes(await response.json());
170
+ }
171
+ /**
172
+ * The window the Hawaii adapter reads by default: the last 365 days, up to today.
173
+ *
174
+ * @param now - the day to count back from, for tests
175
+ * @returns the rolling window, in the plain dates the catalogue wants
176
+ */
177
+ export function usgsHawaiiRollingWindow(now = new Date()) {
178
+ return {
179
+ startDate: new Date(now.getTime() - USGS_ROLLING_WINDOW_DAYS * MS_PER_DAY)
180
+ .toISOString()
181
+ .slice(0, 10),
182
+ endDate: now.toISOString().slice(0, 10),
183
+ minMagnitude: USGS_HAWAII_MIN_MAGNITUDE,
184
+ bounds: USGS_HAWAII_BOUNDS,
185
+ };
186
+ }
187
+ /** Earthquakes near Hawaii, magnitude 2.5 and above, keyless. */
188
+ export const usgsHawaiiEarthquakesAdapter = {
189
+ id: 'usgs-hawaii-earthquakes',
190
+ name: 'USGS earthquakes around Hawaii',
191
+ auth: 'none',
192
+ description: 'Earthquakes of magnitude 2.5 and above near the Hawaiian islands.',
193
+ fetchLive: async (options) => buildUsgsEarthquakeCatalogue(await fetchUsgsEarthquakes(usgsHawaiiRollingWindow(), {
194
+ ...(options?.fetchImpl === undefined ? {} : { fetchImpl: options.fetchImpl }),
195
+ })),
196
+ parse: (payload) => buildUsgsEarthquakeCatalogue(parseUsgsEarthquakes(payload)),
197
+ loadFixture: () => buildUsgsEarthquakeCatalogue(parseUsgsEarthquakes(readFixtureJson('usgs-hawaii-earthquakes.json'))),
198
+ };
199
+ //# sourceMappingURL=usgsEarthquakes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usgsEarthquakes.js","sourceRoot":"","sources":["../src/usgsEarthquakes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA4ChD,qEAAqE;AACrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,kDAAkD,CAAC;AAE3F,6FAA6F;AAC7F,MAAM,CAAC,MAAM,kBAAkB,GAAyB;IACtD,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,CAAC,GAAG;IAClB,YAAY,EAAE,CAAC,GAAG;CACnB,CAAC;AAEF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C,uDAAuD;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC1B,KAAK,EAAE,CAAC,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